diff --git a/.bower.json.un~ b/.bower.json.un~ new file mode 100644 index 0000000..78eb9b8 Binary files /dev/null and b/.bower.json.un~ differ diff --git a/.iframe.html.un~ b/.iframe.html.un~ new file mode 100644 index 0000000..75a25e1 Binary files /dev/null and b/.iframe.html.un~ differ diff --git a/.start.php.un~ b/.start.php.un~ new file mode 100644 index 0000000..3ec7ca8 Binary files /dev/null and b/.start.php.un~ differ diff --git a/assets/.PositionModels.coffee.un~ b/assets/.PositionModels.coffee.un~ new file mode 100644 index 0000000..19c1b76 Binary files /dev/null and b/assets/.PositionModels.coffee.un~ differ diff --git a/assets/.PositionsApplication.coffee.un~ b/assets/.PositionsApplication.coffee.un~ new file mode 100644 index 0000000..09f1995 Binary files /dev/null and b/assets/.PositionsApplication.coffee.un~ differ diff --git a/assets/.PositionsController.coffee.un~ b/assets/.PositionsController.coffee.un~ new file mode 100644 index 0000000..f6082cb Binary files /dev/null and b/assets/.PositionsController.coffee.un~ differ diff --git a/assets/.PositionsViews.coffee.un~ b/assets/.PositionsViews.coffee.un~ new file mode 100644 index 0000000..9902298 Binary files /dev/null and b/assets/.PositionsViews.coffee.un~ differ diff --git a/assets/.setup.coffee.un~ b/assets/.setup.coffee.un~ new file mode 100644 index 0000000..2e53849 Binary files /dev/null and b/assets/.setup.coffee.un~ differ diff --git a/assets/PositionsApplication.coffee b/assets/PositionsApplication.coffee new file mode 100644 index 0000000..9c5da13 --- /dev/null +++ b/assets/PositionsApplication.coffee @@ -0,0 +1,2 @@ +positionsApp = new Backbone.Marionette.Application + diff --git a/assets/PositionsController.coffee b/assets/PositionsController.coffee new file mode 100644 index 0000000..d2eef00 --- /dev/null +++ b/assets/PositionsController.coffee @@ -0,0 +1,18 @@ +positionsApp.module 'Controller', (PositionsController, App, Backbone, Marionette, $, _) -> + + class PositionsController.Controller extends Marionette.Controller + constructor: -> + + start: -> + createView = new positionsApp.View.CreatePosition() + createView.show() + App.vent.on 'position:add', (position) -> + that.positions.add position + + + + PositionsController.addInitializer -> + controller = new PositionsController.Controller + + controller.start() + diff --git a/assets/PositionsViews.coffee b/assets/PositionsViews.coffee new file mode 100644 index 0000000..b93c5d8 --- /dev/null +++ b/assets/PositionsViews.coffee @@ -0,0 +1,84 @@ +positionsApp.module 'Views', (Views, App, Backbone) -> + Helpers = + calculatePensum: ((weeklyHours) -> + (workload) -> + Math.round(workload / weeklyHours * 1000) / 10 + )(Bejoo.organisation.weeklyHours) + + + class Views.CreatePosition extends Marionette.View + template: Handlebars.compile $('#create-view-template').html() + el: 'article#content' + events: + 'click .submit-position': 'submitPosition' + 'click .x': 'hide' + 'change #workload-position': 'workloadChanged' + + ui: + title: '.title-position' + indefinite: '#indefinite' + description: '.description-position' + workload: '#workload-position' + from: '.from-position' + to: '.to-position' + pensum: '.pensum-number' + duration: '#duration' + mon: '#mon' + tue: '#tue' + wed: '#wed' + thu: '#thu' + fri: '#fri' + sat: '#sat' + sun: '#sun' + + show: -> + if not $('article#content #create-panel').length + $('article#content').prepend @render() + @bindUIElements() + @workloadChanged() + else + $('#create-panel').show() + + hide: -> + $('#create-panel').hide() + + render: -> + @template { } + + submitPosition: (e) -> + e.preventDefault() + formData = @formData() + formData.created_at = new Date + formData.closed_at = new Date + formData.user_id = 83 + + position = new positionsApp.Models.Position formData + + positionsApp.vent.trigger 'position:add', position + + position.save() + + checkboxToValue: (box) -> + if box.is ':checked' then 1 else 0 + + formData: -> + title: @ui.title.val() + description: @ui.description.val() + workload: parseFloat @ui.workload.val(), 10 + from: new Date @ui.from.val() + to: new Date @ui.to.val() + duration: @ui.duration.val() + indefinite: @ui.indefinite.val() + weekdays: + Mon: @checkboxToValue @ui.mon + Tue: @checkboxToValue @ui.tue + Wed: @checkboxToValue @ui.wed + Thu: @checkboxToValue @ui.thu + Fri: @checkboxToValue @ui.fri + Sat: @checkboxToValue @ui.sat + Sun: @checkboxToValue @ui.sun + + workloadChanged: -> + workload = parseFloat @ui.workload.val(), 10 + @ui.pensum.html Helpers.calculatePensum workload + diff --git a/assets/app/app.coffee b/assets/app/app.coffee new file mode 100644 index 0000000..db55783 --- /dev/null +++ b/assets/app/app.coffee @@ -0,0 +1,298 @@ +Bejoo.sapiURL = window.Bejoo.sapiurl + "organisation/" + +Handlebars.registerHelper 'printDate', (date) -> + moment(date).format 'DD.MM.YYYY' + +Backbone.Marionette.TemplateCache::compileTemplate = (rawTemplate) -> + Handlebars.compile rawTemplate + +getAuthKey = -> + if sessionStorage.authKey + deferred = new $.Deferred + + deferred.resolve + key: sessionStorage.authKey + + deferred + else + request = $.ajax + url: "#{Bejoo.baseUrl}common/auth/key" + dataType: 'json' + + request.done (data) -> + sessionStorage.authKey = data.key + + request + + +setAuthKey = (key) -> + originalSync = Backbone.sync + + Backbone.sync = (method, model, options) -> + options.headers = options.headers || {}; + _.extend options.headers, {'Authorization': "Token #{key}"} + originalSync.call(model, method, model, options); + +positionsApp = new Backbone.Marionette.Application + +positionsApp.addRegions + compoundView: '#compound-view' + +positionsApp.module 'Helpers', (Helpers, App, Backbone, Marionette, $, _) -> + + +positionsApp.module 'Models', (Models, App, Backbone, Marionette, $, _) -> + + class Models.Position extends Backbone.Model + + class Models.Positions extends Backbone.Collection + model: Models.Position + url: "#{Bejoo.sapiURL}position" + + class Models.Round extends Backbone.Model + + close: -> + Bejoo.requestHelper "#{Bejoo.sapiURL}round/#{@get('id')}/close" + + class Models.Rounds extends Backbone.Collection + model: Models.Round + + initialize: -> + @listenTo @, 'add', (round, rounds) => + name = round.get 'name' + processedName = if name is '' then "Runde #{@rounds.length - rounds.indexOf(round)}" else name + round.set 'name', processedName + + comparator: (a, b) -> + if a.get('created_at') < b.get('created_at') then 1 else -1 + + class Models.Application extends Backbone.Model + promote: -> + Bejoo.requestHelper "#{Bejoo.sapiURL}application/#{@get('id')}/promote" + + close: -> + Bejoo.requestHelper "#{Bejoo.sapiURL}application/#{@get('id')}/close" + + class Models.Applications extends Backbone.Collection + model: Models.Application + + + +positionsApp.module 'Views', (Views, App, Backbone) -> + + class Views.CreatePosition extends Marionette.View + template: Handlebars.compile $('#create-view-template').html() + el: 'article#content' + events: + 'click .submit-position': 'submitPosition' + 'click .x': 'hide' + 'change #workload-position': 'workloadChanged' + + ui: + title: '.title-position' + description: '.description-position' + workload: '#workload-position' + from: '.from-position' + to: '.to-position' + pensum: '.pensum-number' + + initialize: -> + + show: -> + if not $('article#content #create-panel').length + $('article#content').prepend @render() + @bindUIElements() + else + $('#create-panel').show() + + hide: -> + $('#create-panel').hide() + + render: -> + @template { } + + onDomRefresh: -> + @workloadChanged() + + + submitPosition: (e) -> + e.preventDefault() + console.log 'submit' + formData = @formData() + formData.created_at = new Date + formData.closed_at = new Date + formData.user_id = 83 + console.log formData + + position = new positionsApp.Models.Position formData + + positionsApp.vent.trigger 'position:add', position + + position.save() + + formData: -> + title: @ui.title.val() + description: @ui.description.val() + workload: parseFloat @ui.workload.val(), 10 + from: new Date @ui.from.val() + to: new Date @ui.to.val() + + calculatePensum: (weekMax, workload) -> + Math.round(workload / weekMax * 1000) / 10 + + workloadChanged: -> + workload = parseFloat @ui.workload.val(), 10 + @ui.pensum.html @calculatePensum 40, workload + + + class Views.PositionListView extends Backbone.Marionette.ItemView + template: '#position-list-item-template' + tagName: 'li' + className: 'list-group-item position-list-element' + events: + 'click': 'selectPosition' + + selectPosition: -> + App.vent.trigger 'positionsList:selected', @model.get 'id' + + class Views.PositionsListView extends Backbone.Marionette.CompositeView + tagName: 'ul' + className: 'list-group' + itemView: Views.PositionListView + template: '#position-list-view-template' + itemViewContainer: '.position-list-view-container' + + events: + 'click #create-position': 'createPosition' + + createPosition: -> + if not @createView + @createView = new Views.CreatePosition + @createView.show() + + + class Views.RoundView extends Backbone.Marionette.ItemView + template: '#positions-round-template' + className: 'position-round-element' + events: + 'click .close-round': 'closeRound' + + onRender: -> + applicationsCollection = new App.Models.Applications @model.get 'applications' + + applicationsView = new App.Views.ApplicationsView + collection: applicationsCollection + + @$el.append applicationsView.el + applicationsView.render() + + closeRound: -> + @model.close() + + class Views.RoundsView extends Backbone.Marionette.CollectionView + itemView: Views.RoundView + + class Views.ApplicationView extends Backbone.Marionette.ItemView + template: '#positions-appliation-template' + className: 'position-application-element col-md-2' + events: + 'click .application-accept': 'acceptApplication' + 'click .application-decline': 'closeApplication' + + acceptApplication: -> + @model.collection.trigger 'application:accepted' + @model.promote() + + closeApplication: -> + @model.collection.trigger 'application:closed' + @model.close() + + onRender: -> + console.log @model + + class Views.ApplicationsView extends Backbone.Marionette.CollectionView + itemView: Views.ApplicationView + className: 'row' + + class Views.PositionView extends Backbone.Marionette.CompositeView + template: '#position-item-template' + className: 'panel panel-default' + itemView: Views.RoundView + itemViewContainer: '.rounds' + + onRender: -> + roundCollection = @model.get 'rounds' + + roundsView = new App.Views.RoundsView + collection: roundCollection + + @$el.append roundsView.el + roundsView.render() + + # @$el.affix + # offset: + # top: 80 + +positionsApp.module 'Controller', (PositionsController, App, Backbone, Marionette, $, _) -> + + class PositionsController.Controller extends Marionette.Controller + constructor: -> + @positions = new App.Models.Positions + + start: -> + that = @ + authKeyRequest = getAuthKey() + authKeyRequest.done (keyData) => + Bejoo.requestHelper = (url, data) -> + $.ajax + dataType: 'json' + url: url + data: data + type: 'POST' + headers: {'Authorization': "Token #{keyData.key}"} + + setAuthKey keyData.key + + @init() + + App.vent.on 'position:add', (position) -> + that.positions.add position + + init: -> + compoundView = new Marionette.CompoundView + listView: App.Views.PositionsListView, + itemView: App.Views.PositionView, + collection: @positions, + template: '#compound-view-template', + breakWidth: 750 + + request = @prepareData() + request.then -> + App.compoundView.show compoundView + + prepareData: -> + request = @positions.fetch() + + request.then => + @positions.forEach (position) -> + rounds = new App.Models.Rounds position.get('rounds') + + counter = rounds.length + + rounds.forEach (round) -> + counter = counter - 1 + name = round.get 'name' + round.set 'name', if name is '' then "Runde #{counter}" else name + + position.set 'rounds', rounds + #console.log position + + + PositionsController.addInitializer -> + controller = new PositionsController.Controller + + controller.start() + + +positionsApp.start() + diff --git a/assets/app/app.js b/assets/app/app.js new file mode 100644 index 0000000..3c3b4c0 --- /dev/null +++ b/assets/app/app.js @@ -0,0 +1,205 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var positionsApp, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + Bejoo.sapiURL = window.Bejoo.sapiurl + "organisation/"; + + Handlebars.registerHelper('printDate', function(date) { + return moment(date).format('DD.MM.YYYY'); + }); + + Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) { + return Handlebars.compile(rawTemplate); + }; + + positionsApp.module('Models', function(Models, App, Backbone, Marionette, $, _) { + var _ref, _ref1; + Models.Position = (function(_super) { + __extends(Position, _super); + + function Position() { + _ref = Position.__super__.constructor.apply(this, arguments); + return _ref; + } + + Position.prototype.parse = function(pos) { + pos.from = new Date(pos.from); + pos.to = new Date(pos.to); + return pos; + }; + + return Position; + + })(Backbone.Model); + return Models.Positions = (function(_super) { + __extends(Positions, _super); + + function Positions() { + _ref1 = Positions.__super__.constructor.apply(this, arguments); + return _ref1; + } + + Positions.prototype.model = Models.Position; + + Positions.prototype.url = "" + Bejoo.sapiURL + "position"; + + Positions.prototype.comparator = function(a, b) { + if (a.get('from') > b.get('from')) { + return 1; + } else { + return -1; + } + }; + + return Positions; + + })(Backbone.Collection); + }); + + positionsApp = new Backbone.Marionette.Application; + + positionsApp.module('Controller', function(PositionsController, App, Backbone, Marionette, $, _) { + PositionsController.Controller = (function(_super) { + __extends(Controller, _super); + + function Controller() {} + + Controller.prototype.start = function() { + var createView; + createView = new positionsApp.View.CreatePosition(); + createView.show(); + return App.vent.on('position:add', function(position) { + return that.positions.add(position); + }); + }; + + return Controller; + + })(Marionette.Controller); + return PositionsController.addInitializer(function() { + var controller; + controller = new PositionsController.Controller; + return controller.start(); + }); + }); + + positionsApp.module('Views', function(Views, App, Backbone) { + var Helpers, _ref; + Helpers = { + calculatePensum: (function(weeklyHours) { + return function(workload) { + return Math.round(workload / weeklyHours * 1000) / 10; + }; + })(Bejoo.organisation.weeklyHours) + }; + return Views.CreatePosition = (function(_super) { + __extends(CreatePosition, _super); + + function CreatePosition() { + _ref = CreatePosition.__super__.constructor.apply(this, arguments); + return _ref; + } + + CreatePosition.prototype.template = Handlebars.compile($('#create-view-template').html()); + + CreatePosition.prototype.el = 'article#content'; + + CreatePosition.prototype.events = { + 'click .submit-position': 'submitPosition', + 'click .x': 'hide', + 'change #workload-position': 'workloadChanged' + }; + + CreatePosition.prototype.ui = { + title: '.title-position', + indefinite: '#indefinite', + description: '.description-position', + workload: '#workload-position', + from: '.from-position', + to: '.to-position', + pensum: '.pensum-number', + duration: '#duration', + mon: '#mon', + tue: '#tue', + wed: '#wed', + thu: '#thu', + fri: '#fri', + sat: '#sat', + sun: '#sun' + }; + + CreatePosition.prototype.show = function() { + if (!$('article#content #create-panel').length) { + $('article#content').prepend(this.render()); + this.bindUIElements(); + return this.workloadChanged(); + } else { + return $('#create-panel').show(); + } + }; + + CreatePosition.prototype.hide = function() { + return $('#create-panel').hide(); + }; + + CreatePosition.prototype.render = function() { + return this.template({}); + }; + + CreatePosition.prototype.submitPosition = function(e) { + var formData, position; + e.preventDefault(); + formData = this.formData(); + formData.created_at = new Date; + formData.closed_at = new Date; + formData.user_id = 83; + position = new positionsApp.Models.Position(formData); + positionsApp.vent.trigger('position:add', position); + return position.save(); + }; + + CreatePosition.prototype.checkboxToValue = function(box) { + if (box.is(':checked')) { + return 1; + } else { + return 0; + } + }; + + CreatePosition.prototype.formData = function() { + return { + title: this.ui.title.val(), + description: this.ui.description.val(), + workload: parseFloat(this.ui.workload.val(), 10), + from: new Date(this.ui.from.val()), + to: new Date(this.ui.to.val()), + duration: this.ui.duration.val(), + indefinite: this.ui.indefinite.val(), + weekdays: { + Mon: this.checkboxToValue(this.ui.mon), + Tue: this.checkboxToValue(this.ui.tue), + Wed: this.checkboxToValue(this.ui.wed), + Thu: this.checkboxToValue(this.ui.thu), + Fri: this.checkboxToValue(this.ui.fri), + Sat: this.checkboxToValue(this.ui.sat), + Sun: this.checkboxToValue(this.ui.sun) + } + }; + }; + + CreatePosition.prototype.workloadChanged = function() { + var workload; + workload = parseFloat(this.ui.workload.val(), 10); + return this.ui.pensum.html(Helpers.calculatePensum(workload)); + }; + + return CreatePosition; + + })(Marionette.View); + }); + + positionsApp.start(); + +}).call(this); diff --git a/assets/app/app.map b/assets/app/app.map new file mode 100644 index 0000000..3259e38 --- /dev/null +++ b/assets/app/app.map @@ -0,0 +1,10 @@ +{ + "version": 3, + "file": "app.js", + "sourceRoot": "../../../../..", + "sources": [ + "assets/scripts/organisation/stellenausschreibung/app/app.coffee" + ], + "names": [], + "mappings": ";AAAA;AAAA,MAAA,oCAAA;IAAA;mSAAA;;AAAA,EAAA,KAAK,CAAC,OAAN,GAAgB,MAAM,CAAC,KAAK,CAAC,OAAb,GAAuB,eAAvC,CAAA;;AAAA,EAEA,UAAU,CAAC,cAAX,CAA0B,WAA1B,EAAuC,SAAC,IAAD,GAAA;WACtC,MAAA,CAAO,IAAP,CAAY,CAAC,MAAb,CAAoB,YAApB,EADsC;EAAA,CAAvC,CAFA,CAAA;;AAAA,EAKA,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAA,SAAE,CAAA,eAAnC,GAAqD,SAAC,WAAD,GAAA;WACpD,UAAU,CAAC,OAAX,CAAmB,WAAnB,EADoD;EAAA,CALrD,CAAA;;AAAA,EAQA,UAAA,GAAa,SAAA,GAAA;AACZ,QAAA,iBAAA;AAAA,IAAA,IAAG,cAAc,CAAC,OAAlB;AACC,MAAA,QAAA,GAAW,GAAA,CAAA,CAAK,CAAC,QAAjB,CAAA;AAAA,MAEA,QAAQ,CAAC,OAAT,CACC;AAAA,QAAA,GAAA,EAAK,cAAc,CAAC,OAApB;OADD,CAFA,CAAA;aAKA,SAND;KAAA,MAAA;AAQC,MAAA,OAAA,GAAU,CAAC,CAAC,IAAF,CACT;AAAA,QAAA,GAAA,EAAK,EAAA,GAAE,KAAK,CAAC,OAAR,GAAiB,iBAAtB;AAAA,QACA,QAAA,EAAU,MADV;OADS,CAAV,CAAA;AAAA,MAIA,OAAO,CAAC,IAAR,CAAa,SAAC,IAAD,GAAA;eACZ,cAAc,CAAC,OAAf,GAAyB,IAAI,CAAC,IADlB;MAAA,CAAb,CAJA,CAAA;aAOA,QAfD;KADY;EAAA,CARb,CAAA;;AAAA,EA2BA,UAAA,GAAa,SAAC,GAAD,GAAA;AACZ,QAAA,YAAA;AAAA,IAAA,YAAA,GAAe,QAAQ,CAAC,IAAxB,CAAA;WAEA,QAAQ,CAAC,IAAT,GAAgB,SAAC,MAAD,EAAS,KAAT,EAAgB,OAAhB,GAAA;AACf,MAAA,OAAO,CAAC,OAAR,GAAkB,OAAO,CAAC,OAAR,IAAmB,EAArC,CAAA;AAAA,MACA,CAAC,CAAC,MAAF,CAAS,OAAO,CAAC,OAAjB,EAA0B;AAAA,QAAC,eAAA,EAAkB,QAAA,GAAO,GAA1B;OAA1B,CADA,CAAA;aAEA,YAAY,CAAC,IAAb,CAAkB,KAAlB,EAAyB,MAAzB,EAAiC,KAAjC,EAAwC,OAAxC,EAHe;IAAA,EAHJ;EAAA,CA3Bb,CAAA;;AAAA,EAmCA,YAAA,GAAe,GAAA,CAAA,QAAY,CAAC,UAAU,CAAC,WAnCvC,CAAA;;AAAA,EAqCA,YAAY,CAAC,UAAb,CACC;AAAA,IAAA,YAAA,EAAc,gBAAd;GADD,CArCA,CAAA;;AAAA,EAwCA,YAAY,CAAC,MAAb,CAAoB,SAApB,EAA+B,SAAC,OAAD,EAAU,GAAV,EAAe,QAAf,EAAyB,UAAzB,EAAqC,CAArC,EAAwC,CAAxC,GAAA,CAA/B,CAxCA,CAAA;;AAAA,EA2CA,YAAY,CAAC,MAAb,CAAoB,QAApB,EAA8B,SAAC,MAAD,EAAS,GAAT,EAAc,QAAd,EAAwB,UAAxB,EAAoC,CAApC,EAAuC,CAAvC,GAAA;AAE7B,IAAM,MAAM,CAAC;AAAb,iCAAA,CAAA;;;;OAAA;;sBAAA;;OAA8B,QAAQ,CAAC,MAAvC,CAAA;AAAA,IAEM,MAAM,CAAC;AACZ,kCAAA,CAAA;;;;OAAA;;AAAA,0BAAA,KAAA,GAAO,MAAM,CAAC,QAAd,CAAA;;AAAA,0BACA,GAAA,GAAK,EAAA,GAAE,KAAK,CAAC,OAAR,GAAiB,UADtB,CAAA;;uBAAA;;OAD8B,QAAQ,CAAC,WAFxC,CAAA;AAAA,IAMM,MAAM,CAAC;AAEZ,8BAAA,CAAA;;;;OAAA;;AAAA,sBAAA,KAAA,GAAO,SAAA,GAAA;eACN,KAAK,CAAC,aAAN,CAAoB,EAAA,GAAE,KAAK,CAAC,OAAR,GAAiB,QAAjB,GAAwB,CAAA,IAAC,CAAA,GAAD,CAAK,IAAL,CAAA,CAAxB,GAAoC,QAAxD,EADM;MAAA,CAAP,CAAA;;mBAAA;;OAF0B,QAAQ,CAAC,MANpC,CAAA;AAAA,IAWM,MAAM,CAAC;AACZ,+BAAA,CAAA;;;;OAAA;;AAAA,uBAAA,KAAA,GAAO,MAAM,CAAC,KAAd,CAAA;;AAAA,uBAEA,UAAA,GAAY,SAAA,GAAA;eACX,IAAC,CAAA,QAAD,CAAU,IAAV,EAAa,KAAb,EAAoB,CAAA,SAAA,KAAA,GAAA;iBAAA,SAAC,KAAD,EAAQ,MAAR,GAAA;AACnB,gBAAA,mBAAA;AAAA,YAAA,IAAA,GAAO,KAAK,CAAC,GAAN,CAAU,MAAV,CAAP,CAAA;AAAA,YACA,aAAA,GAAmB,IAAA,KAAQ,EAAX,GAAoB,QAAA,GAAO,CAAA,KAAC,CAAA,MAAM,CAAC,MAAR,GAAiB,MAAM,CAAC,OAAP,CAAe,KAAf,CAAjB,CAA3B,GAA0E,IAD1F,CAAA;mBAEA,KAAK,CAAC,GAAN,CAAU,MAAV,EAAkB,aAAlB,EAHmB;UAAA,EAAA;QAAA,CAAA,CAAA,CAAA,IAAA,CAApB,EADW;MAAA,CAFZ,CAAA;;AAAA,uBAQA,UAAA,GAAY,SAAC,CAAD,EAAI,CAAJ,GAAA;AACX,QAAA,IAAG,CAAC,CAAC,GAAF,CAAM,YAAN,CAAA,GAAsB,CAAC,CAAC,GAAF,CAAM,YAAN,CAAzB;iBAAkD,EAAlD;SAAA,MAAA;iBAAyD,CAAA,EAAzD;SADW;MAAA,CARZ,CAAA;;oBAAA;;OAD2B,QAAQ,CAAC,WAXrC,CAAA;AAAA,IAuBM,MAAM,CAAC;AACZ,oCAAA,CAAA;;;;OAAA;;AAAA,4BAAA,OAAA,GAAS,SAAA,GAAA;eACR,KAAK,CAAC,aAAN,CAAoB,EAAA,GAAE,KAAK,CAAC,OAAR,GAAiB,cAAjB,GAA8B,CAAA,IAAC,CAAA,GAAD,CAAK,IAAL,CAAA,CAA9B,GAA0C,UAA9D,EADQ;MAAA,CAAT,CAAA;;AAAA,4BAGA,KAAA,GAAO,SAAA,GAAA;eACN,KAAK,CAAC,aAAN,CAAoB,EAAA,GAAE,KAAK,CAAC,OAAR,GAAiB,cAAjB,GAA8B,CAAA,IAAC,CAAA,GAAD,CAAK,IAAL,CAAA,CAA9B,GAA0C,QAA9D,EADM;MAAA,CAHP,CAAA;;yBAAA;;OADgC,QAAQ,CAAC,MAvB1C,CAAA;WA8BM,MAAM,CAAC;AACZ,qCAAA,CAAA;;;;OAAA;;AAAA,6BAAA,KAAA,GAAO,MAAM,CAAC,WAAd,CAAA;;0BAAA;;OADiC,QAAQ,CAAC,YAhCd;EAAA,CAA9B,CA3CA,CAAA;;AAAA,EAgFA,YAAY,CAAC,MAAb,CAAoB,OAApB,EAA6B,SAAC,KAAD,EAAQ,GAAR,EAAa,QAAb,GAAA;AAE5B,IAAM,KAAK,CAAC;AACX,uCAAA,CAAA;;;;OAAA;;AAAA,+BAAA,QAAA,GAAU,UAAU,CAAC,OAAX,CAAmB,CAAA,CAAE,uBAAF,CAA0B,CAAC,IAA3B,CAAA,CAAnB,CAAV,CAAA;;AAAA,+BACA,EAAA,GAAI,iBADJ,CAAA;;AAAA,+BAEA,MAAA,GACC;AAAA,QAAA,wBAAA,EAA0B,gBAA1B;AAAA,QACA,UAAA,EAAY,MADZ;AAAA,QAEA,2BAAA,EAA6B,iBAF7B;OAHD,CAAA;;AAAA,+BAOA,EAAA,GACC;AAAA,QAAA,KAAA,EAAO,iBAAP;AAAA,QACA,WAAA,EAAa,uBADb;AAAA,QAEA,QAAA,EAAU,oBAFV;AAAA,QAGA,IAAA,EAAM,gBAHN;AAAA,QAIA,EAAA,EAAI,cAJJ;AAAA,QAKA,MAAA,EAAQ,gBALR;OARD,CAAA;;AAAA,+BAeA,UAAA,GAAY,SAAA,GAAA,CAfZ,CAAA;;AAAA,+BAiBA,IAAA,GAAM,SAAA,GAAA;AACL,QAAA,IAAG,CAAA,CAAI,CAAE,+BAAF,CAAkC,CAAC,MAA1C;AACC,UAAA,CAAA,CAAE,iBAAF,CAAoB,CAAC,OAArB,CAA6B,IAAC,CAAA,MAAD,CAAA,CAA7B,CAAA,CAAA;iBACA,IAAC,CAAA,cAAD,CAAA,EAFD;SAAA,MAAA;iBAIC,CAAA,CAAE,eAAF,CAAkB,CAAC,IAAnB,CAAA,EAJD;SADK;MAAA,CAjBN,CAAA;;AAAA,+BAwBA,IAAA,GAAM,SAAA,GAAA;eACL,CAAA,CAAE,eAAF,CAAkB,CAAC,IAAnB,CAAA,EADK;MAAA,CAxBN,CAAA;;AAAA,+BA2BA,MAAA,GAAQ,SAAA,GAAA;eACP,IAAC,CAAA,QAAD,CAAU,EAAV,EADO;MAAA,CA3BR,CAAA;;AAAA,+BA8BA,YAAA,GAAc,SAAA,GAAA;eACb,IAAC,CAAA,eAAD,CAAA,EADa;MAAA,CA9Bd,CAAA;;AAAA,+BAkCA,cAAA,GAAgB,SAAC,CAAD,GAAA;AACf,YAAA,kBAAA;AAAA,QAAA,CAAC,CAAC,cAAF,CAAA,CAAA,CAAA;AAAA,QACA,OAAO,CAAC,GAAR,CAAY,QAAZ,CADA,CAAA;AAAA,QAEA,QAAA,GAAW,IAAC,CAAA,QAAD,CAAA,CAFX,CAAA;AAAA,QAGA,QAAQ,CAAC,UAAT,GAAsB,GAAA,CAAA,IAHtB,CAAA;AAAA,QAIA,QAAQ,CAAC,SAAT,GAAqB,GAAA,CAAA,IAJrB,CAAA;AAAA,QAKA,QAAQ,CAAC,OAAT,GAAmB,EALnB,CAAA;AAAA,QAMA,OAAO,CAAC,GAAR,CAAY,QAAZ,CANA,CAAA;AAAA,QAQA,QAAA,GAAe,IAAA,YAAY,CAAC,MAAM,CAAC,QAApB,CAA6B,QAA7B,CARf,CAAA;AAAA,QAUA,YAAY,CAAC,IAAI,CAAC,OAAlB,CAA0B,cAA1B,EAA0C,QAA1C,CAVA,CAAA;eAYA,QAAQ,CAAC,IAAT,CAAA,EAbe;MAAA,CAlChB,CAAA;;AAAA,+BAiDA,QAAA,GAAU,SAAA,GAAA;eACT;AAAA,UAAA,KAAA,EAAO,IAAC,CAAA,EAAE,CAAC,KAAK,CAAC,GAAV,CAAA,CAAP;AAAA,UACA,WAAA,EAAa,IAAC,CAAA,EAAE,CAAC,WAAW,CAAC,GAAhB,CAAA,CADb;AAAA,UAEA,QAAA,EAAU,UAAA,CAAW,IAAC,CAAA,EAAE,CAAC,QAAQ,CAAC,GAAb,CAAA,CAAX,EAA+B,EAA/B,CAFV;AAAA,UAGA,IAAA,EAAU,IAAA,IAAA,CAAK,IAAC,CAAA,EAAE,CAAC,IAAI,CAAC,GAAT,CAAA,CAAL,CAHV;AAAA,UAIA,EAAA,EAAQ,IAAA,IAAA,CAAK,IAAC,CAAA,EAAE,CAAC,EAAE,CAAC,GAAP,CAAA,CAAL,CAJR;UADS;MAAA,CAjDV,CAAA;;AAAA,+BAwDA,eAAA,GAAiB,SAAC,OAAD,EAAU,QAAV,GAAA;eAChB,IAAI,CAAC,KAAL,CAAW,QAAA,GAAW,OAAX,GAAqB,IAAhC,CAAA,GAAwC,GADxB;MAAA,CAxDjB,CAAA;;AAAA,+BA2DA,eAAA,GAAiB,SAAA,GAAA;AAChB,YAAA,QAAA;AAAA,QAAA,QAAA,GAAW,UAAA,CAAW,IAAC,CAAA,EAAE,CAAC,QAAQ,CAAC,GAAb,CAAA,CAAX,EAA+B,EAA/B,CAAX,CAAA;eACA,IAAC,CAAA,EAAE,CAAC,MAAM,CAAC,IAAX,CAAgB,IAAC,CAAA,eAAD,CAAiB,EAAjB,EAAqB,QAArB,CAAhB,EAFgB;MAAA,CA3DjB,CAAA;;4BAAA;;OADkC,UAAU,CAAC,KAA9C,CAAA;AAAA,IAiEM,KAAK,CAAC;AACX,yCAAA,CAAA;;;;OAAA;;AAAA,iCAAA,QAAA,GAAU,8BAAV,CAAA;;AAAA,iCACA,OAAA,GAAS,IADT,CAAA;;AAAA,iCAEA,SAAA,GAAW,uCAFX,CAAA;;AAAA,iCAGA,MAAA,GACC;AAAA,QAAA,OAAA,EAAS,gBAAT;OAJD,CAAA;;AAAA,iCAMA,cAAA,GAAgB,SAAA,GAAA;eACf,GAAG,CAAC,IAAI,CAAC,OAAT,CAAiB,wBAAjB,EAA2C,IAAC,CAAA,KAAK,CAAC,GAAP,CAAW,IAAX,CAA3C,EADe;MAAA,CANhB,CAAA;;8BAAA;;OADoC,QAAQ,CAAC,UAAU,CAAC,SAjEzD,CAAA;AAAA,IA2EM,KAAK,CAAC;AACX,0CAAA,CAAA;;;;OAAA;;AAAA,kCAAA,OAAA,GAAS,IAAT,CAAA;;AAAA,kCACA,SAAA,GAAW,YADX,CAAA;;AAAA,kCAEA,QAAA,GAAU,KAAK,CAAC,gBAFhB,CAAA;;AAAA,kCAGA,QAAA,GAAU,8BAHV,CAAA;;AAAA,kCAIA,iBAAA,GAAmB,+BAJnB,CAAA;;AAAA,kCAMA,MAAA,GACC;AAAA,QAAA,wBAAA,EAA0B,gBAA1B;OAPD,CAAA;;AAAA,kCASA,cAAA,GAAgB,SAAA,GAAA;AACf,QAAA,IAAG,CAAA,IAAK,CAAA,UAAR;AACC,UAAA,IAAC,CAAA,UAAD,GAAc,GAAA,CAAA,KAAS,CAAC,cAAxB,CADD;SAAA;eAEA,IAAC,CAAA,UAAU,CAAC,IAAZ,CAAA,EAHe;MAAA,CAThB,CAAA;;+BAAA;;OADqC,QAAQ,CAAC,UAAU,CAAC,cA3E1D,CAAA;AAAA,IA2FM,KAAK,CAAC;AACX,kCAAA,CAAA;;;;OAAA;;AAAA,0BAAA,QAAA,GAAU,2BAAV,CAAA;;AAAA,0BACA,SAAA,GAAW,wBADX,CAAA;;AAAA,0BAEA,MAAA,GACC;AAAA,QAAA,oBAAA,EAAsB,YAAtB;OAHD,CAAA;;AAAA,0BAKA,QAAA,GAAU,SAAA,GAAA;AACT,YAAA,wCAAA;AAAA,QAAA,sBAAA,GAA6B,IAAA,GAAG,CAAC,MAAM,CAAC,YAAX,CAAwB,IAAC,CAAA,KAAK,CAAC,GAAP,CAAW,cAAX,CAAxB,CAA7B,CAAA;AAAA,QAEA,gBAAA,GAAuB,IAAA,GAAG,CAAC,KAAK,CAAC,gBAAV,CACtB;AAAA,UAAA,UAAA,EAAY,sBAAZ;SADsB,CAFvB,CAAA;AAAA,QAKA,IAAC,CAAA,GAAG,CAAC,MAAL,CAAY,gBAAgB,CAAC,EAA7B,CALA,CAAA;eAMA,gBAAgB,CAAC,MAAjB,CAAA,EAPS;MAAA,CALV,CAAA;;AAAA,0BAcA,UAAA,GAAY,SAAA,GAAA;eACX,IAAC,CAAA,KAAK,CAAC,KAAP,CAAA,EADW;MAAA,CAdZ,CAAA;;uBAAA;;OAD6B,QAAQ,CAAC,UAAU,CAAC,SA3FlD,CAAA;AAAA,IA6GM,KAAK,CAAC;AACX,mCAAA,CAAA;;;;OAAA;;AAAA,2BAAA,QAAA,GAAU,KAAK,CAAC,SAAhB,CAAA;;wBAAA;;OAD8B,QAAQ,CAAC,UAAU,CAAC,eA7GnD,CAAA;AAAA,IAgHM,KAAK,CAAC;AACX,wCAAA,CAAA;;;;OAAA;;AAAA,gCAAA,QAAA,GAAU,gCAAV,CAAA;;AAAA,gCACA,SAAA,GAAW,uCADX,CAAA;;AAAA,gCAEA,MAAA,GACC;AAAA,QAAA,2BAAA,EAA6B,mBAA7B;AAAA,QACA,4BAAA,EAA8B,kBAD9B;OAHD,CAAA;;AAAA,gCAMA,iBAAA,GAAmB,SAAA,GAAA;AAClB,QAAA,IAAC,CAAA,KAAK,CAAC,UAAU,CAAC,OAAlB,CAA0B,sBAA1B,CAAA,CAAA;eACA,IAAC,CAAA,KAAK,CAAC,OAAP,CAAA,EAFkB;MAAA,CANnB,CAAA;;AAAA,gCAUA,gBAAA,GAAkB,SAAA,GAAA;AACjB,QAAA,IAAC,CAAA,KAAK,CAAC,UAAU,CAAC,OAAlB,CAA0B,oBAA1B,CAAA,CAAA;eACA,IAAC,CAAA,KAAK,CAAC,KAAP,CAAA,EAFiB;MAAA,CAVlB,CAAA;;AAAA,gCAcA,QAAA,GAAU,SAAA,GAAA;eACT,OAAO,CAAC,GAAR,CAAY,IAAC,CAAA,KAAb,EADS;MAAA,CAdV,CAAA;;6BAAA;;OADmC,QAAQ,CAAC,UAAU,CAAC,SAhHxD,CAAA;AAAA,IAkIM,KAAK,CAAC;AACX,yCAAA,CAAA;;;;OAAA;;AAAA,iCAAA,QAAA,GAAU,KAAK,CAAC,eAAhB,CAAA;;AAAA,iCACA,SAAA,GAAW,KADX,CAAA;;8BAAA;;OADoC,QAAQ,CAAC,UAAU,CAAC,eAlIzD,CAAA;WAsIM,KAAK,CAAC;AACX,qCAAA,CAAA;;;;OAAA;;AAAA,6BAAA,QAAA,GAAU,yBAAV,CAAA;;AAAA,6BACA,SAAA,GAAW,qBADX,CAAA;;AAAA,6BAEA,QAAA,GAAU,KAAK,CAAC,SAFhB,CAAA;;AAAA,6BAGA,iBAAA,GAAmB,SAHnB,CAAA;;AAAA,6BAKA,QAAA,GAAU,SAAA,GAAA;AACT,YAAA,2BAAA;AAAA,QAAA,eAAA,GAAkB,IAAC,CAAA,KAAK,CAAC,GAAP,CAAW,QAAX,CAAlB,CAAA;AAAA,QAEA,UAAA,GAAiB,IAAA,GAAG,CAAC,KAAK,CAAC,UAAV,CAChB;AAAA,UAAA,UAAA,EAAY,eAAZ;SADgB,CAFjB,CAAA;AAAA,QAKA,IAAC,CAAA,GAAG,CAAC,MAAL,CAAY,UAAU,CAAC,EAAvB,CALA,CAAA;eAMA,UAAU,CAAC,MAAX,CAAA,EAPS;MAAA,CALV,CAAA;;0BAAA;;OADgC,QAAQ,CAAC,UAAU,CAAC,eAxIzB;EAAA,CAA7B,CAhFA,CAAA;;AAAA,EA2OA,YAAY,CAAC,MAAb,CAAoB,YAApB,EAAkC,SAAC,mBAAD,EAAsB,GAAtB,EAA2B,QAA3B,EAAqC,UAArC,EAAiD,CAAjD,EAAoD,CAApD,GAAA;AAEjC,IAAM,mBAAmB,CAAC;AACzB,mCAAA,CAAA;;AAAa,MAAA,oBAAA,GAAA;AACZ,QAAA,IAAC,CAAA,SAAD,GAAa,GAAA,CAAA,GAAO,CAAC,MAAM,CAAC,SAA5B,CADY;MAAA,CAAb;;AAAA,2BAGA,KAAA,GAAO,SAAA,GAAA;AACN,YAAA,oBAAA;AAAA,QAAA,IAAA,GAAO,IAAP,CAAA;AAAA,QACA,cAAA,GAAiB,UAAA,CAAA,CADjB,CAAA;AAAA,QAEA,cAAc,CAAC,IAAf,CAAoB,CAAA,SAAA,KAAA,GAAA;iBAAA,SAAC,OAAD,GAAA;AACnB,YAAA,KAAK,CAAC,aAAN,GAAsB,SAAC,GAAD,EAAM,IAAN,GAAA;qBACrB,CAAC,CAAC,IAAF,CACC;AAAA,gBAAA,QAAA,EAAU,MAAV;AAAA,gBACA,GAAA,EAAK,GADL;AAAA,gBAEA,IAAA,EAAM,IAFN;AAAA,gBAGA,IAAA,EAAM,MAHN;AAAA,gBAIA,OAAA,EAAS;AAAA,kBAAC,eAAA,EAAkB,QAAA,GAAO,OAAO,CAAC,GAAlC;iBAJT;eADD,EADqB;YAAA,CAAtB,CAAA;AAAA,YAQA,UAAA,CAAW,OAAO,CAAC,GAAnB,CARA,CAAA;mBAUA,KAAC,CAAA,IAAD,CAAA,EAXmB;UAAA,EAAA;QAAA,CAAA,CAAA,CAAA,IAAA,CAApB,CAFA,CAAA;eAeA,GAAG,CAAC,IAAI,CAAC,EAAT,CAAY,cAAZ,EAA4B,SAAC,QAAD,GAAA;iBAC3B,IAAI,CAAC,SAAS,CAAC,GAAf,CAAmB,QAAnB,EAD2B;QAAA,CAA5B,EAhBM;MAAA,CAHP,CAAA;;AAAA,2BAsBA,IAAA,GAAM,SAAA,GAAA;AACL,YAAA,qBAAA;AAAA,QAAA,YAAA,GAAmB,IAAA,UAAU,CAAC,YAAX,CAClB;AAAA,UAAA,QAAA,EAAU,GAAG,CAAC,KAAK,CAAC,iBAApB;AAAA,UACA,QAAA,EAAU,GAAG,CAAC,KAAK,CAAC,YADpB;AAAA,UAEA,UAAA,EAAY,IAAC,CAAA,SAFb;AAAA,UAGA,QAAA,EAAU,yBAHV;AAAA,UAIA,UAAA,EAAY,GAJZ;SADkB,CAAnB,CAAA;AAAA,QAOA,OAAA,GAAU,IAAC,CAAA,WAAD,CAAA,CAPV,CAAA;eAQA,OAAO,CAAC,IAAR,CAAa,SAAA,GAAA;iBACZ,GAAG,CAAC,YAAY,CAAC,IAAjB,CAAsB,YAAtB,EADY;QAAA,CAAb,EATK;MAAA,CAtBN,CAAA;;AAAA,2BAkCA,WAAA,GAAa,SAAA,GAAA;AACZ,YAAA,OAAA;AAAA,QAAA,OAAA,GAAU,IAAC,CAAA,SAAS,CAAC,KAAX,CAAA,CAAV,CAAA;eAEA,OAAO,CAAC,IAAR,CAAa,CAAA,SAAA,KAAA,GAAA;iBAAA,SAAA,GAAA;mBACZ,KAAC,CAAA,SAAS,CAAC,OAAX,CAAmB,SAAC,QAAD,GAAA;AAClB,kBAAA,eAAA;AAAA,cAAA,MAAA,GAAa,IAAA,GAAG,CAAC,MAAM,CAAC,MAAX,CAAkB,QAAQ,CAAC,GAAT,CAAa,QAAb,CAAlB,CAAb,CAAA;AAAA,cAEA,OAAA,GAAU,MAAM,CAAC,MAFjB,CAAA;AAAA,cAIA,MAAM,CAAC,OAAP,CAAe,SAAC,KAAD,GAAA;AACd,oBAAA,IAAA;AAAA,gBAAA,OAAA,GAAU,OAAA,GAAU,CAApB,CAAA;AAAA,gBACA,IAAA,GAAO,KAAK,CAAC,GAAN,CAAU,MAAV,CADP,CAAA;uBAEA,KAAK,CAAC,GAAN,CAAU,MAAV,EAAqB,IAAA,KAAQ,EAAX,GAAoB,QAAA,GAAO,OAA3B,GAA2C,IAA7D,EAHc;cAAA,CAAf,CAJA,CAAA;qBASA,QAAQ,CAAC,GAAT,CAAa,QAAb,EAAuB,MAAvB,EAVkB;YAAA,CAAnB,EADY;UAAA,EAAA;QAAA,CAAA,CAAA,CAAA,IAAA,CAAb,EAHY;MAAA,CAlCb,CAAA;;wBAAA;;OAD4C,UAAU,CAAC,WAAxD,CAAA;WAqDA,mBAAmB,CAAC,cAApB,CAAmC,SAAA,GAAA;AAClC,UAAA,UAAA;AAAA,MAAA,UAAA,GAAa,GAAA,CAAA,mBAAuB,CAAC,UAArC,CAAA;aAEA,UAAU,CAAC,KAAX,CAAA,EAHkC;IAAA,CAAnC,EAvDiC;EAAA,CAAlC,CA3OA,CAAA;;AAAA,EAwSA,YAAY,CAAC,KAAb,CAAA,CAxSA,CAAA;AAAA" +} \ No newline at end of file diff --git a/assets/bsetup.coffee b/assets/bsetup.coffee new file mode 100644 index 0000000..8099e60 --- /dev/null +++ b/assets/bsetup.coffee @@ -0,0 +1,8 @@ +Bejoo.sapiURL = window.Bejoo.sapiurl + "organisation/" + +Handlebars.registerHelper 'printDate', (date) -> + moment(date).format 'DD.MM.YYYY' + +Backbone.Marionette.TemplateCache::compileTemplate = (rawTemplate) -> + Handlebars.compile rawTemplate + diff --git a/assets/css/stellenausschreibung.css b/assets/css/stellenausschreibung.css new file mode 100644 index 0000000..51b0bf1 --- /dev/null +++ b/assets/css/stellenausschreibung.css @@ -0,0 +1,12 @@ +#list .position-public{color:#2b93d1} +.position-round-element h3{background-color:#0f3a50;padding:12px;color:#fff} +li.position-list-element{background-color:#333;color:#fff} +.position-list-view-container{padding:0} +#nav-tabs{padding-left:15px} +.caption p{margin-bottom:0} +#list .position-list-element h3{font-size:18px;margin-top:0} +.panel.affix{top:80px;width:calc(16.200000000000003%)} +.position-application-element .closed h4 a{color:#808080} +.position-application-element .closed img{-webkit-filter:grayscale(100%);filter:grayscale(100%)} +.single-element-container{float:right} +#list>div{height:400px;overflow:auto} diff --git a/assets/dPositionsModels.coffee b/assets/dPositionsModels.coffee new file mode 100644 index 0000000..eda62fe --- /dev/null +++ b/assets/dPositionsModels.coffee @@ -0,0 +1,17 @@ +positionsApp.module 'Models', (Models, App, Backbone, Marionette, $, _) -> + + class Models.Position extends Backbone.Model + parse: (pos) -> + pos.from = new Date pos.from + pos.to = new Date pos.to + pos + + class Models.Positions extends Backbone.Collection + model: Models.Position + url: "#{Bejoo.sapiURL}position" + + comparator: (a, b) -> + if a.get('from') > b.get('from') + 1 + else + -1 diff --git a/assets/zinit.coffee b/assets/zinit.coffee new file mode 100644 index 0000000..973f620 --- /dev/null +++ b/assets/zinit.coffee @@ -0,0 +1,2 @@ +positionsApp.start() + diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..82f259a --- /dev/null +++ b/bower.json @@ -0,0 +1,31 @@ +{ + "name": "bejoo", + "version": "0.0.1", + "private": true, + "dependencies": { + "jquery": "~2.0.3", + "underscore": "1.5.x", + "backbone": "1.1.x", + "backbone.marionette": "1.6.x", + "momentjs": "~2.4.0", + "bootstrap": "~3.0.0", + "messenger": "1.4.x", + "spinjs": "~1.3.2", + "selectize": "~0.8.5", + "bacon": "~0.7.0", + "bacon.jquery": "~0.4.0", + "raven-js": "~1.1.7", + "handlebars": "~1.3.0" + }, + "ignore": [ + "**/.*", + "node_modules/", + "components/", + "bower_components/", + "test/", + "tests/", + "docs/", + "tests/", + "examples/" + ] +} diff --git a/bower_components/backbone.babysitter/.bower.json b/bower_components/backbone.babysitter/.bower.json new file mode 100644 index 0000000..5b5106c --- /dev/null +++ b/bower_components/backbone.babysitter/.bower.json @@ -0,0 +1,14 @@ +{ + "name": "backbone.babysitter", + "homepage": "https://github.com/marionettejs/backbone.babysitter", + "version": "0.0.6", + "_release": "0.0.6", + "_resolution": { + "type": "version", + "tag": "v0.0.6", + "commit": "49b2d401d3ee02021485512f2b089b8b97d1918d" + }, + "_source": "git://github.com/marionettejs/backbone.babysitter.git", + "_target": "~0.0.6", + "_originalSource": "backbone.babysitter" +} \ No newline at end of file diff --git a/bower_components/backbone.babysitter/.gitignore b/bower_components/backbone.babysitter/.gitignore new file mode 100644 index 0000000..ec6903a --- /dev/null +++ b/bower_components/backbone.babysitter/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +*.swp +*.swo +.grunt/ +node_modules +_SpecRunner.html +.idea +npm-debug.log diff --git a/bower_components/backbone.babysitter/.jshintrc b/bower_components/backbone.babysitter/.jshintrc new file mode 100644 index 0000000..cacb6a7 --- /dev/null +++ b/bower_components/backbone.babysitter/.jshintrc @@ -0,0 +1,24 @@ +{ + "curly": true, + "eqeqeq": true, + "immed": false, + "latedef": true, + "newcap": true, + "noarg": true, + "sub": true, + "undef": true, + "boss": true, + "eqnull": true, + "browser": true, + "globals": { + "jQuery": true, + "Backbone": true, + "_": true, + "Marionette": true, + "$": true, + "slice": true, + "require": true, + "define": true, + "module": true + } +} diff --git a/bower_components/backbone.babysitter/CHANGELOG.md b/bower_components/backbone.babysitter/CHANGELOG.md new file mode 100644 index 0000000..4ad341d --- /dev/null +++ b/bower_components/backbone.babysitter/CHANGELOG.md @@ -0,0 +1,29 @@ +# Change log + +### v0.0.6 + +* Removed `.findByCollection` method +* Added `.findByModelCid` method + +### v0.0.5 + +* Updated build process to use GruntJS v0.4 + +### v0.0.4 + +* Added a fix for IE < 9, when applying a function to the views +* Added `.pluck` as a method, from Underscore.js +* Can specify an array of views to the container constructor + +### v0.0.3 + +* Added iterators and other collection processing functions from Underscore.js + +### v0.0.2 + +* Added `.length` attribute +* Added `.findByIndex` method + +### v0.0.1 + +* Initial release diff --git a/bower_components/backbone.babysitter/Gruntfile.js b/bower_components/backbone.babysitter/Gruntfile.js new file mode 100644 index 0000000..20cc8b5 --- /dev/null +++ b/bower_components/backbone.babysitter/Gruntfile.js @@ -0,0 +1,150 @@ +/*global module:false*/ +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + version: '<%= pkg.version %>', + banner: + '// Backbone.BabySitter\n' + + '// -------------------\n' + + '// v<%= pkg.version %>\n' + + '//\n' + + '// Copyright (c)<%= grunt.template.today("yyyy") %> Derick Bailey, Muted Solutions, LLC.\n' + + '// Distributed under MIT license\n' + + '//\n' + + '// http://github.com/babysitterjs/backbone.babysitter\n' + + '\n' + }, + + lint: { + files: ['src/*.js'] + }, + + preprocess: { + core_build: { + files: { + 'lib/backbone.babysitter.js' : 'src/childviewcontainer.js' + } + }, + core_amd: { + files: { + 'lib/amd/backbone.babysitter.js' : 'src/amd.js' + } + }, + }, + + concat: { + options: { + banner: "<%= meta.banner %>" + }, + core: { + src: 'lib/backbone.babysitter.js', + dest: 'lib/backbone.babysitter.js' + }, + amd: { + src: 'lib/amd/backbone.babysitter.js', + dest: 'lib/amd/backbone.babysitter.js' + } + }, + + uglify : { + options: { + banner: "<%= meta.banner %>" + }, + amd : { + src : 'lib/amd/backbone.babysitter.js', + dest : 'lib/amd/backbone.babysitter.min.js', + }, + core : { + src : 'lib/backbone.babysitter.js', + dest : 'lib/backbone.babysitter.min.js', + options : { + sourceMap : 'lib/backbone.babysitter.map', + sourceMappingURL : 'backbone.babysitter.map', + sourceMapPrefix : 2, + } + } + }, + + jasmine : { + options : { + helpers : 'spec/javascripts/helpers/*.js', + specs : 'spec/javascripts/**/*.spec.js', + vendor : [ + 'public/javascripts/jquery.js', + 'public/javascripts/json2.js', + 'public/javascripts/underscore.js', + 'public/javascripts/backbone.js' + ], + }, + coverage : { + src : '<%= jasmine.babysitter.src %>', + options : { + template : require('grunt-template-jasmine-istanbul'), + templateOptions: { + coverage: 'reports/coverage.json', + report: 'reports/coverage' + } + } + }, + babysitter : { + src : ['src/*.js'], + } + }, + + jshint: { + options: { + jshintrc : '.jshintrc' + }, + babysitter : [ 'src/*.js' ] + }, + plato: { + babysitter : { + src : 'src/*.js', + dest : 'reports', + options : { + jshint : grunt.file.readJSON('.jshintrc') + } + } + }, + watch: { + babysitter : { + files : ['src/*.js', 'spec/**/*.js'], + tasks : ['jshint', 'jasmine:babysitter'] + }, + server : { + files : ['src/*.js', 'spec/**/*.js'], + tasks : ['jasmine:babysitter:build'] + } + }, + + connect: { + server: { + options: { + port: 8888 + } + } + } + }); + + grunt.loadNpmTasks('grunt-preprocess'); + grunt.loadNpmTasks('grunt-contrib-jasmine'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-plato'); + + grunt.registerTask('test', ['jshint', 'jasmine:babysitter']); + + grunt.registerTask('dev', ['test', 'watch:babysitter']); + + grunt.registerTask('server', ['jasmine:babysitter:build', 'connect:server', 'watch:server']); + + // Default task. + grunt.registerTask('default', ['jshint', 'jasmine:coverage', 'preprocess', 'concat', 'uglify']); + +}; diff --git a/bower_components/backbone.babysitter/LICENSE.md b/bower_components/backbone.babysitter/LICENSE.md new file mode 100644 index 0000000..1ec483c --- /dev/null +++ b/bower_components/backbone.babysitter/LICENSE.md @@ -0,0 +1,5 @@ +# Backbone.BabySitter + +Copyright (C)2013 Derick Bailey, Muted Solutions, LLC + +Distributed Under [MIT License](http://mutedsolutions.mit-license.org/) diff --git a/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.js b/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.js new file mode 100644 index 0000000..a182eda --- /dev/null +++ b/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.js @@ -0,0 +1,178 @@ +// Backbone.BabySitter +// ------------------- +// v0.0.6 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://github.com/babysitterjs/backbone.babysitter + +(function (root, factory) { + if (typeof exports === 'object') { + + var underscore = require('underscore'); + var backbone = require('backbone'); + + module.exports = factory(underscore, backbone); + + } else if (typeof define === 'function' && define.amd) { + + define(['underscore', 'backbone'], factory); + + } +}(this, function (_, Backbone) { + "option strict"; + + // Backbone.ChildViewContainer +// --------------------------- +// +// Provide a container to store, retrieve and +// shut down child views. + +Backbone.ChildViewContainer = (function(Backbone, _){ + + // Container Constructor + // --------------------- + + var Container = function(views){ + this._views = {}; + this._indexByModel = {}; + this._indexByCustom = {}; + this._updateLength(); + + _.each(views, this.add, this); + }; + + // Container Methods + // ----------------- + + _.extend(Container.prototype, { + + // Add a view to this container. Stores the view + // by `cid` and makes it searchable by the model + // cid (and model itself). Optionally specify + // a custom key to store an retrieve the view. + add: function(view, customIndex){ + var viewCid = view.cid; + + // store the view + this._views[viewCid] = view; + + // index it by model + if (view.model){ + this._indexByModel[view.model.cid] = viewCid; + } + + // index by custom + if (customIndex){ + this._indexByCustom[customIndex] = viewCid; + } + + this._updateLength(); + }, + + // Find a view by the model that was attached to + // it. Uses the model's `cid` to find it. + findByModel: function(model){ + return this.findByModelCid(model.cid); + }, + + // Find a view by the `cid` of the model that was attached to + // it. Uses the model's `cid` to find the view `cid` and + // retrieve the view using it. + findByModelCid: function(modelCid){ + var viewCid = this._indexByModel[modelCid]; + return this.findByCid(viewCid); + }, + + // Find a view by a custom indexer. + findByCustom: function(index){ + var viewCid = this._indexByCustom[index]; + return this.findByCid(viewCid); + }, + + // Find by index. This is not guaranteed to be a + // stable index. + findByIndex: function(index){ + return _.values(this._views)[index]; + }, + + // retrieve a view by it's `cid` directly + findByCid: function(cid){ + return this._views[cid]; + }, + + // Remove a view + remove: function(view){ + var viewCid = view.cid; + + // delete model index + if (view.model){ + delete this._indexByModel[view.model.cid]; + } + + // delete custom index + _.any(this._indexByCustom, function(cid, key) { + if (cid === viewCid) { + delete this._indexByCustom[key]; + return true; + } + }, this); + + // remove the view from the container + delete this._views[viewCid]; + + // update the length + this._updateLength(); + }, + + // Call a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.call`. + call: function(method){ + this.apply(method, _.tail(arguments)); + }, + + // Apply a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.apply`. + apply: function(method, args){ + _.each(this._views, function(view){ + if (_.isFunction(view[method])){ + view[method].apply(view, args || []); + } + }); + }, + + // Update the `.length` attribute on this container + _updateLength: function(){ + this.length = _.size(this._views); + } + }); + + // Borrowing this code from Backbone.Collection: + // http://backbonejs.org/docs/backbone.html#section-106 + // + // Mix in methods from Underscore, for iteration, and other + // collection related features. + var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter', + 'select', 'reject', 'every', 'all', 'some', 'any', 'include', + 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest', + 'last', 'without', 'isEmpty', 'pluck']; + + _.each(methods, function(method) { + Container.prototype[method] = function() { + var views = _.values(this._views); + var args = [views].concat(_.toArray(arguments)); + return _[method].apply(_, args); + }; + }); + + // return the public API + return Container; +})(Backbone, _); + + return Backbone.ChildViewContainer; + +})); + diff --git a/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.min.js b/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.min.js new file mode 100644 index 0000000..78355c8 --- /dev/null +++ b/bower_components/backbone.babysitter/lib/amd/backbone.babysitter.min.js @@ -0,0 +1,10 @@ +// Backbone.BabySitter +// ------------------- +// v0.0.6 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://github.com/babysitterjs/backbone.babysitter + +(function(i,e){if("object"==typeof exports){var t=require("underscore"),n=require("backbone");module.exports=e(t,n)}else"function"==typeof define&&define.amd&&define(["underscore","backbone"],e)})(this,function(i,e){"option strict";return e.ChildViewContainer=function(i,e){var t=function(i){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),e.each(i,this.add,this)};e.extend(t.prototype,{add:function(i,e){var t=i.cid;this._views[t]=i,i.model&&(this._indexByModel[i.model.cid]=t),e&&(this._indexByCustom[e]=t),this._updateLength()},findByModel:function(i){return this.findByModelCid(i.cid)},findByModelCid:function(i){var e=this._indexByModel[i];return this.findByCid(e)},findByCustom:function(i){var e=this._indexByCustom[i];return this.findByCid(e)},findByIndex:function(i){return e.values(this._views)[i]},findByCid:function(i){return this._views[i]},remove:function(i){var t=i.cid;i.model&&delete this._indexByModel[i.model.cid],e.any(this._indexByCustom,function(i,e){return i===t?(delete this._indexByCustom[e],!0):void 0},this),delete this._views[t],this._updateLength()},call:function(i){this.apply(i,e.tail(arguments))},apply:function(i,t){e.each(this._views,function(n){e.isFunction(n[i])&&n[i].apply(n,t||[])})},_updateLength:function(){this.length=e.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return e.each(n,function(i){t.prototype[i]=function(){var t=e.values(this._views),n=[t].concat(e.toArray(arguments));return e[i].apply(e,n)}}),t}(e,i),e.ChildViewContainer}); \ No newline at end of file diff --git a/bower_components/backbone.babysitter/lib/backbone.babysitter.js b/bower_components/backbone.babysitter/lib/backbone.babysitter.js new file mode 100644 index 0000000..8190ad3 --- /dev/null +++ b/bower_components/backbone.babysitter/lib/backbone.babysitter.js @@ -0,0 +1,157 @@ +// Backbone.BabySitter +// ------------------- +// v0.0.6 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://github.com/babysitterjs/backbone.babysitter + +// Backbone.ChildViewContainer +// --------------------------- +// +// Provide a container to store, retrieve and +// shut down child views. + +Backbone.ChildViewContainer = (function(Backbone, _){ + + // Container Constructor + // --------------------- + + var Container = function(views){ + this._views = {}; + this._indexByModel = {}; + this._indexByCustom = {}; + this._updateLength(); + + _.each(views, this.add, this); + }; + + // Container Methods + // ----------------- + + _.extend(Container.prototype, { + + // Add a view to this container. Stores the view + // by `cid` and makes it searchable by the model + // cid (and model itself). Optionally specify + // a custom key to store an retrieve the view. + add: function(view, customIndex){ + var viewCid = view.cid; + + // store the view + this._views[viewCid] = view; + + // index it by model + if (view.model){ + this._indexByModel[view.model.cid] = viewCid; + } + + // index by custom + if (customIndex){ + this._indexByCustom[customIndex] = viewCid; + } + + this._updateLength(); + }, + + // Find a view by the model that was attached to + // it. Uses the model's `cid` to find it. + findByModel: function(model){ + return this.findByModelCid(model.cid); + }, + + // Find a view by the `cid` of the model that was attached to + // it. Uses the model's `cid` to find the view `cid` and + // retrieve the view using it. + findByModelCid: function(modelCid){ + var viewCid = this._indexByModel[modelCid]; + return this.findByCid(viewCid); + }, + + // Find a view by a custom indexer. + findByCustom: function(index){ + var viewCid = this._indexByCustom[index]; + return this.findByCid(viewCid); + }, + + // Find by index. This is not guaranteed to be a + // stable index. + findByIndex: function(index){ + return _.values(this._views)[index]; + }, + + // retrieve a view by it's `cid` directly + findByCid: function(cid){ + return this._views[cid]; + }, + + // Remove a view + remove: function(view){ + var viewCid = view.cid; + + // delete model index + if (view.model){ + delete this._indexByModel[view.model.cid]; + } + + // delete custom index + _.any(this._indexByCustom, function(cid, key) { + if (cid === viewCid) { + delete this._indexByCustom[key]; + return true; + } + }, this); + + // remove the view from the container + delete this._views[viewCid]; + + // update the length + this._updateLength(); + }, + + // Call a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.call`. + call: function(method){ + this.apply(method, _.tail(arguments)); + }, + + // Apply a method on every view in the container, + // passing parameters to the call method one at a + // time, like `function.apply`. + apply: function(method, args){ + _.each(this._views, function(view){ + if (_.isFunction(view[method])){ + view[method].apply(view, args || []); + } + }); + }, + + // Update the `.length` attribute on this container + _updateLength: function(){ + this.length = _.size(this._views); + } + }); + + // Borrowing this code from Backbone.Collection: + // http://backbonejs.org/docs/backbone.html#section-106 + // + // Mix in methods from Underscore, for iteration, and other + // collection related features. + var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter', + 'select', 'reject', 'every', 'all', 'some', 'any', 'include', + 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest', + 'last', 'without', 'isEmpty', 'pluck']; + + _.each(methods, function(method) { + Container.prototype[method] = function() { + var views = _.values(this._views); + var args = [views].concat(_.toArray(arguments)); + return _[method].apply(_, args); + }; + }); + + // return the public API + return Container; +})(Backbone, _); diff --git a/bower_components/backbone.babysitter/lib/backbone.babysitter.map b/bower_components/backbone.babysitter/lib/backbone.babysitter.map new file mode 100644 index 0000000..7f03801 --- /dev/null +++ b/bower_components/backbone.babysitter/lib/backbone.babysitter.map @@ -0,0 +1 @@ +{"version":3,"file":"lib/backbone.babysitter.min.js","sources":["?"],"names":["Backbone","ChildViewContainer","_","Container","views","this","_views","_indexByModel","_indexByCustom","_updateLength","each","add","extend","prototype","view","customIndex","viewCid","cid","model","findByModel","findByModelCid","modelCid","findByCid","findByCustom","index","findByIndex","values","remove","any","key","call","method","apply","tail","arguments","args","isFunction","length","size","methods","concat","toArray"],"mappings":"AAeAA,SAASC,mBAAqB,SAAUD,EAAUE,GAKhD,GAAIC,GAAY,SAASC,GACvBC,KAAKC,UACLD,KAAKE,iBACLF,KAAKG,kBACLH,KAAKI,gBAELP,EAAEQ,KAAKN,EAAOC,KAAKM,IAAKN,MAM1BH,GAAEU,OAAOT,EAAUU,WAMjBF,IAAK,SAASG,EAAMC,GAClB,GAAIC,GAAUF,EAAKG,GAGnBZ,MAAKC,OAAOU,GAAWF,EAGnBA,EAAKI,QACPb,KAAKE,cAAcO,EAAKI,MAAMD,KAAOD,GAInCD,IACFV,KAAKG,eAAeO,GAAeC,GAGrCX,KAAKI,iBAKPU,YAAa,SAASD,GACpB,MAAOb,MAAKe,eAAeF,EAAMD,MAMnCG,eAAgB,SAASC,GACvB,GAAIL,GAAUX,KAAKE,cAAcc,EACjC,OAAOhB,MAAKiB,UAAUN,IAIxBO,aAAc,SAASC,GACrB,GAAIR,GAAUX,KAAKG,eAAegB,EAClC,OAAOnB,MAAKiB,UAAUN,IAKxBS,YAAa,SAASD,GACpB,MAAOtB,GAAEwB,OAAOrB,KAAKC,QAAQkB,IAI/BF,UAAW,SAASL,GAClB,MAAOZ,MAAKC,OAAOW,IAIrBU,OAAQ,SAASb,GACf,GAAIE,GAAUF,EAAKG,GAGfH,GAAKI,aACAb,MAAKE,cAAcO,EAAKI,MAAMD,KAIvCf,EAAE0B,IAAIvB,KAAKG,eAAgB,SAASS,EAAKY,GACvC,MAAIZ,KAAQD,SACHX,MAAKG,eAAeqB,IACpB,GAFT,QAICxB,YAGIA,MAAKC,OAAOU,GAGnBX,KAAKI,iBAMPqB,KAAM,SAASC,GACb1B,KAAK2B,MAAMD,EAAQ7B,EAAE+B,KAAKC,aAM5BF,MAAO,SAASD,EAAQI,GACtBjC,EAAEQ,KAAKL,KAAKC,OAAQ,SAASQ,GACvBZ,EAAEkC,WAAWtB,EAAKiB,KACpBjB,EAAKiB,GAAQC,MAAMlB,EAAMqB,UAM/B1B,cAAe,WACbJ,KAAKgC,OAASnC,EAAEoC,KAAKjC,KAAKC,UAS9B,IAAIiC,IAAW,UAAW,OAAQ,MAAO,OAAQ,SAAU,SACzD,SAAU,SAAU,QAAS,MAAO,OAAQ,MAAO,UACnD,WAAY,SAAU,UAAW,QAAS,UAAW,OACrD,OAAQ,UAAW,UAAW,QAWhC,OATArC,GAAEQ,KAAK6B,EAAS,SAASR,GACvB5B,EAAUU,UAAUkB,GAAU,WAC5B,GAAI3B,GAAQF,EAAEwB,OAAOrB,KAAKC,QACtB6B,GAAQ/B,GAAOoC,OAAOtC,EAAEuC,QAAQP,WACpC,OAAOhC,GAAE6B,GAAQC,MAAM9B,EAAGiC,MAKvBhC,GACNH,SAAUE"} \ No newline at end of file diff --git a/bower_components/backbone.babysitter/lib/backbone.babysitter.min.js b/bower_components/backbone.babysitter/lib/backbone.babysitter.min.js new file mode 100644 index 0000000..e930c0f --- /dev/null +++ b/bower_components/backbone.babysitter/lib/backbone.babysitter.min.js @@ -0,0 +1,11 @@ +// Backbone.BabySitter +// ------------------- +// v0.0.6 +// +// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC. +// Distributed under MIT license +// +// http://github.com/babysitterjs/backbone.babysitter + +Backbone.ChildViewContainer=function(i,t){var e=function(i){this._views={},this._indexByModel={},this._indexByCustom={},this._updateLength(),t.each(i,this.add,this)};t.extend(e.prototype,{add:function(i,t){var e=i.cid;this._views[e]=i,i.model&&(this._indexByModel[i.model.cid]=e),t&&(this._indexByCustom[t]=e),this._updateLength()},findByModel:function(i){return this.findByModelCid(i.cid)},findByModelCid:function(i){var t=this._indexByModel[i];return this.findByCid(t)},findByCustom:function(i){var t=this._indexByCustom[i];return this.findByCid(t)},findByIndex:function(i){return t.values(this._views)[i]},findByCid:function(i){return this._views[i]},remove:function(i){var e=i.cid;i.model&&delete this._indexByModel[i.model.cid],t.any(this._indexByCustom,function(i,t){return i===e?(delete this._indexByCustom[t],!0):void 0},this),delete this._views[e],this._updateLength()},call:function(i){this.apply(i,t.tail(arguments))},apply:function(i,e){t.each(this._views,function(n){t.isFunction(n[i])&&n[i].apply(n,e||[])})},_updateLength:function(){this.length=t.size(this._views)}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return t.each(n,function(i){e.prototype[i]=function(){var e=t.values(this._views),n=[e].concat(t.toArray(arguments));return t[i].apply(t,n)}}),e}(Backbone,_); +//@ sourceMappingURL=backbone.babysitter.map \ No newline at end of file diff --git a/bower_components/backbone.babysitter/package.json b/bower_components/backbone.babysitter/package.json new file mode 100644 index 0000000..aaab9be --- /dev/null +++ b/bower_components/backbone.babysitter/package.json @@ -0,0 +1,89 @@ +{ + "name": "backbone.babysitter", + "description": "Manage child views in a Backbone.View", + "version": "0.0.6", + "homepage": "https://github.com/marionettejs/backbone.babysitter", + "main": "lib/amd/backbone.babysitter.js", + "keywords": [ + "backbone", + "plugin", + "computed", + "field", + "model", + "client", + "browser" + ], + + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/marionettejs/backbone.babysitter/blob/master/LICENSE.md" + } + ], + + "scripts": { + "test" : "grunt jasmine", + "start" : "grunt jasmine-server" + }, + + "author": { + "name": "Derick Bailey", + "email": "marionettejs@gmail.com", + "web": "http://derickbailey.lostechies.com" + }, + + "bugs": { + "web": "https://github.com/marionettejs/backbone.babysitter/issues" + }, + + "repository": { + "type": "git", + "url": "https://github.com/marionettejs/backbone.babysitter.git" + }, + + "github": "https://github.com/marionettejs/backbone.babysitter", + + "dependencies": { + "jquery": "~1.8.3", + "backbone": "~1.0.0" + }, + "devDependencies": { + "grunt": "~0.4.0", + "grunt-contrib-jasmine": "~0.3.1", + "grunt-contrib-jshint": "~0.1.1", + "grunt-plato": "~0.1.4", + "grunt-preprocess": "git://github.com/onehealth/grunt-preprocess.git#grunt-0.4.0", + "grunt-contrib-uglify": "~0.1.1", + "grunt-contrib-concat": "~0.1.2", + "grunt-template-jasmine-istanbul": "~0.1.1", + "grunt-contrib-watch": "~0.2.0", + "grunt-contrib-connect": "~0.1.2" + }, + "jam":{ + "dependencies": { + "backbone": ">=0.9.9", + "underscore": ">=1.4.0" + }, + "main": "lib/amd/backbone.babysitter.js", + "include": [ + "lib/amd/backbone.babysitter.js", + "readme.md" + ] + }, + "maintainers": [ + { + "name": "Stefan Zerkalica", + "email": "zerkalica@gmail.com", + "web": "https://github.com/zerkalica" + }, + { + "name": "Richard Mitchell", + "email": "richard.j.mitchell@gmail.com" + }, + { + "name": "Joe Gornick", + "web": "http://joegornick.com", + "twitter": "https://twitter.com/jgornick" + } + ] +} diff --git a/bower_components/backbone.babysitter/public/javascripts/backbone.js b/bower_components/backbone.babysitter/public/javascripts/backbone.js new file mode 100644 index 0000000..3512d42 --- /dev/null +++ b/bower_components/backbone.babysitter/public/javascripts/backbone.js @@ -0,0 +1,1571 @@ +// Backbone.js 1.0.0 + +// (c) 2010-2013 Jeremy Ashkenas, DocumentCloud Inc. +// Backbone may be freely distributed under the MIT license. +// For all details and documentation: +// http://backbonejs.org + +(function(){ + + // Initial Setup + // ------------- + + // Save a reference to the global object (`window` in the browser, `exports` + // on the server). + var root = this; + + // Save the previous value of the `Backbone` variable, so that it can be + // restored later on, if `noConflict` is used. + var previousBackbone = root.Backbone; + + // Create local references to array methods we'll want to use later. + var array = []; + var push = array.push; + var slice = array.slice; + var splice = array.splice; + + // The top-level namespace. All public Backbone classes and modules will + // be attached to this. Exported for both the browser and the server. + var Backbone; + if (typeof exports !== 'undefined') { + Backbone = exports; + } else { + Backbone = root.Backbone = {}; + } + + // Current version of the library. Keep in sync with `package.json`. + Backbone.VERSION = '1.0.0'; + + // Require Underscore, if we're on the server, and it's not already present. + var _ = root._; + if (!_ && (typeof require !== 'undefined')) _ = require('underscore'); + + // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns + // the `$` variable. + Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$; + + // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable + // to its previous owner. Returns a reference to this Backbone object. + Backbone.noConflict = function() { + root.Backbone = previousBackbone; + return this; + }; + + // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option + // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and + // set a `X-Http-Method-Override` header. + Backbone.emulateHTTP = false; + + // Turn on `emulateJSON` to support legacy servers that can't deal with direct + // `application/json` requests ... will encode the body as + // `application/x-www-form-urlencoded` instead and will send the model in a + // form param named `model`. + Backbone.emulateJSON = false; + + // Backbone.Events + // --------------- + + // A module that can be mixed in to *any object* in order to provide it with + // custom events. You may bind with `on` or remove with `off` callback + // functions to an event; `trigger`-ing an event fires all callbacks in + // succession. + // + // var object = {}; + // _.extend(object, Backbone.Events); + // object.on('expand', function(){ alert('expanded'); }); + // object.trigger('expand'); + // + var Events = Backbone.Events = { + + // Bind an event to a `callback` function. Passing `"all"` will bind + // the callback to all events fired. + on: function(name, callback, context) { + if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; + this._events || (this._events = {}); + var events = this._events[name] || (this._events[name] = []); + events.push({callback: callback, context: context, ctx: context || this}); + return this; + }, + + // Bind an event to only be triggered a single time. After the first time + // the callback is invoked, it will be removed. + once: function(name, callback, context) { + if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; + var self = this; + var once = _.once(function() { + self.off(name, once); + callback.apply(this, arguments); + }); + once._callback = callback; + return this.on(name, once, context); + }, + + // Remove one or many callbacks. If `context` is null, removes all + // callbacks with that function. If `callback` is null, removes all + // callbacks for the event. If `name` is null, removes all bound + // callbacks for all events. + off: function(name, callback, context) { + var retain, ev, events, names, i, l, j, k; + if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; + if (!name && !callback && !context) { + this._events = {}; + return this; + } + + names = name ? [name] : _.keys(this._events); + for (i = 0, l = names.length; i < l; i++) { + name = names[i]; + if (events = this._events[name]) { + this._events[name] = retain = []; + if (callback || context) { + for (j = 0, k = events.length; j < k; j++) { + ev = events[j]; + if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || + (context && context !== ev.context)) { + retain.push(ev); + } + } + } + if (!retain.length) delete this._events[name]; + } + } + + return this; + }, + + // Trigger one or many events, firing all bound callbacks. Callbacks are + // passed the same arguments as `trigger` is, apart from the event name + // (unless you're listening on `"all"`, which will cause your callback to + // receive the true name of the event as the first argument). + trigger: function(name) { + if (!this._events) return this; + var args = slice.call(arguments, 1); + if (!eventsApi(this, 'trigger', name, args)) return this; + var events = this._events[name]; + var allEvents = this._events.all; + if (events) triggerEvents(events, args); + if (allEvents) triggerEvents(allEvents, arguments); + return this; + }, + + // Tell this object to stop listening to either specific events ... or + // to every object it's currently listening to. + stopListening: function(obj, name, callback) { + var listeners = this._listeners; + if (!listeners) return this; + var deleteListener = !name && !callback; + if (typeof name === 'object') callback = this; + if (obj) (listeners = {})[obj._listenerId] = obj; + for (var id in listeners) { + listeners[id].off(name, callback, this); + if (deleteListener) delete this._listeners[id]; + } + return this; + } + + }; + + // Regular expression used to split event strings. + var eventSplitter = /\s+/; + + // Implement fancy features of the Events API such as multiple event + // names `"change blur"` and jQuery-style event maps `{change: action}` + // in terms of the existing API. + var eventsApi = function(obj, action, name, rest) { + if (!name) return true; + + // Handle event maps. + if (typeof name === 'object') { + for (var key in name) { + obj[action].apply(obj, [key, name[key]].concat(rest)); + } + return false; + } + + // Handle space separated event names. + if (eventSplitter.test(name)) { + var names = name.split(eventSplitter); + for (var i = 0, l = names.length; i < l; i++) { + obj[action].apply(obj, [names[i]].concat(rest)); + } + return false; + } + + return true; + }; + + // A difficult-to-believe, but optimized internal dispatch function for + // triggering events. Tries to keep the usual cases speedy (most internal + // Backbone events have 3 arguments). + var triggerEvents = function(events, args) { + var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; + switch (args.length) { + case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; + case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; + case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; + case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; + default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); + } + }; + + var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; + + // Inversion-of-control versions of `on` and `once`. Tell *this* object to + // listen to an event in another object ... keeping track of what it's + // listening to. + _.each(listenMethods, function(implementation, method) { + Events[method] = function(obj, name, callback) { + var listeners = this._listeners || (this._listeners = {}); + var id = obj._listenerId || (obj._listenerId = _.uniqueId('l')); + listeners[id] = obj; + if (typeof name === 'object') callback = this; + obj[implementation](name, callback, this); + return this; + }; + }); + + // Aliases for backwards compatibility. + Events.bind = Events.on; + Events.unbind = Events.off; + + // Allow the `Backbone` object to serve as a global event bus, for folks who + // want global "pubsub" in a convenient place. + _.extend(Backbone, Events); + + // Backbone.Model + // -------------- + + // Backbone **Models** are the basic data object in the framework -- + // frequently representing a row in a table in a database on your server. + // A discrete chunk of data and a bunch of useful, related methods for + // performing computations and transformations on that data. + + // Create a new model with the specified attributes. A client id (`cid`) + // is automatically generated and assigned for you. + var Model = Backbone.Model = function(attributes, options) { + var defaults; + var attrs = attributes || {}; + options || (options = {}); + this.cid = _.uniqueId('c'); + this.attributes = {}; + _.extend(this, _.pick(options, modelOptions)); + if (options.parse) attrs = this.parse(attrs, options) || {}; + if (defaults = _.result(this, 'defaults')) { + attrs = _.defaults({}, attrs, defaults); + } + this.set(attrs, options); + this.changed = {}; + this.initialize.apply(this, arguments); + }; + + // A list of options to be attached directly to the model, if provided. + var modelOptions = ['url', 'urlRoot', 'collection']; + + // Attach all inheritable methods to the Model prototype. + _.extend(Model.prototype, Events, { + + // A hash of attributes whose current and previous value differ. + changed: null, + + // The value returned during the last failed validation. + validationError: null, + + // The default name for the JSON `id` attribute is `"id"`. MongoDB and + // CouchDB users may want to set this to `"_id"`. + idAttribute: 'id', + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // Return a copy of the model's `attributes` object. + toJSON: function(options) { + return _.clone(this.attributes); + }, + + // Proxy `Backbone.sync` by default -- but override this if you need + // custom syncing semantics for *this* particular model. + sync: function() { + return Backbone.sync.apply(this, arguments); + }, + + // Get the value of an attribute. + get: function(attr) { + return this.attributes[attr]; + }, + + // Get the HTML-escaped value of an attribute. + escape: function(attr) { + return _.escape(this.get(attr)); + }, + + // Returns `true` if the attribute contains a value that is not null + // or undefined. + has: function(attr) { + return this.get(attr) != null; + }, + + // Set a hash of model attributes on the object, firing `"change"`. This is + // the core primitive operation of a model, updating the data and notifying + // anyone who needs to know about the change in state. The heart of the beast. + set: function(key, val, options) { + var attr, attrs, unset, changes, silent, changing, prev, current; + if (key == null) return this; + + // Handle both `"key", value` and `{key: value}` -style arguments. + if (typeof key === 'object') { + attrs = key; + options = val; + } else { + (attrs = {})[key] = val; + } + + options || (options = {}); + + // Run validation. + if (!this._validate(attrs, options)) return false; + + // Extract attributes and options. + unset = options.unset; + silent = options.silent; + changes = []; + changing = this._changing; + this._changing = true; + + if (!changing) { + this._previousAttributes = _.clone(this.attributes); + this.changed = {}; + } + current = this.attributes, prev = this._previousAttributes; + + // Check for changes of `id`. + if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; + + // For each `set` attribute, update or delete the current value. + for (attr in attrs) { + val = attrs[attr]; + if (!_.isEqual(current[attr], val)) changes.push(attr); + if (!_.isEqual(prev[attr], val)) { + this.changed[attr] = val; + } else { + delete this.changed[attr]; + } + unset ? delete current[attr] : current[attr] = val; + } + + // Trigger all relevant attribute changes. + if (!silent) { + if (changes.length) this._pending = true; + for (var i = 0, l = changes.length; i < l; i++) { + this.trigger('change:' + changes[i], this, current[changes[i]], options); + } + } + + // You might be wondering why there's a `while` loop here. Changes can + // be recursively nested within `"change"` events. + if (changing) return this; + if (!silent) { + while (this._pending) { + this._pending = false; + this.trigger('change', this, options); + } + } + this._pending = false; + this._changing = false; + return this; + }, + + // Remove an attribute from the model, firing `"change"`. `unset` is a noop + // if the attribute doesn't exist. + unset: function(attr, options) { + return this.set(attr, void 0, _.extend({}, options, {unset: true})); + }, + + // Clear all attributes on the model, firing `"change"`. + clear: function(options) { + var attrs = {}; + for (var key in this.attributes) attrs[key] = void 0; + return this.set(attrs, _.extend({}, options, {unset: true})); + }, + + // Determine if the model has changed since the last `"change"` event. + // If you specify an attribute name, determine if that attribute has changed. + hasChanged: function(attr) { + if (attr == null) return !_.isEmpty(this.changed); + return _.has(this.changed, attr); + }, + + // Return an object containing all the attributes that have changed, or + // false if there are no changed attributes. Useful for determining what + // parts of a view need to be updated and/or what attributes need to be + // persisted to the server. Unset attributes will be set to undefined. + // You can also pass an attributes object to diff against the model, + // determining if there *would be* a change. + changedAttributes: function(diff) { + if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; + var val, changed = false; + var old = this._changing ? this._previousAttributes : this.attributes; + for (var attr in diff) { + if (_.isEqual(old[attr], (val = diff[attr]))) continue; + (changed || (changed = {}))[attr] = val; + } + return changed; + }, + + // Get the previous value of an attribute, recorded at the time the last + // `"change"` event was fired. + previous: function(attr) { + if (attr == null || !this._previousAttributes) return null; + return this._previousAttributes[attr]; + }, + + // Get all of the attributes of the model at the time of the previous + // `"change"` event. + previousAttributes: function() { + return _.clone(this._previousAttributes); + }, + + // Fetch the model from the server. If the server's representation of the + // model differs from its current attributes, they will be overridden, + // triggering a `"change"` event. + fetch: function(options) { + options = options ? _.clone(options) : {}; + if (options.parse === void 0) options.parse = true; + var model = this; + var success = options.success; + options.success = function(resp) { + if (!model.set(model.parse(resp, options), options)) return false; + if (success) success(model, resp, options); + model.trigger('sync', model, resp, options); + }; + wrapError(this, options); + return this.sync('read', this, options); + }, + + // Set a hash of model attributes, and sync the model to the server. + // If the server returns an attributes hash that differs, the model's + // state will be `set` again. + save: function(key, val, options) { + var attrs, method, xhr, attributes = this.attributes; + + // Handle both `"key", value` and `{key: value}` -style arguments. + if (key == null || typeof key === 'object') { + attrs = key; + options = val; + } else { + (attrs = {})[key] = val; + } + + // If we're not waiting and attributes exist, save acts as `set(attr).save(null, opts)`. + if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false; + + options = _.extend({validate: true}, options); + + // Do not persist invalid models. + if (!this._validate(attrs, options)) return false; + + // Set temporary attributes if `{wait: true}`. + if (attrs && options.wait) { + this.attributes = _.extend({}, attributes, attrs); + } + + // After a successful server-side save, the client is (optionally) + // updated with the server-side state. + if (options.parse === void 0) options.parse = true; + var model = this; + var success = options.success; + options.success = function(resp) { + // Ensure attributes are restored during synchronous saves. + model.attributes = attributes; + var serverAttrs = model.parse(resp, options); + if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); + if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { + return false; + } + if (success) success(model, resp, options); + model.trigger('sync', model, resp, options); + }; + wrapError(this, options); + + method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); + if (method === 'patch') options.attrs = attrs; + xhr = this.sync(method, this, options); + + // Restore attributes. + if (attrs && options.wait) this.attributes = attributes; + + return xhr; + }, + + // Destroy this model on the server if it was already persisted. + // Optimistically removes the model from its collection, if it has one. + // If `wait: true` is passed, waits for the server to respond before removal. + destroy: function(options) { + options = options ? _.clone(options) : {}; + var model = this; + var success = options.success; + + var destroy = function() { + model.trigger('destroy', model, model.collection, options); + }; + + options.success = function(resp) { + if (options.wait || model.isNew()) destroy(); + if (success) success(model, resp, options); + if (!model.isNew()) model.trigger('sync', model, resp, options); + }; + + if (this.isNew()) { + options.success(); + return false; + } + wrapError(this, options); + + var xhr = this.sync('delete', this, options); + if (!options.wait) destroy(); + return xhr; + }, + + // Default URL for the model's representation on the server -- if you're + // using Backbone's restful methods, override this to change the endpoint + // that will be called. + url: function() { + var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError(); + if (this.isNew()) return base; + return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id); + }, + + // **parse** converts a response into the hash of attributes to be `set` on + // the model. The default implementation is just to pass the response along. + parse: function(resp, options) { + return resp; + }, + + // Create a new model with identical attributes to this one. + clone: function() { + return new this.constructor(this.attributes); + }, + + // A model is new if it has never been saved to the server, and lacks an id. + isNew: function() { + return this.id == null; + }, + + // Check if the model is currently in a valid state. + isValid: function(options) { + return this._validate({}, _.extend(options || {}, { validate: true })); + }, + + // Run validation against the next complete set of model attributes, + // returning `true` if all is well. Otherwise, fire an `"invalid"` event. + _validate: function(attrs, options) { + if (!options.validate || !this.validate) return true; + attrs = _.extend({}, this.attributes, attrs); + var error = this.validationError = this.validate(attrs, options) || null; + if (!error) return true; + this.trigger('invalid', this, error, _.extend(options || {}, {validationError: error})); + return false; + } + + }); + + // Underscore methods that we want to implement on the Model. + var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit']; + + // Mix in each Underscore method as a proxy to `Model#attributes`. + _.each(modelMethods, function(method) { + Model.prototype[method] = function() { + var args = slice.call(arguments); + args.unshift(this.attributes); + return _[method].apply(_, args); + }; + }); + + // Backbone.Collection + // ------------------- + + // If models tend to represent a single row of data, a Backbone Collection is + // more analagous to a table full of data ... or a small slice or page of that + // table, or a collection of rows that belong together for a particular reason + // -- all of the messages in this particular folder, all of the documents + // belonging to this particular author, and so on. Collections maintain + // indexes of their models, both in order, and for lookup by `id`. + + // Create a new **Collection**, perhaps to contain a specific type of `model`. + // If a `comparator` is specified, the Collection will maintain + // its models in sort order, as they're added and removed. + var Collection = Backbone.Collection = function(models, options) { + options || (options = {}); + if (options.url) this.url = options.url; + if (options.model) this.model = options.model; + if (options.comparator !== void 0) this.comparator = options.comparator; + this._reset(); + this.initialize.apply(this, arguments); + if (models) this.reset(models, _.extend({silent: true}, options)); + }; + + // Default options for `Collection#set`. + var setOptions = {add: true, remove: true, merge: true}; + var addOptions = {add: true, merge: false, remove: false}; + + // Define the Collection's inheritable methods. + _.extend(Collection.prototype, Events, { + + // The default model for a collection is just a **Backbone.Model**. + // This should be overridden in most cases. + model: Model, + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // The JSON representation of a Collection is an array of the + // models' attributes. + toJSON: function(options) { + return this.map(function(model){ return model.toJSON(options); }); + }, + + // Proxy `Backbone.sync` by default. + sync: function() { + return Backbone.sync.apply(this, arguments); + }, + + // Add a model, or list of models to the set. + add: function(models, options) { + return this.set(models, _.defaults(options || {}, addOptions)); + }, + + // Remove a model, or a list of models from the set. + remove: function(models, options) { + models = _.isArray(models) ? models.slice() : [models]; + options || (options = {}); + var i, l, index, model; + for (i = 0, l = models.length; i < l; i++) { + model = this.get(models[i]); + if (!model) continue; + delete this._byId[model.id]; + delete this._byId[model.cid]; + index = this.indexOf(model); + this.models.splice(index, 1); + this.length--; + if (!options.silent) { + options.index = index; + model.trigger('remove', model, this, options); + } + this._removeReference(model); + } + return this; + }, + + // Update a collection by `set`-ing a new list of models, adding new ones, + // removing models that are no longer present, and merging models that + // already exist in the collection, as necessary. Similar to **Model#set**, + // the core operation for updating the data contained by the collection. + set: function(models, options) { + options = _.defaults(options || {}, setOptions); + if (options.parse) models = this.parse(models, options); + if (!_.isArray(models)) models = models ? [models] : []; + var i, l, model, attrs, existing, sort; + var at = options.at; + var sortable = this.comparator && (at == null) && options.sort !== false; + var sortAttr = _.isString(this.comparator) ? this.comparator : null; + var toAdd = [], toRemove = [], modelMap = {}; + + // Turn bare objects into model references, and prevent invalid models + // from being added. + for (i = 0, l = models.length; i < l; i++) { + if (!(model = this._prepareModel(models[i], options))) continue; + + // If a duplicate is found, prevent it from being added and + // optionally merge it into the existing model. + if (existing = this.get(model)) { + if (options.remove) modelMap[existing.cid] = true; + if (options.merge) { + existing.set(model.attributes, options); + if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true; + } + + // This is a new model, push it to the `toAdd` list. + } else if (options.add) { + toAdd.push(model); + + // Listen to added models' events, and index models for lookup by + // `id` and by `cid`. + model.on('all', this._onModelEvent, this); + this._byId[model.cid] = model; + if (model.id != null) this._byId[model.id] = model; + } + } + + // Remove nonexistent models if appropriate. + if (options.remove) { + for (i = 0, l = this.length; i < l; ++i) { + if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model); + } + if (toRemove.length) this.remove(toRemove, options); + } + + // See if sorting is needed, update `length` and splice in new models. + if (toAdd.length) { + if (sortable) sort = true; + this.length += toAdd.length; + if (at != null) { + splice.apply(this.models, [at, 0].concat(toAdd)); + } else { + push.apply(this.models, toAdd); + } + } + + // Silently sort the collection if appropriate. + if (sort) this.sort({silent: true}); + + if (options.silent) return this; + + // Trigger `add` events. + for (i = 0, l = toAdd.length; i < l; i++) { + (model = toAdd[i]).trigger('add', model, this, options); + } + + // Trigger `sort` if the collection was sorted. + if (sort) this.trigger('sort', this, options); + return this; + }, + + // When you have more items than you want to add or remove individually, + // you can reset the entire set with a new list of models, without firing + // any granular `add` or `remove` events. Fires `reset` when finished. + // Useful for bulk operations and optimizations. + reset: function(models, options) { + options || (options = {}); + for (var i = 0, l = this.models.length; i < l; i++) { + this._removeReference(this.models[i]); + } + options.previousModels = this.models; + this._reset(); + this.add(models, _.extend({silent: true}, options)); + if (!options.silent) this.trigger('reset', this, options); + return this; + }, + + // Add a model to the end of the collection. + push: function(model, options) { + model = this._prepareModel(model, options); + this.add(model, _.extend({at: this.length}, options)); + return model; + }, + + // Remove a model from the end of the collection. + pop: function(options) { + var model = this.at(this.length - 1); + this.remove(model, options); + return model; + }, + + // Add a model to the beginning of the collection. + unshift: function(model, options) { + model = this._prepareModel(model, options); + this.add(model, _.extend({at: 0}, options)); + return model; + }, + + // Remove a model from the beginning of the collection. + shift: function(options) { + var model = this.at(0); + this.remove(model, options); + return model; + }, + + // Slice out a sub-array of models from the collection. + slice: function(begin, end) { + return this.models.slice(begin, end); + }, + + // Get a model from the set by id. + get: function(obj) { + if (obj == null) return void 0; + return this._byId[obj.id != null ? obj.id : obj.cid || obj]; + }, + + // Get the model at the given index. + at: function(index) { + return this.models[index]; + }, + + // Return models with matching attributes. Useful for simple cases of + // `filter`. + where: function(attrs, first) { + if (_.isEmpty(attrs)) return first ? void 0 : []; + return this[first ? 'find' : 'filter'](function(model) { + for (var key in attrs) { + if (attrs[key] !== model.get(key)) return false; + } + return true; + }); + }, + + // Return the first model with matching attributes. Useful for simple cases + // of `find`. + findWhere: function(attrs) { + return this.where(attrs, true); + }, + + // Force the collection to re-sort itself. You don't need to call this under + // normal circumstances, as the set will maintain sort order as each item + // is added. + sort: function(options) { + if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); + options || (options = {}); + + // Run sort based on type of `comparator`. + if (_.isString(this.comparator) || this.comparator.length === 1) { + this.models = this.sortBy(this.comparator, this); + } else { + this.models.sort(_.bind(this.comparator, this)); + } + + if (!options.silent) this.trigger('sort', this, options); + return this; + }, + + // Figure out the smallest index at which a model should be inserted so as + // to maintain order. + sortedIndex: function(model, value, context) { + value || (value = this.comparator); + var iterator = _.isFunction(value) ? value : function(model) { + return model.get(value); + }; + return _.sortedIndex(this.models, model, iterator, context); + }, + + // Pluck an attribute from each model in the collection. + pluck: function(attr) { + return _.invoke(this.models, 'get', attr); + }, + + // Fetch the default set of models for this collection, resetting the + // collection when they arrive. If `reset: true` is passed, the response + // data will be passed through the `reset` method instead of `set`. + fetch: function(options) { + options = options ? _.clone(options) : {}; + if (options.parse === void 0) options.parse = true; + var success = options.success; + var collection = this; + options.success = function(resp) { + var method = options.reset ? 'reset' : 'set'; + collection[method](resp, options); + if (success) success(collection, resp, options); + collection.trigger('sync', collection, resp, options); + }; + wrapError(this, options); + return this.sync('read', this, options); + }, + + // Create a new instance of a model in this collection. Add the model to the + // collection immediately, unless `wait: true` is passed, in which case we + // wait for the server to agree. + create: function(model, options) { + options = options ? _.clone(options) : {}; + if (!(model = this._prepareModel(model, options))) return false; + if (!options.wait) this.add(model, options); + var collection = this; + var success = options.success; + options.success = function(resp) { + if (options.wait) collection.add(model, options); + if (success) success(model, resp, options); + }; + model.save(null, options); + return model; + }, + + // **parse** converts a response into a list of models to be added to the + // collection. The default implementation is just to pass it through. + parse: function(resp, options) { + return resp; + }, + + // Create a new collection with an identical list of models as this one. + clone: function() { + return new this.constructor(this.models); + }, + + // Private method to reset all internal state. Called when the collection + // is first initialized or reset. + _reset: function() { + this.length = 0; + this.models = []; + this._byId = {}; + }, + + // Prepare a hash of attributes (or other model) to be added to this + // collection. + _prepareModel: function(attrs, options) { + if (attrs instanceof Model) { + if (!attrs.collection) attrs.collection = this; + return attrs; + } + options || (options = {}); + options.collection = this; + var model = new this.model(attrs, options); + if (!model._validate(attrs, options)) { + this.trigger('invalid', this, attrs, options); + return false; + } + return model; + }, + + // Internal method to sever a model's ties to a collection. + _removeReference: function(model) { + if (this === model.collection) delete model.collection; + model.off('all', this._onModelEvent, this); + }, + + // Internal method called every time a model in the set fires an event. + // Sets need to update their indexes when models change ids. All other + // events simply proxy through. "add" and "remove" events that originate + // in other collections are ignored. + _onModelEvent: function(event, model, collection, options) { + if ((event === 'add' || event === 'remove') && collection !== this) return; + if (event === 'destroy') this.remove(model, options); + if (model && event === 'change:' + model.idAttribute) { + delete this._byId[model.previous(model.idAttribute)]; + if (model.id != null) this._byId[model.id] = model; + } + this.trigger.apply(this, arguments); + } + + }); + + // Underscore methods that we want to implement on the Collection. + // 90% of the core usefulness of Backbone Collections is actually implemented + // right here: + var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', + 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', + 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', + 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', + 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf', + 'isEmpty', 'chain']; + + // Mix in each Underscore method as a proxy to `Collection#models`. + _.each(methods, function(method) { + Collection.prototype[method] = function() { + var args = slice.call(arguments); + args.unshift(this.models); + return _[method].apply(_, args); + }; + }); + + // Underscore methods that take a property name as an argument. + var attributeMethods = ['groupBy', 'countBy', 'sortBy']; + + // Use attributes instead of properties. + _.each(attributeMethods, function(method) { + Collection.prototype[method] = function(value, context) { + var iterator = _.isFunction(value) ? value : function(model) { + return model.get(value); + }; + return _[method](this.models, iterator, context); + }; + }); + + // Backbone.View + // ------------- + + // Backbone Views are almost more convention than they are actual code. A View + // is simply a JavaScript object that represents a logical chunk of UI in the + // DOM. This might be a single item, an entire list, a sidebar or panel, or + // even the surrounding frame which wraps your whole app. Defining a chunk of + // UI as a **View** allows you to define your DOM events declaratively, without + // having to worry about render order ... and makes it easy for the view to + // react to specific changes in the state of your models. + + // Creating a Backbone.View creates its initial element outside of the DOM, + // if an existing element is not provided... + var View = Backbone.View = function(options) { + this.cid = _.uniqueId('view'); + this._configure(options || {}); + this._ensureElement(); + this.initialize.apply(this, arguments); + this.delegateEvents(); + }; + + // Cached regex to split keys for `delegate`. + var delegateEventSplitter = /^(\S+)\s*(.*)$/; + + // List of view options to be merged as properties. + var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; + + // Set up all inheritable **Backbone.View** properties and methods. + _.extend(View.prototype, Events, { + + // The default `tagName` of a View's element is `"div"`. + tagName: 'div', + + // jQuery delegate for element lookup, scoped to DOM elements within the + // current view. This should be prefered to global lookups where possible. + $: function(selector) { + return this.$el.find(selector); + }, + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // **render** is the core function that your view should override, in order + // to populate its element (`this.el`), with the appropriate HTML. The + // convention is for **render** to always return `this`. + render: function() { + return this; + }, + + // Remove this view by taking the element out of the DOM, and removing any + // applicable Backbone.Events listeners. + remove: function() { + this.$el.remove(); + this.stopListening(); + return this; + }, + + // Change the view's element (`this.el` property), including event + // re-delegation. + setElement: function(element, delegate) { + if (this.$el) this.undelegateEvents(); + this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); + this.el = this.$el[0]; + if (delegate !== false) this.delegateEvents(); + return this; + }, + + // Set callbacks, where `this.events` is a hash of + // + // *{"event selector": "callback"}* + // + // { + // 'mousedown .title': 'edit', + // 'click .button': 'save' + // 'click .open': function(e) { ... } + // } + // + // pairs. Callbacks will be bound to the view, with `this` set properly. + // Uses event delegation for efficiency. + // Omitting the selector binds the event to `this.el`. + // This only works for delegate-able events: not `focus`, `blur`, and + // not `change`, `submit`, and `reset` in Internet Explorer. + delegateEvents: function(events) { + if (!(events || (events = _.result(this, 'events')))) return this; + this.undelegateEvents(); + for (var key in events) { + var method = events[key]; + if (!_.isFunction(method)) method = this[events[key]]; + if (!method) continue; + + var match = key.match(delegateEventSplitter); + var eventName = match[1], selector = match[2]; + method = _.bind(method, this); + eventName += '.delegateEvents' + this.cid; + if (selector === '') { + this.$el.on(eventName, method); + } else { + this.$el.on(eventName, selector, method); + } + } + return this; + }, + + // Clears all callbacks previously bound to the view with `delegateEvents`. + // You usually don't need to use this, but may wish to if you have multiple + // Backbone views attached to the same DOM element. + undelegateEvents: function() { + this.$el.off('.delegateEvents' + this.cid); + return this; + }, + + // Performs the initial configuration of a View with a set of options. + // Keys with special meaning *(e.g. model, collection, id, className)* are + // attached directly to the view. See `viewOptions` for an exhaustive + // list. + _configure: function(options) { + if (this.options) options = _.extend({}, _.result(this, 'options'), options); + _.extend(this, _.pick(options, viewOptions)); + this.options = options; + }, + + // Ensure that the View has a DOM element to render into. + // If `this.el` is a string, pass it through `$()`, take the first + // matching element, and re-assign it to `el`. Otherwise, create + // an element from the `id`, `className` and `tagName` properties. + _ensureElement: function() { + if (!this.el) { + var attrs = _.extend({}, _.result(this, 'attributes')); + if (this.id) attrs.id = _.result(this, 'id'); + if (this.className) attrs['class'] = _.result(this, 'className'); + var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); + this.setElement($el, false); + } else { + this.setElement(_.result(this, 'el'), false); + } + } + + }); + + // Backbone.sync + // ------------- + + // Override this function to change the manner in which Backbone persists + // models to the server. You will be passed the type of request, and the + // model in question. By default, makes a RESTful Ajax request + // to the model's `url()`. Some possible customizations could be: + // + // * Use `setTimeout` to batch rapid-fire updates into a single request. + // * Send up the models as XML instead of JSON. + // * Persist models via WebSockets instead of Ajax. + // + // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests + // as `POST`, with a `_method` parameter containing the true HTTP method, + // as well as all requests with the body as `application/x-www-form-urlencoded` + // instead of `application/json` with the model in a param named `model`. + // Useful when interfacing with server-side languages like **PHP** that make + // it difficult to read the body of `PUT` requests. + Backbone.sync = function(method, model, options) { + var type = methodMap[method]; + + // Default options, unless specified. + _.defaults(options || (options = {}), { + emulateHTTP: Backbone.emulateHTTP, + emulateJSON: Backbone.emulateJSON + }); + + // Default JSON-request options. + var params = {type: type, dataType: 'json'}; + + // Ensure that we have a URL. + if (!options.url) { + params.url = _.result(model, 'url') || urlError(); + } + + // Ensure that we have the appropriate request data. + if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { + params.contentType = 'application/json'; + params.data = JSON.stringify(options.attrs || model.toJSON(options)); + } + + // For older servers, emulate JSON by encoding the request into an HTML-form. + if (options.emulateJSON) { + params.contentType = 'application/x-www-form-urlencoded'; + params.data = params.data ? {model: params.data} : {}; + } + + // For older servers, emulate HTTP by mimicking the HTTP method with `_method` + // And an `X-HTTP-Method-Override` header. + if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { + params.type = 'POST'; + if (options.emulateJSON) params.data._method = type; + var beforeSend = options.beforeSend; + options.beforeSend = function(xhr) { + xhr.setRequestHeader('X-HTTP-Method-Override', type); + if (beforeSend) return beforeSend.apply(this, arguments); + }; + } + + // Don't process data on a non-GET request. + if (params.type !== 'GET' && !options.emulateJSON) { + params.processData = false; + } + + // If we're sending a `PATCH` request, and we're in an old Internet Explorer + // that still has ActiveX enabled by default, override jQuery to use that + // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8. + if (params.type === 'PATCH' && window.ActiveXObject && + !(window.external && window.external.msActiveXFilteringEnabled)) { + params.xhr = function() { + return new ActiveXObject("Microsoft.XMLHTTP"); + }; + } + + // Make the request, allowing the user to override any Ajax options. + var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); + model.trigger('request', model, xhr, options); + return xhr; + }; + + // Map from CRUD to HTTP for our default `Backbone.sync` implementation. + var methodMap = { + 'create': 'POST', + 'update': 'PUT', + 'patch': 'PATCH', + 'delete': 'DELETE', + 'read': 'GET' + }; + + // Set the default implementation of `Backbone.ajax` to proxy through to `$`. + // Override this if you'd like to use a different library. + Backbone.ajax = function() { + return Backbone.$.ajax.apply(Backbone.$, arguments); + }; + + // Backbone.Router + // --------------- + + // Routers map faux-URLs to actions, and fire events when routes are + // matched. Creating a new one sets its `routes` hash, if not set statically. + var Router = Backbone.Router = function(options) { + options || (options = {}); + if (options.routes) this.routes = options.routes; + this._bindRoutes(); + this.initialize.apply(this, arguments); + }; + + // Cached regular expressions for matching named param parts and splatted + // parts of route strings. + var optionalParam = /\((.*?)\)/g; + var namedParam = /(\(\?)?:\w+/g; + var splatParam = /\*\w+/g; + var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; + + // Set up all inheritable **Backbone.Router** properties and methods. + _.extend(Router.prototype, Events, { + + // Initialize is an empty function by default. Override it with your own + // initialization logic. + initialize: function(){}, + + // Manually bind a single named route to a callback. For example: + // + // this.route('search/:query/p:num', 'search', function(query, num) { + // ... + // }); + // + route: function(route, name, callback) { + if (!_.isRegExp(route)) route = this._routeToRegExp(route); + if (_.isFunction(name)) { + callback = name; + name = ''; + } + if (!callback) callback = this[name]; + var router = this; + Backbone.history.route(route, function(fragment) { + var args = router._extractParameters(route, fragment); + callback && callback.apply(router, args); + router.trigger.apply(router, ['route:' + name].concat(args)); + router.trigger('route', name, args); + Backbone.history.trigger('route', router, name, args); + }); + return this; + }, + + // Simple proxy to `Backbone.history` to save a fragment into the history. + navigate: function(fragment, options) { + Backbone.history.navigate(fragment, options); + return this; + }, + + // Bind all defined routes to `Backbone.history`. We have to reverse the + // order of the routes here to support behavior where the most general + // routes can be defined at the bottom of the route map. + _bindRoutes: function() { + if (!this.routes) return; + this.routes = _.result(this, 'routes'); + var route, routes = _.keys(this.routes); + while ((route = routes.pop()) != null) { + this.route(route, this.routes[route]); + } + }, + + // Convert a route string into a regular expression, suitable for matching + // against the current location hash. + _routeToRegExp: function(route) { + route = route.replace(escapeRegExp, '\\$&') + .replace(optionalParam, '(?:$1)?') + .replace(namedParam, function(match, optional){ + return optional ? match : '([^\/]+)'; + }) + .replace(splatParam, '(.*?)'); + return new RegExp('^' + route + '$'); + }, + + // Given a route, and a URL fragment that it matches, return the array of + // extracted decoded parameters. Empty or unmatched parameters will be + // treated as `null` to normalize cross-browser behavior. + _extractParameters: function(route, fragment) { + var params = route.exec(fragment).slice(1); + return _.map(params, function(param) { + return param ? decodeURIComponent(param) : null; + }); + } + + }); + + // Backbone.History + // ---------------- + + // Handles cross-browser history management, based on either + // [pushState](http://diveintohtml5.info/history.html) and real URLs, or + // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) + // and URL fragments. If the browser supports neither (old IE, natch), + // falls back to polling. + var History = Backbone.History = function() { + this.handlers = []; + _.bindAll(this, 'checkUrl'); + + // Ensure that `History` can be used outside of the browser. + if (typeof window !== 'undefined') { + this.location = window.location; + this.history = window.history; + } + }; + + // Cached regex for stripping a leading hash/slash and trailing space. + var routeStripper = /^[#\/]|\s+$/g; + + // Cached regex for stripping leading and trailing slashes. + var rootStripper = /^\/+|\/+$/g; + + // Cached regex for detecting MSIE. + var isExplorer = /msie [\w.]+/; + + // Cached regex for removing a trailing slash. + var trailingSlash = /\/$/; + + // Has the history handling already been started? + History.started = false; + + // Set up all inheritable **Backbone.History** properties and methods. + _.extend(History.prototype, Events, { + + // The default interval to poll for hash changes, if necessary, is + // twenty times a second. + interval: 50, + + // Gets the true hash value. Cannot use location.hash directly due to bug + // in Firefox where location.hash will always be decoded. + getHash: function(window) { + var match = (window || this).location.href.match(/#(.*)$/); + return match ? match[1] : ''; + }, + + // Get the cross-browser normalized URL fragment, either from the URL, + // the hash, or the override. + getFragment: function(fragment, forcePushState) { + if (fragment == null) { + if (this._hasPushState || !this._wantsHashChange || forcePushState) { + fragment = this.location.pathname; + var root = this.root.replace(trailingSlash, ''); + if (!fragment.indexOf(root)) fragment = fragment.substr(root.length); + } else { + fragment = this.getHash(); + } + } + return fragment.replace(routeStripper, ''); + }, + + // Start the hash change handling, returning `true` if the current URL matches + // an existing route, and `false` otherwise. + start: function(options) { + if (History.started) throw new Error("Backbone.history has already been started"); + History.started = true; + + // Figure out the initial configuration. Do we need an iframe? + // Is pushState desired ... is it available? + this.options = _.extend({}, {root: '/'}, this.options, options); + this.root = this.options.root; + this._wantsHashChange = this.options.hashChange !== false; + this._wantsPushState = !!this.options.pushState; + this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState); + var fragment = this.getFragment(); + var docMode = document.documentMode; + var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); + + // Normalize root to always include a leading and trailing slash. + this.root = ('/' + this.root + '/').replace(rootStripper, '/'); + + if (oldIE && this._wantsHashChange) { + this.iframe = Backbone.$(' + + + diff --git a/bower_components/jquery/test/data/dashboard.xml b/bower_components/jquery/test/data/dashboard.xml new file mode 100644 index 0000000..5a6f561 --- /dev/null +++ b/bower_components/jquery/test/data/dashboard.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/bower_components/jquery/test/data/dimensions/documentLarge.html b/bower_components/jquery/test/data/dimensions/documentLarge.html new file mode 100644 index 0000000..a6598fc --- /dev/null +++ b/bower_components/jquery/test/data/dimensions/documentLarge.html @@ -0,0 +1,17 @@ + + + + + + + +
+ +
+ + diff --git a/bower_components/jquery/test/data/dimensions/documentSmall.html b/bower_components/jquery/test/data/dimensions/documentSmall.html new file mode 100644 index 0000000..63e1c2a --- /dev/null +++ b/bower_components/jquery/test/data/dimensions/documentSmall.html @@ -0,0 +1,21 @@ + + + + + + + +
+ +
+ + diff --git a/bower_components/jquery/test/data/echoData.php b/bower_components/jquery/test/data/echoData.php new file mode 100644 index 0000000..a37ba51 --- /dev/null +++ b/bower_components/jquery/test/data/echoData.php @@ -0,0 +1 @@ + diff --git a/bower_components/jquery/test/data/echoQuery.php b/bower_components/jquery/test/data/echoQuery.php new file mode 100644 index 0000000..b72f329 --- /dev/null +++ b/bower_components/jquery/test/data/echoQuery.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/bower_components/jquery/test/data/errorWithJSON.php b/bower_components/jquery/test/data/errorWithJSON.php new file mode 100644 index 0000000..62b187e --- /dev/null +++ b/bower_components/jquery/test/data/errorWithJSON.php @@ -0,0 +1,6 @@ + diff --git a/bower_components/jquery/test/data/evalScript.php b/bower_components/jquery/test/data/evalScript.php new file mode 100644 index 0000000..ea9b8c5 --- /dev/null +++ b/bower_components/jquery/test/data/evalScript.php @@ -0,0 +1 @@ +ok( "" === "GET", "request method is " ); \ No newline at end of file diff --git a/bower_components/jquery/test/data/event/focusElem.html b/bower_components/jquery/test/data/event/focusElem.html new file mode 100644 index 0000000..10726b4 --- /dev/null +++ b/bower_components/jquery/test/data/event/focusElem.html @@ -0,0 +1,16 @@ + + + + + .focus() (activeElement access #13393) + + + + + + + + diff --git a/bower_components/jquery/test/data/event/longLoadScript.php b/bower_components/jquery/test/data/event/longLoadScript.php new file mode 100644 index 0000000..ba47168 --- /dev/null +++ b/bower_components/jquery/test/data/event/longLoadScript.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/bower_components/jquery/test/data/event/onbeforeunload.html b/bower_components/jquery/test/data/event/onbeforeunload.html new file mode 100644 index 0000000..11ad196 --- /dev/null +++ b/bower_components/jquery/test/data/event/onbeforeunload.html @@ -0,0 +1,20 @@ + + + + + diff --git a/bower_components/jquery/test/data/event/promiseReady.html b/bower_components/jquery/test/data/event/promiseReady.html new file mode 100644 index 0000000..17b6e7f --- /dev/null +++ b/bower_components/jquery/test/data/event/promiseReady.html @@ -0,0 +1,17 @@ + + + + +Test case for jQuery ticket #11470 + + + + + + + diff --git a/bower_components/jquery/test/data/event/syncReady.html b/bower_components/jquery/test/data/event/syncReady.html new file mode 100644 index 0000000..e088570 --- /dev/null +++ b/bower_components/jquery/test/data/event/syncReady.html @@ -0,0 +1,23 @@ + + + + +Test case for jQuery ticket #10067 + + + + + + + + +
+ + diff --git a/bower_components/jquery/test/data/headers.php b/bower_components/jquery/test/data/headers.php new file mode 100644 index 0000000..968f13f --- /dev/null +++ b/bower_components/jquery/test/data/headers.php @@ -0,0 +1,18 @@ + $value ) { + + $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key ); + $headers[ $key ] = $value; + +} + +foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) { + echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; +} diff --git a/bower_components/jquery/test/data/if_modified_since.php b/bower_components/jquery/test/data/if_modified_since.php new file mode 100644 index 0000000..098b7da --- /dev/null +++ b/bower_components/jquery/test/data/if_modified_since.php @@ -0,0 +1,20 @@ + diff --git a/bower_components/jquery/test/data/iframe.html b/bower_components/jquery/test/data/iframe.html new file mode 100644 index 0000000..ad646c4 --- /dev/null +++ b/bower_components/jquery/test/data/iframe.html @@ -0,0 +1,8 @@ + + + iframe + + +
span text
+ + diff --git a/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js b/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js new file mode 100644 index 0000000..0c5f64c --- /dev/null +++ b/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js @@ -0,0 +1,5 @@ +/*! jQuery v1.9.1 -css,-event-alias,-ajax/script,-ajax/jsonp,-effects,-offset,-dimensions,-deprecated | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license +//@ sourceMappingURL=jquery.min.map +*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],d="1.9.1 -css,-event-alias,-ajax/script,-ajax/jsonp,-effects,-offset,-dimensions,-deprecated",p=c.concat,f=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=d.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,N=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,w=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,k=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,S=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,j=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(M(),b.ready())},M=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:d,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:w.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&E.test(n.replace(A,"@").replace(S,"]").replace(k,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,j)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=B(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(N,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(B(Object(e))?b.merge(n,"string"==typeof e?[e]:e):f.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=B(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return p.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}M(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function B(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function O(e){var t=_[e]={};return b.each(e.match(T)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||O(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:d.disable())},d={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&d.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||d.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return d.fireWith(this,arguments),this},fired:function(){return!!i}};return d},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,d,p,f=o.createElement("div");if(f.setAttribute("className","t"),f.innerHTML="
a",n=f.getElementsByTagName("*"),r=f.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=f.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==f.className,leadingWhitespace:3===f.firstChild.nodeType,tbody:!f.getElementsByTagName("tbody").length,htmlSerialize:!!f.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete f.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,f.attachEvent&&(f.attachEvent("onclick",function(){t.noCloneEvent=!1}),f.cloneNode(!0).click());for(p in{submit:!0,change:!0,focusin:!0})f.setAttribute(c="on"+p,"t"),t[p+"Bubbles"]=c in e||f.attributes[c].expando===!1;return f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===f.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(f),f.innerHTML="
t
",a=f.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",d=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=d&&0===a[0].offsetHeight,f.innerHTML="",f.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===f.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(f,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(f,null)||{width:"4px"}).width,r=f.appendChild(o.createElement("div")),r.style.cssText=f.style.cssText=s,r.style.marginRight=r.style.width="0",f.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof f.style.zoom!==i&&(f.innerHTML="",f.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===f.offsetWidth,f.style.display="block",f.innerHTML="
",f.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==f.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=f=a=r=null)}),n=s=u=l=r=a=null,t}();var F=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,q=/([A-Z])/g;function R(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,d=l?b.cache:e,p=l?e[s]:e[s]&&s;if(p&&d[p]&&(i||d[p].data)||!u||r!==t)return p||(l?e[s]=p=c.pop()||b.guid++:p=s),d[p]||(d[p]={},l||(d[p].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?d[p]=b.extend(d[p],n):d[p].data=b.extend(d[p].data,n)),o=d[p],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function P(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?I:b.isEmptyObject)(o))return}(n||(delete s[u].data,I(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(d+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return P(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return P(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),$(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?$(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(q,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:F.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var W,X,z=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,Q=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,K=b.support.getSetAttribute,Y=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(z," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(z," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(T)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(z," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(Q.test(n)?X:W)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,Q.test(n)?!K&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(K?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:t}}}}),X={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?Y&&K?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):Y&&K||!G.test(n)?e.setAttribute(!K&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},Y&&K||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):W&&W.set(e,n,r)}}),K||(W=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:W.get,set:function(e,t,n){W.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,d,p,f,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(p=v.handle)||(p=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(p.elem,arguments)},p.elem=e),n=(n||"").match(T)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),d=b.event.special[g]||{},g=(a?d.delegateType:d.bindType)||g,d=b.event.special[g]||{},f=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,d.setup&&d.setup.call(e,o,m,p)!==!1||(e.addEventListener?e.addEventListener(g,p,!1):e.attachEvent&&e.attachEvent("on"+g,p))),d.add&&(d.add.call(e,f),f.handler.guid||(f.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,f):h.push(f),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,d,p,f,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],f=g=s[1],h=(s[2]||"").split(".").sort(),f){d=b.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,p=c[f]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=p.length;while(o--)a=p[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(p.splice(o,1),a.selector&&p.delegateCount--,d.remove&&d.remove.call(e,a));u&&!p.length&&(d.teardown&&d.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,f,m.handle),delete c[f])}else for(f in c)b.event.remove(e,f+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,d,p,f,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=p=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),d=b.event.special[g]||{},a||!d.trigger||d.trigger.apply(i,r)!==!1)){if(!a&&!d.noBubble&&!b.isWindow(i)){for(c=d.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),p=l;p===(i.ownerDocument||o)&&h.push(p.defaultView||p.parentWindow||e)}f=0;while((l=h[f++])&&!n.isPropagationStopped())n.type=f>1?c:d.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||d._default&&d._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){p=i[u],p&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,p&&(i[u]=p)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; +return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,d,p,f,h,g,m,y,v,x="sizzle"+-new Date,T=e.document,N={},w=0,C=0,E=it(),k=it(),A=it(),S=typeof t,D=1<<31,L=[],j=L.pop,H=L.push,M=L.slice,B=L.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",O="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",F=O.replace("w","w#"),q="([*^$|!~]?=)",R="\\["+_+"*("+O+")"+_+"*(?:"+q+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+F+")|)|)"+_+"*\\]",P=":("+O+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+R.replace(3,8)+")*)|.*)\\)|)",$=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),I=RegExp("^"+_+"*,"+_+"*"),W=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),X=RegExp(P),z=RegExp("^"+F+"$"),U={ID:RegExp("^#("+O+")"),CLASS:RegExp("^\\.("+O+")"),NAME:RegExp("^\\[name=['\"]?("+O+")['\"]?\\]"),TAG:RegExp("^("+O.replace("w","w*")+")"),ATTR:RegExp("^"+R),PSEUDO:RegExp("^"+P),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,J=/^[^{]+\{\s*\[native code/,Q=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,K=/^h\d$/i,Y=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{M.call(T.documentElement.childNodes,0)[0].nodeType}catch(nt){M=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return J.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=d.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,p,g,m,v;if((t?t.ownerDocument||t:T)!==d&&c(t),t=t||d,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!f&&!r){if(i=Q.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,M.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&N.getByClassName&&t.getElementsByClassName)return H.apply(n,M.call(t.getElementsByClassName(a),0)),n}if(N.qsa&&!h.test(e)){if(p=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=pt(e),(p=t.getAttribute("id"))?g=p.replace(Y,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+ft(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,M.call(m.querySelectorAll(v),0)),n}catch(b){}finally{p||t.removeAttribute("id")}}}return Tt(e.replace($,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:T;return n!==d&&9===n.nodeType&&n.documentElement?(d=n,p=n.documentElement,f=a(n),N.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),N.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),N.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),N.getByName=at(function(e){e.id=x+0,e.innerHTML="
",p.insertBefore(e,p.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return N.getIdNotName=!n.getElementById(x),p.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==S&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},N.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==S&&!f){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==S&&!f){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==S&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==S&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=N.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==S?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=N.getByName&&function(e,n){return typeof n.getElementsByName!==S?n.getElementsByName(name):t},i.find.CLASS=N.getByClassName&&function(e,n){return typeof n.getElementsByClassName===S||f?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(N.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(N.matchesSelector=rt(m=p.matchesSelector||p.mozMatchesSelector||p.webkitMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&at(function(e){N.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",P)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(p.contains)||p.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=p.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(T,e)?-1:t===n||y(T,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===T?-1:l[i]===T?1:0},u=!1,[0,0].sort(v),N.detectDuplicates=u,d):d},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&c(e),t=t.replace(Z,"='$1']"),!(!N.matchesSelector||f||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||N.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,d,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==d&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==d&&c(e),f||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):f||N.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!N.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function dt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&X.test(n)&&(t=pt(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=E[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&E(e,function(e){return t.test(e.className||typeof e.getAttribute!==S&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,d,p,f,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){d=t;while(d=d[g])if(s?d.nodeName.toLowerCase()===y:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],f=l[0]===w&&l[1],p=l[0]===w&&l[2],d=f&&m.childNodes[f];while(d=++f&&d&&d[g]||(p=f=0)||h.pop())if(1===d.nodeType&&++p&&d===t){c[e]=[w,f,p];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===w)p=l[1];else while(d=++f&&d&&d[g]||(p=f=0)||h.pop())if((s?d.nodeName.toLowerCase()===y:1===d.nodeType)&&++p&&(v&&((d[x]||(d[x]={}))[e]=[w,p]),d===t))break;return p-=i,p===r||0===p%r&&p/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=B.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace($,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return z.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=f?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:dt(function(){return[0]}),last:dt(function(e,t){return[t-1]}),eq:dt(function(e,t,n){return[0>n?n+t:n]}),even:dt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:dt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:dt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:dt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function pt(e,t){var n,r,o,a,s,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=I.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=W.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace($," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):k(e,u).slice(0)}function ft(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,d=w+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===d){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[d],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,d,p=[],f=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,p,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,f),r(l,[],s,u),c=l.length;while(c--)(d=l[c])&&(y[f[c]]=!(m[f[c]]=d))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(d=y[c])&&l.push(m[c]=d);i(null,y=[],l,u)}c=y.length;while(c--)(d=y[c])&&(l=i?B.call(o,d):p[c])>-1&&(o[l]=!(a[l]=d))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),d=ht(function(e){return B.call(t,e)>-1},s,!0),p=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):d(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])p=[ht(gt(p),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(p),u>1&&ft(e.slice(0,u-1)).replace($,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&ft(e))}p.push(n)}return gt(p)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,p,f){var h,g,m,y=[],v=0,b="0",x=s&&[],T=null!=f,N=l,C=s||a&&i.find.TAG("*",f&&u.parentNode||u),E=w+=null==N?1:Math.random()||.1;for(T&&(l=u!==d&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){p.push(h);break}T&&(w=E,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=j.call(p));y=mt(y)}H.apply(p,y),T&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(p)}return T&&(w=E,l=N),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=A[e+" "];if(!o){t||(t=pt(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=A(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function Tt(e,t,n,r){var o,a,u,l,c,d=pt(e);if(!r&&1===d.length){if(a=d[0]=d[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!f&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&ft(a),!e)return H.apply(n,M.call(r,0)),n;break}}}return s(e,d)(r,t,f,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Nt(){}i.filters=Nt.prototype=i.pseudos,i.setFilters=new Nt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(pt(this,e,!1))},filter:function(e){return this.pushStack(pt(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function dt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return dt(e,"nextSibling")},prev:function(e){return dt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function pt(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function ft(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,St={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},Dt=ft(o),Lt=Dt.appendChild(o.createElement("div"));St.optgroup=St.option,St.tbody=St.tfoot=St.colgroup=St.caption=St.thead,St.th=St.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ft(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Bt(Ft(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Nt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||St[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=p.apply([],e);var i,o,a,s,u,l,c=0,d=this.length,f=this,h=d-1,g=e[0],m=b.isFunction(g);if(m||!(1>=d||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=f.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(d&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ft(l,"script"),Ht),a=s.length;d>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ft(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?jt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,Mt),c=0;a>c;c++)o=s[c],Et.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(At,"")));l=i=null}return this}});function jt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function Mt(e){var t=kt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Bt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,Mt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&wt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),f.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ft(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function qt(e){wt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Lt.innerHTML=e.outerHTML,Lt.removeChild(o=Lt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ft(o,"script"),r.length>0&&Bt(r,!u&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,d=e.length,p=ft(t),f=[],h=0;for(;d>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(f,o.nodeType?[o]:o);else if(Tt.test(o)){s=s||p.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=St[u]||St._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&f.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) +}b.merge(f,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=p.lastChild}else f.push(t.createTextNode(o));s&&p.removeChild(s),b.support.appendChecked||b.grep(Ft(f,"input"),qt),h=0;while(o=f[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ft(p.appendChild(o),"script"),a&&Bt(s),n)){i=0;while(o=s[i++])Et.test(o.type||"")&&n.push(o)}return s=null,p},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,d=b.support.deleteExpando,p=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)p[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],d?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Rt=/%20/g,Pt=/\[\]$/,$t=/\r?\n/g,It=/^(?:submit|button|image|reset|file)$/i,Wt=/^(?:input|select|textarea|keygen)/i;b.fn.extend({serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=b.prop(this,"elements");return e?b.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!b(this).is(":disabled")&&Wt.test(this.nodeName)&&!It.test(e)&&(this.checked||!wt.test(e))}).map(function(e,t){var n=b(this).val();return null==n?null:b.isArray(n)?b.map(n,function(e){return{name:t.name,value:e.replace($t,"\r\n")}}):{name:t.name,value:n.replace($t,"\r\n")}}).get()}}),b.param=function(e,n){var r,i=[],o=function(e,t){t=b.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=b.ajaxSettings&&b.ajaxSettings.traditional),b.isArray(e)||e.jquery&&!b.isPlainObject(e))b.each(e,function(){o(this.name,this.value)});else for(r in e)Xt(r,e[r],n,o);return i.join("&").replace(Rt,"+")};function Xt(e,t,n,r){var i;if(b.isArray(t))b.each(t,function(t,i){n||Pt.test(e)?r(e,i):Xt(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==b.type(t))r(e,t);else for(i in t)Xt(e+"["+i+"]",t[i],n,r)}var zt,Ut,Vt=b.now(),Jt=/\?/,Qt=/#.*$/,Gt=/([?&])_=[^&]*/,Kt=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Yt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Zt=/^(?:GET|HEAD)$/,en=/^\/\//,tn=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,nn=b.fn.load,rn={},on={},an="*/".concat("*");try{Ut=a.href}catch(sn){Ut=o.createElement("a"),Ut.href="",Ut=Ut.href}zt=tn.exec(Ut.toLowerCase())||[];function un(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(b.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ln(e,n,r,i){var o={},a=e===on;function s(u){var l;return o[u]=!0,b.each(e[u]||[],function(e,u){var c=u(n,r,i);return"string"!=typeof c||a||o[c]?a?!(l=c):t:(n.dataTypes.unshift(c),s(c),!1)}),l}return s(n.dataTypes[0])||!o["*"]&&s("*")}function cn(e,n){var r,i,o=b.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&b.extend(!0,e,r),e}b.fn.load=function(e,n,r){if("string"!=typeof e&&nn)return nn.apply(this,arguments);var i,o,a,s=this,u=e.indexOf(" ");return u>=0&&(i=e.slice(u,e.length),e=e.slice(0,u)),b.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&b.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?b("
").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each(["get","post"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ut,type:"GET",isLocal:Yt.test(zt[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":an,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?cn(cn(e,b.ajaxSettings),t):cn(b.ajaxSettings,e)},ajaxPrefilter:un(rn),ajaxTransport:un(on),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,d=b.ajaxSetup({},n),p=d.context||d,f=d.context&&(p.nodeType||p.jquery)?b(p):b.event,h=b.Deferred(),g=b.Callbacks("once memory"),m=d.statusCode||{},y={},v={},x=0,N="canceled",w={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Kt.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else w.always(e[w.status]);return this},abort:function(e){var t=e||N;return l&&l.abort(t),E(0,t),this}};if(h.promise(w).complete=g.add,w.success=w.done,w.error=w.fail,d.url=((e||d.url||Ut)+"").replace(Qt,"").replace(en,zt[1]+"//"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=b.trim(d.dataType||"*").toLowerCase().match(T)||[""],null==d.crossDomain&&(r=tn.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]===zt[1]&&r[2]===zt[2]&&(r[3]||("http:"===r[1]?80:443))==(zt[3]||("http:"===zt[1]?80:443)))),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=b.param(d.data,d.traditional)),ln(rn,d,n,w),2===x)return w;u=d.global,u&&0===b.active++&&b.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Zt.test(d.type),o=d.url,d.hasContent||(d.data&&(o=d.url+=(Jt.test(o)?"&":"?")+d.data,delete d.data),d.cache===!1&&(d.url=Gt.test(o)?o.replace(Gt,"$1_="+Vt++):o+(Jt.test(o)?"&":"?")+"_="+Vt++)),d.ifModified&&(b.lastModified[o]&&w.setRequestHeader("If-Modified-Since",b.lastModified[o]),b.etag[o]&&w.setRequestHeader("If-None-Match",b.etag[o])),(d.data&&d.hasContent&&d.contentType!==!1||n.contentType)&&w.setRequestHeader("Content-Type",d.contentType),w.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+an+"; q=0.01":""):d.accepts["*"]);for(i in d.headers)w.setRequestHeader(i,d.headers[i]);if(d.beforeSend&&(d.beforeSend.call(p,w,d)===!1||2===x))return w.abort();N="abort";for(i in{success:1,error:1,complete:1})w[i](d[i]);if(l=ln(on,d,n,w)){w.readyState=1,u&&f.trigger("ajaxSend",[w,d]),d.async&&d.timeout>0&&(s=setTimeout(function(){w.abort("timeout")},d.timeout));try{x=1,l.send(y,E)}catch(C){if(!(2>x))throw C;E(-1,C)}}else E(-1,"No Transport");function E(e,n,r,i){var c,y,v,T,N,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||"",w.readyState=e>0?4:0,r&&(T=dn(d,w,r)),e>=200&&300>e||304===e?(d.ifModified&&(N=w.getResponseHeader("Last-Modified"),N&&(b.lastModified[o]=N),N=w.getResponseHeader("etag"),N&&(b.etag[o]=N)),204===e?(c=!0,C="nocontent"):304===e?(c=!0,C="notmodified"):(c=pn(d,T),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C="error",0>e&&(e=0))),w.status=e,w.statusText=(n||C)+"",c?h.resolveWith(p,[y,C,w]):h.rejectWith(p,[w,C,v]),w.statusCode(m),m=t,u&&f.trigger(c?"ajaxSuccess":"ajaxError",[w,d,c?y:v]),g.fireWith(p,[w,C]),u&&(f.trigger("ajaxComplete",[w,d]),--b.active||b.event.trigger("ajaxStop")))}return w},getScript:function(e,n){return b.get(e,t,n,"script")},getJSON:function(e,t,n){return b.get(e,t,n,"json")}});function dn(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while("*"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+" "+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function pn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if("*"!==r){if("*"!==l&&l!==r){if(i=a[l+" "+r]||a["* "+r],!i)for(n in a)if(o=n.split(" "),o[1]===r&&(i=a[l+" "+o[0]]||a["* "+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e["throws"])t=i(t);else try{t=i(t)}catch(c){return{state:"parsererror",error:i?c:"No conversion from "+l+" to "+r}}}l=r}return{state:"success",data:t}}var fn,hn,gn=0,mn=e.ActiveXObject&&function(){var e;for(e in fn)fn[e](t,!0)};function yn(){try{return new e.XMLHttpRequest}catch(t){}}function vn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&yn()||vn()}:yn,hn=b.ajaxSettings.xhr(),b.support.cors=!!hn&&"withCredentials"in hn,hn=b.support.ajax=!!hn,hn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,d;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,mn&&delete fn[a]),i)4!==u.readyState&&u.abort();else{d={},s=u.status,l=u.getAllResponseHeaders(),"string"==typeof u.responseText&&(d.text=u.responseText);try{c=u.statusText}catch(p){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=d.text?200:404}}catch(f){i||o(-1,f)}d&&o(s,c,d,l)},n.async?4===u.readyState?setTimeout(r):(a=++gn,mn&&(fn||(fn={},b(e).unload(mn)),fn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}}),e.jQuery=e.$=b,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return b})})(window); \ No newline at end of file diff --git a/bower_components/jquery/test/data/json.php b/bower_components/jquery/test/data/json.php new file mode 100644 index 0000000..d6e0f2f --- /dev/null +++ b/bower_components/jquery/test/data/json.php @@ -0,0 +1,13 @@ + diff --git a/bower_components/jquery/test/data/json_obj.js b/bower_components/jquery/test/data/json_obj.js new file mode 100644 index 0000000..7fa6182 --- /dev/null +++ b/bower_components/jquery/test/data/json_obj.js @@ -0,0 +1 @@ +{ "data": {"lang": "en", "length": 25} } diff --git a/bower_components/jquery/test/data/jsonp.php b/bower_components/jquery/test/data/jsonp.php new file mode 100644 index 0000000..6c13d72 --- /dev/null +++ b/bower_components/jquery/test/data/jsonp.php @@ -0,0 +1,14 @@ + diff --git a/bower_components/jquery/test/data/manipulation/iframe-denied.html b/bower_components/jquery/test/data/manipulation/iframe-denied.html new file mode 100644 index 0000000..14df26a --- /dev/null +++ b/bower_components/jquery/test/data/manipulation/iframe-denied.html @@ -0,0 +1,36 @@ + + + + + body + + +
+ + + + diff --git a/bower_components/jquery/test/data/name.html b/bower_components/jquery/test/data/name.html new file mode 100644 index 0000000..0fa32d1 --- /dev/null +++ b/bower_components/jquery/test/data/name.html @@ -0,0 +1 @@ +ERROR diff --git a/bower_components/jquery/test/data/name.php b/bower_components/jquery/test/data/name.php new file mode 100644 index 0000000..6402858 --- /dev/null +++ b/bower_components/jquery/test/data/name.php @@ -0,0 +1,24 @@ +$xml$result"; + die(); +} +$name = $_REQUEST['name']; +if($name == 'foo') { + echo "bar"; + die(); +} else if($name == 'peter') { + echo "pan"; + die(); +} + +echo 'ERROR '; +?> \ No newline at end of file diff --git a/bower_components/jquery/test/data/nocontent.php b/bower_components/jquery/test/data/nocontent.php new file mode 100644 index 0000000..9c8431b --- /dev/null +++ b/bower_components/jquery/test/data/nocontent.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/bower_components/jquery/test/data/offset/absolute.html b/bower_components/jquery/test/data/offset/absolute.html new file mode 100644 index 0000000..7665d7a --- /dev/null +++ b/bower_components/jquery/test/data/offset/absolute.html @@ -0,0 +1,41 @@ + + + + + absolute + + + + + +
absolute-1 +
absolute-1-1 +
absolute-1-1-1
+
+
+
absolute-2
+
Has absolute position but no values set for the location ('auto').
+
+

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

+ + diff --git a/bower_components/jquery/test/data/offset/body.html b/bower_components/jquery/test/data/offset/body.html new file mode 100644 index 0000000..6dc3d37 --- /dev/null +++ b/bower_components/jquery/test/data/offset/body.html @@ -0,0 +1,26 @@ + + + + + body + + + + + +
+
+ + diff --git a/bower_components/jquery/test/data/offset/fixed.html b/bower_components/jquery/test/data/offset/fixed.html new file mode 100644 index 0000000..7564f08 --- /dev/null +++ b/bower_components/jquery/test/data/offset/fixed.html @@ -0,0 +1,34 @@ + + + + + fixed + + + + + +
+
+
+
+
+

Click the white box to move the marker to it.

+ + diff --git a/bower_components/jquery/test/data/offset/relative.html b/bower_components/jquery/test/data/offset/relative.html new file mode 100644 index 0000000..3ac0548 --- /dev/null +++ b/bower_components/jquery/test/data/offset/relative.html @@ -0,0 +1,31 @@ + + + + + relative + + + + + +
+
+
+

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

+ + diff --git a/bower_components/jquery/test/data/offset/scroll.html b/bower_components/jquery/test/data/offset/scroll.html new file mode 100644 index 0000000..113400c --- /dev/null +++ b/bower_components/jquery/test/data/offset/scroll.html @@ -0,0 +1,39 @@ + + + + + scroll + + + + + +
+
+
+
+
+
+
+

Click the white box to move the marker to it.

+ + diff --git a/bower_components/jquery/test/data/offset/static.html b/bower_components/jquery/test/data/offset/static.html new file mode 100644 index 0000000..1e6ab7c --- /dev/null +++ b/bower_components/jquery/test/data/offset/static.html @@ -0,0 +1,31 @@ + + + + + static + + + + + +
+
+
+

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

+ + diff --git a/bower_components/jquery/test/data/offset/table.html b/bower_components/jquery/test/data/offset/table.html new file mode 100644 index 0000000..5510e2b --- /dev/null +++ b/bower_components/jquery/test/data/offset/table.html @@ -0,0 +1,43 @@ + + + + + table + + + + + +
+ + + + + + + + + + + + + + +
th-1th-2th-3
td-1td-2td-3
+
+

Click the white box to move the marker to it.

+ + diff --git a/bower_components/jquery/test/data/params_html.php b/bower_components/jquery/test/data/params_html.php new file mode 100644 index 0000000..e88ef15 --- /dev/null +++ b/bower_components/jquery/test/data/params_html.php @@ -0,0 +1,12 @@ +
+$value ) + echo "$value"; +?> +
+
+$value ) + echo "$value"; +?> +
\ No newline at end of file diff --git a/bower_components/jquery/test/data/readywaitasset.js b/bower_components/jquery/test/data/readywaitasset.js new file mode 100644 index 0000000..2308965 --- /dev/null +++ b/bower_components/jquery/test/data/readywaitasset.js @@ -0,0 +1 @@ +var delayedMessage = "It worked!"; diff --git a/bower_components/jquery/test/data/readywaitloader.js b/bower_components/jquery/test/data/readywaitloader.js new file mode 100644 index 0000000..e07dac7 --- /dev/null +++ b/bower_components/jquery/test/data/readywaitloader.js @@ -0,0 +1,25 @@ +// Simple script loader that uses jQuery.readyWait via jQuery.holdReady() + +//Hold on jQuery! +jQuery.holdReady(true); + +var readyRegExp = /^(complete|loaded)$/; + +function assetLoaded( evt ){ + var node = evt.currentTarget || evt.srcElement; + if ( evt.type === "load" || readyRegExp.test(node.readyState) ) { + jQuery.holdReady(false); + } +} + +setTimeout( function() { + var script = document.createElement("script"); + script.type = "text/javascript"; + if ( script.addEventListener ) { + script.addEventListener( "load", assetLoaded, false ); + } else { + script.attachEvent( "onreadystatechange", assetLoaded ); + } + script.src = "data/readywaitasset.js"; + document.getElementsByTagName("head")[0].appendChild(script); +}, 2000 ); diff --git a/bower_components/jquery/test/data/script.php b/bower_components/jquery/test/data/script.php new file mode 100644 index 0000000..fb71104 --- /dev/null +++ b/bower_components/jquery/test/data/script.php @@ -0,0 +1,11 @@ + +ok( true, "Script executed correctly." ); diff --git a/bower_components/jquery/test/data/selector/html5_selector.html b/bower_components/jquery/test/data/selector/html5_selector.html new file mode 100644 index 0000000..30f25c9 --- /dev/null +++ b/bower_components/jquery/test/data/selector/html5_selector.html @@ -0,0 +1,114 @@ + + + + + jQuery selector - attributes + + + + + + + + + + +
+ +
+ + +
+ + + +
+ + + + + +
    + +
    + +
    + + + + + + + + + + + + + + + +
    +
    Term
    This is the first definition in compact format.
    +
    Term
    This is the second definition in compact format.
    +
    + + + + Scrolling text (non-standard) + + diff --git a/bower_components/jquery/test/data/selector/sizzle_cache.html b/bower_components/jquery/test/data/selector/sizzle_cache.html new file mode 100644 index 0000000..1055c75 --- /dev/null +++ b/bower_components/jquery/test/data/selector/sizzle_cache.html @@ -0,0 +1,21 @@ + + + + + jQuery selector - sizzle cache + + + + + + +
    + Worlds collide +
    + + diff --git a/bower_components/jquery/test/data/statusText.php b/bower_components/jquery/test/data/statusText.php new file mode 100644 index 0000000..daf58ce --- /dev/null +++ b/bower_components/jquery/test/data/statusText.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/bower_components/jquery/test/data/support/bodyBackground.html b/bower_components/jquery/test/data/support/bodyBackground.html new file mode 100644 index 0000000..8991007 --- /dev/null +++ b/bower_components/jquery/test/data/support/bodyBackground.html @@ -0,0 +1,28 @@ + + + + + + + +
    + +
    + + + diff --git a/bower_components/jquery/test/data/support/boxSizing.html b/bower_components/jquery/test/data/support/boxSizing.html new file mode 100644 index 0000000..63c4c90 --- /dev/null +++ b/bower_components/jquery/test/data/support/boxSizing.html @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/bower_components/jquery/test/data/support/csp.js b/bower_components/jquery/test/data/support/csp.js new file mode 100644 index 0000000..8bce34f --- /dev/null +++ b/bower_components/jquery/test/data/support/csp.js @@ -0,0 +1,3 @@ +jQuery(function() { + parent.iframeCallback( jQuery.support ); +}); diff --git a/bower_components/jquery/test/data/support/csp.php b/bower_components/jquery/test/data/support/csp.php new file mode 100644 index 0000000..f72aa07 --- /dev/null +++ b/bower_components/jquery/test/data/support/csp.php @@ -0,0 +1,22 @@ + + + + + + CSP Test Page + + + + +

    CSP Test Page

    + + diff --git a/bower_components/jquery/test/data/support/shrinkWrapBlocks.html b/bower_components/jquery/test/data/support/shrinkWrapBlocks.html new file mode 100644 index 0000000..a2097cb --- /dev/null +++ b/bower_components/jquery/test/data/support/shrinkWrapBlocks.html @@ -0,0 +1,23 @@ + + + + + + + +
    + +
    + + + diff --git a/bower_components/jquery/test/data/support/testElementCrash.html b/bower_components/jquery/test/data/support/testElementCrash.html new file mode 100644 index 0000000..16de48c --- /dev/null +++ b/bower_components/jquery/test/data/support/testElementCrash.html @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/bower_components/jquery/test/data/test.html b/bower_components/jquery/test/data/test.html new file mode 100644 index 0000000..eec028e --- /dev/null +++ b/bower_components/jquery/test/data/test.html @@ -0,0 +1,7 @@ +html text
    + + +blabla diff --git a/bower_components/jquery/test/data/test.js b/bower_components/jquery/test/data/test.js new file mode 100644 index 0000000..fb33952 --- /dev/null +++ b/bower_components/jquery/test/data/test.js @@ -0,0 +1,3 @@ +this.testBar = "bar"; +jQuery("#ap").html("bar"); +ok( true, "test.js executed"); diff --git a/bower_components/jquery/test/data/test.php b/bower_components/jquery/test/data/test.php new file mode 100644 index 0000000..3d08f32 --- /dev/null +++ b/bower_components/jquery/test/data/test.php @@ -0,0 +1,7 @@ +html text
    + + +blabla \ No newline at end of file diff --git a/bower_components/jquery/test/data/test2.html b/bower_components/jquery/test/data/test2.html new file mode 100644 index 0000000..1df6151 --- /dev/null +++ b/bower_components/jquery/test/data/test2.html @@ -0,0 +1,5 @@ + diff --git a/bower_components/jquery/test/data/test3.html b/bower_components/jquery/test/data/test3.html new file mode 100644 index 0000000..909d417 --- /dev/null +++ b/bower_components/jquery/test/data/test3.html @@ -0,0 +1,3 @@ +
    This is a user
    +
    This is a user
    +
    This is a teacher
    diff --git a/bower_components/jquery/test/data/testinit.js b/bower_components/jquery/test/data/testinit.js new file mode 100644 index 0000000..0351f02 --- /dev/null +++ b/bower_components/jquery/test/data/testinit.js @@ -0,0 +1,264 @@ +/*jshint multistr:true, quotmark:false */ + +var amdDefined, fireNative, + originaljQuery = this.jQuery || "jQuery", + original$ = this.$ || "$", + // see RFC 2606 + externalHost = "example.com"; + +this.hasPHP = true; +this.isLocal = window.location.protocol === "file:"; + +// For testing .noConflict() +this.jQuery = originaljQuery; +this.$ = original$; + +/** + * Set up a mock AMD define function for testing AMD registration. + */ +function define( name, dependencies, callback ) { + amdDefined = callback(); +} + +define.amd = {}; + +/** + * Returns an array of elements with the given IDs + * @example q("main", "foo", "bar") + * @result [
    , , ] + */ +this.q = function() { + var r = [], + i = 0; + + for ( ; i < arguments.length; i++ ) { + r.push( document.getElementById( arguments[i] ) ); + } + return r; +}; + +/** + * Asserts that a select matches the given IDs + * @param {String} a - Assertion name + * @param {String} b - Sizzle selector + * @param {String} c - Array of ids to construct what is expected + * @example t("Check for something", "//[a]", ["foo", "baar"]); + * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar' + */ +this.t = function( a, b, c ) { + var f = jQuery(b).get(), + s = "", + i = 0; + + for ( ; i < f.length; i++ ) { + s += ( s && "," ) + '"' + f[ i ].id + '"'; + } + + deepEqual(f, q.apply( q, c ), a + " (" + b + ")"); +}; + +this.createDashboardXML = function() { + var string = ' \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + '; + + return jQuery.parseXML(string); +}; + +this.createWithFriesXML = function() { + var string = ' \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + 1 \ + \ + \ + \ + \ + foo \ + \ + \ + \ + \ + \ + \ + '; + + return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) ); +}; + +this.createXMLFragment = function() { + var xml, frag; + if ( window.ActiveXObject ) { + xml = new ActiveXObject("msxml2.domdocument"); + } else { + xml = document.implementation.createDocument( "", "", null ); + } + + if ( xml ) { + frag = xml.createElement("data"); + } + + return frag; +}; + +fireNative = document.createEvent ? + function( node, type ) { + var event = document.createEvent('HTMLEvents'); + event.initEvent( type, true, true ); + node.dispatchEvent( event ); + } : + function( node, type ) { + var event = document.createEventObject(); + node.fireEvent( 'on' + type, event ); + }; + +/** + * Add random number to url to stop caching + * + * @example url("data/test.html") + * @result "data/test.html?10538358428943" + * + * @example url("data/test.php?foo=bar") + * @result "data/test.php?foo=bar&10538358345554" + */ +function url( value ) { + return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 10); +} + +// Ajax testing helper +this.ajaxTest = function( title, expect, options ) { + var requestOptions; + if ( jQuery.isFunction( options ) ) { + options = options(); + } + options = options || []; + requestOptions = options.requests || options.request || options; + if ( !jQuery.isArray( requestOptions ) ) { + requestOptions = [ requestOptions ]; + } + asyncTest( title, expect, function() { + if ( options.setup ) { + options.setup(); + } + + var completed = false, + remaining = requestOptions.length, + complete = function() { + if ( !completed && --remaining === 0 ) { + completed = true; + delete ajaxTest.abort; + if ( options.teardown ) { + options.teardown(); + } + start(); + } + }, + requests = jQuery.map( requestOptions, function( options ) { + var request = ( options.create || jQuery.ajax )( options ), + callIfDefined = function( deferType, optionType ) { + var handler = options[ deferType ] || !!options[ optionType ]; + return function( _, status ) { + if ( !completed ) { + if ( !handler ) { + ok( false, "unexpected " + status ); + } else if ( jQuery.isFunction( handler ) ) { + handler.apply( this, arguments ); + } + } + }; + }; + + if ( options.afterSend ) { + options.afterSend( request ); + } + + return request + .done( callIfDefined( "done", "success" ) ) + .fail( callIfDefined( "fail", "error" ) ) + .always( complete ); + }); + + ajaxTest.abort = function( reason ) { + if ( !completed ) { + completed = true; + delete ajaxTest.abort; + ok( false, "aborted " + reason ); + jQuery.each( requests, function( i, request ) { + request.abort(); + }); + } + }; + }); +}; + + +this.testIframe = function( fileName, name, fn ) { + + test(name, function() { + // pause execution for now + stop(); + + // load fixture in iframe + var iframe = loadFixture(), + win = iframe.contentWindow, + interval = setInterval( function() { + if ( win && win.jQuery && win.jQuery.isReady ) { + clearInterval( interval ); + // continue + start(); + // call actual tests passing the correct jQuery instance to use + fn.call( this, win.jQuery, win, win.document ); + document.body.removeChild( iframe ); + iframe = null; + } + }, 15 ); + }); + + function loadFixture() { + var src = url("./data/" + fileName + ".html"), + iframe = jQuery(" +
    +
    +

    See this blog entry for more information.

    +

    + Here are some links in a normal paragraph: Google, + Google Groups (Link). + This link has class="blog": + diveintomark + +

    +
    +

    Everything inside the red border is inside a div with id="foo".

    +

    This is a normal link: Yahoo

    +

    This link has class="blog": Simon Willison's Weblog

    + +
    +
    +
    +
    + +

    Try them out:

    +
      +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + test element +
        + Float test. + +
        + + +
        +
        + +
        + + + + +
        + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        +
        +
        + +
        +
        hi there
        +
        +
        +
        +
        +
        +
        +
        +
        + +
        +
          +
        1. Rice
        2. +
        3. Beans
        4. +
        5. Blinis
        6. +
        7. Tofu
        8. +
        + +
        I'm hungry. I should...
        + ...Eat lots of food... | + ...Eat a little food... | + ...Eat no food... + ...Eat a burger... + ...Eat some funyuns... + ...Eat some funyuns... + + + + + + +
        + +
        + + +
        + +
        + 1 + 2 + + + + + + + + +
        +
        +
        +
        fadeIn
        fadeIn
        +
        fadeOut
        fadeOut
        + +
        show
        show
        +
        hide
        hide
        +
        hide
        hide
        + +
        togglein
        togglein
        +
        toggleout
        toggleout
        +
        toggleout
        toggleout
        + +
        slideUp
        slideUp
        +
        slideDown
        slideDown
        +
        slideUp
        slideUp
        + +
        slideToggleIn
        slideToggleIn
        +
        slideToggleOut
        slideToggleOut
        + +
        fadeToggleIn
        fadeToggleIn
        +
        fadeToggleOut
        fadeToggleOut
        + +
        fadeTo
        fadeTo
        +
        + +
        + +
        +
        +
        + + + + + + diff --git a/bower_components/jquery/test/jquery.js b/bower_components/jquery/test/jquery.js new file mode 100644 index 0000000..93d1095 --- /dev/null +++ b/bower_components/jquery/test/jquery.js @@ -0,0 +1,5 @@ +// Use the right jQuery source in iframe tests +document.write( " + + + +

        jQuery Local File Test

        +

        + Introduction +

        + +

        + Results +

        + +

        + Logs: +

        + + + diff --git a/bower_components/jquery/test/networkerror.html b/bower_components/jquery/test/networkerror.html new file mode 100644 index 0000000..edbaaba --- /dev/null +++ b/bower_components/jquery/test/networkerror.html @@ -0,0 +1,84 @@ + + + + + + jQuery Network Error Test for Firefox + + + + + + +

        + jQuery Network Error Test for Firefox +

        +
        + This is a test page for + + #8135 + + which was reported in Firefox when accessing properties + of an XMLHttpRequest object after a network error occurred. +
        +
        Take the following steps:
        +
          +
        1. + make sure you accessed this page through a web server, +
        2. +
        3. + stop the web server, +
        4. +
        5. + open the console, +
        6. +
        7. + click this + + , +
        8. +
        9. + wait for both requests to fail. +
        10. +
        +
        + Test passes if you get two log lines: +
          +
        • + the first starting with "abort", +
        • +
        • + the second starting with "complete", +
        • +
        +
        +
        + Test fails if the browser notifies an exception. +
        + + diff --git a/bower_components/jquery/test/readywait.html b/bower_components/jquery/test/readywait.html new file mode 100644 index 0000000..7a736be --- /dev/null +++ b/bower_components/jquery/test/readywait.html @@ -0,0 +1,70 @@ + + + + + + jQuery.holdReady Test + + + + + + + + + + +

        + jQuery.holdReady Test +

        +

        + This is a test page for jQuery.readyWait and jQuery.holdReady, + see + #6781 + and + #8803. +

        +

        + Test for jQuery.holdReady, which can be used + by plugins and other scripts to indicate something + important to the page is still loading and needs + to block the DOM ready callbacks that are registered + with jQuery. +

        +

        + Script loaders are the most likely kind of script + to use jQuery.holdReady, but it could be used by + other things like a script that loads a CSS file + and wants to pause the DOM ready callbacks. +

        +

        + Expected Result: The text + It Worked! + appears below after about 2 seconds. +

        +

        + If there is an error in the console, + or the text does not show up, then the test failed. +

        +
        + + diff --git a/bower_components/jquery/test/unit/ajax.js b/bower_components/jquery/test/unit/ajax.js new file mode 100644 index 0000000..761885c --- /dev/null +++ b/bower_components/jquery/test/unit/ajax.js @@ -0,0 +1,1954 @@ +module( "ajax", { + setup: function() { + var jsonpCallback = this.jsonpCallback = jQuery.ajaxSettings.jsonpCallback; + jQuery.ajaxSettings.jsonpCallback = function() { + var callback = jsonpCallback.apply( this, arguments ); + Globals.register( callback ); + return callback; + }; + }, + teardown: function() { + jQuery( document ).off( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess" ); + moduleTeardown.apply( this, arguments ); + } +}); + +(function() { + + if ( !jQuery.ajax || ( isLocal && !hasPHP ) ) { + return; + } + + function addGlobalEvents( expected ) { + return function() { + expected = expected || ""; + jQuery( document ).on( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess", function( e ) { + ok( expected.indexOf(e.type) !== -1, e.type ); + }); + }; + } + +//----------- jQuery.ajax() + + testIframeWithCallback( "XMLHttpRequest - Attempt to block tests because of dangling XHR requests (IE)", "ajax/unreleasedXHR.html", function() { + expect( 1 ); + ok( true, "done" ); + }); + + ajaxTest( "jQuery.ajax() - success callbacks", 8, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + success: function() { + ok( true, "success" ); + }, + complete: function() { + ok( true, "complete"); + } + }); + + ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), + create: function( options ) { + return jQuery.ajax( url("data/name.html"), options ); + }, + beforeSend: function() { + ok( true, "beforeSend" ); + }, + success: function() { + ok( true, "success" ); + }, + complete: function() { + ok( true, "complete" ); + } + }); + + ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + success: true, + afterSend: function( request ) { + request.complete(function() { + ok( true, "complete" ); + }).success(function() { + ok( true, "success" ); + }).error(function() { + ok( false, "error" ); + }); + } + }); + + ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess"), + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + success: true, + complete: function( xhr ) { + xhr.complete(function() { + ok( true, "complete" ); + }).success(function() { + ok( true, "success" ); + }).error(function() { + ok( false, "error" ); + }); + } + }); + + ajaxTest( "jQuery.ajax() - error callbacks", 8, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError"), + url: url("data/name.php?wait=5"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + afterSend: function( request ) { + request.abort(); + }, + error: function() { + ok( true, "error" ); + }, + complete: function() { + ok( true, "complete" ); + } + }); + + ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, [ + { + url: url("data/name.php?wait=5"), + error: function( _, textStatus, errorThrown ) { + strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" ); + strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" ); + }, + afterSend: function( request ) { + request.abort(); + } + }, + { + url: url("data/name.php?wait=5"), + error: function( _, textStatus, errorThrown ) { + strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" ); + strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" ); + }, + afterSend: function( request ) { + request.abort("mystatus"); + } + } + ]); + + ajaxTest( "jQuery.ajax() - responseText on error", 1, { + url: url("data/errorWithText.php"), + error: function( xhr ) { + strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" ); + } + }); + + asyncTest( "jQuery.ajax() - retry with jQuery.ajax( this )", 2, function() { + var previousUrl, + firstTime = true; + jQuery.ajax({ + url: url("data/errorWithText.php"), + error: function() { + if ( firstTime ) { + firstTime = false; + jQuery.ajax( this ); + } else { + ok ( true, "Test retrying with jQuery.ajax(this) works" ); + jQuery.ajax({ + url: url("data/errorWithText.php"), + data: { + "x": 1 + }, + beforeSend: function() { + if ( !previousUrl ) { + previousUrl = this.url; + } else { + strictEqual( this.url, previousUrl, "url parameters are not re-appended" ); + start(); + return false; + } + }, + error: function() { + jQuery.ajax( this ); + } + }); + } + } + }); + }); + + ajaxTest( "jQuery.ajax() - headers", 4, { + setup: function() { + jQuery( document ).ajaxSend(function( evt, xhr ) { + xhr.setRequestHeader( "ajax-send", "test" ); + }); + }, + url: url("data/headers.php?keys=siMPle_SometHing-elsE_OthEr_ajax-send"), + headers: { + "siMPle": "value", + "SometHing-elsE": "other value", + "OthEr": "something else" + }, + success: function( data, _, xhr ) { + var i, emptyHeader, + requestHeaders = jQuery.extend( this.headers, { + "ajax-send": "test" + }), + tmp = []; + for ( i in requestHeaders ) { + tmp.push( i, ": ", requestHeaders[ i ], "\n" ); + } + tmp = tmp.join(""); + + strictEqual( data, tmp, "Headers were sent" ); + strictEqual( xhr.getResponseHeader("Sample-Header"), "Hello World", "Sample header received" ); + + emptyHeader = xhr.getResponseHeader("Empty-Header"); + if ( emptyHeader === null ) { + ok( true, "Firefox doesn't support empty headers" ); + } else { + strictEqual( emptyHeader, "", "Empty header received" ); + } + strictEqual( xhr.getResponseHeader("Sample-Header2"), "Hello World 2", "Second sample header received" ); + } + }); + + ajaxTest( "jQuery.ajax() - Accept header", 1, { + url: url("data/headers.php?keys=accept"), + headers: { + Accept: "very wrong accept value" + }, + beforeSend: function( xhr ) { + xhr.setRequestHeader("Accept", "*/*"); + }, + success: function( data ) { + strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" ); + } + }); + + ajaxTest( "jQuery.ajax() - contentType", 2, [ + { + url: url("data/headers.php?keys=content-type"), + contentType: "test", + success: function( data ) { + strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); + } + }, + { + url: url("data/headers.php?keys=content-type"), + contentType: false, + success: function( data ) { + strictEqual( data, "content-type: \n", "Test content-type is not sent when options.contentType===false" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - protocol-less urls", 1, { + url: "//somedomain.com", + beforeSend: function( xhr, settings ) { + equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." ); + return false; + }, + error: true + }); + + ajaxTest( "jQuery.ajax() - hash", 3, [ + { + url: "data/name.html#foo", + beforeSend: function( xhr, settings ) { + equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." ); + return false; + }, + error: true + }, + { + url: "data/name.html?abc#foo", + beforeSend: function( xhr, settings ) { + equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." ); + return false; + }, + error: true + }, + { + url: "data/name.html?abc#foo", + data: { + "test": 123 + }, + beforeSend: function( xhr, settings ) { + equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." ); + return false; + }, + error: true + } + ]); + + ajaxTest( "jQuery.ajax() - cross-domain detection", 7, function() { + function request( url, title, crossDomainOrOptions ) { + return jQuery.extend( { + dataType: "jsonp", + url: url, + beforeSend: function( _, s ) { + ok( crossDomainOrOptions === false ? !s.crossDomain : s.crossDomain, title ); + return false; + }, + error: true + }, crossDomainOrOptions ); + } + + var loc = document.location, + samePort = loc.port || ( loc.protocol === "http:" ? 80 : 443 ), + otherPort = loc.port === 666 ? 667 : 666, + otherProtocol = loc.protocol === "http:" ? "https:" : "http:"; + + return [ + request( + loc.protocol + "//" + loc.host + ":" + samePort, + "Test matching ports are not detected as cross-domain", + false + ), + request( + otherProtocol + "//" + loc.host, + "Test different protocols are detected as cross-domain" + ), + request( + "app:/path", + "Adobe AIR app:/ URL detected as cross-domain" + ), + request( + loc.protocol + "//example.invalid:" + ( loc.port || 80 ), + "Test different hostnames are detected as cross-domain" + ), + request( + loc.protocol + "//" + loc.hostname + ":" + otherPort, + "Test different ports are detected as cross-domain" + ), + request( + "about:blank", + "Test about:blank is detected as cross-domain" + ), + request( + loc.protocol + "//" + loc.host, + "Test forced crossDomain is detected as cross-domain", + { + crossDomain: true + } + ) + ]; + }); + + ajaxTest( "jQuery.ajax() - abort", 9, { + setup: addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete"), + url: url("data/name.php?wait=5"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + afterSend: function( xhr ) { + strictEqual( xhr.readyState, 1, "XHR readyState indicates successful dispatch" ); + xhr.abort(); + strictEqual( xhr.readyState, 0, "XHR readyState indicates successful abortion" ); + }, + error: true, + complete: function() { + ok( true, "complete" ); + } + }); + + ajaxTest( "jQuery.ajax() - events with context", 12, function() { + + var context = document.createElement("div"); + + function event( e ) { + equal( this, context, e.type ); + } + + function callback( msg ) { + return function() { + equal( this, context, "context is preserved on callback " + msg ); + }; + } + + return { + setup: function() { + jQuery( context ).appendTo("#foo") + .ajaxSend( event ) + .ajaxComplete( event ) + .ajaxError( event ) + .ajaxSuccess( event ); + }, + requests: [{ + url: url("data/name.html"), + context: context, + beforeSend: callback("beforeSend"), + success: callback("success"), + complete: callback("complete") + }, { + url: url("data/404.html"), + context: context, + beforeSend: callback("beforeSend"), + error: callback("error"), + complete: callback("complete") + }] + }; + }); + + ajaxTest( "jQuery.ajax() - events without context", 3, function() { + function nocallback( msg ) { + return function() { + equal( typeof this.url, "string", "context is settings on callback " + msg ); + }; + } + return { + url: url("data/404.html"), + beforeSend: nocallback("beforeSend"), + error: nocallback("error"), + complete: nocallback("complete") + }; + }); + + ajaxTest( "jQuery.ajax() - context modification", 1, { + url: url("data/name.html"), + context: {}, + beforeSend: function() { + this.test = "foo"; + }, + afterSend: function() { + strictEqual( this.context.test, "foo", "Make sure the original object is maintained." ); + }, + success: true + }); + + ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function() { + var obj = {}; + return { + setup: function() { + jQuery.ajaxSetup({ + context: obj + }); + strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); + }, + requests: [{ + url: url("data/name.html"), + success: function() { + strictEqual( this, obj, "Make sure the original object is maintained." ); + } + }, { + url: url("data/name.html"), + context: {}, + success: function() { + ok( this !== obj, "Make sure overriding context is possible." ); + } + }] + }; + }); + + ajaxTest( "jQuery.ajax() - disabled globals", 3, { + setup: addGlobalEvents(""), + global: false, + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend" ); + }, + success: function() { + ok( true, "success" ); + }, + complete: function() { + ok( true, "complete" ); + } + }); + + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, { + url: url("data/with_fries.xml"), + dataType: "xml", + success: function( resp ) { + equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + } + }); + + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, { + url: url("data/with_fries_over_jsonp.php"), + dataType: "jsonp xml", + success: function( resp ) { + equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + } + }); + + ajaxTest( "jQuery.ajax() - HEAD requests", 2, [ + { + url: url("data/name.html"), + type: "HEAD", + success: function( data, status, xhr ) { + ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response" ); + } + }, + { + url: url("data/name.html"), + data: { + "whip_it": "good" + }, + type: "HEAD", + success: function( data, status, xhr ) { + ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response with data" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - beforeSend", 1, { + url: url("data/name.html"), + beforeSend: function() { + this.check = true; + }, + success: function() { + ok( this.check, "check beforeSend was executed" ); + } + }); + + ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, { + create: function() { + return jQuery.ajax({ + url: url("data/name.html"), + beforeSend: function( xhr ) { + ok( true, "beforeSend got called, canceling" ); + xhr.abort(); + }, + success: function() { + ok( false, "request didn't get canceled" ); + }, + complete: function() { + ok( false, "request didn't get canceled" ); + }, + error: function() { + ok( false, "request didn't get canceled" ); + } + }); + }, + fail: function( _, reason ) { + strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); + } + }); + + ajaxTest( "jQuery.ajax() - dataType html", 5, { + setup: function() { + Globals.register("testFoo"); + Globals.register("testBar"); + }, + dataType: "html", + url: url("data/test.html"), + success: function( data ) { + ok( data.match( /^html text/ ), "Check content for datatype html" ); + jQuery("#ap").html( data ); + strictEqual( window["testFoo"], "foo", "Check if script was evaluated for datatype html" ); + strictEqual( window["testBar"], "bar", "Check if script src was evaluated for datatype html" ); + } + }); + + ajaxTest( "jQuery.ajax() - synchronous request", 1, { + url: url("data/json_obj.js"), + dataType: "text", + async: false, + success: true, + afterSend: function( xhr ) { + ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" ); + } + }); + + ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, { + url: url("data/json_obj.js"), + async: false, + dataType: "text", + success: true, + afterSend: function( xhr ) { + var result; + xhr.done(function( data ) { + ok( true, "success callback executed" ); + result = data; + }); + ok( /^\{ "data"/.test( result ), "check returned text" ); + } + }); + + asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function() { + var target = "data/name.html", + successCount = 0, + errorCount = 0, + errorEx = "", + success = function() { + successCount++; + }; + jQuery( document ).on( "ajaxError.passthru", function( e, xml ) { + errorCount++; + errorEx += ": " + xml.status; + }); + jQuery( document ).one( "ajaxStop", function() { + equal( successCount, 5, "Check all ajax calls successful" ); + equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" ); + jQuery( document ).off("ajaxError.passthru"); + start(); + }); + Globals.register("testBar"); + + ok( jQuery.get( url(target), success ), "get" ); + ok( jQuery.post( url(target), success ), "post" ); + ok( jQuery.getScript( url("data/test.js"), success ), "script" ); + ok( jQuery.getJSON( url("data/json_obj.js"), success ), "json" ); + ok( jQuery.ajax({ + url: url( target ), + success: success + }), "generic" ); + }); + + ajaxTest( "jQuery.ajax() - cache", 12, function() { + + var re = /_=(.*?)(&|$)/g; + + function request( url, title ) { + return { + url: url, + cache: false, + beforeSend: function() { + var parameter, tmp; + while(( tmp = re.exec( this.url ) )) { + strictEqual( parameter, undefined, title + ": only one 'no-cache' parameter" ); + parameter = tmp[ 1 ]; + notStrictEqual( parameter, "tobereplaced555", title + ": parameter (if it was there) was replaced" ); + } + return false; + }, + error: true + }; + } + + return [ + request( + "data/text.php", + "no parameter" + ), + request( + "data/text.php?pizza=true", + "1 parameter" + ), + request( + "data/text.php?_=tobereplaced555", + "_= parameter" + ), + request( + "data/text.php?pizza=true&_=tobereplaced555", + "1 parameter and _=" + ), + request( + "data/text.php?_=tobereplaced555&tv=false", + "_= and 1 parameter" + ), + request( + "data/text.php?name=David&_=tobereplaced555&washere=true", + "2 parameters surrounding _=" + ) + ]; + }); + + jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { + + ajaxTest( "jQuery.ajax() - JSONP - Query String (?n)" + label, 4, [ + { + url: "data/jsonp.php?callback=?", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data.data, "JSON results returned (GET, url callback)" ); + } + }, + { + url: "data/jsonp.php?callback=??", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data.data, "JSON results returned (GET, url context-free callback)" ); + } + }, + { + url: "data/jsonp.php/??", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data.data, "JSON results returned (GET, REST-like)" ); + } + }, + { + url: "data/jsonp.php/???json=1", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + strictEqual( jQuery.type( data ), "array", "JSON results returned (GET, REST-like with param)" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 9, { + setup: function() { + Globals.register("functionToCleanUp"); + Globals.register("XXX"); + Globals.register("jsonpResults"); + window["jsonpResults"] = function( data ) { + ok( data["data"], "JSON results returned (GET, custom callback function)" ); + }; + }, + requests: [{ + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + jsonp: "callback", + success: function( data ) { + ok( data["data"], "JSON results returned (GET, data obj callback)" ); + } + }, { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + jsonpCallback: "jsonpResults", + success: function( data ) { + ok( data.data, "JSON results returned (GET, custom callback name)" ); + } + }, { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + jsonpCallback: "functionToCleanUp", + success: function( data ) { + ok( data["data"], "JSON results returned (GET, custom callback name to be cleaned up)" ); + strictEqual( window["functionToCleanUp"], undefined, "Callback was removed (GET, custom callback name to be cleaned up)" ); + var xhr; + jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + jsonpCallback: "functionToCleanUp", + beforeSend: function( jqXHR ) { + xhr = jqXHR; + return false; + } + }); + xhr.fail(function() { + ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" ); + strictEqual( window["functionToCleanUp"], undefined, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" ); + }); + } + }, { + url: "data/jsonp.php?callback=XXX", + dataType: "jsonp", + jsonp: false, + jsonpCallback: "XXX", + crossDomain: crossDomain, + beforeSend: function() { + ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" ); + }, + success: function( data ) { + ok( data["data"], "JSON results returned (GET, custom callback name with no url manipulation)" ); + } + }] + }); + + ajaxTest( "jQuery.ajax() - JSONP - Callback in data" + label, 2, [ + { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + data: "callback=?", + success: function( data ) { + ok( data.data, "JSON results returned (GET, data callback)" ); + } + }, + { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + data: "callback=??", + success: function( data ) { + ok( data.data, "JSON results returned (GET, data context-free callback)" ); + } + } + ]); + + + ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [ + { + type: "POST", + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, no callback)" ); + } + }, + { + type: "POST", + url: "data/jsonp.php", + data: "callback=?", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, data callback)" ); + } + }, + { + type: "POST", + url: "data/jsonp.php", + jsonp: "callback", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data["data"], "JSON results returned (POST, data obj callback)" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - JSONP" + label, 3, [ + { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + success: function( data ) { + ok( data.data, "JSON results returned (GET, no callback)" ); + } + }, + { + create: function( options ) { + var request = jQuery.ajax( options ), + promise = request.then(function( data ) { + ok( data.data, "first request: JSON results returned (GET, no callback)" ); + request = jQuery.ajax( this ).done(function( data ) { + ok( data.data, "this re-used: JSON results returned (GET, no callback)" ); + }); + promise.abort = request.abort; + return request; + }); + promise.abort = request.abort; + return promise; + }, + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + success: true + } + ]); + + }); + + ajaxTest( "jQuery.ajax() - script, Remote", 2, { + setup: function() { + Globals.register("testBar"); + }, + url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js", + dataType: "script", + success: function() { + strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" ); + } + }); + + ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, { + setup: function() { + Globals.register("testBar"); + }, + url: window.location.href.replace( /[^\/]*$/, "" ) + "data/test.js", + type: "POST", + dataType: "script", + success: function( data, status ) { + strictEqual( window["testBar"], "bar", "Script results returned (POST, no callback)" ); + strictEqual( status, "success", "Script results returned (POST, no callback)" ); + } + }); + + ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, { + setup: function() { + Globals.register("testBar"); + }, + url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/test.js", + dataType: "script", + success: function() { + strictEqual( window["testBar"], "bar", "Script results returned (GET, no callback)" ); + } + }); + + ajaxTest( "jQuery.ajax() - malformed JSON", 2, { + url: "data/badjson.js", + dataType: "json", + error: function( xhr, msg, detailedMsg ) { + strictEqual( msg, "parsererror", "A parse error occurred." ); + ok( /(invalid|error|exception)/i.test( detailedMsg ), "Detailed parsererror message provided" ); + } + }); + + ajaxTest( "jQuery.ajax() - script by content-type", 2, [ + { + url: "data/script.php", + data: { + "header": "script" + }, + success: true + }, + { + url: "data/script.php", + data: { + "header": "ecma" + }, + success: true + } + ]); + + ajaxTest( "jQuery.ajax() - JSON by content-type", 5, { + url: "data/json.php", + data: { + "header": "json", + "json": "array" + }, + success: function( json ) { + ok( json.length >= 2, "Check length" ); + strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); + strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); + strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); + strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); + } + }); + + ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, { + url: url("data/json.php"), + data: { + "header": "json", + "json": "array" + }, + contents: { + "json": false + }, + success: function( text ) { + strictEqual( typeof text, "string", "json wasn't auto-determined" ); + var json = jQuery.parseJSON( text ); + ok( json.length >= 2, "Check length"); + strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); + strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); + strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); + strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); + } + }); + + ajaxTest( "jQuery.ajax() - simple get", 1, { + type: "GET", + url: url("data/name.php?name=foo"), + success: function( msg ) { + strictEqual( msg, "bar", "Check for GET" ); + } + }); + + ajaxTest( "jQuery.ajax() - simple post", 1, { + type: "POST", + url: url("data/name.php"), + data: "name=peter", + success: function( msg ) { + strictEqual( msg, "pan", "Check for POST" ); + } + }); + + ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, { + url: "data/echoData.php", + data: undefined, + type: "post", + success: function( result ) { + strictEqual( result, "" ); + } + }); + + var ifModifiedNow = new Date(); + + jQuery.each( + /* jQuery.each arguments start */ + { + " (cache)": true, + " (no cache)": false + }, + function( label, cache ) { + // Support: Opera 12.0 + // In Opera 12.0, XHR doesn't notify 304 back to the user properly + var opera = window.opera && window.opera.version(); + jQuery.each( + { + "If-Modified-Since": "if_modified_since.php", + "Etag": "etag.php" + }, + function( type, url ) { + url = "data/" + url + "?ts=" + ifModifiedNow++; + asyncTest( "jQuery.ajax() - " + type + " support" + label, 4, function() { + jQuery.ajax({ + url: url, + ifModified: true, + cache: cache, + success: function( _, status ) { + strictEqual( status, "success", "Initial status is 'success'" ); + jQuery.ajax({ + url: url, + ifModified: true, + cache: cache, + success: function( data, status, jqXHR ) { + if ( status === "success" && opera === "12.00" ) { + strictEqual( status, "success", "Opera 12.0: Following status is 'success'" ); + strictEqual( jqXHR.status, 200, "Opera 12.0: XHR status is 200, not 304" ); + strictEqual( data, "", "Opera 12.0: response body is empty" ); + } else { + strictEqual( status, "notmodified", "Following status is 'notmodified'" ); + strictEqual( jqXHR.status, 304, "XHR status is 304" ); + equal( data, null, "no response body is given" ); + } + }, + complete: function() { + start(); + } + }); + } + }); + }); + } + ); + } + /* jQuery.each arguments end */ + ); + + ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, { + // see RFC 2606 + url: "http://example.invalid", + error: function( xhr, _, e ) { + ok( true, "file not found: " + xhr.status + " => " + e ); + } + }); + + ajaxTest( "jQuery.ajax() - failing cross-domain", 1, { + url: "http://" + externalHost, + error: function( xhr, _, e ) { + ok( true, "access denied: " + xhr.status + " => " + e ); + } + }); + + ajaxTest( "jQuery.ajax() - atom+xml", 1, { + url: url("data/atom+xml.php"), + success: function() { + ok( true, "success" ); + } + }); + + asyncTest( "jQuery.ajax() - statusText", 3, function() { + jQuery.ajax( url("data/statusText.php?status=200&text=Hello") ).done(function( _, statusText, jqXHR ) { + strictEqual( statusText, "success", "callback status text ok for success" ); + ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); + jQuery.ajax( url("data/statusText.php?status=404&text=World") ).fail(function( jqXHR, statusText ) { + strictEqual( statusText, "error", "callback status text ok for error" ); + start(); + }); + }); + }); + + asyncTest( "jQuery.ajax() - statusCode", 20, function() { + + var count = 12; + + function countComplete() { + if ( ! --count ) { + start(); + } + } + + function createStatusCodes( name, isSuccess ) { + name = "Test " + name + " " + ( isSuccess ? "success" : "error" ); + return { + 200: function() { + ok( isSuccess, name ); + }, + 404: function() { + ok( !isSuccess, name ); + } + }; + } + + jQuery.each( + /* jQuery.each arguments start */ + { + "data/name.html": true, + "data/someFileThatDoesNotExist.html": false + }, + function( uri, isSuccess ) { + + jQuery.ajax( url(uri), { + statusCode: createStatusCodes( "in options", isSuccess ), + complete: countComplete + }); + + jQuery.ajax( url(uri), { + complete: countComplete + }).statusCode( createStatusCodes("immediately with method", isSuccess) ); + + jQuery.ajax( url(uri), { + complete: function( jqXHR ) { + jqXHR.statusCode( createStatusCodes("on complete", isSuccess) ); + countComplete(); + } + }); + + jQuery.ajax( url(uri), { + complete: function( jqXHR ) { + setTimeout(function() { + jqXHR.statusCode( createStatusCodes("very late binding", isSuccess) ); + countComplete(); + }, 100 ); + } + }); + + jQuery.ajax( url(uri), { + statusCode: createStatusCodes( "all (options)", isSuccess ), + complete: function( jqXHR ) { + jqXHR.statusCode( createStatusCodes("all (on complete)", isSuccess) ); + setTimeout(function() { + jqXHR.statusCode( createStatusCodes("all (very late binding)", isSuccess) ); + countComplete(); + }, 100 ); + } + }).statusCode( createStatusCodes("all (immediately with method)", isSuccess) ); + + var testString = ""; + + jQuery.ajax( url(uri), { + success: function( a, b, jqXHR ) { + ok( isSuccess, "success" ); + var statusCode = {}; + statusCode[ jqXHR.status ] = function() { + testString += "B"; + }; + jqXHR.statusCode( statusCode ); + testString += "A"; + }, + error: function( jqXHR ) { + ok( !isSuccess, "error" ); + var statusCode = {}; + statusCode[ jqXHR.status ] = function() { + testString += "B"; + }; + jqXHR.statusCode( statusCode ); + testString += "A"; + }, + complete: function() { + strictEqual( + testString, + "AB", + "Test statusCode callbacks are ordered like " + ( isSuccess ? "success" : "error" ) + " callbacks" + ); + countComplete(); + } + }); + + } + /* jQuery.each arguments end*/ + ); + }); + + ajaxTest( "jQuery.ajax() - transitive conversions", 8, [ + { + url: url("data/json.php"), + converters: { + "json myJson": function( data ) { + ok( true, "converter called" ); + return data; + } + }, + dataType: "myJson", + success: function() { + ok( true, "Transitive conversion worked" ); + strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text" ); + strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType" ); + } + }, + { + url: url("data/json.php"), + converters: { + "json myJson": function( data ) { + ok( true, "converter called (*)" ); + return data; + } + }, + contents: false, /* headers are wrong so we ignore them */ + dataType: "* myJson", + success: function() { + ok( true, "Transitive conversion worked (*)" ); + strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text (*)" ); + strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - overrideMimeType", 2, [ + { + url: url("data/json.php"), + beforeSend: function( xhr ) { + xhr.overrideMimeType( "application/json" ); + }, + success: function( json ) { + ok( json.data, "Mimetype overridden using beforeSend" ); + } + }, + { + url: url("data/json.php"), + mimeType: "application/json", + success: function( json ) { + ok( json.data, "Mimetype overridden using mimeType option" ); + } + } + ]); + + ajaxTest( "jQuery.ajax() - empty json gets to error callback instead of success callback.", 1, { + url: url("data/echoData.php"), + error: function( _, __, error ) { + equal( typeof error === "object", true, "Didn't get back error object for empty json response" ); + }, + dataType: "json" + }); + + ajaxTest( "#2688 - jQuery.ajax() - beforeSend, cancel request", 2, { + create: function() { + return jQuery.ajax({ + url: url("data/name.html"), + beforeSend: function() { + ok( true, "beforeSend got called, canceling" ); + return false; + }, + success: function() { + ok( false, "request didn't get canceled" ); + }, + complete: function() { + ok( false, "request didn't get canceled" ); + }, + error: function() { + ok( false, "request didn't get canceled" ); + } + }); + }, + fail: function( _, reason ) { + strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); + } + }); + + ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, { + url: "data/echoQuery.php", + data: { + key: function() { + return "value"; + } + }, + success: function( result ) { + strictEqual( result, "key=value" ); + } + }); + + test( "#7531 - jQuery.ajax() - Location object as url", 1, function () { + var xhr, + success = false; + try { + xhr = jQuery.ajax({ + url: window.location + }); + success = true; + xhr.abort(); + } catch (e) { + + } + ok( success, "document.location did not generate exception" ); + }); + + jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { + ajaxTest( "#7578 - jQuery.ajax() - JSONP - default for cache option" + label, 1, { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + beforeSend: function() { + strictEqual( this.cache, false, "cache must be false on JSON request" ); + return false; + }, + error: true + }); + }); + + ajaxTest( "#8107 - jQuery.ajax() - multiple method signatures introduced in 1.5", 4, [ + { + create: function() { + return jQuery.ajax(); + }, + done: function() { + ok( true, "With no arguments" ); + } + }, + { + create: function() { + return jQuery.ajax("data/name.html"); + }, + done: function() { + ok( true, "With only string URL argument" ); + } + }, + { + create: function() { + return jQuery.ajax( "data/name.html", {}); + }, + done: function() { + ok( true, "With string URL param and map" ); + } + }, + { + create: function( options ) { + return jQuery.ajax( options ); + }, + url: "data/name.html", + success: function() { + ok( true, "With only map" ); + } + } + ]); + + jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { + ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 2, { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + beforeSend: function( jqXHR, s ) { + s.callback = s.jsonpCallback; + }, + success: function() { + var previous = this; + strictEqual( previous.jsonpCallback, undefined, "jsonpCallback option is set back to default in callbacks" ); + jQuery.ajax({ + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + beforeSend: function() { + strictEqual( this.jsonpCallback, previous.callback, "JSONP callback name is re-used" ); + return false; + } + }); + } + }); + }); + + test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", 2, function () { + var success = false, + context = {}; + context.field = context; + try { + jQuery.ajax( "non-existing", { + context: context, + beforeSend: function() { + ok( this === context, "context was not deep extended" ); + return false; + } + }); + success = true; + } catch ( e ) { + console.log( e ); + } + ok( success, "context with circular reference did not generate an exception" ); + }); + + jQuery.each( [ "as argument", "in settings object" ], function( inSetting, title ) { + + function request( url, test ) { + return { + create: function() { + return jQuery.ajax( inSetting ? { url: url } : url ); + }, + done: function() { + ok( true, ( test || url ) + " " + title ); + } + }; + } + + ajaxTest( "#10093 - jQuery.ajax() - falsy url " + title, 4, [ + request( "", "empty string" ), + request( false ), + request( null ), + request( undefined ) + ]); + + }); + + ajaxTest( "#11151 - jQuery.ajax() - parse error body", 2, { + url: url("data/errorWithJSON.php"), + dataFilter: function( string ) { + ok( false, "dataFilter called" ); + return string; + }, + error: function( jqXHR ) { + strictEqual( jqXHR.responseText, "{ \"code\": 40, \"message\": \"Bad Request\" }", "Error body properly set" ); + deepEqual( jqXHR.responseJSON, { code: 40, message: "Bad Request" }, "Error body properly parsed" ); + } + }); + + ajaxTest( "#11426 - jQuery.ajax() - loading binary data shouldn't throw an exception in IE", 1, { + url: url("data/1x1.jpg"), + success: function( data ) { + ok( data === undefined || /JFIF/.test( data ), "success callback reached" ); + } + }); + + asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function() { + var onerror = window.onerror; + window.onerror = function() { + ok( true, "Exception thrown" ); + window.onerror = onerror; + start(); + }; + jQuery.ajax({ + url: "data/badjson.js", + dataType: "script", + throws: true, + // Global events get confused by the exception + global: false, + success: function() { + ok( false, "Success." ); + }, + error: function() { + ok( false, "Error." ); + } + }); + }); + + jQuery.each( [ "method", "type" ], function( _, globalOption ) { + + function request( option ) { + var options = { + url: url("data/echoData.php"), + data: "hello", + success: function( msg ) { + strictEqual( msg, "hello", "Check for POST (no override)" ); + } + }; + if ( option ) { + options[ option ] = "GET"; + options.success = function( msg ) { + strictEqual( msg, "", "Check for no POST (overriding with " + option + ")" ); + }; + } + return options; + } + + ajaxTest( "#12004 - jQuery.ajax() - method is an alias of type - " + globalOption + " set globally", 3, { + setup: function() { + var options = {}; + options[ globalOption ] = "POST"; + jQuery.ajaxSetup( options ); + }, + requests: [ + request("type"), + request("method"), + request() + ] + }); + + }); + + ajaxTest( "#13276 - jQuery.ajax() - compatibility between XML documents from ajax requests and parsed string", 1, { + url: "data/dashboard.xml", + dataType: "xml", + success: function( ajaxXML ) { + var parsedXML = jQuery( jQuery.parseXML("blibli") ).find("tab"); + ajaxXML = jQuery( ajaxXML ); + try { + ajaxXML.find("infowindowtab").append( parsedXML ); + } catch( e ) { + strictEqual( e, undefined, "error" ); + return; + } + strictEqual( ajaxXML.find("tab").length, 3, "Parsed node was added properly" ); + } + }); + + ajaxTest( "#13292 - jQuery.ajax() - converter is bypassed for 204 requests", 3, { + url: "data/nocontent.php", + dataType: "testing", + converters: { + "* testing": function() { + throw "converter was called"; + } + }, + success: function( data, status, jqXHR ) { + strictEqual( jqXHR.status, 204, "status code is 204" ); + strictEqual( status, "nocontent", "status text is 'nocontent'" ); + strictEqual( data, undefined, "data is undefined" ); + }, + error: function( _, status, error ) { + ok( false, "error" ); + strictEqual( status, "parsererror", "Parser Error" ); + strictEqual( error, "converter was called", "Converter was called" ); + } + }); + + ajaxTest( "#13388 - jQuery.ajax() - responseXML", 3, { + url: url("data/with_fries.xml"), + dataType: "xml", + success: function( resp, _, jqXHR ) { + notStrictEqual( resp, undefined, "XML document exists" ); + ok( "responseXML" in jqXHR, "jqXHR.responseXML exists" ); + strictEqual( resp, jqXHR.responseXML, "jqXHR.responseXML is set correctly" ); + } + }); + + ajaxTest( "#13922 - jQuery.ajax() - converter is bypassed for HEAD requests", 3, { + url: "data/json.php", + method: "HEAD", + data: { + header: "yes" + }, + converters: { + "text json": function() { + throw "converter was called"; + } + }, + success: function( data, status ) { + ok( true, "success" ); + strictEqual( status, "nocontent", "data is undefined" ); + strictEqual( data, undefined, "data is undefined" ); + }, + error: function( _, status, error ) { + ok( false, "error" ); + strictEqual( status, "parsererror", "Parser Error" ); + strictEqual( error, "converter was called", "Converter was called" ); + } + } ); + +//----------- jQuery.ajaxPrefilter() + + ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, { + setup: function() { + jQuery.ajaxPrefilter(function( options, _, jqXHR ) { + if ( options.abortInPrefilter ) { + jqXHR.abort(); + } + }); + }, + abortInPrefilter: true, + error: function() { + ok( false, "error callback called" ); + }, + fail: function( _, reason ) { + strictEqual( reason, "canceled", "Request aborted by the prefilter must fail with 'canceled' status text" ); + } + }); + +//----------- jQuery.ajaxSetup() + + asyncTest( "jQuery.ajaxSetup()", 1, function() { + jQuery.ajaxSetup({ + url: url("data/name.php?name=foo"), + success: function( msg ) { + strictEqual( msg, "bar", "Check for GET" ); + start(); + } + }); + jQuery.ajax(); + }); + + asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function() { + var passed = 0, + pass = function() { + ok( passed++ < 2, "Error callback executed" ); + if ( passed === 2 ) { + jQuery( document ).off("ajaxError.setupTest"); + start(); + } + }, + fail = function( a, b ) { + ok( false, "Check for timeout failed " + a + " " + b ); + start(); + }; + + jQuery( document ).on( "ajaxError.setupTest", pass ); + + jQuery.ajaxSetup({ + timeout: 1000 + }); + + jQuery.ajax({ + type: "GET", + url: url("data/name.php?wait=5"), + error: pass, + success: fail + }); + }); + + asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function() { + jQuery.ajaxSetup({ + timeout: 50 + }); + jQuery.ajax({ + type: "GET", + timeout: 15000, + url: url("data/name.php?wait=1"), + error: function() { + ok( false, "Check for local timeout failed" ); + start(); + }, + success: function() { + ok( true, "Check for local timeout" ); + start(); + } + }); + }); + +//----------- jQuery.domManip() + + test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", 1, function() { + jQuery.ajaxSetup({ + type: "POST" + }); + + jQuery( document ).on( "ajaxStart ajaxStop", function() { + ok( false, "Global event triggered" ); + }); + + jQuery("#qunit-fixture").append(""); + + jQuery( document ).off("ajaxStart ajaxStop"); + }); + + asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { + jQuery("#qunit-fixture").load( "data/cleanScript.html", start ); + }); + +//----------- jQuery.get() + + asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function() { + jQuery.get( url("data/dashboard.xml"), function( xml ) { + var content = []; + jQuery( "tab", xml ).each(function() { + content.push( jQuery( this ).text() ); + }); + strictEqual( content[ 0 ], "blabla", "Check first tab" ); + strictEqual( content[ 1 ], "blublu", "Check second tab" ); + start(); + }); + }); + + asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function() { + jQuery.ajaxSetup({ + data: "helloworld" + }); + jQuery.get( url("data/echoQuery.php"), function( data ) { + ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" ); + start(); + }); + }); + +//----------- jQuery.getJSON() + + asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function() { + jQuery.getJSON( + url("data/json.php"), + { + "json": "array" + }, + function( json ) { + ok( json.length >= 2, "Check length" ); + strictEqual( json[ 0 ]["name"], "John", "Check JSON: first, name" ); + strictEqual( json[ 0 ]["age"], 21, "Check JSON: first, age" ); + strictEqual( json[ 1 ]["name"], "Peter", "Check JSON: second, name" ); + strictEqual( json[ 1 ]["age"], 25, "Check JSON: second, age" ); + start(); + } + ); + }); + + asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function() { + jQuery.getJSON( url("data/json.php"), function( json ) { + if ( json && json["data"] ) { + strictEqual( json["data"]["lang"], "en", "Check JSON: lang" ); + strictEqual( json["data"].length, 25, "Check JSON: length" ); + start(); + } + }); + }); + + asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function() { + jQuery.getJSON( url( window.location.href.replace( /[^\/]*$/, "" ) + "data/json.php" ), function( json ) { + strictEqual( json.data.lang, "en", "Check JSON: lang" ); + strictEqual( json.data.length, 25, "Check JSON: length" ); + start(); + }); + }); + +//----------- jQuery.getScript() + + asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() { + Globals.register("testBar"); + jQuery.getScript( url("data/test.js"), function() { + strictEqual( window["testBar"], "bar", "Check if script was evaluated" ); + start(); + }); + }); + + asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() { + Globals.register("testBar"); + jQuery.getScript( url("data/test.js") ).done( start ); + }); + + asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() { + Globals.register("testBar"); + jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) { + strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" ); + start(); + }); + }); + +//----------- jQuery.fn.load() + + // check if load can be called with only url + asyncTest( "jQuery.fn.load( String )", 2, function() { + jQuery.ajaxSetup({ + beforeSend: function() { + strictEqual( this.type, "GET", "no data means GET request" ); + } + }); + jQuery("#first").load( "data/name.html", start ); + }); + + asyncTest( "jQuery.fn.load() - 404 error callbacks", 6, function() { + addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError")(); + jQuery( document ).ajaxStop( start ); + jQuery("
        ").load( "data/404.html", function() { + ok( true, "complete" ); + }); + }); + + // check if load can be called with url and null data + asyncTest( "jQuery.fn.load( String, null )", 2, function() { + jQuery.ajaxSetup({ + beforeSend: function() { + strictEqual( this.type, "GET", "no data means GET request" ); + } + }); + jQuery("#first").load( "data/name.html", null, start ); + }); + + // check if load can be called with url and undefined data + asyncTest( "jQuery.fn.load( String, undefined )", 2, function() { + jQuery.ajaxSetup({ + beforeSend: function() { + strictEqual( this.type, "GET", "no data means GET request" ); + } + }); + jQuery("#first").load( "data/name.html", undefined, start ); + }); + + // check if load can be called with only url + asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function() { + jQuery("#first").load( "data/test3.html div.user", function() { + strictEqual( jQuery( this ).children("div").length, 2, "Verify that specific elements were injected" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() { + jQuery("#first").load( url("data/name.html"), function() { + ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function() { + var verifyEvaluation = function() { + strictEqual( window["testBar"], "bar", "Check if script src was evaluated after load" ); + strictEqual( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM"); + start(); + }; + + Globals.register("testFoo"); + Globals.register("testBar"); + + jQuery("#first").load( url("data/test.html"), function() { + ok( jQuery("#first").html().match( /^html text/ ), "Check content after loading html" ); + strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM" ); + strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" ); + setTimeout( verifyEvaluation, 600 ); + }); + }); + + asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() { + Globals.register("testFoo"); + + jQuery("#first").load( url("data/test2.html"), function() { + strictEqual( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); + strictEqual( window["testFoo"], "foo", "Check if script was evaluated after load" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", 2, function() { + jQuery.ajaxSetup({ + dataFilter: function() { + return "Hello World"; + } + }); + jQuery("
        ").load( url("data/name.html"), function( responseText ) { + strictEqual( jQuery( this ).html(), "Hello World", "Test div was filled with filtered data" ); + strictEqual( responseText, "Hello World", "Test callback receives filtered data" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function() { + jQuery("
        ").load( url("data/params_html.php"), { + "foo": 3, + "bar": "ok" + }, function() { + var $post = jQuery( this ).find("#post"); + strictEqual( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly" ); + strictEqual( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load( String, String, Function )", 2, function() { + jQuery("
        ").load( url("data/params_html.php"), "foo=3&bar=ok", function() { + var $get = jQuery( this ).find("#get"); + strictEqual( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly" ); + strictEqual( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly" ); + start(); + }); + }); + + asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() { + var completeArgs = {}; + + jQuery.ajaxSetup({ + success: function( _, status, jqXHR ) { + completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ]; + }, + error: function( jqXHR, status ) { + completeArgs[ this.url ] = [ jqXHR.responseText, status, jqXHR ]; + } + }); + + jQuery.when.apply( + jQuery, + jQuery.map([ + { + type: "success", + url: "data/echoQuery.php?arg=pop" + }, + { + type: "error", + url: "data/404.php" + } + ], + function( options ) { + return jQuery.Deferred(function( defer ) { + jQuery("#foo").load( options.url, function() { + var args = arguments; + strictEqual( completeArgs[ options.url ].length, args.length, "same number of arguments (" + options.type + ")" ); + jQuery.each( completeArgs[ options.url ], function( i, value ) { + strictEqual( args[ i ], value, "argument #" + i + " is the same (" + options.type + ")" ); + }); + defer.resolve(); + }); + }); + }) + ).always( start ); + }); + + asyncTest( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", 1, function() { + jQuery.ajaxSetup({ + dataType: "json" + }); + jQuery( document ).ajaxComplete(function( e, xml, s ) { + strictEqual( s.dataType, "html", "Verify the load() dataType was html" ); + jQuery( document ).off("ajaxComplete"); + start(); + }); + jQuery("#first").load("data/test3.html"); + }); + + asyncTest( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { + var data = { + "baz": 1 + }; + jQuery.ajaxSetup({ + data: { + "foo": "bar" + } + }); + jQuery("#foo").load( "data/echoQuery.php", data ); + jQuery( document ).ajaxComplete(function( event, jqXHR, options ) { + ok( ~options.data.indexOf("foo=bar"), "Data from ajaxSettings was used" ); + start(); + }); + }); + +//----------- jQuery.post() + + asyncTest( "jQuery.post() - data", 3, function() { + jQuery.when( + jQuery.post( + url("data/name.php"), + { + xml: "5-2", + length: 3 + }, + function( xml ) { + jQuery( "math", xml ).each(function() { + strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + }); + } + ), + jQuery.ajax({ + url: url("data/echoData.php"), + type: "POST", + data: { + "test": { + "length": 7, + "foo": "bar" + } + }, + success: function( data ) { + strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" ); + } + }) + ).always( start ); + }); + + asyncTest( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function() { + jQuery.when( + jQuery.post( + url("data/name.php"), + { + "xml": "5-2" + }, + function( xml ) { + jQuery( "math", xml ).each(function() { + strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + }); + } + ), + jQuery.post( url("data/name.php?xml=5-2"), {}, function( xml ) { + jQuery( "math", xml ).each(function() { + strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + }); + }) + ).always( start ); + }); + +//----------- jQuery.active + + test( "jQuery.active", 1, function() { + ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active ); + }); + +})(); diff --git a/bower_components/jquery/test/unit/attributes.js b/bower_components/jquery/test/unit/attributes.js new file mode 100644 index 0000000..84ac8c2 --- /dev/null +++ b/bower_components/jquery/test/unit/attributes.js @@ -0,0 +1,1384 @@ +module( "attributes", { + teardown: moduleTeardown +}); + +function bareObj( value ) { + return value; +} + +function functionReturningObj( value ) { + return function() { + return value; + }; +} + +/* + ======== local reference ======= + bareObj and functionReturningObj can be used to test passing functions to setters + See testVal below for an example + + bareObj( value ); + This function returns whatever value is passed in + + functionReturningObj( value ); + Returns a function that returns the value +*/ + +test( "jQuery.propFix integrity test", function() { + expect( 1 ); + + // This must be maintained and equal jQuery.attrFix when appropriate + // Ensure that accidental or erroneous property + // overwrites don't occur + // This is simply for better code coverage and future proofing. + var props = { + "tabindex": "tabIndex", + "readonly": "readOnly", + "for": "htmlFor", + "class": "className", + "maxlength": "maxLength", + "cellspacing": "cellSpacing", + "cellpadding": "cellPadding", + "rowspan": "rowSpan", + "colspan": "colSpan", + "usemap": "useMap", + "frameborder": "frameBorder", + "contenteditable": "contentEditable" + }; + + deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); +}); + +test( "attr(String)", function() { + expect( 50 ); + + var extras, body, $body, + select, optgroup, option, $img, styleElem, + $button, $form, $a; + + equal( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); + equal( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); + equal( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" ); + equal( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" ); + equal( jQuery("#google").attr("title"), "Google!", "Check for title attribute" ); + equal( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" ); + equal( jQuery("#en").attr("lang"), "en", "Check for lang attribute" ); + equal( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" ); + equal( jQuery("#name").attr("name"), "name", "Check for name attribute" ); + equal( jQuery("#text1").attr("name"), "action", "Check for name attribute" ); + ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" ); + equal( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" ); + equal( jQuery("#text1").attr("value", "").attr("value"), "", "Check setting the value attribute to empty string" ); + equal( jQuery("
        ").attr("value"), "t", "Check setting custom attr named 'value' on a div" ); + equal( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existent attribute on a form" ); + equal( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" ); + + // [7472] & [3113] (form contains an input with name="action" or name="id") + extras = jQuery("").appendTo("#testForm"); + equal( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" ); + equal( jQuery("#testForm").attr("target"), undefined, "Retrieving target does not equal the input with name=target" ); + equal( jQuery("#testForm").attr("target", "newTarget").attr("target"), "newTarget", "Set target successfully on a form" ); + equal( jQuery("#testForm").removeAttr("id").attr("id"), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" ); + // Bug #3685 (form contains input with name="name") + equal( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" ); + extras.remove(); + + equal( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" ); + equal( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" ); + equal( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); + + // using innerHTML in IE causes href attribute to be serialized to the full path + jQuery("").attr({ + "id": "tAnchor5", + "href": "#5" + }).appendTo("#qunit-fixture"); + equal( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); + jQuery("").appendTo("#qunit-fixture"); + equal( jQuery("#tAnchor5").prop("href"), jQuery("#tAnchor6").prop("href"), "Check for absolute href prop on an anchor" ); + + $("").appendTo("#qunit-fixture"); + equal( jQuery("#tAnchor5").prop("href"), jQuery("#scriptSrc").prop("src"), "Check for absolute src prop on a script" ); + + // list attribute is readonly by default in browsers that support it + jQuery("#list-test").attr( "list", "datalist" ); + equal( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" ); + + // Related to [5574] and [5683] + body = document.body; + $body = jQuery( body ); + + strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" ); + + body.setAttribute( "foo", "baz" ); + equal( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); + + $body.attr( "foo","cool" ); + equal( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); + + body.removeAttribute("foo"); // Cleanup + + select = document.createElement("select"); + optgroup = document.createElement("optgroup"); + option = document.createElement("option"); + + optgroup.appendChild( option ); + select.appendChild( optgroup ); + + equal( jQuery( option ).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." ); + + $img = jQuery("").appendTo("body"); + equal( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." ); + equal( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." ); + + // Check for style support + styleElem = jQuery("
        ").appendTo("#qunit-fixture").css({ + background: "url(UPPERlower.gif)" + }); + ok( !!~styleElem.attr("style").indexOf("UPPERlower.gif"), "Check style attribute getter" ); + ok( !!~styleElem.attr("style", "position:absolute;").attr("style").indexOf("absolute"), "Check style setter" ); + + // Check value on button element (#1954) + $button = jQuery("").insertAfter("#button"); + strictEqual( $button.attr("value"), undefined, "Absence of value attribute on a button" ); + equal( $button.attr( "value", "foobar" ).attr("value"), "foobar", "Value attribute on a button does not return innerHTML" ); + equal( $button.attr("value", "baz").html(), "text", "Setting the value attribute does not change innerHTML" ); + + // Attributes with a colon on a table element (#1591) + equal( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." ); + equal( jQuery("#table").attr( "test:attrib", "foobar" ).attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." ); + + $form = jQuery("
        ").appendTo("#qunit-fixture"); + equal( $form.attr("class"), "something", "Retrieve the class attribute on a form." ); + + $a = jQuery("
        Click").appendTo("#qunit-fixture"); + equal( $a.attr("onclick"), "something()", "Retrieve ^on attribute without anonymous function wrapper." ); + + ok( jQuery("
        ").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); + ok( jQuery("
        ").attr("title") === undefined, "Make sure undefined is returned when no attribute is found." ); + equal( jQuery("
        ").attr( "title", "something" ).attr("title"), "something", "Set the title attribute." ); + ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); + equal( jQuery("
        ").attr("value"), undefined, "An unset value on a div returns undefined." ); + strictEqual( jQuery("").attr("value"), undefined, "An unset value on a select returns undefined." ); + + $form = jQuery("#form").attr( "enctype", "multipart/form-data" ); + equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); + +}); + +test( "attr(String) on cloned elements, #9646", function() { + expect( 4 ); + + var div, + input = jQuery(""); + + input.attr("name"); + + strictEqual( input.clone( true ).attr( "name", "test" )[ 0 ].name, "test", "Name attribute should be changed on cloned element" ); + + div = jQuery("
        "); + div.attr("id"); + + strictEqual( div.clone( true ).attr( "id", "test" )[ 0 ].id, "test", "Id attribute should be changed on cloned element" ); + + input = jQuery(""); + input.attr("value"); + + strictEqual( input.clone( true ).attr( "value", "test" )[ 0 ].value, "test", "Value attribute should be changed on cloned element" ); + + strictEqual( input.clone( true ).attr( "value", 42 )[ 0 ].value, "42", "Value attribute should be changed on cloned element" ); +}); + +test( "attr(String) in XML Files", function() { + expect( 3 ); + var xml = createDashboardXML(); + equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" ); + equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" ); + equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" ); +}); + +test( "attr(String, Function)", function() { + expect( 2 ); + + equal( + jQuery("#text1").attr( "value", function() { + return this.id; + }).attr("value"), + "text1", + "Set value from id" + ); + + equal( + jQuery("#text1").attr( "title", function(i) { + return i; + }).attr("title"), + "0", + "Set value with an index" + ); +}); + +test( "attr(Hash)", function() { + expect( 3 ); + var pass = true; + jQuery("div").attr({ + "foo": "baz", + "zoo": "ping" + }).each(function() { + if ( this.getAttribute("foo") !== "baz" && this.getAttribute("zoo") !== "ping" ) { + pass = false; + } + }); + + ok( pass, "Set Multiple Attributes" ); + + equal( + jQuery("#text1").attr({ + "value": function() { + return this["id"]; + }}).attr("value"), + "text1", + "Set attribute to computed value #1" + ); + + equal( + jQuery("#text1").attr({ + "title": function(i) { + return i; + } + }).attr("title"), + "0", + "Set attribute to computed value #2" + ); +}); + +test( "attr(String, Object)", function() { + expect( 71 ); + + var $input, $text, $details, + attributeNode, commentNode, textNode, obj, + table, td, j, type, + check, thrown, button, $radio, $radios, $svg, + div = jQuery("div").attr("foo", "bar"), + i = 0, + fail = false; + + for ( ; i < div.length; i++ ) { + if ( div[ i ].getAttribute("foo") !== "bar" ) { + fail = i; + break; + } + } + + equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); + + ok( + jQuery("#foo").attr({ + "width": null + }), + "Try to set an attribute to nothing" + ); + + jQuery("#name").attr( "name", "something" ); + equal( jQuery("#name").attr("name"), "something", "Set name attribute" ); + jQuery("#name").attr( "name", null ); + equal( jQuery("#name").attr("name"), undefined, "Remove name attribute" ); + + $input = jQuery( "", { + name: "something", + id: "specified" + }); + equal( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." ); + equal( $input.attr("id"), "specified", "Check element creation gets/sets the id attribute." ); + + // As of fixing #11115, we only guarantee boolean property update for checked and selected + $input = jQuery("").attr( "checked", true ); + equal( $input.prop("checked"), true, "Setting checked updates property (verified by .prop)" ); + equal( $input[0].checked, true, "Setting checked updates property (verified by native property)" ); + $input = jQuery(""); + $select1.val( valueObj( 4 ) ); + equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" ); + + // using contents will get comments regular, text, and comment nodes + j = jQuery("#nonnodes").contents(); + j.val( valueObj( "asdf" ) ); + equal( j.val(), "asdf", "Check node,textnode,comment with val()" ); + j.removeAttr("value"); +}; + +test( "val(String/Number)", function() { + testVal( bareObj ); +}); + +test( "val(Function)", function() { + testVal( functionReturningObj ); +}); + +test( "val(Array of Numbers) (Bug #7123)", function() { + expect( 4 ); + jQuery("#form").append(""); + var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]); + ok( elements[ 0 ].checked, "First element was checked" ); + ok( elements[ 1 ].checked, "Second element was checked" ); + ok( !elements[ 2 ].checked, "Third element was unchecked" ); + ok( !elements[ 3 ].checked, "Fourth element remained unchecked" ); + + elements.remove(); +}); + +test( "val(Function) with incoming value", function() { + expect( 10 ); + + QUnit.reset(); + var oldVal = jQuery("#text1").val(); + + jQuery("#text1").val(function( i, val ) { + equal( val, oldVal, "Make sure the incoming value is correct." ); + return "test"; + }); + + equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" ); + + oldVal = jQuery("#text1").val(); + + jQuery("#text1").val(function( i, val ) { + equal( val, oldVal, "Make sure the incoming value is correct." ); + return 67; + }); + + equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" ); + + oldVal = jQuery("#select1").val(); + + jQuery("#select1").val(function( i, val ) { + equal( val, oldVal, "Make sure the incoming value is correct." ); + return "3"; + }); + + equal( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" ); + + oldVal = jQuery("#select1").val(); + + jQuery("#select1").val(function( i, val ) { + equal( val, oldVal, "Make sure the incoming value is correct." ); + return 2; + }); + + equal( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" ); + + jQuery("#select1").append(""); + + oldVal = jQuery("#select1").val(); + + jQuery("#select1").val(function( i, val ) { + equal( val, oldVal, "Make sure the incoming value is correct." ); + return 4; + }); + + equal( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" ); +}); + +// testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only) +test( "val(select) after form.reset() (Bug #2551)", function() { + expect( 3 ); + + jQuery("
        ").appendTo("#qunit-fixture"); + + jQuery("#kkk").val("gf"); + + document["kk"].reset(); + + equal( jQuery("#kkk")[ 0 ].value, "cf", "Check value of select after form reset." ); + equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." ); + + // re-verify the multi-select is not broken (after form.reset) by our fix for single-select + deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple='multiple' select" ); + + jQuery("#kk").remove(); +}); + +var testAddClass = function( valueObj ) { + expect( 9 ); + + var pass, j, i, + div = jQuery("#qunit-fixture div"); + div.addClass( valueObj("test") ); + pass = true; + for ( i = 0; i < div.length; i++ ) { + if ( !~div.get( i ).className.indexOf("test") ) { + pass = false; + } + } + ok( pass, "Add Class" ); + + // using contents will get regular, text, and comment nodes + j = jQuery("#nonnodes").contents(); + j.addClass( valueObj("asdf") ); + ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" ); + + div = jQuery("
        "); + + div.addClass( valueObj("test") ); + equal( div.attr("class"), "test", "Make sure there's no extra whitespace." ); + + div.attr( "class", " foo" ); + div.addClass( valueObj("test") ); + equal( div.attr("class"), "foo test", "Make sure there's no extra whitespace." ); + + div.attr( "class", "foo" ); + div.addClass( valueObj("bar baz") ); + equal( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." ); + + div.removeClass(); + div.addClass( valueObj("foo") ).addClass( valueObj("foo") ); + equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." ); + + div.addClass( valueObj("fo") ); + equal( div.attr("class"), "foo fo", "Adding a similar class does not get interrupted." ); + div.removeClass().addClass("wrap2"); + ok( div.addClass("wrap").hasClass("wrap"), "Can add similarly named classes"); + + div.removeClass(); + div.addClass( valueObj("bar bar") ); + equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." ); +}; + +test( "addClass(String)", function() { + testAddClass( bareObj ); +}); + +test( "addClass(Function)", function() { + testAddClass( functionReturningObj ); +}); + +test( "addClass(Function) with incoming value", function() { + expect( 52 ); + var pass, i, + div = jQuery("#qunit-fixture div"), + old = div.map(function() { + return jQuery(this).attr("class") || ""; + }); + + div.addClass(function( i, val ) { + if ( this.id !== "_firebugConsole" ) { + equal( val, old[ i ], "Make sure the incoming value is correct." ); + return "test"; + } + }); + + pass = true; + for ( i = 0; i < div.length; i++ ) { + if ( div.get(i).className.indexOf("test") === -1 ) { + pass = false; + } + } + ok( pass, "Add Class" ); +}); + +var testRemoveClass = function(valueObj) { + expect( 8 ); + + var $set = jQuery("#qunit-fixture div"), + div = document.createElement("div"); + + $set.addClass("test").removeClass( valueObj("test") ); + + ok( !$set.is(".test"), "Remove Class" ); + + $set.addClass("test").addClass("foo").addClass("bar"); + $set.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") ); + + ok( !$set.is(".test,.bar,.foo"), "Remove multiple classes" ); + + // Make sure that a null value doesn't cause problems + $set.eq( 0 ).addClass("expected").removeClass( valueObj( null ) ); + ok( $set.eq( 0 ).is(".expected"), "Null value passed to removeClass" ); + + $set.eq( 0 ).addClass("expected").removeClass( valueObj("") ); + ok( $set.eq( 0 ).is(".expected"), "Empty string passed to removeClass" ); + + // using contents will get regular, text, and comment nodes + $set = jQuery("#nonnodes").contents(); + $set.removeClass( valueObj("asdf") ); + ok( !$set.hasClass("asdf"), "Check node,textnode,comment for removeClass" ); + + + jQuery( div ).removeClass( valueObj("foo") ); + strictEqual( jQuery( div ).attr("class"), undefined, "removeClass doesn't create a class attribute" ); + + div.className = " test foo "; + + jQuery( div ).removeClass( valueObj("foo") ); + equal( div.className, "test", "Make sure remaining className is trimmed." ); + + div.className = " test "; + + jQuery( div ).removeClass( valueObj("test") ); + equal( div.className, "", "Make sure there is nothing left after everything is removed." ); +}; + +test( "removeClass(String) - simple", function() { + testRemoveClass( bareObj ); +}); + +test( "removeClass(Function) - simple", function() { + testRemoveClass( functionReturningObj ); +}); + +test( "removeClass(Function) with incoming value", function() { + expect( 52 ); + + var $divs = jQuery("#qunit-fixture div").addClass("test"), old = $divs.map(function() { + return jQuery( this ).attr("class"); + }); + + $divs.removeClass(function( i, val ) { + if ( this.id !== "_firebugConsole" ) { + equal( val, old[ i ], "Make sure the incoming value is correct." ); + return "test"; + } + }); + + ok( !$divs.is(".test"), "Remove Class" ); +}); + +test( "removeClass() removes duplicates", function() { + expect( 1 ); + + var $div = jQuery( jQuery.parseHTML("
        ") ); + + $div.removeClass("x"); + + ok( !$div.hasClass("x"), "Element with multiple same classes does not escape the wrath of removeClass()" ); +}); + +test("removeClass(undefined) is a no-op", function() { + expect( 1 ); + + var $div = jQuery("
        "); + $div.removeClass( undefined ); + + ok( $div.hasClass("base") && $div.hasClass("second"), "Element still has classes after removeClass(undefined)" ); +}); + +var testToggleClass = function(valueObj) { + expect( 17 ); + + var e = jQuery("#firstp"); + ok( !e.is(".test"), "Assert class not present" ); + e.toggleClass( valueObj("test") ); + ok( e.is(".test"), "Assert class present" ); + e.toggleClass( valueObj("test") ); + ok( !e.is(".test"), "Assert class not present" ); + + // class name with a boolean + e.toggleClass( valueObj("test"), false ); + ok( !e.is(".test"), "Assert class not present" ); + e.toggleClass( valueObj("test"), true ); + ok( e.is(".test"), "Assert class present" ); + e.toggleClass( valueObj("test"), false ); + ok( !e.is(".test"), "Assert class not present" ); + + // multiple class names + e.addClass("testA testB"); + ok( e.is(".testA.testB"), "Assert 2 different classes present" ); + e.toggleClass( valueObj("testB testC") ); + ok( (e.is(".testA.testC") && !e.is(".testB")), "Assert 1 class added, 1 class removed, and 1 class kept" ); + e.toggleClass( valueObj("testA testC") ); + ok( (!e.is(".testA") && !e.is(".testB") && !e.is(".testC")), "Assert no class present" ); + + // toggleClass storage + e.toggleClass( true ); + ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" ); + e.addClass("testD testE"); + ok( e.is(".testD.testE"), "Assert class present" ); + e.toggleClass(); + ok( !e.is(".testD.testE"), "Assert class not present" ); + ok( jQuery._data(e[ 0 ], "__className__") === "testD testE", "Assert data was stored" ); + e.toggleClass(); + ok( e.is(".testD.testE"), "Assert class present (restored from data)" ); + e.toggleClass( false ); + ok( !e.is(".testD.testE"), "Assert class not present" ); + e.toggleClass( true ); + ok( e.is(".testD.testE"), "Assert class present (restored from data)" ); + e.toggleClass(); + e.toggleClass( false ); + e.toggleClass(); + ok( e.is(".testD.testE"), "Assert class present (restored from data)" ); + + // Cleanup + e.removeClass("testD"); + QUnit.expectJqData( e[ 0 ], "__className__" ); +}; + +test( "toggleClass(String|boolean|undefined[, boolean])", function() { + testToggleClass( bareObj ); +}); + +test( "toggleClass(Function[, boolean])", function() { + testToggleClass( functionReturningObj ); +}); + +test( "toggleClass(Function[, boolean]) with incoming value", function() { + expect( 14 ); + + var e = jQuery("#firstp"), + old = e.attr("class") || ""; + + ok( !e.is(".test"), "Assert class not present" ); + + e.toggleClass(function( i, val ) { + equal( old, val, "Make sure the incoming value is correct." ); + return "test"; + }); + ok( e.is(".test"), "Assert class present" ); + + old = e.attr("class"); + + e.toggleClass(function( i, val ) { + equal( old, val, "Make sure the incoming value is correct." ); + return "test"; + }); + ok( !e.is(".test"), "Assert class not present" ); + + old = e.attr("class") || ""; + + // class name with a boolean + e.toggleClass(function( i, val, state ) { + equal( old, val, "Make sure the incoming value is correct." ); + equal( state, false, "Make sure that the state is passed in." ); + return "test"; + }, false ); + ok( !e.is(".test"), "Assert class not present" ); + + old = e.attr("class") || ""; + + e.toggleClass(function( i, val, state ) { + equal( old, val, "Make sure the incoming value is correct." ); + equal( state, true, "Make sure that the state is passed in." ); + return "test"; + }, true ); + ok( e.is(".test"), "Assert class present" ); + + old = e.attr("class"); + + e.toggleClass(function( i, val, state ) { + equal( old, val, "Make sure the incoming value is correct." ); + equal( state, false, "Make sure that the state is passed in." ); + return "test"; + }, false ); + ok( !e.is(".test"), "Assert class not present" ); +}); + +test( "addClass, removeClass, hasClass", function() { + expect( 17 ); + + var jq = jQuery("

        Hi

        "), x = jq[ 0 ]; + + jq.addClass("hi"); + equal( x.className, "hi", "Check single added class" ); + + jq.addClass("foo bar"); + equal( x.className, "hi foo bar", "Check more added classes" ); + + jq.removeClass(); + equal( x.className, "", "Remove all classes" ); + + jq.addClass("hi foo bar"); + jq.removeClass("foo"); + equal( x.className, "hi bar", "Check removal of one class" ); + + ok( jq.hasClass("hi"), "Check has1" ); + ok( jq.hasClass("bar"), "Check has2" ); + + jq = jQuery("

        "); + + ok( jq.hasClass("class1"), "Check hasClass with line feed" ); + ok( jq.is(".class1"), "Check is with line feed" ); + ok( jq.hasClass("class2"), "Check hasClass with tab" ); + ok( jq.is(".class2"), "Check is with tab" ); + ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" ); + ok( jq.hasClass("class4"), "Check hasClass with carriage return" ); + ok( jq.is(".class4"), "Check is with carriage return" ); + + jq.removeClass("class2"); + ok( jq.hasClass("class2") === false, "Check the class has been properly removed" ); + jq.removeClass("cla"); + ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" ); + jq.removeClass("cla.ss3"); + ok( jq.hasClass("cla.ss3") === false, "Check the dotted class has been removed" ); + jq.removeClass("class4"); + ok( jq.hasClass("class4") === false, "Check the class has been properly removed" ); +}); + +test( "contents().hasClass() returns correct values", function() { + expect( 2 ); + + var $div = jQuery("
        text
        "), + $contents = $div.contents(); + + ok( $contents.hasClass("foo"), "Found 'foo' in $contents" ); + ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" ); +}); + +test( "hasClass correctly interprets non-space separators (#13835)", function() { + expect( 4 ); + + var + map = { + tab: " ", + "line-feed": " ", + "form-feed": " ", + "carriage-return": " " + }, + classes = jQuery.map( map, function( separator, label ) { + return " " + separator + label + separator + " "; + }), + $div = jQuery( "
        " ); + + jQuery.each( map, function( label ) { + ok( $div.hasClass( label ), label.replace( "-", " " ) ); + }); +}); + +test( "coords returns correct values in IE6/IE7, see #10828", function() { + expect( 1 ); + + var area, + map = jQuery(""); + + area = map.html("a").find("area"); + equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" ); +}); diff --git a/bower_components/jquery/test/unit/callbacks.js b/bower_components/jquery/test/unit/callbacks.js new file mode 100644 index 0000000..843c958 --- /dev/null +++ b/bower_components/jquery/test/unit/callbacks.js @@ -0,0 +1,342 @@ +module( "callbacks", { + teardown: moduleTeardown +}); + +(function() { + +var output, + addToOutput = function( string ) { + return function() { + output += string; + }; + }, + outputA = addToOutput("A"), + outputB = addToOutput("B"), + outputC = addToOutput("C"), + tests = { + "": "XABC X XABCABCC X XBB X XABA X XX", + "once": "XABC X X X X X XABA X XX", + "memory": "XABC XABC XABCABCCC XA XBB XB XABA XC XX", + "unique": "XABC X XABCA X XBB X XAB X X", + "stopOnFalse": "XABC X XABCABCC X XBB X XA X XX", + "once memory": "XABC XABC X XA X XA XABA XC XX", + "once unique": "XABC X X X X X XAB X X", + "once stopOnFalse": "XABC X X X X X XA X XX", + "memory unique": "XABC XA XABCA XA XBB XB XAB XC X", + "memory stopOnFalse": "XABC XABC XABCABCCC XA XBB XB XA X XX", + "unique stopOnFalse": "XABC X XABCA X XBB X XA X X" + }, + filters = { + "no filter": undefined, + "filter": function( fn ) { + return function() { + return fn.apply( this, arguments ); + }; + } + }; + + function showFlags( flags ) { + if ( typeof flags === "string" ) { + return "'" + flags + "'"; + } + var output = [], key; + for ( key in flags ) { + output.push( "'" + key + "': " + flags[ key ] ); + } + return "{ " + output.join( ", " ) + " }"; + } + +jQuery.each( tests, function( strFlags, resultString ) { + + var objectFlags = {}; + + jQuery.each( strFlags.split( " " ), function() { + if ( this.length ) { + objectFlags[ this ] = true; + } + }); + + jQuery.each( filters, function( filterLabel ) { + + jQuery.each({ + "string": strFlags, + "object": objectFlags + }, function( flagsTypes, flags ) { + + test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() { + + expect( 21 ); + + // Give qunit a little breathing room + stop(); + setTimeout( start, 0 ); + + var cblist, + results = resultString.split( /\s+/ ); + + // Basic binding and firing + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add(function( str ) { + output += str; + }); + cblist.fire("A"); + strictEqual( output, "XA", "Basic binding and firing" ); + strictEqual( cblist.fired(), true, ".fired() detects firing" ); + output = "X"; + cblist.disable(); + cblist.add(function( str ) { + output += str; + }); + strictEqual( output, "X", "Adding a callback after disabling" ); + cblist.fire("A"); + strictEqual( output, "X", "Firing after disabling" ); + + // #13517 - Emptying while firing + cblist = jQuery.Callbacks( flags ); + cblist.add( cblist.empty ); + cblist.add( function() { + ok( false, "not emptied" ); + } ); + cblist.fire(); + + // Disabling while firing + cblist = jQuery.Callbacks( flags ); + cblist.add( cblist.disable ); + cblist.add( function() { + ok( false, "not disabled" ); + } ); + cblist.fire(); + + // Basic binding and firing (context, arguments) + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add(function() { + equal( this, window, "Basic binding and firing (context)" ); + output += Array.prototype.join.call( arguments, "" ); + }); + cblist.fireWith( window, [ "A", "B" ] ); + strictEqual( output, "XAB", "Basic binding and firing (arguments)" ); + + // fireWith with no arguments + output = ""; + cblist = jQuery.Callbacks( flags ); + cblist.add(function() { + equal( this, window, "fireWith with no arguments (context is window)" ); + strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" ); + }); + cblist.fireWith(); + + // Basic binding, removing and firing + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add( outputA, outputB, outputC ); + cblist.remove( outputB, outputC ); + cblist.fire(); + strictEqual( output, "XA", "Basic binding, removing and firing" ); + + // Empty + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add( outputA ); + cblist.add( outputB ); + cblist.add( outputC ); + cblist.empty(); + cblist.fire(); + strictEqual( output, "X", "Empty" ); + + // Locking + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add(function( str ) { + output += str; + }); + cblist.lock(); + cblist.add(function( str ) { + output += str; + }); + cblist.fire("A"); + cblist.add(function( str ) { + output += str; + }); + strictEqual( output, "X", "Lock early" ); + + // Ordering + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add(function() { + cblist.add( outputC ); + outputA(); + }, outputB ); + cblist.fire(); + strictEqual( output, results.shift(), "Proper ordering" ); + + // Add and fire again + output = "X"; + cblist.add(function() { + cblist.add( outputC ); + outputA(); + }, outputB ); + strictEqual( output, results.shift(), "Add after fire" ); + + output = "X"; + cblist.fire(); + strictEqual( output, results.shift(), "Fire again" ); + + // Multiple fire + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add(function( str ) { + output += str; + }); + cblist.fire("A"); + strictEqual( output, "XA", "Multiple fire (first fire)" ); + output = "X"; + cblist.add(function( str ) { + output += str; + }); + strictEqual( output, results.shift(), "Multiple fire (first new callback)" ); + output = "X"; + cblist.fire("B"); + strictEqual( output, results.shift(), "Multiple fire (second fire)" ); + output = "X"; + cblist.add(function( str ) { + output += str; + }); + strictEqual( output, results.shift(), "Multiple fire (second new callback)" ); + + // Return false + output = "X"; + cblist = jQuery.Callbacks( flags ); + cblist.add( outputA, function() { return false; }, outputB ); + cblist.add( outputA ); + cblist.fire(); + strictEqual( output, results.shift(), "Callback returning false" ); + + // Add another callback (to control lists with memory do not fire anymore) + output = "X"; + cblist.add( outputC ); + strictEqual( output, results.shift(), "Adding a callback after one returned false" ); + + // Callbacks are not iterated + output = ""; + function handler() { + output += "X"; + } + handler.method = function() { + output += "!"; + }; + cblist = jQuery.Callbacks( flags ); + cblist.add( handler ); + cblist.add( handler ); + cblist.fire(); + strictEqual( output, results.shift(), "No callback iteration" ); + }); + }); + }); +}); + +})(); + +test( "jQuery.Callbacks( options ) - options are copied", function() { + + expect( 1 ); + + var options = { + "unique": true + }, + cb = jQuery.Callbacks( options ), + count = 0, + fn = function() { + ok( !( count++ ), "called once" ); + }; + options["unique"] = false; + cb.add( fn, fn ); + cb.fire(); +}); + +test( "jQuery.Callbacks.fireWith - arguments are copied", function() { + + expect( 1 ); + + var cb = jQuery.Callbacks("memory"), + args = ["hello"]; + + cb.fireWith( null, args ); + args[ 0 ] = "world"; + + cb.add(function( hello ) { + strictEqual( hello, "hello", "arguments are copied internally" ); + }); +}); + +test( "jQuery.Callbacks.remove - should remove all instances", function() { + + expect( 1 ); + + var cb = jQuery.Callbacks(); + + function fn() { + ok( false, "function wasn't removed" ); + } + + cb.add( fn, fn, function() { + ok( true, "end of test" ); + }).remove( fn ).fire(); +}); + +test( "jQuery.Callbacks.has", function() { + + expect( 13 ); + + var cb = jQuery.Callbacks(); + function getA() { + return "A"; + } + function getB() { + return "B"; + } + function getC() { + return "C"; + } + cb.add(getA, getB, getC); + strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" ); + strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" ); + + cb.remove(getB); + strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" ); + strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" ); + + cb.empty(); + strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" ); + strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" ); + + cb.add(getA, getB, function(){ + strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" ); + strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" ); + }).fire(); + + strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" ); + + cb.disable(); + strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" ); + strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" ); + + cb = jQuery.Callbacks("unique"); + cb.add(getA); + cb.add(getA); + strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" ); + cb.lock(); + strictEqual( cb.has(), false, "locked() list is empty and returns false" ); + + +}); + +test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function() { + + expect( 1 ); + + jQuery.Callbacks().add( "hello world" ); + + ok( true, "no stack overflow" ); +}); diff --git a/bower_components/jquery/test/unit/core.js b/bower_components/jquery/test/unit/core.js new file mode 100644 index 0000000..5fba3cf --- /dev/null +++ b/bower_components/jquery/test/unit/core.js @@ -0,0 +1,1387 @@ +module("core", { teardown: moduleTeardown }); + +test("Unit Testing Environment", function () { + expect(2); + ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" ); + ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" ); +}); + +test("Basic requirements", function() { + expect(7); + ok( Array.prototype.push, "Array.push()" ); + ok( Function.prototype.apply, "Function.apply()" ); + ok( document.getElementById, "getElementById" ); + ok( document.getElementsByTagName, "getElementsByTagName" ); + ok( RegExp, "RegExp" ); + ok( jQuery, "jQuery" ); + ok( $, "$" ); +}); + +testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/cc_on.html", function( cc_on, errors, $ ) { + expect( 3 ); + ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) ); + deepEqual( errors, [], "No errors" ); + ok( $(), "jQuery executes" ); +}); + +testIframeWithCallback( "document ready when jQuery loaded asynchronously (#13655)", "core/dynamic_ready.html", function( ready ) { + expect( 1 ); + equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" ); +}); + +test("jQuery()", function() { + + var elem, i, + obj = jQuery("div"), + code = jQuery(""), + img = jQuery(""), + div = jQuery("

        "), + exec = false, + lng = "", + expected = 22, + attrObj = { + "text": "test", + "class": "test2", + "id": "test3" + }; + + // The $(html, props) signature can stealth-call any $.fn method, check for a + // few here but beware of modular builds where these methods may be excluded. + if ( jQuery.fn.click ) { + expected++; + attrObj["click"] = function() { ok( exec, "Click executed." ); }; + } + if ( jQuery.fn.width ) { + expected++; + attrObj["width"] = 10; + } + if ( jQuery.fn.offset ) { + expected++; + attrObj["offset"] = { "top": 1, "left": 1 }; + } + if ( jQuery.fn.css ) { + expected += 2; + attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 }; + } + if ( jQuery.fn.attr ) { + expected++; + attrObj.attr = { "desired": "very" }; + } + + expect( expected ); + + // Basic constructor's behavior + equal( jQuery().length, 0, "jQuery() === jQuery([])" ); + equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" ); + equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" ); + equal( jQuery("").length, 0, "jQuery('') === jQuery([])" ); + equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" ); + + equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" ); + + // can actually yield more than one, when iframes are included, the window is an array as well + equal( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" ); + +/* + // disabled since this test was doing nothing. i tried to fix it but i'm not sure + // what the expected behavior should even be. FF returns "\n" for the text node + // make sure this is handled + var crlfContainer = jQuery('

        \r\n

        '); + var x = crlfContainer.contents().get(0).nodeValue; + equal( x, what???, "Check for \\r and \\n in jQuery()" ); +*/ + + /* // Disabled until we add this functionality in + var pass = true; + try { + jQuery("
        Testing
        ").appendTo(document.getElementById("iframe").contentDocument.body); + } catch(e){ + pass = false; + } + ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/ + + equal( code.length, 1, "Correct number of elements generated for code" ); + equal( code.parent().length, 0, "Make sure that the generated HTML has no parent." ); + + equal( img.length, 1, "Correct number of elements generated for img" ); + equal( img.parent().length, 0, "Make sure that the generated HTML has no parent." ); + + equal( div.length, 4, "Correct number of elements generated for div hr code b" ); + equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); + + equal( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" ); + + equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" ); + + elem = jQuery(" hello")[0]; + equal( elem.nodeName.toLowerCase(), "em", "leading space" ); + + elem = jQuery("\n\nworld")[0]; + equal( elem.nodeName.toLowerCase(), "em", "leading newlines" ); + + elem = jQuery("
        ", attrObj ); + + if ( jQuery.fn.width ) { + equal( elem[0].style.width, "10px", "jQuery() quick setter width"); + } + + if ( jQuery.fn.offset ) { + equal( elem[0].style.top, "1px", "jQuery() quick setter offset"); + } + + if ( jQuery.fn.css ) { + equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); + equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); + } + + if ( jQuery.fn.attr ) { + equal( elem[0].getAttribute("desired"), "very", "jQuery quick setter attr"); + } + + equal( elem[0].childNodes.length, 1, "jQuery quick setter text"); + equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text"); + equal( elem[0].className, "test2", "jQuery() quick setter class"); + equal( elem[0].id, "test3", "jQuery() quick setter id"); + + exec = true; + elem.trigger("click"); + + // manually clean up detached elements + elem.remove(); + + for ( i = 0; i < 3; ++i ) { + elem = jQuery(""); + } + equal( elem[0].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" ); + + // manually clean up detached elements + elem.remove(); + + for ( i = 0; i < 128; i++ ) { + lng += "12345678"; + } +}); + +test("jQuery(selector, context)", function() { + expect(3); + deepEqual( jQuery("div p", "#qunit-fixture").get(), q("sndp", "en", "sap"), "Basic selector with string as context" ); + deepEqual( jQuery("div p", q("qunit-fixture")[0]).get(), q("sndp", "en", "sap"), "Basic selector with element as context" ); + deepEqual( jQuery("div p", jQuery("#qunit-fixture")).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); +}); + +test( "selector state", function() { + expect( 18 ); + + var test; + + test = jQuery( undefined ); + equal( test.selector, "", "Empty jQuery Selector" ); + equal( test.context, undefined, "Empty jQuery Context" ); + + test = jQuery( document ); + equal( test.selector, "", "Document Selector" ); + equal( test.context, document, "Document Context" ); + + test = jQuery( document.body ); + equal( test.selector, "", "Body Selector" ); + equal( test.context, document.body, "Body Context" ); + + test = jQuery("#qunit-fixture"); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document, "#qunit-fixture Context" ); + + test = jQuery("#notfoundnono"); + equal( test.selector, "#notfoundnono", "#notfoundnono Selector" ); + equal( test.context, document, "#notfoundnono Context" ); + + test = jQuery( "#qunit-fixture", document ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document, "#qunit-fixture Context" ); + + test = jQuery( "#qunit-fixture", document.body ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document.body, "#qunit-fixture Context" ); + + // Test cloning + test = jQuery( test ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document.body, "#qunit-fixture Context" ); + + test = jQuery( document.body ).find("#qunit-fixture"); + equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" ); + equal( test.context, document.body, "#qunit-fixture find Context" ); +}); + +test( "globalEval", function() { + expect( 3 ); + Globals.register("globalEvalTest"); + + jQuery.globalEval("globalEvalTest = 1;"); + equal( window.globalEvalTest, 1, "Test variable assignments are global" ); + + jQuery.globalEval("var globalEvalTest = 2;"); + equal( window.globalEvalTest, 2, "Test variable declarations are global" ); + + jQuery.globalEval("this.globalEvalTest = 3;"); + equal( window.globalEvalTest, 3, "Test context (this) is the window object" ); +}); + +test( "globalEval with 'use strict'", function() { + expect( 1 ); + Globals.register("strictEvalTest"); + + jQuery.globalEval("'use strict'; var strictEvalTest = 1;"); + equal( window.strictEvalTest, 1, "Test variable declarations are global (strict mode)" ); +}); + +test("noConflict", function() { + expect(7); + + var $$ = jQuery; + + strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); + strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." ); + strictEqual( window["$"], original$, "Make sure $ was reverted." ); + + jQuery = $ = $$; + + strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); + strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." ); + strictEqual( window["$"], original$, "Make sure $ was reverted." ); + ok( $$().pushStack([]), "Make sure that jQuery still works." ); + + window["jQuery"] = jQuery = $$; +}); + +test("trim", function() { + expect(13); + + var nbsp = String.fromCharCode(160); + + equal( jQuery.trim("hello "), "hello", "trailing space" ); + equal( jQuery.trim(" hello"), "hello", "leading space" ); + equal( jQuery.trim(" hello "), "hello", "space on both sides" ); + equal( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " ); + + equal( jQuery.trim(), "", "Nothing in." ); + equal( jQuery.trim( undefined ), "", "Undefined" ); + equal( jQuery.trim( null ), "", "Null" ); + equal( jQuery.trim( 5 ), "5", "Number" ); + equal( jQuery.trim( false ), "false", "Boolean" ); + + equal( jQuery.trim(" "), "", "space should be trimmed" ); + equal( jQuery.trim("ipad\xA0"), "ipad", "nbsp should be trimmed" ); + equal( jQuery.trim("\uFEFF"), "", "zwsp should be trimmed" ); + equal( jQuery.trim("\uFEFF \xA0! | \uFEFF"), "! |", "leading/trailing should be trimmed" ); +}); + +test("type", function() { + expect( 28 ); + + equal( jQuery.type(null), "null", "null" ); + equal( jQuery.type(undefined), "undefined", "undefined" ); + equal( jQuery.type(true), "boolean", "Boolean" ); + equal( jQuery.type(false), "boolean", "Boolean" ); + equal( jQuery.type(Boolean(true)), "boolean", "Boolean" ); + equal( jQuery.type(0), "number", "Number" ); + equal( jQuery.type(1), "number", "Number" ); + equal( jQuery.type(Number(1)), "number", "Number" ); + equal( jQuery.type(""), "string", "String" ); + equal( jQuery.type("a"), "string", "String" ); + equal( jQuery.type(String("a")), "string", "String" ); + equal( jQuery.type({}), "object", "Object" ); + equal( jQuery.type(/foo/), "regexp", "RegExp" ); + equal( jQuery.type(new RegExp("asdf")), "regexp", "RegExp" ); + equal( jQuery.type([1]), "array", "Array" ); + equal( jQuery.type(new Date()), "date", "Date" ); + equal( jQuery.type(new Function("return;")), "function", "Function" ); + equal( jQuery.type(function(){}), "function", "Function" ); + equal( jQuery.type(new Error()), "error", "Error" ); + equal( jQuery.type(window), "object", "Window" ); + equal( jQuery.type(document), "object", "Document" ); + equal( jQuery.type(document.body), "object", "Element" ); + equal( jQuery.type(document.createTextNode("foo")), "object", "TextNode" ); + equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" ); + + // Avoid Lint complaints + var MyString = String, + MyNumber = Number, + MyBoolean = Boolean, + MyObject = Object; + equal( jQuery.type(new MyBoolean(true)), "boolean", "Boolean" ); + equal( jQuery.type(new MyNumber(1)), "number", "Number" ); + equal( jQuery.type(new MyString("a")), "string", "String" ); + equal( jQuery.type(new MyObject()), "object", "Object" ); +}); + +asyncTest("isPlainObject", function() { + expect(15); + + var pass, iframe, doc, + fn = function() {}; + + // The use case that we want to match + ok( jQuery.isPlainObject({}), "{}" ); + + // Not objects shouldn't be matched + ok( !jQuery.isPlainObject(""), "string" ); + ok( !jQuery.isPlainObject(0) && !jQuery.isPlainObject(1), "number" ); + ok( !jQuery.isPlainObject(true) && !jQuery.isPlainObject(false), "boolean" ); + ok( !jQuery.isPlainObject(null), "null" ); + ok( !jQuery.isPlainObject(undefined), "undefined" ); + + // Arrays shouldn't be matched + ok( !jQuery.isPlainObject([]), "array" ); + + // Instantiated objects shouldn't be matched + ok( !jQuery.isPlainObject(new Date()), "new Date" ); + + // Functions shouldn't be matched + ok( !jQuery.isPlainObject(fn), "fn" ); + + // Again, instantiated objects shouldn't be matched + ok( !jQuery.isPlainObject(new fn()), "new fn (no methods)" ); + + // Makes the function a little more realistic + // (and harder to detect, incidentally) + fn.prototype["someMethod"] = function(){}; + + // Again, instantiated objects shouldn't be matched + ok( !jQuery.isPlainObject(new fn()), "new fn" ); + + // DOM Element + ok( !jQuery.isPlainObject( document.createElement("div") ), "DOM Element" ); + + // Window + ok( !jQuery.isPlainObject( window ), "window" ); + + pass = false; + try { + jQuery.isPlainObject( window.location ); + pass = true; + } catch ( e ) {} + ok( pass, "Does not throw exceptions on host objects" ); + + // Objects from other windows should be matched + window.iframeCallback = function( otherObject, detail ) { + window.iframeCallback = undefined; + iframe.parentNode.removeChild( iframe ); + ok( jQuery.isPlainObject(new otherObject()), "new otherObject" + ( detail ? " - " + detail : "" ) ); + start(); + }; + + try { + iframe = jQuery("#qunit-fixture")[0].appendChild( document.createElement("iframe") ); + doc = iframe.contentDocument || iframe.contentWindow.document; + doc.open(); + doc.write(""); + doc.close(); + } catch(e) { + window.iframeDone( Object, "iframes not supported" ); + } +}); + +test("isFunction", function() { + expect(19); + + var mystr, myarr, myfunction, fn, obj, nodes, first, input, a; + + // Make sure that false values return false + ok( !jQuery.isFunction(), "No Value" ); + ok( !jQuery.isFunction( null ), "null Value" ); + ok( !jQuery.isFunction( undefined ), "undefined Value" ); + ok( !jQuery.isFunction( "" ), "Empty String Value" ); + ok( !jQuery.isFunction( 0 ), "0 Value" ); + + // Check built-ins + // Safari uses "(Internal Function)" + ok( jQuery.isFunction(String), "String Function("+String+")" ); + ok( jQuery.isFunction(Array), "Array Function("+Array+")" ); + ok( jQuery.isFunction(Object), "Object Function("+Object+")" ); + ok( jQuery.isFunction(Function), "Function Function("+Function+")" ); + + // When stringified, this could be misinterpreted + mystr = "function"; + ok( !jQuery.isFunction(mystr), "Function String" ); + + // When stringified, this could be misinterpreted + myarr = [ "function" ]; + ok( !jQuery.isFunction(myarr), "Function Array" ); + + // When stringified, this could be misinterpreted + myfunction = { "function": "test" }; + ok( !jQuery.isFunction(myfunction), "Function Object" ); + + // Make sure normal functions still work + fn = function(){}; + ok( jQuery.isFunction(fn), "Normal Function" ); + + obj = document.createElement("object"); + + // Firefox says this is a function + ok( !jQuery.isFunction(obj), "Object Element" ); + + // IE says this is an object + // Since 1.3, this isn't supported (#2968) + //ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" ); + + nodes = document.body.childNodes; + + // Safari says this is a function + ok( !jQuery.isFunction(nodes), "childNodes Property" ); + + first = document.body.firstChild; + + // Normal elements are reported ok everywhere + ok( !jQuery.isFunction(first), "A normal DOM Element" ); + + input = document.createElement("input"); + input.type = "text"; + document.body.appendChild( input ); + + // IE says this is an object + // Since 1.3, this isn't supported (#2968) + //ok( jQuery.isFunction(input.focus), "A default function property" ); + + document.body.removeChild( input ); + + a = document.createElement("a"); + a.href = "some-function"; + document.body.appendChild( a ); + + // This serializes with the word 'function' in it + ok( !jQuery.isFunction(a), "Anchor Element" ); + + document.body.removeChild( a ); + + // Recursive function calls have lengths and array-like properties + function callme(callback){ + function fn(response){ + callback(response); + } + + ok( jQuery.isFunction(fn), "Recursive Function Call" ); + + fn({ some: "data" }); + } + + callme(function(){ + callme(function(){}); + }); +}); + +test( "isNumeric", function() { + expect( 36 ); + + var t = jQuery.isNumeric, + Traditionalists = /** @constructor */ function(n) { + this.value = n; + this.toString = function(){ + return String(this.value); + }; + }, + answer = new Traditionalists( "42" ), + rong = new Traditionalists( "Devo" ); + + ok( t("-10"), "Negative integer string"); + ok( t("0"), "Zero string"); + ok( t("5"), "Positive integer string"); + ok( t(-16), "Negative integer number"); + ok( t(0), "Zero integer number"); + ok( t(32), "Positive integer number"); + ok( t("040"), "Octal integer literal string"); + // OctalIntegerLiteral has been deprecated since ES3/1999 + // It doesn't pass lint, so disabling until a solution can be found + //ok( t(0144), "Octal integer literal"); + ok( t("0xFF"), "Hexadecimal integer literal string"); + ok( t(0xFFF), "Hexadecimal integer literal"); + ok( t("-1.6"), "Negative floating point string"); + ok( t("4.536"), "Positive floating point string"); + ok( t(-2.6), "Negative floating point number"); + ok( t(3.1415), "Positive floating point number"); + ok( t(8e5), "Exponential notation"); + ok( t("123e-2"), "Exponential notation string"); + ok( t(answer), "Custom .toString returning number"); + equal( t(""), false, "Empty string"); + equal( t(" "), false, "Whitespace characters string"); + equal( t("\t\t"), false, "Tab characters string"); + equal( t("abcdefghijklm1234567890"), false, "Alphanumeric character string"); + equal( t("xabcdefx"), false, "Non-numeric character string"); + equal( t(true), false, "Boolean true literal"); + equal( t(false), false, "Boolean false literal"); + equal( t("bcfed5.2"), false, "Number with preceding non-numeric characters"); + equal( t("7.2acdgs"), false, "Number with trailling non-numeric characters"); + equal( t(undefined), false, "Undefined value"); + equal( t(null), false, "Null value"); + equal( t(NaN), false, "NaN value"); + equal( t(Infinity), false, "Infinity primitive"); + equal( t(Number.POSITIVE_INFINITY), false, "Positive Infinity"); + equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity"); + equal( t(rong), false, "Custom .toString returning non-number"); + equal( t({}), false, "Empty object"); + equal( t(function(){} ), false, "Instance of a function"); + equal( t( new Date() ), false, "Instance of a Date"); + equal( t(function(){} ), false, "Instance of a function"); +}); + +test("isXMLDoc - HTML", function() { + expect(4); + + ok( !jQuery.isXMLDoc( document ), "HTML document" ); + ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" ); + ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" ); + + var body, + iframe = document.createElement("iframe"); + document.body.appendChild( iframe ); + + try { + body = jQuery(iframe).contents()[0]; + + try { + ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); + } catch(e) { + ok( false, "Iframe body element exception" ); + } + + } catch(e) { + ok( true, "Iframe body element - iframe not working correctly" ); + } + + document.body.removeChild( iframe ); +}); + +test("XSS via location.hash", function() { + expect(1); + + stop(); + jQuery["_check9521"] = function(x){ + ok( x, "script called from #id-like selector with inline handler" ); + jQuery("#check9521").remove(); + delete jQuery["_check9521"]; + start(); + }; + try { + // This throws an error because it's processed like an id + jQuery( "#" ).appendTo("#qunit-fixture"); + } catch (err) { + jQuery["_check9521"](true); + } +}); + +test("isXMLDoc - XML", function() { + expect(3); + var xml = createDashboardXML(); + ok( jQuery.isXMLDoc( xml ), "XML document" ); + ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); + ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" ); +}); + +test("isWindow", function() { + expect( 14 ); + + ok( jQuery.isWindow(window), "window" ); + ok( jQuery.isWindow(document.getElementsByTagName("iframe")[0].contentWindow), "iframe.contentWindow" ); + ok( !jQuery.isWindow(), "empty" ); + ok( !jQuery.isWindow(null), "null" ); + ok( !jQuery.isWindow(undefined), "undefined" ); + ok( !jQuery.isWindow(document), "document" ); + ok( !jQuery.isWindow(document.documentElement), "documentElement" ); + ok( !jQuery.isWindow(""), "string" ); + ok( !jQuery.isWindow(1), "number" ); + ok( !jQuery.isWindow(true), "boolean" ); + ok( !jQuery.isWindow({}), "object" ); + ok( !jQuery.isWindow({ setInterval: function(){} }), "fake window" ); + ok( !jQuery.isWindow(/window/), "regexp" ); + ok( !jQuery.isWindow(function(){}), "function" ); +}); + +test("jQuery('html')", function() { + expect( 15 ); + + var s, div, j; + + QUnit.reset(); + jQuery["foo"] = false; + s = jQuery("")[0]; + ok( s, "Creating a script" ); + ok( !jQuery["foo"], "Make sure the script wasn't executed prematurely" ); + jQuery("body").append(""); + ok( jQuery["foo"], "Executing a scripts contents in the right context" ); + + // Test multi-line HTML + div = jQuery("
        \r\nsome text\n

        some p

        \nmore text\r\n
        ")[0]; + equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." ); + equal( div.firstChild.nodeType, 3, "Text node." ); + equal( div.lastChild.nodeType, 3, "Text node." ); + equal( div.childNodes[1].nodeType, 1, "Paragraph." ); + equal( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." ); + + QUnit.reset(); + ok( jQuery("")[0], "Creating a link" ); + + ok( !jQuery(""; + equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" ); + equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve scripts when requested" ); + + html += "
        "; + equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Preserve non-script nodes" ); + equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve script position"); + + equal( jQuery.parseHTML("text")[0].nodeType, 3, "Parsing text returns a text node" ); + equal( jQuery.parseHTML( "\t
        " )[0].nodeValue, "\t", "Preserve leading whitespace" ); + + equal( jQuery.parseHTML("
        ")[0].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" ); + + html = jQuery.parseHTML( "
        test div
        " ); + + equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); + equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" ); + + equal( jQuery.parseHTML("").length, 1, "Incorrect html-strings should not break anything" ); + equal( jQuery.parseHTML("")[ 1 ].parentNode.nodeType, 11, + "parentNode should be documentFragment for wrapMap (variable in manipulation module) elements too" ); + ok( jQuery.parseHTML("<#if>

        This is a test.

        <#/if>") || true, "Garbage input should not cause error" ); +}); + +test("jQuery.parseJSON", function(){ + expect( 9 ); + + equal( jQuery.parseJSON( null ), null, "Actual null returns null" ); + equal( jQuery.isEmptyObject( jQuery.parseJSON("{}") ), true, "Empty object returns empty object" ); + deepEqual( jQuery.parseJSON("{\"test\":1}"), { "test": 1 }, "Plain object parses" ); + deepEqual( jQuery.parseJSON("\n{\"test\":1}"), { "test": 1 }, "Leading whitespaces are ignored." ); + raises(function() { + jQuery.parseJSON(); + }, null, "Undefined raises an error" ); + raises( function() { + jQuery.parseJSON( "" ); + }, null, "Empty string raises an error" ); + raises(function() { + jQuery.parseJSON("''"); + }, null, "Single-quoted string raises an error" ); + raises(function() { + jQuery.parseJSON("{a:1}"); + }, null, "Unquoted property raises an error" ); + raises(function() { + jQuery.parseJSON("{'a':1}"); + }, null, "Single-quoted property raises an error" ); +}); + +test("jQuery.parseXML", 8, function(){ + var xml, tmp; + try { + xml = jQuery.parseXML( "

        A well-formed xml string

        " ); + tmp = xml.getElementsByTagName( "p" )[ 0 ]; + ok( !!tmp, "

        present in document" ); + tmp = tmp.getElementsByTagName( "b" )[ 0 ]; + ok( !!tmp, " present in document" ); + strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", " text is as expected" ); + } catch (e) { + strictEqual( e, undefined, "unexpected error" ); + } + try { + xml = jQuery.parseXML( "

        Not a <well-formed xml string

        " ); + ok( false, "invalid xml not detected" ); + } catch( e ) { + strictEqual( e.message, "Invalid XML:

        Not a <well-formed xml string

        ", "invalid xml detected" ); + } + try { + xml = jQuery.parseXML( "" ); + strictEqual( xml, null, "empty string => null document" ); + xml = jQuery.parseXML(); + strictEqual( xml, null, "undefined string => null document" ); + xml = jQuery.parseXML( null ); + strictEqual( xml, null, "null string => null document" ); + xml = jQuery.parseXML( true ); + strictEqual( xml, null, "non-string => null document" ); + } catch( e ) { + ok( false, "empty input throws exception" ); + } +}); + +test("jQuery.camelCase()", function() { + + var tests = { + "foo-bar": "fooBar", + "foo-bar-baz": "fooBarBaz", + "girl-u-want": "girlUWant", + "the-4th-dimension": "the4thDimension", + "-o-tannenbaum": "OTannenbaum", + "-moz-illa": "MozIlla", + "-ms-take": "msTake" + }; + + expect(7); + + jQuery.each( tests, function( key, val ) { + equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val ); + }); +}); diff --git a/bower_components/jquery/test/unit/css.js b/bower_components/jquery/test/unit/css.js new file mode 100644 index 0000000..297fbec --- /dev/null +++ b/bower_components/jquery/test/unit/css.js @@ -0,0 +1,1017 @@ +if ( jQuery.css ) { + +module("css", { teardown: moduleTeardown }); + +test("css(String|Hash)", function() { + expect( 40 ); + + equal( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"" ); + + var $child, div, div2, width, height, child, prctval, checkval, old; + + $child = jQuery("#nothiddendivchild").css({ "width": "20%", "height": "20%" }); + notEqual( $child.css("width"), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" ); + notEqual( $child.css("height"), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" ); + + div = jQuery( "
        " ); + + // These should be "auto" (or some better value) + // temporarily provide "0px" for backwards compat + equal( div.css("width"), "0px", "Width on disconnected node." ); + equal( div.css("height"), "0px", "Height on disconnected node." ); + + div.css({ "width": 4, "height": 4 }); + + equal( div.css("width"), "4px", "Width on disconnected node." ); + equal( div.css("height"), "4px", "Height on disconnected node." ); + + div2 = jQuery( "
        "); + clone = element.clone(); + equal( clone[ 0 ].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); +}); + +test( "clone(multiple selected options) (Bug #8129)", function() { + + expect( 1 ); + + var element = jQuery(""); + + equal( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" ); + +}); + +test( "clone() on XML nodes", function() { + + expect( 2 ); + + var xml = createDashboardXML(), + root = jQuery(xml.documentElement).clone(), + origTab = jQuery("tab", xml).eq( 0 ), + cloneTab = jQuery("tab", root).eq( 0 ); + + origTab.text("origval"); + cloneTab.text("cloneval"); + equal( origTab.text(), "origval", "Check original XML node was correctly set" ); + equal( cloneTab.text(), "cloneval", "Check cloned XML node was correctly set" ); +}); + +test( "clone() on local XML nodes with html5 nodename", function() { + + expect( 2 ); + + var $xmlDoc = jQuery( jQuery.parseXML( "" ) ), + $meter = $xmlDoc.find( "meter" ).clone(); + + equal( $meter[ 0 ].nodeName, "meter", "Check if nodeName was not changed due to cloning" ); + equal( $meter[ 0 ].nodeType, 1, "Check if nodeType is not changed due to cloning" ); +}); + +test( "html(undefined)", function() { + + expect( 1 ); + + equal( jQuery("#foo").html("test").html(undefined).html().toLowerCase(), "test", ".html(undefined) is chainable (#5571)" ); +}); + +test( "html() on empty set", function() { + + expect( 1 ); + + strictEqual( jQuery().html(), undefined, ".html() returns undefined for empty sets (#11962)" ); +}); + +function childNodeNames( node ) { + return jQuery.map( node.childNodes, function( child ) { + return child.nodeName.toUpperCase(); + }).join(" "); +} + +function testHtml( valueObj ) { + expect( 37 ); + + var actual, expected, tmp, + div = jQuery("
        "), + fixture = jQuery("#qunit-fixture"); + + div.html( valueObj("
        ") ); + equal( div.children().length, 2, "Found children" ); + equal( div.children().children().length, 1, "Found grandchild" ); + + actual = []; expected = []; + tmp = jQuery("").html( valueObj("area") ).each(function() { + expected.push("AREA"); + actual.push( childNodeNames( this ) ); + }); + equal( expected.length, 1, "Expecting one parent" ); + deepEqual( actual, expected, "Found the inserted area element" ); + + equal( div.html(valueObj(5)).html(), "5", "Setting a number as html" ); + equal( div.html(valueObj(0)).html(), "0", "Setting a zero as html" ); + + div.html( valueObj(" &") ); + equal( + div[ 0 ].innerHTML.replace( /\xA0/, " " ), + " &", + "Entities are passed through correctly" + ); + + tmp = "<div>hello1</div>"; + equal( div.html(valueObj(tmp) ).html().replace( />/g, ">" ), tmp, "Escaped html" ); + tmp = "x" + tmp; + equal( div.html(valueObj( tmp )).html().replace( />/g, ">" ), tmp, "Escaped html, leading x" ); + tmp = " " + tmp.slice( 1 ); + equal( div.html(valueObj( tmp )).html().replace( />/g, ">" ), tmp, "Escaped html, leading space" ); + + actual = []; expected = []; tmp = {}; + jQuery("#nonnodes").contents().html( valueObj("bold") ).each(function() { + var html = jQuery( this ).html(); + tmp[ this.nodeType ] = true; + expected.push( this.nodeType === 1 ? "bold" : undefined ); + actual.push( html ? html.toLowerCase() : html ); + }); + deepEqual( actual, expected, "Set containing element, text node, comment" ); + ok( tmp[ 1 ], "element" ); + ok( tmp[ 3 ], "text node" ); + ok( tmp[ 8 ], "comment" ); + + actual = []; expected = []; + fixture.children("div").html( valueObj("test") ).each(function() { + expected.push("B"); + actual.push( childNodeNames( this ) ); + }); + equal( expected.length, 7, "Expecting many parents" ); + deepEqual( actual, expected, "Correct childNodes after setting HTML" ); + + actual = []; expected = []; + fixture.html( valueObj("") ).each(function() { + expected.push("STYLE"); + actual.push( childNodeNames( this ) ); + }); + equal( expected.length, 1, "Expecting one parent" ); + deepEqual( actual, expected, "Found the inserted style element" ); + + fixture.html( valueObj("", {} ); + ok( true, "Does not allow attribute object to be treated like a doc object" ); + } catch ( e ) {} +}); + +test( "jQuery.clone - no exceptions for object elements #9587", function() { + + expect( 1 ); + + try { + jQuery("#no-clone-exception").clone(); + ok( true, "cloned with no exceptions" ); + } catch( e ) { + ok( false, e.message ); + } +}); + +test( "Cloned, detached HTML5 elems (#10667,10670)", function() { + + expect( 7 ); + + var $clone, + $section = jQuery( "
        " ).appendTo( "#qunit-fixture" ); + + // First clone + $clone = $section.clone(); + + // Infer that the test is being run in IE<=8 + if ( $clone[ 0 ].outerHTML && !jQuery.support.opacity ) { + // This branch tests cloning nodes by reading the outerHTML, used only in IE<=8 + equal( $clone[ 0 ].outerHTML, "
        ", "detached clone outerHTML matches '
        '" ); + } else { + // This branch tests a known behaviour in modern browsers that should never fail. + // Included for expected test count symmetry (expecting 1) + equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" ); + } + + // Bind an event + $section.on( "click", function() { + ok( true, "clone fired event" ); + }); + + // Second clone (will have an event bound) + $clone = $section.clone( true ); + + // Trigger an event from the first clone + $clone.trigger("click"); + $clone.off("click"); + + // Add a child node with text to the original + $section.append("

        Hello

        "); + + // Third clone (will have child node and text) + $clone = $section.clone( true ); + + equal( $clone.find("p").text(), "Hello", "Assert text in child of clone" ); + + // Trigger an event from the third clone + $clone.trigger("click"); + $clone.off("click"); + + // Add attributes to copy + $section.attr({ + "class": "foo bar baz", + "title": "This is a title" + }); + + // Fourth clone (will have newly added attributes) + $clone = $section.clone( true ); + + equal( $clone.attr("class"), $section.attr("class"), "clone and element have same class attribute" ); + equal( $clone.attr("title"), $section.attr("title"), "clone and element have same title attribute" ); + + // Remove the original + $section.remove(); + + // Clone the clone + $section = $clone.clone( true ); + + // Remove the clone + $clone.remove(); + + // Trigger an event from the clone of the clone + $section.trigger("click"); + + // Unbind any remaining events + $section.off("click"); + $clone.off("click"); +}); + +test( "Guard against exceptions when clearing safeChildNodes", function() { + + expect( 1 ); + + var div; + + try { + div = jQuery("

        "); + } catch(e) {} + + ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); +}); + +test( "Ensure oldIE creates a new set on appendTo (#8894)", function() { + + expect( 5 ); + + strictEqual( jQuery("
        ").clone().addClass("test").appendTo("
        ").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" ); + strictEqual( jQuery("
        ").find("p").end().addClass("test").appendTo("
        ").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" ); + strictEqual( jQuery("
        ").text("test").addClass("test").appendTo("
        ").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" ); + strictEqual( jQuery("").clone().addClass("test").appendTo("
        ").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" ); + strictEqual( jQuery("

        ").appendTo("

        ").end().length, jQuery("

        test

        ").appendTo("
        ").end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" ); +}); + +test( "html() - script exceptions bubble (#11743)", function() { + + expect( 3 ); + + raises(function() { + jQuery("#qunit-fixture").html(""); + ok( false, "Exception ignored" ); + }, "Exception bubbled from inline script" ); + + if ( jQuery.ajax ) { + var onerror = window.onerror; + window.onerror = function() { + ok( true, "Exception thrown in remote script" ); + }; + + jQuery("#qunit-fixture").html(""); + ok( true, "Exception ignored" ); + window.onerror = onerror; + } else { + ok( true, "No jQuery.ajax" ); + ok( true, "No jQuery.ajax" ); + } +}); + +test( "checked state is cloned with clone()", function() { + + expect( 2 ); + + var elem = jQuery.parseHTML("")[ 0 ]; + elem.checked = false; + equal( jQuery(elem).clone().attr("id","clone")[ 0 ].checked, false, "Checked false state correctly cloned" ); + + elem = jQuery.parseHTML("")[ 0 ]; + elem.checked = true; + equal( jQuery(elem).clone().attr("id","clone")[ 0 ].checked, true, "Checked true state correctly cloned" ); +}); + +test( "manipulate mixed jQuery and text (#12384, #12346)", function() { + + expect( 2 ); + + var div = jQuery("
        a
        ").append( " ", jQuery("b"), " ", jQuery("c") ), + nbsp = String.fromCharCode( 160 ); + + equal( div.text(), "a" + nbsp + "b" + nbsp+ "c", "Appending mixed jQuery with text nodes" ); + + div = jQuery("
        ") + .find("div") + .after( "

        a

        ", "

        b

        " ) + .parent(); + equal( div.find("*").length, 3, "added 2 paragraphs after inner div" ); +}); + +testIframeWithCallback( "buildFragment works even if document[0] is iframe's window object in IE9/10 (#12266)", "manipulation/iframe-denied.html", function( test ) { + expect( 1 ); + + ok( test.status, test.description ); +}); + +test( "script evaluation (#11795)", function() { + + expect( 13 ); + + var scriptsIn, scriptsOut, + fixture = jQuery("#qunit-fixture").empty(), + objGlobal = (function() { + return this; + })(), + isOk = objGlobal.ok, + notOk = function() { + var args = arguments; + args[ 0 ] = !args[ 0 ]; + return isOk.apply( this, args ); + }; + + objGlobal.ok = notOk; + scriptsIn = jQuery([ + "", + "", + "", + "", + "
        ", + "", + "", + "", + "", + "
        " + ].join("")); + scriptsIn.appendTo( jQuery("
        ") ); + objGlobal.ok = isOk; + + scriptsOut = fixture.append( scriptsIn ).find("script"); + equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." ); + equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." ); + deepEqual( scriptsOut.get(), fixture.find("script").get(), "All script tags remain." ); + + objGlobal.ok = notOk; + scriptsOut = scriptsOut.add( scriptsOut.clone() ).appendTo( fixture.find("div") ); + deepEqual( fixture.find("div script").get(), scriptsOut.get(), "Scripts cloned without reevaluation" ); + fixture.append( scriptsOut.detach() ); + deepEqual( fixture.children("script").get(), scriptsOut.get(), "Scripts detached without reevaluation" ); + objGlobal.ok = isOk; + + if ( jQuery.ajax ) { + Globals.register("testBar"); + jQuery("#qunit-fixture").append( " + + + + +# Messenger + +#### [Demo and Usage](http://hubspot.github.com/messenger/docs/welcome) + +- Show messages in your app. +- Wrap AJAX requests with progress, success and error messages, and add retry to your failed requests. +- Add actions (undo, cancel, etc.) to your messages. + +![Messenger](https://raw.github.com/HubSpot/messenger/master/docs/images/messenger.gif) + +Messenger is different from other solutions for a few reasons: + +- Each message can be updated after being posted without losing it's place +- Actions and events can be bound to messages +- It's completely themeable with CSS +- A 'tray' element exists to allow you to style the box around the messages, and limit the number +of messages on the screen + +### Messenger Object + +Messenger is accessed through a global `Messenger` object. The object is called at each usage to give +it a chance to instantiate if necessary. + +The most basic usage is to post a message: + +```javascript +Messenger().post({ options }) +``` + +Options can be a string representing the body of the message: + +```javascript +Messenger().post("Welcome to the darkside (tm)") +``` + +It can also be an object: + +```javascript +Messenger().post({ + message: "How's it going?", + type: "error" +}) +``` + +The full list of options: + +- `message`: The text of the message +- `type`: `info`, `error` or `success` are understood by the provided themes. You can also pass your +own string, and that class will be added. +- `theme`: What theme class should be applied to the message? Defaults to the theme set for Messenger in +general. +- `id`: A unique id. If supplied, only one message with that ID will be shown at a time. +- `singleton`: Hide the newer message if there is an `id` collision, as opposed to the older message. +- `actions`: Action links to put in the message, see the 'Actions' section on this page. +- `hideAfter`: Hide the message after the provided number of seconds +- `hideOnNavigate`: Hide the message if Backbone client-side navigation occurs +- `showCloseButton`: Should a close button be added to the message? + +Messenger also includes aliases which set the `type` for you: `Messenger().error()`, `Messenger().success()`, and `messenger().info()`. + +### Updating Messages + +Rather than posting a new message when progress occurs, it can be nice to update an existing message. + +`.post`, along with the other message posting methods, provide a `Message` instance which has the +following methods: + +- `show()`: Show the message, if it's hidden +- `hide()`: Hide the message, if it's shown +- `cancel()`: If the message is associated with an ajax request or is counting down to retry, cancel it +- `update({ options })`: Update the message with the provided options + +Any option, such as `type` or `message` can be changed with `update`: + +```javascript +message = Messenger().post("Calculating position") +message.update({ + type: "error", + message: "Error calculating position" +}) +``` + +### Messenger Object + +When `Messenger` is called, it creates, if necessary, a container for future messages to be placed into. +`Messenger` can be passed options to configure the container when it's first called, future calls will +alter the existing container. + +`Messenger` options: + +- `extraClasses`: Extra classes to be appended to the container. These can be used to configure the active theme. +If you'd like the messenger box to be overlayed on the screen, you should provide the `messenger-fixed` class along with any of +the following positioning classes: `messenger-on-bottom`, `messenger-on-top`, `messenger-on-left`, `messenger-on-right`. +Adding the `top` or `bottom` class along with a `left` or `right` will move the messenger dialog into the specified corner. +- `maxMessages`: The maximum number of messages to show at once +- `parentLocations`: Which locations should be tried when inserting the message container into the page. The default is `['body']`. +It accepts a list to allow you to try a variety of places when deciding what the optimal location is on any given page. This should +generally not need to be changed unless you are inserting the messages into the flow of the document, rather than using `messenger-fixed`. +- `theme`: What theme are you using? Some themes have associated javascript, specifing this allows that js to run. +- `messageDefaults`: Default options for created messages + +```javascript +Messenger({ + parentLocations: ['.page'], // Let's insert it into the page + extraClasses: '' // And not add the fixed classes +}) + +// Future calls just need to refer to Messenger(), they'll get the same instance +``` + +```javascript +Messenger({ + // Let's put the messenger in the top left corner + extraClasses: 'messenger-fixed messenger-on-left messenger-on-top' +}); +``` + +The object provided by `Messenger()` also has a couple of additional methods: + +- `hideAll`: Hide all messages +- `run`: See 'Running Things' below +- `ajax`: See 'Running Things' below +- `expectPromise`: See 'Running Things' below +- `hookBackboneAjax`: See Backbone below + +### Running Things + +One of the most common use cases for messenger is to show the progress and success or error of an asynchronous action, like an ajax request. +Messenger includes a method to help with that, `run`. + +`run({ messageOptions }, { actionOptions })` + +messageOptions: + +- `action`: The function which should be passed `actionOptions`. `success` and `error` callbacks will be added to `actionOptions` +and used to show the appropriate messages. +- `successMessage`: What message should be shown if the action is a success? Can be a string, or false if no message should be shown. Can also +be a function returning a string, message options object, or false. +- `errorMessage`: Same as success message, but shown after the `error` callback is called. +- `progressMessage`: A message to be shown while the action is underway, or false. +- `showSuccessWithoutError`: Set to false if you only want the success message to be shown if the success comes after a failure +- `ignoredErrorCodes`: By default the error handler looks for `xhr.status`, assuming the action is $.ajax. If it is, this can be set to an +array of HTTP status codes which should _not_ be considered an error. +- `returnsPromise`: If true, instead of wrapping the `success` and `error` callbacks passed to `action`, we expect `action` to return to +us a promise, and use that to show the appropriate messages. +- `retry`: Set to false to not have the action retried if it fails. Or set it to an object with the following options: + - `allow`: Should we show a manual 'Retry' button? + - `auto`: Should we automatically start the retry timer after a failure? +- Any other message options + +Your success and error handlers can return false if they don't wish the message to be shown. They can also return a string to change the +message, or an object to change more message options. + +```javascript +Messenger().run({ + action: $.ajax, + + successMessage: 'Contact saved', + errorMessage: 'Error saving contact', + progressMessage: 'Saving contact...' +}, { + /* These options are provided to $.ajax, with success and error wrapped */ + url: '/contact', + data: contact, + + error: function(resp){ + if (resp.status === 409) + return "A contact with that email already exists"; + } +}); +``` + +We also provide a couple of aliases: + +- `Messenger().ajax({ messageOptions }, { actionOptions })`: Call `run` with `$.ajax` as the action (which is already the default). +- `Messenger().expectPromise(action, { messageOptions })`: Call `run` with a function which returns a promise, so actionOptions aren't necessary. + +```javascript +Messenger().expectPromise(function(){ + return $.ajax({ + url: '/aliens/44', + type: 'DELETE' + }); +}, { + successMessage: 'Alien Destroyed!', + progressMessage: false +}); +``` + +All three methods return a `Message` instance. You can call `message.cancel()` to stop the retrying, if necessary. + +### Actions + +You can pass messages a hash of actions the user can execute on the message. For example, `run` will add 'Retry' and 'Cancel' +buttons to error messages which have retry enabled. + +Actions are provided as the `actions` hash to `post` or `run`: + +```javascript +msg = Messenger().post({ + message: "Are you sure you'd like to delete this contact?", + + actions: { + delete: { + label: "Delete", + action: function(){ + delete() + msg.hide() + } + }, + + cancel: { + action: function(){ + msg.hide() + } + } + } +}) +``` + +### Events + +You can add DOM event handlers to the message itself, or any element within it. For example, you might wish to do +something when the user clicks on the message. + +The format of the event key is: "`[type] event [selector]`" + +Type is a message type, like `success`, `error`, or `info`, or skip to ignore the type. It's useful with `run` where +the same options are getting applied to the `success` and `error` messages. +Event is the DOM event to bind to. +Selector is any jQuery selector, or skip to bind to the message element itsef. + +```javascript +Messenger().post({ + message: "Click me to explode!", + + events: { + "click": function(e){ + explode(); + }, + "hover a.button": function(e){ + e.stopPropagation(); + } + } +}); +``` + +### Backbone.js + +Messenger includes a function to hook into Backbone.js' sync method. To enable it, call `Messenger().hookBackboneAjax({ defaultOptions })` +before making any Backbone requests (but after bringing in the Backbone.js js file). + +You can pass it any default message options you would like to apply to your requests. You can also set those options as `messenger` in +your save and fetch calls. + +```javascript +Messenger().hookBackboneAjax({ + errorMessage: 'Error syncing with the server', + retry: false +}); + +// Later on: +myModel.save({ + errorMessage: 'Error saving contact' +}); +``` + +### Classes + +Each message can have the following classes: + +- `messenger-hidden` (message): Applied when a message is hidden +- `messenger-will-hide-after` (message): Applied if the `hideAfter` option is not false +- `messenger-will-hide-on-navigate` (message): Applied if the `hideOnNavigate` option is not false +- `messenger-clickable` (message): Applied if a 'click' event is included in the events hash +- `messenger-message` (message): Applied to all messages +- `messenger-{type}` (message): Applied based on the message's `type` (usually 'success', 'error', or 'info') +- `message`, `alert`, `alert-{type}` (message): Added for compatiblity with external CSS +- `messenger-retry-soon` (message): Added when the next retry will occur in less than or equal to 10s +- `messenger-retry-later` (message): Added when the next retry will occur in greater than 10s (usually 5min) + +Every message lives in a slot, which is a li in the list of all the messages which have been created: + +- `messenger-first` (slot): Added when this slot is the first shown slot in the list +- `messenger-last` (slot): Added when this slot is the last shown slot in the list +- `messenger-shown` (slot): Added when this slot is visible + +All the slots are in a tray element: + +- `messenger-empty` (tray): Added when there are no visible messages +- `messenger-theme-{theme}` (tray): Added based on the passed in `theme` option + +### Multiple Messenger Trays + +You can have multiple messenger trays on the page at the same time. Manually create them using the +jQuery method: + +```javascript +instance = $('.myContainer').messenger(); +``` + +You can then pass your instance into the messenger methods: + +```javascript +Messenger({instance: instance}).post("My awesome message") +``` + +### Contributing + +The build process requires nodejs and grunt-cli. +You can build the output files by running `grunt`. +The automated tests can be run by opening SpecRunner.html in a browser. diff --git a/bower_components/messenger/docs/welcome/iframe-demo.html b/bower_components/messenger/docs/welcome/iframe-demo.html new file mode 100644 index 0000000..bea5320 --- /dev/null +++ b/bower_components/messenger/docs/welcome/iframe-demo.html @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Messenger – Demo + + + + + diff --git a/bower_components/messenger/docs/welcome/images/bg_hr.png b/bower_components/messenger/docs/welcome/images/bg_hr.png new file mode 100644 index 0000000..7973bd6 Binary files /dev/null and b/bower_components/messenger/docs/welcome/images/bg_hr.png differ diff --git a/bower_components/messenger/docs/welcome/images/blacktocat.png b/bower_components/messenger/docs/welcome/images/blacktocat.png new file mode 100644 index 0000000..6e264fe Binary files /dev/null and b/bower_components/messenger/docs/welcome/images/blacktocat.png differ diff --git a/bower_components/messenger/docs/welcome/images/icon_download.png b/bower_components/messenger/docs/welcome/images/icon_download.png new file mode 100644 index 0000000..a2a287f Binary files /dev/null and b/bower_components/messenger/docs/welcome/images/icon_download.png differ diff --git a/bower_components/messenger/docs/welcome/images/messenger_preview.png b/bower_components/messenger/docs/welcome/images/messenger_preview.png new file mode 100644 index 0000000..0c67dc3 Binary files /dev/null and b/bower_components/messenger/docs/welcome/images/messenger_preview.png differ diff --git a/bower_components/messenger/docs/welcome/images/sprite_download.png b/bower_components/messenger/docs/welcome/images/sprite_download.png new file mode 100644 index 0000000..f2babd5 Binary files /dev/null and b/bower_components/messenger/docs/welcome/images/sprite_download.png differ diff --git a/bower_components/messenger/docs/welcome/index.html b/bower_components/messenger/docs/welcome/index.html new file mode 100644 index 0000000..bea971e --- /dev/null +++ b/bower_components/messenger/docs/welcome/index.html @@ -0,0 +1,436 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Messenger - Alerts for the 21st Century + + + + + +
        +
        + View on GitHub + + + +

        Messenger

        +

        Alerts for the 21st century

        + +
        + Download this project as a .zip file + Download this project as a tar.gz file +
        +
        +
        + + +
        +
        +

        HubSpot Messaging Library

        + +
          +
        • Show transactional messages in your app. +
        • Wrap AJAX requests with progress, success and error messages. +
        • Add action links to your messages. +
        • 4kb minified and compressed. +
        • Works in everything modern, and IE7 and above. +
        + +

        Demo

        + + + + +

        Requires

        + +
          +
        • jQuery
        • +
        • Plays well with, but doesn't require, Bootstrap
        + +

        Including

        + +

        JS

        + +
        /build/js/messenger.min.js
        +/build/js/messenger-theme-future.js
        +
        + +

        CSS

        + +
        /build/css/messenger.css
        +/build/css/messenger-theme-future.css
        +
        + +

        + Also available as a Rails gem and on cdnjs. +

        + +

        Really Quick Usage

        +
        +
        +# Replace:
        +$.ajax
        +    url: "/some-url"
        +    success: ->
        +
        +# With:
        +Messenger().run
        +    errorMessage: "This did not go well."
        +,
        +    url: "/some-url"
        +    success: ->
        +
        +
        +

        Usage Click Code to Edit

        +
        +
        +

        Change Location

        +
        +
        +
        +

        Change Theme

        +
          +
          +
          +

          Change Language

          +
            +
          • JavaScript
          • +
          • CoffeeScript
          • +
          +
          +
          +
          +
          +
          +
          +Messenger().post "Your request has succeded!"
          +
          +Messenger().post
          +    message: 'There was an explosion while processing your request.'
          +    type: 'error'
          +    showCloseButton: true
          +
          +msg = Messenger().post "My Message"
          +msg.update "I changed my mind, this is my message"
          +msg.hide()
          +
          +# Want to put actions at the end of your messages?
          +msg = Messenger().post
          +    message: 'Launching thermonuclear war...'
          +    type: 'info'
          +    actions:
          +        cancel:
          +            label: 'cancel launch'
          +            action: ->
          +                msg.update
          +                    message: 'Thermonuclear war averted'
          +                    type: 'success'
          +                    actions: false
          +
          +# This guy will 500 a few times, then succeed
          +i = 0
          +Messenger().run
          +  errorMessage: 'Error destroying alien planet'
          +  successMessage: 'Alien planet destroyed!'
          +
          +  action: (opts) ->
          +    if (++i < 3)
          +      opts.error({status: 500, readyState: 0, responseText: 0})
          +    else
          +      opts.success()
          +
          +
          +# Have an error? How about auto retrys with a Gmail-style countdown
          +# (hidden in the future theme)?:
          +msg = Messenger().post
          +    message: "I'm sorry Hal, I just can't do that."
          +    actions:
          +        retry:
          +            label: 'retry now'
          +            phrase: 'Retrying TIME'
          +            auto: true
          +            delay: 10
          +            action: ->
          +                # Do some retrying...
          +
          +        cancel:
          +            action: ->
          +                do msg.cancel
          +
          +# You can bind to action events as well:
          +msg.on 'action:retry', ->
          +    alert('Hey, you retried!')
          +
          +# Need more control? You can bind events backbone-style based
          +# on the type of message.
          +msg.update
          +    events:
          +        'success click': ->
          +            # Will fire when the user clicks the message
          +            # in a success state.
          +
          +        'error click a.awesome-class': ->
          +            # Rock on
          +
          +# Need your message to hide after a while, or when the Backbone
          +# router changes the page?
          +Messenger().post
          +    message: "Weeeeee"
          +
          +    hideAfter: 10
          +    hideOnNavigate: true
          +
          +# You can use the id property to ensure that only one
          +# instance of a message will appear on the page at a time
          +# (the older message will be hidden).
          +Messenger().post
          +  message: "Only one at a time!"
          +  id: "Only-one-message"
          +
          +# When you add the singleton attribute, it ensures that no
          +# other messages with that id will ever be shown again
          +# (the newer message will be hidden).
          +Messenger().post
          +  message: "It's just me!"
          +  id: '4'
          +  singleton: true
          +
          +Messenger().post
          +  message: "You'll never see me"
          +  id: '4'
          +  singleton: true
          +
          +# Rather than hiding and showing multiple messages
          +# you can also maintain a single message between
          +# requests.
          +msg = Messenger().run()
          +Messenger().run({messageInstance: msg})
          +
          +# Don't want your message hidden on a long page? (Not necessary
          +# if you're using the default fixed positioning)
          +msg = Messenger().post
          +    message: "You'll see me!"
          +
          +    scrollTo: true
          +    # Requires jQuery scrollTo plugin
          +
          +msg.scrollTo() # also works
          +
          +# Lazy/smart? How about messenger does it all for you?  All the
          +# retry magic comes with.
          +Messenger().run
          +    successMessage: 'Data saved.'
          +    errorMessage: 'Error saving data'
          +    progressMessage: 'Saving data' # Don't include messages you
          +                                   # don't want to appear.
          +
          +    # Any standard message opts can go here
          +,
          +    # All the standard jQuery ajax options here
          +
          +    url: '/data'
          +
          +# Need to override the messages based on the response?
          +Messenger().run
          +    errorMessage: 'Oops'
          +,
          +    url: '/data'
          +    error: (xhr) ->
          +        # Whatever you return from your handlers will replace
          +        # the default messages
          +
          +        if xhr?.status is 404
          +            return "Data not found"
          +
          +        # Return true or undefined for your predefined message
          +        # Return false to not show any message
          +
          +        return true
          +
          +# Sometimes you only want to show the success message when a
          +# retry succeeds, not if a retry wasen't required:
          +Messenger().run
          +    successMessage: 'Successfully saved.'
          +    errorMessage: 'Error saving'
          +
          +    showSuccessWithoutError: false
          +,
          +    url: '/data'
          +
          +# You don't have to use $.ajax as your action, messenger works
          +# great for any async process:
          +Messenger().run
          +    successMessage: 'Bomb defused successfully'
          +
          +    action: defuseBomb
          +    # You can put options for defuseBomb here
          +    # It will be passed success and error callbacks
          +
          +# Need to hide all messages?
          +Messenger().hideAll()
          +
          +# If your action responds with a promise-like thing, its
          +# methods will be copied onto the message:
          +
          +Messenger().run({}, {url: 'a'}).fail(-> alert "Uh oh")
          +
          +# Do you use Backbone? Hook all backbone calls:
          +Messenger().hookBackboneAjax()
          +
          +# By default, there will be no error message (just background
          +# retries), return an error message from your backbone error handler,
          +# or add an errorMessage to the messenger opts to set one.
          +# You can override these options by passing them into
          +# hookBackboneAjax, or adding a {'messenger': } hash to your
          +# fetch call.
          +
          +# You don't have to use the global messenger
          +$('div#message-container').messenger().post "My message"
          +
          +# By default, the global messenger will create an ActionMessenger
          +# instance fixed to the bottom-right corner of the screen.
          +
          +# You can pass an instance of messenger into globalMessenger
          +# to override the default position.
          +myAwesomeMessenger = $('.mess').messenger()
          +Messenger({instance: myAwesomeMessenger});
          +
          +Messenger() # <-- Will return your messenger
          +
          +Messenger({'parentLocations': ['.page', 'body']});
          +# Will try to insert the messenger into the el matching
          +# .page before inserting it into the page.
          +
          +# This can be important if you're not using fixed positioning.
          +
          +# All the options for globalMessenger and their defaults:
          +
          +{
          +  'parentLocations': ['body'],
          +  'maxMessages': 9,
          +  'extraClasses': 'messenger-fixed messenger-on-right messenger-on-bottom messenger-theme-future',
          +  'instance': undefined,
          +  'messageDefaults': {
          +    # Default message options
          +  }
          +}
          +
          +# You can also set default options on the Messenger.options object.
          +Messenger.options = {'extraClasses': 'messenger-fixed messenger-on-left'}
          +
          +
          + +

          Contributing

          + +

          We welcome contributors!

          +

          +The build process requires nodejs and grunt-cli. +You can build the output files by running grunt. +The automated tests can be run by opening SpecRunner.html in a browser. +

          +

          +There is plenty to be done, pick an issue and start hacking! +

          +
          +
          + + + + + + + + + + + diff --git a/bower_components/messenger/docs/welcome/javascripts/demo.js b/bower_components/messenger/docs/welcome/javascripts/demo.js new file mode 100644 index 0000000..b9f8095 --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/demo.js @@ -0,0 +1,41 @@ +$(function(){ + Messenger().post("Thanks for checking out Messenger!"); + + var loc = ['bottom', 'right']; + var style = 'flat'; + + var $output = $('.controls output'); + var $lsel = $('.location-selector'); + var $tsel = $('.theme-selector'); + + var update = function(){ + var classes = 'messenger-fixed'; + + for (var i=0; i < loc.length; i++) + classes += ' messenger-on-' + loc[i]; + + $.globalMessenger({ extraClasses: classes, theme: style }); + Messenger.options = { extraClasses: classes, theme: style }; + + $output.text("Messenger.options = {\n extraClasses: '" + classes + "',\n theme: '" + style + "'\n}"); + }; + + update(); + + $lsel.locationSelector() + .on('update', function(pos){ + loc = pos; + + update(); + }) + ; + + $tsel.themeSelector({ + themes: ['flat', 'future', 'block', 'air', 'ice'] + }).on('update', function(theme){ + style = theme; + + update(); + }); + +}); \ No newline at end of file diff --git a/bower_components/messenger/docs/welcome/javascripts/execute.coffee b/bower_components/messenger/docs/welcome/javascripts/execute.coffee new file mode 100644 index 0000000..67e2109 --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/execute.coffee @@ -0,0 +1,19 @@ +$.fn.executr = (opts) -> + defaults = + codeSelector: 'code[executable]' + + opts = $.extend {}, defaults, opts + + this.on 'click', opts.codeSelector, (e) -> + $target = $ e.target + $code = $target.parents(opts.codeSelector) + + ctx = window + if opts.setUp? + CoffeeScript.run opts.setUp, ctx + + CoffeeScript.run $code.text(), ctx + + if opts.tearDown? + CoffeeScript.run opts.tearDown, ctx + diff --git a/bower_components/messenger/docs/welcome/javascripts/location-sel.coffee b/bower_components/messenger/docs/welcome/javascripts/location-sel.coffee new file mode 100644 index 0000000..8fdc605 --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/location-sel.coffee @@ -0,0 +1,41 @@ +class LocationSelector extends Backbone.View + className: 'location-selector' + + events: + 'click .bit': 'handleClick' + + render: -> + @$el.html '' + + do @draw + + draw: -> + @_addBit 'top left' + @_addBit 'top right' + @_addBit 'top' + + @_addBit 'bottom left' + @_addBit 'bottom right' + @_addBit 'bottom' + + _addBit: (classes) -> + bit = $ '
          ' + bit.addClass "bit #{ classes }" + bit.attr 'data-position', classes + @$el.append bit + + bit + + handleClick: (e) -> + $bit = $ e.target + + @trigger 'update', $bit.attr('data-position').split(' ') + +$.fn.locationSelector = (opts) -> + loc = new LocationSelector $.extend {}, opts, + el: this + + $(this).addClass loc.className + loc.render() + + loc diff --git a/bower_components/messenger/docs/welcome/javascripts/location-sel.js b/bower_components/messenger/docs/welcome/javascripts/location-sel.js new file mode 100644 index 0000000..f43a374 --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/location-sel.js @@ -0,0 +1,63 @@ +(function() { + var LocationSelector, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + LocationSelector = (function(_super) { + + __extends(LocationSelector, _super); + + function LocationSelector() { + return LocationSelector.__super__.constructor.apply(this, arguments); + } + + LocationSelector.prototype.className = 'location-selector'; + + LocationSelector.prototype.events = { + 'click .bit': 'handleClick' + }; + + LocationSelector.prototype.render = function() { + this.$el.html(''); + return this.draw(); + }; + + LocationSelector.prototype.draw = function() { + this._addBit('top left'); + this._addBit('top right'); + this._addBit('top'); + this._addBit('bottom left'); + this._addBit('bottom right'); + return this._addBit('bottom'); + }; + + LocationSelector.prototype._addBit = function(classes) { + var bit; + bit = $('
          '); + bit.addClass("bit " + classes); + bit.attr('data-position', classes); + this.$el.append(bit); + return bit; + }; + + LocationSelector.prototype.handleClick = function(e) { + var $bit; + $bit = $(e.target); + return this.trigger('update', $bit.attr('data-position').split(' ')); + }; + + return LocationSelector; + + })(Backbone.View); + + $.fn.locationSelector = function(opts) { + var loc; + loc = new LocationSelector($.extend({}, opts, { + el: this + })); + $(this).addClass(loc.className); + loc.render(); + return loc; + }; + +}).call(this); diff --git a/bower_components/messenger/docs/welcome/javascripts/main.js b/bower_components/messenger/docs/welcome/javascripts/main.js new file mode 100644 index 0000000..d8135d3 --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/main.js @@ -0,0 +1 @@ +console.log('This would be the main JS file.'); diff --git a/bower_components/messenger/docs/welcome/javascripts/theme-sel.coffee b/bower_components/messenger/docs/welcome/javascripts/theme-sel.coffee new file mode 100644 index 0000000..cab8aca --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/theme-sel.coffee @@ -0,0 +1,30 @@ +class ThemeSelector extends Backbone.View + tagName: 'ul' + className: 'theme-selector' + + events: + 'click li': 'handleClick' + + render: -> + @$el.html '' + + for theme in @options.themes + $li = $ '
        • ' + $li.attr 'data-id', theme + $li.text theme + + @$el.append $li + + handleClick: (e) -> + $li = $ e.target + + @trigger 'update', $li.attr('data-id') + +$.fn.themeSelector = (opts) -> + sel = new ThemeSelector $.extend {}, opts, + el: this + + $(this).addClass sel.className + sel.render() + + sel diff --git a/bower_components/messenger/docs/welcome/javascripts/theme-sel.js b/bower_components/messenger/docs/welcome/javascripts/theme-sel.js new file mode 100644 index 0000000..c96374f --- /dev/null +++ b/bower_components/messenger/docs/welcome/javascripts/theme-sel.js @@ -0,0 +1,57 @@ +(function() { + var ThemeSelector, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + ThemeSelector = (function(_super) { + + __extends(ThemeSelector, _super); + + function ThemeSelector() { + return ThemeSelector.__super__.constructor.apply(this, arguments); + } + + ThemeSelector.prototype.tagName = 'ul'; + + ThemeSelector.prototype.className = 'theme-selector'; + + ThemeSelector.prototype.events = { + 'click li': 'handleClick' + }; + + ThemeSelector.prototype.render = function() { + var $li, theme, _i, _len, _ref, _results; + this.$el.html(''); + _ref = this.options.themes; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + theme = _ref[_i]; + $li = $('
        • '); + $li.attr('data-id', theme); + $li.text(theme); + _results.push(this.$el.append($li)); + } + return _results; + }; + + ThemeSelector.prototype.handleClick = function(e) { + var $li; + $li = $(e.target); + return this.trigger('update', $li.attr('data-id')); + }; + + return ThemeSelector; + + })(Backbone.View); + + $.fn.themeSelector = function(opts) { + var sel; + sel = new ThemeSelector($.extend({}, opts, { + el: this + })); + $(this).addClass(sel.className); + sel.render(); + return sel; + }; + +}).call(this); diff --git a/bower_components/messenger/docs/welcome/lib/executr/LICENSE b/bower_components/messenger/docs/welcome/lib/executr/LICENSE new file mode 100644 index 0000000..d746b04 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/LICENSE @@ -0,0 +1,8 @@ +Copyright (c) 2013 HubSpot, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/bower_components/messenger/docs/welcome/lib/executr/README.md b/bower_components/messenger/docs/welcome/lib/executr/README.md new file mode 100644 index 0000000..d0b9658 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/README.md @@ -0,0 +1,93 @@ +## executr + +Let your users execute and play with the CoffeeScript and JavaScript in your documentation + +### Example + +See our messenger documentation for an example: http://hubspot.github.com/messenger/ + +### Including + +````html + + + + + + + + + + + + + +```` + +### Usage + +The code blocks you wish to be executable should be wrapped in ``. + +Run `$.executr` on the container of multiple code elements, the body, or a single code block. + +The blocks will be converted into CodeMirror Editors, and a run button will be added. If you're not interested +in the code being editable, take a look at the v1.1 tag. + +Only the text (not tags) in the block will be executed, feel free to wrap your already-syntax-highlighted code. + +The code editor will assume the height + 10px and width of the code element. + +````html +
          
          +$ ->
          +  alert "Testing!"
          +
          +```` + +````javascript +$(function(){ + $('body').executr(); +}); +```` + +You can also make javascript executable, by either adding a `data-type="javascript"` attribute to the code +block, or by adding `defaultType: 'javascript'` to the executr call. + +````html + +alert("Testing!"); + +```` + +### Other Options + +$.executr can be passed the following options + +````coffeescript +{ + codeSelector: 'code[executable]' # The jQuery selector items to be bound must match + + outputTo: 'div.output' # An element which should receive the output. + appendOutput: true # Whether output should replace the contents of outputTo, or append to it + + defaultType: 'coffeescript' # The default source languange, if not supplied as a data-type attribute + type: 'coffeescript' # The type to force on all code blocks, even if otherwise specified. Can also be a function. + coffeeOptions: {} # Extra options for the CoffeeScript compiler + + codeMirrorOptions: {} # Extra options for CodeMirror + + setUp: -> # Code to run before each code block + tearDown: -> # Code to run after each code block +} +```` + +#### Events + +Executr will fire two events on the element it is bound to: + +- `executrBeforeExecute(code string, normalized code language, executr options)` +- `executrAfterExecute(code output, code string, normalized code language, executr options)` + +#### Contributing + +You can build the project by running `./build.sh`. It requires the CoffeeScript compiler. diff --git a/bower_components/messenger/docs/welcome/lib/executr/build.sh b/bower_components/messenger/docs/welcome/lib/executr/build.sh new file mode 100755 index 0000000..c9b1500 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/build.sh @@ -0,0 +1,4 @@ +cp src/css/* build/css + +coffee -o build/js src/coffee + diff --git a/bower_components/messenger/docs/welcome/lib/executr/build/css/executr.css b/bower_components/messenger/docs/welcome/lib/executr/build/css/executr.css new file mode 100644 index 0000000..8b80bf8 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/build/css/executr.css @@ -0,0 +1,38 @@ +code[executable] { + display: block; +} + +.executr-code-editor { + overflow: hidden; + position: relative; + box-sizing: border-box; +} +.executr-code-editor .CodeMirror pre { + box-shadow: none; + border-width: 0; + line-height: 1.3; + font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; + font-size: 13px; +} +.executr-code-editor .executr-run-button { + width: 84px; + padding: 0 10px; + font-size: 24px; + z-index: 5; + border-width: 0; + background-color: #DDD; + + position: absolute; + top: 0; + bottom: 0; + right: 0; + + opacity: 0.5; +} +.executr-code-editor .executr-run-button:hover { + opacity: 0.8; +} + +.CodeMirror { + height: auto; +} \ No newline at end of file diff --git a/bower_components/messenger/docs/welcome/lib/executr/build/js/executr.js b/bower_components/messenger/docs/welcome/lib/executr/build/js/executr.js new file mode 100644 index 0000000..2023796 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/build/js/executr.js @@ -0,0 +1,217 @@ +(function() { + var Editor, converters, getCodeElement, insertOutput, normalizeType, runners; + var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + runners = { + 'javascript': function(opts, code) { + return eval(code); + } + }; + converters = { + 'coffeescript:javascript': function(opts, code) { + var csOptions; + csOptions = $.extend({}, opts.coffeeOptions, { + bare: true + }); + return CoffeeScript.compile(code, csOptions); + }, + 'javascript:coffeescript': function(opts, code) { + var out; + if (Js2coffee) { + return out = Js2coffee.build(code); + } else { + console.error("Can't convert javascript to coffeescript"); + return code; + } + } + }; + normalizeType = function(codeType) { + switch (codeType.toLowerCase()) { + case 'js': + case 'javascript': + case 'text/javascript': + case 'application/javascript': + return 'javascript'; + case 'cs': + case 'coffee': + case 'coffeescript': + case 'text/coffeescript': + case 'application/coffeescript': + return 'coffeescript'; + default: + return console.error("Code type " + codeType + " not understood."); + } + }; + Editor = (function() { + function Editor(args) { + this.el = args.el; + this.opts = args.opts; + this.codeCache = {}; + this.$el = $(this.el); + this.buildEditor(); + this.addRunButton(); + this.addListeners(); + } + Editor.prototype.getValue = function() { + return this.editor.getValue(); + }; + Editor.prototype.addListeners = function() { + return this.$el.on('executrSwitchType', __bind(function(e, type) { + return this.switchType(type); + }, this)); + }; + Editor.prototype.addRunButton = function() { + this.$runButton = $(' + + diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/LICENSE b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/LICENSE new file mode 100644 index 0000000..482d55e --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/LICENSE @@ -0,0 +1,23 @@ +Copyright (C) 2013 by Marijn Haverbeke + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Please note that some subdirectories of the CodeMirror distribution +include their own LICENSE files, and are released under different +licences. diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.css b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.css new file mode 100644 index 0000000..1ceb080 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.css @@ -0,0 +1,240 @@ +/* BASICS */ + +.CodeMirror { + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; +} +.CodeMirror-scroll { + /* Set scrolling behaviour here */ + overflow: auto; +} + +/* PADDING */ + +.CodeMirror-lines { + padding: 4px 0; /* Vertical padding around content */ +} +.CodeMirror pre { + padding: 0 4px; /* Horizontal padding of content */ +} + +.CodeMirror-scrollbar-filler { + background-color: white; /* The little square between H and V scrollbars */ +} + +/* GUTTER */ + +.CodeMirror-gutters { + border-right: 1px solid #ddd; + background-color: #f7f7f7; +} +.CodeMirror-linenumbers {} +.CodeMirror-linenumber { + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; +} + +/* CURSOR */ + +.CodeMirror div.CodeMirror-cursor { + border-left: 1px solid black; +} +/* Shown when moving in bi-directional text */ +.CodeMirror div.CodeMirror-secondarycursor { + border-left: 1px solid silver; +} +.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { + width: auto; + border: 0; + background: transparent; + background: rgba(0, 200, 0, .4); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800); +} +/* Kludge to turn off filter in ie9+, which also accepts rgba */ +.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor:not(#nonsense_id) { + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} +/* Can style cursor different in overwrite (non-insert) mode */ +.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {} + +/* DEFAULT THEME */ + +.cm-s-default .cm-keyword {color: #708;} +.cm-s-default .cm-atom {color: #219;} +.cm-s-default .cm-number {color: #164;} +.cm-s-default .cm-def {color: #00f;} +.cm-s-default .cm-variable {color: black;} +.cm-s-default .cm-variable-2 {color: #05a;} +.cm-s-default .cm-variable-3 {color: #085;} +.cm-s-default .cm-property {color: black;} +.cm-s-default .cm-operator {color: black;} +.cm-s-default .cm-comment {color: #a50;} +.cm-s-default .cm-string {color: #a11;} +.cm-s-default .cm-string-2 {color: #f50;} +.cm-s-default .cm-meta {color: #555;} +.cm-s-default .cm-error {color: #f00;} +.cm-s-default .cm-qualifier {color: #555;} +.cm-s-default .cm-builtin {color: #30a;} +.cm-s-default .cm-bracket {color: #997;} +.cm-s-default .cm-tag {color: #170;} +.cm-s-default .cm-attribute {color: #00c;} +.cm-s-default .cm-header {color: blue;} +.cm-s-default .cm-quote {color: #090;} +.cm-s-default .cm-hr {color: #999;} +.cm-s-default .cm-link {color: #00c;} + +.cm-negative {color: #d44;} +.cm-positive {color: #292;} +.cm-header, .cm-strong {font-weight: bold;} +.cm-em {font-style: italic;} +.cm-emstrong {font-style: italic; font-weight: bold;} +.cm-link {text-decoration: underline;} + +.cm-invalidchar {color: #f00;} + +div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} + +/* STOP */ + +/* The rest of this file contains styles related to the mechanics of + the editor. You probably shouldn't touch them. */ + +.CodeMirror { + line-height: 1; + position: relative; + overflow: hidden; +} + +.CodeMirror-scroll { + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror, and the paddings in .CodeMirror-sizer */ + margin-bottom: -30px; margin-right: -30px; + padding-bottom: 30px; padding-right: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; +} +.CodeMirror-sizer { + position: relative; +} + +/* The fake, visible scrollbars. Used to force redraw during scrolling + before actuall scrolling happens, thus preventing shaking and + flickering artifacts. */ +.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler { + position: absolute; + z-index: 6; + display: none; +} +.CodeMirror-vscrollbar { + right: 0; top: 0; + overflow-x: hidden; + overflow-y: scroll; +} +.CodeMirror-hscrollbar { + bottom: 0; left: 0; + overflow-y: hidden; + overflow-x: scroll; +} +.CodeMirror-scrollbar-filler { + right: 0; bottom: 0; + z-index: 6; +} + +.CodeMirror-gutters { + position: absolute; left: 0; top: 0; + height: 100%; + z-index: 3; +} +.CodeMirror-gutter { + height: 100%; + display: inline-block; + /* Hack to make IE7 behave */ + *zoom:1; + *display:inline; +} +.CodeMirror-gutter-elt { + position: absolute; + cursor: default; + z-index: 4; +} + +.CodeMirror-lines { + cursor: text; +} +.CodeMirror pre { + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; -webkit-border-radius: 0; -o-border-radius: 0; border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; +} +.CodeMirror-wrap pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; +} +.CodeMirror-linebackground { + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 0; +} + +.CodeMirror-linewidget { + position: relative; + z-index: 2; + overflow: auto; +} + +.CodeMirror-wrap .CodeMirror-scroll { + overflow-x: hidden; +} + +.CodeMirror-measure { + position: absolute; + width: 100%; height: 0px; + overflow: hidden; + visibility: hidden; +} +.CodeMirror-measure pre { position: static; } + +.CodeMirror div.CodeMirror-cursor { + position: absolute; + visibility: hidden; + border-right: none; + width: 0; +} +.CodeMirror-focused div.CodeMirror-cursor { + visibility: visible; +} + +.CodeMirror-selected { background: #d9d9d9; } +.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } + +.cm-searching { + background: #ffa; + background: rgba(255, 255, 0, .4); +} + +/* IE7 hack to prevent it from returning funny offsetTops on the spans */ +.CodeMirror span { *vertical-align: text-bottom; } + +@media print { + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursor { + visibility: hidden; + } +} diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.js b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.js new file mode 100644 index 0000000..8fa0e94 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/codemirror.js @@ -0,0 +1,4786 @@ +// CodeMirror version 3.02 +// +// CodeMirror is the only global var we claim +window.CodeMirror = (function() { + "use strict"; + + // BROWSER SNIFFING + + // Crude, but necessary to handle a number of hard-to-feature-detect + // bugs and behavior differences. + var gecko = /gecko\/\d/i.test(navigator.userAgent); + var ie = /MSIE \d/.test(navigator.userAgent); + var ie_lt8 = ie && (document.documentMode == null || document.documentMode < 8); + var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9); + var webkit = /WebKit\//.test(navigator.userAgent); + var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); + var chrome = /Chrome\//.test(navigator.userAgent); + var opera = /Opera\//.test(navigator.userAgent); + var safari = /Apple Computer/.test(navigator.vendor); + var khtml = /KHTML\//.test(navigator.userAgent); + var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent); + var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); + var phantom = /PhantomJS/.test(navigator.userAgent); + + var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); + // This is woefully incomplete. Suggestions for alternative methods welcome. + var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); + var mac = ios || /Mac/.test(navigator.platform); + var windows = /windows/i.test(navigator.platform); + + var opera_version = opera && navigator.userAgent.match(/Version\/(\d*\.\d*)/); + if (opera_version) opera_version = Number(opera_version[1]); + // Some browsers use the wrong event properties to signal cmd/ctrl on OS X + var flipCtrlCmd = mac && (qtwebkit || opera && (opera_version == null || opera_version < 12.11)); + + // Optimize some code when these features are not used + var sawReadOnlySpans = false, sawCollapsedSpans = false; + + // CONSTRUCTOR + + function CodeMirror(place, options) { + if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); + + this.options = options = options || {}; + // Determine effective options based on given values and defaults. + for (var opt in defaults) if (!options.hasOwnProperty(opt) && defaults.hasOwnProperty(opt)) + options[opt] = defaults[opt]; + setGuttersForLineNumbers(options); + + var display = this.display = makeDisplay(place); + display.wrapper.CodeMirror = this; + updateGutters(this); + if (options.autofocus && !mobile) focusInput(this); + + this.view = makeView(new BranchChunk([new LeafChunk([makeLine("", null, textHeight(display))])])); + this.nextOpId = 0; + loadMode(this); + themeChanged(this); + if (options.lineWrapping) + this.display.wrapper.className += " CodeMirror-wrap"; + + // Initialize the content. + this.setValue(options.value || ""); + // Override magic textarea content restore that IE sometimes does + // on our hidden textarea on reload + if (ie) setTimeout(bind(resetInput, this, true), 20); + this.view.history = makeHistory(); + + registerEventHandlers(this); + // IE throws unspecified error in certain cases, when + // trying to access activeElement before onload + var hasFocus; try { hasFocus = (document.activeElement == display.input); } catch(e) { } + if (hasFocus || (options.autofocus && !mobile)) setTimeout(bind(onFocus, this), 20); + else onBlur(this); + + operation(this, function() { + for (var opt in optionHandlers) + if (optionHandlers.propertyIsEnumerable(opt)) + optionHandlers[opt](this, options[opt], Init); + for (var i = 0; i < initHooks.length; ++i) initHooks[i](this); + })(); + } + + // DISPLAY CONSTRUCTOR + + function makeDisplay(place) { + var d = {}; + var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none;"); + if (webkit) input.style.width = "1000px"; + else input.setAttribute("wrap", "off"); + input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); + // Wraps and hides input textarea + d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); + // The actual fake scrollbars. + d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar"); + d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar"); + d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); + // DIVs containing the selection and the actual code + d.lineDiv = elt("div"); + d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); + // Blinky cursor, and element used to ensure cursor fits at the end of a line + d.cursor = elt("div", "\u00a0", "CodeMirror-cursor"); + // Secondary cursor, shown when on a 'jump' in bi-directional text + d.otherCursor = elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"); + // Used to measure text size + d.measure = elt("div", null, "CodeMirror-measure"); + // Wraps everything that needs to exist inside the vertically-padded coordinate system + d.lineSpace = elt("div", [d.measure, d.selectionDiv, d.lineDiv, d.cursor, d.otherCursor], + null, "position: relative; outline: none"); + // Moved around its parent to cover visible view + d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); + // Set to the height of the text, causes scrolling + d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); + // D is needed because behavior of elts with overflow: auto and padding is inconsistent across browsers + d.heightForcer = elt("div", "\u00a0", null, "position: absolute; height: " + scrollerCutOff + "px"); + // Will contain the gutters, if any + d.gutters = elt("div", null, "CodeMirror-gutters"); + d.lineGutter = null; + // Helper element to properly size the gutter backgrounds + var scrollerInner = elt("div", [d.sizer, d.heightForcer, d.gutters], null, "position: relative; min-height: 100%"); + // Provides scrolling + d.scroller = elt("div", [scrollerInner], "CodeMirror-scroll"); + d.scroller.setAttribute("tabIndex", "-1"); + // The element in which the editor lives. + d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV, + d.scrollbarFiller, d.scroller], "CodeMirror"); + // Work around IE7 z-index bug + if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } + if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper); + + // Needed to hide big blue blinking cursor on Mobile Safari + if (ios) input.style.width = "0px"; + if (!webkit) d.scroller.draggable = true; + // Needed to handle Tab key in KHTML + if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; } + // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). + else if (ie_lt8) d.scrollbarH.style.minWidth = d.scrollbarV.style.minWidth = "18px"; + + // Current visible range (may be bigger than the view window). + d.viewOffset = d.showingFrom = d.showingTo = d.lastSizeC = 0; + + // Used to only resize the line number gutter when necessary (when + // the amount of lines crosses a boundary that makes its width change) + d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; + // See readInput and resetInput + d.prevInput = ""; + // Set to true when a non-horizontal-scrolling widget is added. As + // an optimization, widget aligning is skipped when d is false. + d.alignWidgets = false; + // Flag that indicates whether we currently expect input to appear + // (after some event like 'keypress' or 'input') and are polling + // intensively. + d.pollingFast = false; + // Self-resetting timeout for the poller + d.poll = new Delayed(); + // True when a drag from the editor is active + d.draggingText = false; + + d.cachedCharWidth = d.cachedTextHeight = null; + d.measureLineCache = []; + d.measureLineCachePos = 0; + + // Tracks when resetInput has punted to just putting a short + // string instead of the (large) selection. + d.inaccurateSelection = false; + + // Used to adjust overwrite behaviour when a paste has been + // detected + d.pasteIncoming = false; + + // Used for measuring wheel scrolling granularity + d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; + + return d; + } + + // VIEW CONSTRUCTOR + + function makeView(doc) { + var selPos = {line: 0, ch: 0}; + return { + doc: doc, + // frontier is the point up to which the content has been parsed, + frontier: 0, highlight: new Delayed(), + sel: {from: selPos, to: selPos, head: selPos, anchor: selPos, shift: false, extend: false}, + scrollTop: 0, scrollLeft: 0, + overwrite: false, focused: false, + // Tracks the maximum line length so that + // the horizontal scrollbar can be kept + // static when scrolling. + maxLine: getLine(doc, 0), + maxLineLength: 0, + maxLineChanged: false, + suppressEdits: false, + goalColumn: null, + cantEdit: false, + keyMaps: [], + overlays: [], + modeGen: 0 + }; + } + + // STATE UPDATES + + // Used to get the editor into a consistent state again when options change. + + function loadMode(cm) { + var doc = cm.view.doc; + cm.view.mode = CodeMirror.getMode(cm.options, cm.options.mode); + doc.iter(0, doc.size, function(line) { + if (line.stateAfter) line.stateAfter = null; + if (line.styles) line.styles = null; + }); + cm.view.frontier = 0; + startWorker(cm, 100); + cm.view.modeGen++; + if (cm.curOp) regChange(cm, 0, doc.size); + } + + function wrappingChanged(cm) { + var doc = cm.view.doc, th = textHeight(cm.display); + if (cm.options.lineWrapping) { + cm.display.wrapper.className += " CodeMirror-wrap"; + var perLine = cm.display.scroller.clientWidth / charWidth(cm.display) - 3; + doc.iter(0, doc.size, function(line) { + if (line.height == 0) return; + var guess = Math.ceil(line.text.length / perLine) || 1; + if (guess != 1) updateLineHeight(line, guess * th); + }); + cm.display.sizer.style.minWidth = ""; + } else { + cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-wrap", ""); + computeMaxLength(cm.view); + doc.iter(0, doc.size, function(line) { + if (line.height != 0) updateLineHeight(line, th); + }); + } + regChange(cm, 0, doc.size); + clearCaches(cm); + setTimeout(function(){updateScrollbars(cm.display, cm.view.doc.height);}, 100); + } + + function keyMapChanged(cm) { + var style = keyMap[cm.options.keyMap].style; + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") + + (style ? " cm-keymap-" + style : ""); + } + + function themeChanged(cm) { + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); + clearCaches(cm); + } + + function guttersChanged(cm) { + updateGutters(cm); + updateDisplay(cm, true); + } + + function updateGutters(cm) { + var gutters = cm.display.gutters, specs = cm.options.gutters; + removeChildren(gutters); + for (var i = 0; i < specs.length; ++i) { + var gutterClass = specs[i]; + var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); + if (gutterClass == "CodeMirror-linenumbers") { + cm.display.lineGutter = gElt; + gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; + } + } + gutters.style.display = i ? "" : "none"; + } + + function lineLength(doc, line) { + if (line.height == 0) return 0; + var len = line.text.length, merged, cur = line; + while (merged = collapsedSpanAtStart(cur)) { + var found = merged.find(); + cur = getLine(doc, found.from.line); + len += found.from.ch - found.to.ch; + } + cur = line; + while (merged = collapsedSpanAtEnd(cur)) { + var found = merged.find(); + len -= cur.text.length - found.from.ch; + cur = getLine(doc, found.to.line); + len += cur.text.length - found.to.ch; + } + return len; + } + + function computeMaxLength(view) { + view.maxLine = getLine(view.doc, 0); + view.maxLineLength = lineLength(view.doc, view.maxLine); + view.maxLineChanged = true; + view.doc.iter(1, view.doc.size, function(line) { + var len = lineLength(view.doc, line); + if (len > view.maxLineLength) { + view.maxLineLength = len; + view.maxLine = line; + } + }); + } + + // Make sure the gutters options contains the element + // "CodeMirror-linenumbers" when the lineNumbers option is true. + function setGuttersForLineNumbers(options) { + var found = false; + for (var i = 0; i < options.gutters.length; ++i) { + if (options.gutters[i] == "CodeMirror-linenumbers") { + if (options.lineNumbers) found = true; + else options.gutters.splice(i--, 1); + } + } + if (!found && options.lineNumbers) + options.gutters.push("CodeMirror-linenumbers"); + } + + // SCROLLBARS + + // Re-synchronize the fake scrollbars with the actual size of the + // content. Optionally force a scrollTop. + function updateScrollbars(d /* display */, docHeight) { + var totalHeight = docHeight + 2 * paddingTop(d); + d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px"; + var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight); + var needsH = d.scroller.scrollWidth > d.scroller.clientWidth; + var needsV = scrollHeight > d.scroller.clientHeight; + if (needsV) { + d.scrollbarV.style.display = "block"; + d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0"; + d.scrollbarV.firstChild.style.height = + (scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px"; + } else d.scrollbarV.style.display = ""; + if (needsH) { + d.scrollbarH.style.display = "block"; + d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0"; + d.scrollbarH.firstChild.style.width = + (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px"; + } else d.scrollbarH.style.display = ""; + if (needsH && needsV) { + d.scrollbarFiller.style.display = "block"; + d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px"; + } else d.scrollbarFiller.style.display = ""; + + if (mac_geLion && scrollbarWidth(d.measure) === 0) + d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px"; + } + + function visibleLines(display, doc, viewPort) { + var top = display.scroller.scrollTop, height = display.wrapper.clientHeight; + if (typeof viewPort == "number") top = viewPort; + else if (viewPort) {top = viewPort.top; height = viewPort.bottom - viewPort.top;} + top = Math.floor(top - paddingTop(display)); + var bottom = Math.ceil(top + height); + return {from: lineAtHeight(doc, top), to: lineAtHeight(doc, bottom)}; + } + + // LINE NUMBERS + + function alignHorizontally(cm) { + var display = cm.display; + if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return; + var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.view.scrollLeft; + var gutterW = display.gutters.offsetWidth, l = comp + "px"; + for (var n = display.lineDiv.firstChild; n; n = n.nextSibling) if (n.alignable) { + for (var i = 0, a = n.alignable; i < a.length; ++i) a[i].style.left = l; + } + if (cm.options.fixedGutter) + display.gutters.style.left = (comp + gutterW) + "px"; + } + + function maybeUpdateLineNumberWidth(cm) { + if (!cm.options.lineNumbers) return false; + var doc = cm.view.doc, last = lineNumberFor(cm.options, doc.size - 1), display = cm.display; + if (last.length != display.lineNumChars) { + var test = display.measure.appendChild(elt("div", [elt("div", last)], + "CodeMirror-linenumber CodeMirror-gutter-elt")); + var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; + display.lineGutter.style.width = ""; + display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding); + display.lineNumWidth = display.lineNumInnerWidth + padding; + display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; + display.lineGutter.style.width = display.lineNumWidth + "px"; + return true; + } + return false; + } + + function lineNumberFor(options, i) { + return String(options.lineNumberFormatter(i + options.firstLineNumber)); + } + function compensateForHScroll(display) { + return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; + } + + // DISPLAY DRAWING + + function updateDisplay(cm, changes, viewPort) { + var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo; + var updated = updateDisplayInner(cm, changes, viewPort); + if (updated) { + signalLater(cm, cm, "update", cm); + if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo) + signalLater(cm, cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo); + } + updateSelection(cm); + updateScrollbars(cm.display, cm.view.doc.height); + + return updated; + } + + // Uses a set of changes plus the current scroll position to + // determine which DOM updates have to be made, and makes the + // updates. + function updateDisplayInner(cm, changes, viewPort) { + var display = cm.display, doc = cm.view.doc; + if (!display.wrapper.clientWidth) { + display.showingFrom = display.showingTo = display.viewOffset = 0; + return; + } + + // Compute the new visible window + // If scrollTop is specified, use that to determine which lines + // to render instead of the current scrollbar position. + var visible = visibleLines(display, doc, viewPort); + // Bail out if the visible area is already rendered and nothing changed. + if (changes !== true && changes.length == 0 && + visible.from > display.showingFrom && visible.to < display.showingTo) + return; + + if (changes && maybeUpdateLineNumberWidth(cm)) + changes = true; + var gutterW = display.sizer.style.marginLeft = display.gutters.offsetWidth + "px"; + display.scrollbarH.style.left = cm.options.fixedGutter ? gutterW : "0"; + + // When merged lines are present, the line that needs to be + // redrawn might not be the one that was changed. + if (changes !== true && sawCollapsedSpans) + for (var i = 0; i < changes.length; ++i) { + var ch = changes[i], merged; + while (merged = collapsedSpanAtStart(getLine(doc, ch.from))) { + var from = merged.find().from.line; + if (ch.diff) ch.diff -= ch.from - from; + ch.from = from; + } + } + + // Used to determine which lines need their line numbers updated + var positionsChangedFrom = changes === true ? 0 : Infinity; + if (cm.options.lineNumbers && changes && changes !== true) + for (var i = 0; i < changes.length; ++i) + if (changes[i].diff) { positionsChangedFrom = changes[i].from; break; } + + var from = Math.max(visible.from - cm.options.viewportMargin, 0); + var to = Math.min(doc.size, visible.to + cm.options.viewportMargin); + if (display.showingFrom < from && from - display.showingFrom < 20) from = display.showingFrom; + if (display.showingTo > to && display.showingTo - to < 20) to = Math.min(doc.size, display.showingTo); + if (sawCollapsedSpans) { + from = lineNo(visualLine(doc, getLine(doc, from))); + while (to < doc.size && lineIsHidden(getLine(doc, to))) ++to; + } + + // Create a range of theoretically intact lines, and punch holes + // in that using the change info. + var intact = changes === true ? [] : + computeIntact([{from: display.showingFrom, to: display.showingTo}], changes); + // Clip off the parts that won't be visible + var intactLines = 0; + for (var i = 0; i < intact.length; ++i) { + var range = intact[i]; + if (range.from < from) range.from = from; + if (range.to > to) range.to = to; + if (range.from >= range.to) intact.splice(i--, 1); + else intactLines += range.to - range.from; + } + if (intactLines == to - from && from == display.showingFrom && to == display.showingTo) + return; + intact.sort(function(a, b) {return a.from - b.from;}); + + var focused = document.activeElement; + if (intactLines < (to - from) * .7) display.lineDiv.style.display = "none"; + patchDisplay(cm, from, to, intact, positionsChangedFrom); + display.lineDiv.style.display = ""; + if (document.activeElement != focused && focused.offsetHeight) focused.focus(); + + var different = from != display.showingFrom || to != display.showingTo || + display.lastSizeC != display.wrapper.clientHeight; + // This is just a bogus formula that detects when the editor is + // resized or the font size changes. + if (different) display.lastSizeC = display.wrapper.clientHeight; + display.showingFrom = from; display.showingTo = to; + startWorker(cm, 100); + + var prevBottom = display.lineDiv.offsetTop; + for (var node = display.lineDiv.firstChild, height; node; node = node.nextSibling) if (node.lineObj) { + if (ie_lt8) { + var bot = node.offsetTop + node.offsetHeight; + height = bot - prevBottom; + prevBottom = bot; + } else { + var box = node.getBoundingClientRect(); + height = box.bottom - box.top; + } + var diff = node.lineObj.height - height; + if (height < 2) height = textHeight(display); + if (diff > .001 || diff < -.001) { + updateLineHeight(node.lineObj, height); + var widgets = node.lineObj.widgets; + if (widgets) for (var i = 0; i < widgets.length; ++i) + widgets[i].height = widgets[i].node.offsetHeight; + } + } + display.viewOffset = heightAtLine(cm, getLine(doc, from)); + // Position the mover div to align with the current virtual scroll position + display.mover.style.top = display.viewOffset + "px"; + + if (visibleLines(display, doc, viewPort).to >= to) + updateDisplayInner(cm, [], viewPort); + return true; + } + + function computeIntact(intact, changes) { + for (var i = 0, l = changes.length || 0; i < l; ++i) { + var change = changes[i], intact2 = [], diff = change.diff || 0; + for (var j = 0, l2 = intact.length; j < l2; ++j) { + var range = intact[j]; + if (change.to <= range.from && change.diff) { + intact2.push({from: range.from + diff, to: range.to + diff}); + } else if (change.to <= range.from || change.from >= range.to) { + intact2.push(range); + } else { + if (change.from > range.from) + intact2.push({from: range.from, to: change.from}); + if (change.to < range.to) + intact2.push({from: change.to + diff, to: range.to + diff}); + } + } + intact = intact2; + } + return intact; + } + + function getDimensions(cm) { + var d = cm.display, left = {}, width = {}; + for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { + left[cm.options.gutters[i]] = n.offsetLeft; + width[cm.options.gutters[i]] = n.offsetWidth; + } + return {fixedPos: compensateForHScroll(d), + gutterTotalWidth: d.gutters.offsetWidth, + gutterLeft: left, + gutterWidth: width, + wrapperWidth: d.wrapper.clientWidth}; + } + + function patchDisplay(cm, from, to, intact, updateNumbersFrom) { + var dims = getDimensions(cm); + var display = cm.display, lineNumbers = cm.options.lineNumbers; + if (!intact.length && (!webkit || !cm.display.currentWheelTarget)) + removeChildren(display.lineDiv); + var container = display.lineDiv, cur = container.firstChild; + + function rm(node) { + var next = node.nextSibling; + if (webkit && mac && cm.display.currentWheelTarget == node) { + node.style.display = "none"; + node.lineObj = null; + } else { + node.parentNode.removeChild(node); + } + return next; + } + + var nextIntact = intact.shift(), lineNo = from; + cm.view.doc.iter(from, to, function(line) { + if (nextIntact && nextIntact.to == lineNo) nextIntact = intact.shift(); + if (lineIsHidden(line)) { + if (line.height != 0) updateLineHeight(line, 0); + if (line.widgets && cur.previousSibling) for (var i = 0; i < line.widgets.length; ++i) + if (line.widgets[i].showIfHidden) { + var prev = cur.previousSibling; + if (prev.nodeType == "pre") { + var wrap = elt("div", null, null, "position: relative"); + prev.parentNode.replaceChild(wrap, prev); + wrap.appendChild(prev); + prev = wrap; + } + prev.appendChild(buildLineWidget(line.widgets[i], prev, dims)); + } + } else if (nextIntact && nextIntact.from <= lineNo && nextIntact.to > lineNo) { + // This line is intact. Skip to the actual node. Update its + // line number if needed. + while (cur.lineObj != line) cur = rm(cur); + if (lineNumbers && updateNumbersFrom <= lineNo && cur.lineNumber) + setTextContent(cur.lineNumber, lineNumberFor(cm.options, lineNo)); + cur = cur.nextSibling; + } else { + // This line needs to be generated. + var lineNode = buildLineElement(cm, line, lineNo, dims); + container.insertBefore(lineNode, cur); + lineNode.lineObj = line; + } + ++lineNo; + }); + while (cur) cur = rm(cur); + } + + function buildLineElement(cm, line, lineNo, dims) { + var lineElement = lineContent(cm, line); + var markers = line.gutterMarkers, display = cm.display; + + if (!cm.options.lineNumbers && !markers && !line.bgClass && !line.wrapClass && + (!line.widgets || !line.widgets.length)) return lineElement; + + // Lines with gutter elements or a background class need + // to be wrapped again, and have the extra elements added + // to the wrapper div + + var wrap = elt("div", null, line.wrapClass, "position: relative"); + if (cm.options.lineNumbers || markers) { + var gutterWrap = wrap.appendChild(elt("div", null, null, "position: absolute; left: " + + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px")); + if (cm.options.fixedGutter) wrap.alignable = [gutterWrap]; + if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) + wrap.lineNumber = gutterWrap.appendChild( + elt("div", lineNumberFor(cm.options, lineNo), + "CodeMirror-linenumber CodeMirror-gutter-elt", + "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + + display.lineNumInnerWidth + "px")); + if (markers) + for (var k = 0; k < cm.options.gutters.length; ++k) { + var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; + if (found) + gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); + } + } + // Kludge to make sure the styled element lies behind the selection (by z-index) + if (line.bgClass) + wrap.appendChild(elt("div", "\u00a0", line.bgClass + " CodeMirror-linebackground")); + wrap.appendChild(lineElement); + if (line.widgets) for (var i = 0, ws = line.widgets; i < ws.length; ++i) { + var widget = ws[i], node = buildLineWidget(widget, wrap, dims); + if (widget.above) + wrap.insertBefore(node, cm.options.lineNumbers && line.height != 0 ? gutterWrap : lineElement); + else + wrap.appendChild(node); + } + if (ie_lt8) wrap.style.zIndex = 2; + return wrap; + } + + function buildLineWidget(widget, wrap, dims) { + var node = elt("div", [widget.node], "CodeMirror-linewidget"); + node.widget = widget; + if (widget.noHScroll) { + (wrap.alignable || (wrap.alignable = [])).push(node); + var width = dims.wrapperWidth; + node.style.left = dims.fixedPos + "px"; + if (!widget.coverGutter) { + width -= dims.gutterTotalWidth; + node.style.paddingLeft = dims.gutterTotalWidth + "px"; + } + node.style.width = width + "px"; + } + if (widget.coverGutter) { + node.style.zIndex = 5; + node.style.position = "relative"; + if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px"; + } + return node; + } + + // SELECTION / CURSOR + + function updateSelection(cm) { + var display = cm.display; + var collapsed = posEq(cm.view.sel.from, cm.view.sel.to); + if (collapsed || cm.options.showCursorWhenSelecting) + updateSelectionCursor(cm); + else + display.cursor.style.display = display.otherCursor.style.display = "none"; + if (!collapsed) + updateSelectionRange(cm); + else + display.selectionDiv.style.display = "none"; + + // Move the hidden textarea near the cursor to prevent scrolling artifacts + var headPos = cursorCoords(cm, cm.view.sel.head, "div"); + var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); + display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10, + headPos.top + lineOff.top - wrapOff.top)) + "px"; + display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10, + headPos.left + lineOff.left - wrapOff.left)) + "px"; + } + + // No selection, plain cursor + function updateSelectionCursor(cm) { + var display = cm.display, pos = cursorCoords(cm, cm.view.sel.head, "div"); + display.cursor.style.left = pos.left + "px"; + display.cursor.style.top = pos.top + "px"; + display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; + display.cursor.style.display = ""; + + if (pos.other) { + display.otherCursor.style.display = ""; + display.otherCursor.style.left = pos.other.left + "px"; + display.otherCursor.style.top = pos.other.top + "px"; + display.otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; + } else { display.otherCursor.style.display = "none"; } + } + + // Highlight selection + function updateSelectionRange(cm) { + var display = cm.display, doc = cm.view.doc, sel = cm.view.sel; + var fragment = document.createDocumentFragment(); + var clientWidth = display.lineSpace.offsetWidth, pl = paddingLeft(cm.display); + + function add(left, top, width, bottom) { + if (top < 0) top = 0; + fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + + "px; top: " + top + "px; width: " + (width == null ? clientWidth - left : width) + + "px; height: " + (bottom - top) + "px")); + } + + function drawForLine(line, fromArg, toArg, retTop) { + var lineObj = getLine(doc, line); + var lineLen = lineObj.text.length, rVal = retTop ? Infinity : -Infinity; + function coords(ch) { + return charCoords(cm, {line: line, ch: ch}, "div", lineObj); + } + + iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) { + var leftPos = coords(dir == "rtl" ? to - 1 : from); + var rightPos = coords(dir == "rtl" ? from : to - 1); + var left = leftPos.left, right = rightPos.right; + if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part + add(left, leftPos.top, null, leftPos.bottom); + left = pl; + if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top); + } + if (toArg == null && to == lineLen) right = clientWidth; + if (fromArg == null && from == 0) left = pl; + rVal = retTop ? Math.min(rightPos.top, rVal) : Math.max(rightPos.bottom, rVal); + if (left < pl + 1) left = pl; + add(left, rightPos.top, right - left, rightPos.bottom); + }); + return rVal; + } + + if (sel.from.line == sel.to.line) { + drawForLine(sel.from.line, sel.from.ch, sel.to.ch); + } else { + var fromObj = getLine(doc, sel.from.line); + var cur = fromObj, merged, path = [sel.from.line, sel.from.ch], singleLine; + while (merged = collapsedSpanAtEnd(cur)) { + var found = merged.find(); + path.push(found.from.ch, found.to.line, found.to.ch); + if (found.to.line == sel.to.line) { + path.push(sel.to.ch); + singleLine = true; + break; + } + cur = getLine(doc, found.to.line); + } + + // This is a single, merged line + if (singleLine) { + for (var i = 0; i < path.length; i += 3) + drawForLine(path[i], path[i+1], path[i+2]); + } else { + var middleTop, middleBot, toObj = getLine(doc, sel.to.line); + if (sel.from.ch) + // Draw the first line of selection. + middleTop = drawForLine(sel.from.line, sel.from.ch, null, false); + else + // Simply include it in the middle block. + middleTop = heightAtLine(cm, fromObj) - display.viewOffset; + + if (!sel.to.ch) + middleBot = heightAtLine(cm, toObj) - display.viewOffset; + else + middleBot = drawForLine(sel.to.line, collapsedSpanAtStart(toObj) ? null : 0, sel.to.ch, true); + + if (middleTop < middleBot) add(pl, middleTop, null, middleBot); + } + } + + removeChildrenAndAdd(display.selectionDiv, fragment); + display.selectionDiv.style.display = ""; + } + + // Cursor-blinking + function restartBlink(cm) { + var display = cm.display; + clearInterval(display.blinker); + var on = true; + display.cursor.style.visibility = display.otherCursor.style.visibility = ""; + display.blinker = setInterval(function() { + if (!display.cursor.offsetHeight) return; + display.cursor.style.visibility = display.otherCursor.style.visibility = (on = !on) ? "" : "hidden"; + }, cm.options.cursorBlinkRate); + } + + // HIGHLIGHT WORKER + + function startWorker(cm, time) { + if (cm.view.mode.startState && cm.view.frontier < cm.display.showingTo) + cm.view.highlight.set(time, bind(highlightWorker, cm)); + } + + function highlightWorker(cm) { + var view = cm.view, doc = view.doc; + if (view.frontier >= cm.display.showingTo) return; + var end = +new Date + cm.options.workTime; + var state = copyState(view.mode, getStateBefore(cm, view.frontier)); + var changed = [], prevChange; + doc.iter(view.frontier, Math.min(doc.size, cm.display.showingTo + 500), function(line) { + if (view.frontier >= cm.display.showingFrom) { // Visible + var oldStyles = line.styles; + line.styles = highlightLine(cm, line, state); + var ischange = !oldStyles || oldStyles.length != line.styles.length; + for (var i = 0; !ischange && i < oldStyles.length; ++i) + ischange = oldStyles[i] != line.styles[i]; + if (ischange) { + if (prevChange && prevChange.end == view.frontier) prevChange.end++; + else changed.push(prevChange = {start: view.frontier, end: view.frontier + 1}); + } + line.stateAfter = copyState(view.mode, state); + } else { + processLine(cm, line, state); + line.stateAfter = view.frontier % 5 == 0 ? copyState(view.mode, state) : null; + } + ++view.frontier; + if (+new Date > end) { + startWorker(cm, cm.options.workDelay); + return true; + } + }); + if (changed.length) + operation(cm, function() { + for (var i = 0; i < changed.length; ++i) + regChange(this, changed[i].start, changed[i].end); + })(); + } + + // Finds the line to start with when starting a parse. Tries to + // find a line with a stateAfter, so that it can start with a + // valid state. If that fails, it returns the line with the + // smallest indentation, which tends to need the least context to + // parse correctly. + function findStartLine(cm, n) { + var minindent, minline, doc = cm.view.doc; + for (var search = n, lim = n - 100; search > lim; --search) { + if (search == 0) return 0; + var line = getLine(doc, search-1); + if (line.stateAfter) return search; + var indented = countColumn(line.text, null, cm.options.tabSize); + if (minline == null || minindent > indented) { + minline = search - 1; + minindent = indented; + } + } + return minline; + } + + function getStateBefore(cm, n) { + var view = cm.view; + if (!view.mode.startState) return true; + var pos = findStartLine(cm, n), state = pos && getLine(view.doc, pos-1).stateAfter; + if (!state) state = startState(view.mode); + else state = copyState(view.mode, state); + view.doc.iter(pos, n, function(line) { + processLine(cm, line, state); + var save = pos == n - 1 || pos % 5 == 0 || pos >= view.showingFrom && pos < view.showingTo; + line.stateAfter = save ? copyState(view.mode, state) : null; + ++pos; + }); + return state; + } + + // POSITION MEASUREMENT + + function paddingTop(display) {return display.lineSpace.offsetTop;} + function paddingLeft(display) { + var e = removeChildrenAndAdd(display.measure, elt("pre")).appendChild(elt("span", "x")); + return e.offsetLeft; + } + + function measureChar(cm, line, ch, data) { + var dir = -1; + data = data || measureLine(cm, line); + + for (var pos = ch;; pos += dir) { + var r = data[pos]; + if (r) break; + if (dir < 0 && pos == 0) dir = 1; + } + return {left: pos < ch ? r.right : r.left, + right: pos > ch ? r.left : r.right, + top: r.top, bottom: r.bottom}; + } + + function measureLine(cm, line) { + // First look in the cache + var display = cm.display, cache = cm.display.measureLineCache; + for (var i = 0; i < cache.length; ++i) { + var memo = cache[i]; + if (memo.text == line.text && memo.markedSpans == line.markedSpans && + display.scroller.clientWidth == memo.width) + return memo.measure; + } + + var measure = measureLineInner(cm, line); + // Store result in the cache + var memo = {text: line.text, width: display.scroller.clientWidth, + markedSpans: line.markedSpans, measure: measure}; + if (cache.length == 16) cache[++display.measureLineCachePos % 16] = memo; + else cache.push(memo); + return measure; + } + + function measureLineInner(cm, line) { + var display = cm.display, measure = emptyArray(line.text.length); + var pre = lineContent(cm, line, measure); + + // IE does not cache element positions of inline elements between + // calls to getBoundingClientRect. This makes the loop below, + // which gathers the positions of all the characters on the line, + // do an amount of layout work quadratic to the number of + // characters. When line wrapping is off, we try to improve things + // by first subdividing the line into a bunch of inline blocks, so + // that IE can reuse most of the layout information from caches + // for those blocks. This does interfere with line wrapping, so it + // doesn't work when wrapping is on, but in that case the + // situation is slightly better, since IE does cache line-wrapping + // information and only recomputes per-line. + if (ie && !ie_lt8 && !cm.options.lineWrapping && pre.childNodes.length > 100) { + var fragment = document.createDocumentFragment(); + var chunk = 10, n = pre.childNodes.length; + for (var i = 0, chunks = Math.ceil(n / chunk); i < chunks; ++i) { + var wrap = elt("div", null, null, "display: inline-block"); + for (var j = 0; j < chunk && n; ++j) { + wrap.appendChild(pre.firstChild); + --n; + } + fragment.appendChild(wrap); + } + pre.appendChild(fragment); + } + + removeChildrenAndAdd(display.measure, pre); + + var outer = display.lineDiv.getBoundingClientRect(); + var vranges = [], data = emptyArray(line.text.length), maxBot = pre.offsetHeight; + for (var i = 0, cur; i < measure.length; ++i) if (cur = measure[i]) { + var size = cur.getBoundingClientRect(); + var top = Math.max(0, size.top - outer.top), bot = Math.min(size.bottom - outer.top, maxBot); + for (var j = 0; j < vranges.length; j += 2) { + var rtop = vranges[j], rbot = vranges[j+1]; + if (rtop > bot || rbot < top) continue; + if (rtop <= top && rbot >= bot || + top <= rtop && bot >= rbot || + Math.min(bot, rbot) - Math.max(top, rtop) >= (bot - top) >> 1) { + vranges[j] = Math.min(top, rtop); + vranges[j+1] = Math.max(bot, rbot); + break; + } + } + if (j == vranges.length) vranges.push(top, bot); + data[i] = {left: size.left - outer.left, right: size.right - outer.left, top: j}; + } + for (var i = 0, cur; i < data.length; ++i) if (cur = data[i]) { + var vr = cur.top; + cur.top = vranges[vr]; cur.bottom = vranges[vr+1]; + } + return data; + } + + function clearCaches(cm) { + cm.display.measureLineCache.length = cm.display.measureLineCachePos = 0; + cm.display.cachedCharWidth = cm.display.cachedTextHeight = null; + cm.view.maxLineChanged = true; + } + + // Context is one of "line", "div" (display.lineDiv), "local"/null (editor), or "page" + function intoCoordSystem(cm, lineObj, rect, context) { + if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { + var size = widgetHeight(lineObj.widgets[i]); + rect.top += size; rect.bottom += size; + } + if (context == "line") return rect; + if (!context) context = "local"; + var yOff = heightAtLine(cm, lineObj); + if (context != "local") yOff -= cm.display.viewOffset; + if (context == "page") { + var lOff = cm.display.lineSpace.getBoundingClientRect(); + yOff += lOff.top + (window.pageYOffset || (document.documentElement || document.body).scrollTop); + var xOff = lOff.left + (window.pageXOffset || (document.documentElement || document.body).scrollLeft); + rect.left += xOff; rect.right += xOff; + } + rect.top += yOff; rect.bottom += yOff; + return rect; + } + + function charCoords(cm, pos, context, lineObj) { + if (!lineObj) lineObj = getLine(cm.view.doc, pos.line); + return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch), context); + } + + function cursorCoords(cm, pos, context, lineObj, measurement) { + lineObj = lineObj || getLine(cm.view.doc, pos.line); + if (!measurement) measurement = measureLine(cm, lineObj); + function get(ch, right) { + var m = measureChar(cm, lineObj, ch, measurement); + if (right) m.left = m.right; else m.right = m.left; + return intoCoordSystem(cm, lineObj, m, context); + } + var order = getOrder(lineObj), ch = pos.ch; + if (!order) return get(ch); + var main, other, linedir = order[0].level; + for (var i = 0; i < order.length; ++i) { + var part = order[i], rtl = part.level % 2, nb, here; + if (part.from < ch && part.to > ch) return get(ch, rtl); + var left = rtl ? part.to : part.from, right = rtl ? part.from : part.to; + if (left == ch) { + // Opera and IE return bogus offsets and widths for edges + // where the direction flips, but only for the side with the + // lower level. So we try to use the side with the higher + // level. + if (i && part.level < (nb = order[i-1]).level) here = get(nb.level % 2 ? nb.from : nb.to - 1, true); + else here = get(rtl && part.from != part.to ? ch - 1 : ch); + if (rtl == linedir) main = here; else other = here; + } else if (right == ch) { + var nb = i < order.length - 1 && order[i+1]; + if (!rtl && nb && nb.from == nb.to) continue; + if (nb && part.level < nb.level) here = get(nb.level % 2 ? nb.to - 1 : nb.from); + else here = get(rtl ? ch : ch - 1, true); + if (rtl == linedir) main = here; else other = here; + } + } + if (linedir && !ch) other = get(order[0].to - 1); + if (!main) return other; + if (other) main.other = other; + return main; + } + + // Coords must be lineSpace-local + function coordsChar(cm, x, y) { + var doc = cm.view.doc; + y += cm.display.viewOffset; + if (y < 0) return {line: 0, ch: 0, outside: true}; + var lineNo = lineAtHeight(doc, y); + if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc, doc.size - 1).text.length}; + if (x < 0) x = 0; + + for (;;) { + var lineObj = getLine(doc, lineNo); + var found = coordsCharInner(cm, lineObj, lineNo, x, y); + var merged = collapsedSpanAtEnd(lineObj); + var mergedPos = merged && merged.find(); + if (merged && found.ch >= mergedPos.from.ch) + lineNo = mergedPos.to.line; + else + return found; + } + } + + function coordsCharInner(cm, lineObj, lineNo, x, y) { + var innerOff = y - heightAtLine(cm, lineObj); + var wrongLine = false, cWidth = cm.display.wrapper.clientWidth; + var measurement = measureLine(cm, lineObj); + + function getX(ch) { + var sp = cursorCoords(cm, {line: lineNo, ch: ch}, "line", + lineObj, measurement); + wrongLine = true; + if (innerOff > sp.bottom) return Math.max(0, sp.left - cWidth); + else if (innerOff < sp.top) return sp.left + cWidth; + else wrongLine = false; + return sp.left; + } + + var bidi = getOrder(lineObj), dist = lineObj.text.length; + var from = lineLeft(lineObj), to = lineRight(lineObj); + var fromX = paddingLeft(cm.display), toX = getX(to); + + if (x > toX) return {line: lineNo, ch: to, outside: wrongLine}; + // Do a binary search between these bounds. + for (;;) { + if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { + var after = x - fromX < toX - x, ch = after ? from : to; + while (isExtendingChar.test(lineObj.text.charAt(ch))) ++ch; + return {line: lineNo, ch: ch, after: after, outside: wrongLine}; + } + var step = Math.ceil(dist / 2), middle = from + step; + if (bidi) { + middle = from; + for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1); + } + var middleX = getX(middle); + if (middleX > x) {to = middle; toX = middleX; if (wrongLine) toX += 1000; dist -= step;} + else {from = middle; fromX = middleX; dist = step;} + } + } + + var measureText; + function textHeight(display) { + if (display.cachedTextHeight != null) return display.cachedTextHeight; + if (measureText == null) { + measureText = elt("pre"); + // Measure a bunch of lines, for browsers that compute + // fractional heights. + for (var i = 0; i < 49; ++i) { + measureText.appendChild(document.createTextNode("x")); + measureText.appendChild(elt("br")); + } + measureText.appendChild(document.createTextNode("x")); + } + removeChildrenAndAdd(display.measure, measureText); + var height = measureText.offsetHeight / 50; + if (height > 3) display.cachedTextHeight = height; + removeChildren(display.measure); + return height || 1; + } + + function charWidth(display) { + if (display.cachedCharWidth != null) return display.cachedCharWidth; + var anchor = elt("span", "x"); + var pre = elt("pre", [anchor]); + removeChildrenAndAdd(display.measure, pre); + var width = anchor.offsetWidth; + if (width > 2) display.cachedCharWidth = width; + return width || 10; + } + + // OPERATIONS + + // Operations are used to wrap changes in such a way that each + // change won't have to update the cursor and display (which would + // be awkward, slow, and error-prone), but instead updates are + // batched and then all combined and executed at once. + + function startOperation(cm) { + if (cm.curOp) ++cm.curOp.depth; + else cm.curOp = { + // Nested operations delay update until the outermost one + // finishes. + depth: 1, + // An array of ranges of lines that have to be updated. See + // updateDisplay. + changes: [], + delayedCallbacks: [], + updateInput: null, + userSelChange: null, + textChanged: null, + selectionChanged: false, + updateMaxLine: false, + id: ++cm.nextOpId + }; + } + + function endOperation(cm) { + var op = cm.curOp; + if (--op.depth) return; + cm.curOp = null; + var view = cm.view, display = cm.display; + if (op.updateMaxLine) computeMaxLength(view); + if (view.maxLineChanged && !cm.options.lineWrapping) { + var width = measureChar(cm, view.maxLine, view.maxLine.text.length).right; + display.sizer.style.minWidth = (width + 3 + scrollerCutOff) + "px"; + view.maxLineChanged = false; + var maxScrollLeft = Math.max(0, display.sizer.offsetLeft + display.sizer.offsetWidth - display.scroller.clientWidth); + if (maxScrollLeft < view.scrollLeft) + setScrollLeft(cm, Math.min(display.scroller.scrollLeft, maxScrollLeft), true); + } + var newScrollPos, updated; + if (op.selectionChanged) { + var coords = cursorCoords(cm, view.sel.head); + newScrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom); + } + if (op.changes.length || newScrollPos && newScrollPos.scrollTop != null) + updated = updateDisplay(cm, op.changes, newScrollPos && newScrollPos.scrollTop); + if (!updated && op.selectionChanged) updateSelection(cm); + if (newScrollPos) scrollCursorIntoView(cm); + if (op.selectionChanged) restartBlink(cm); + + if (view.focused && op.updateInput) + resetInput(cm, op.userSelChange); + + if (op.textChanged) + signal(cm, "change", cm, op.textChanged); + if (op.selectionChanged) signal(cm, "cursorActivity", cm); + for (var i = 0; i < op.delayedCallbacks.length; ++i) op.delayedCallbacks[i](cm); + } + + // Wraps a function in an operation. Returns the wrapped function. + function operation(cm1, f) { + return function() { + var cm = cm1 || this; + startOperation(cm); + try {var result = f.apply(cm, arguments);} + finally {endOperation(cm);} + return result; + }; + } + + function regChange(cm, from, to, lendiff) { + cm.curOp.changes.push({from: from, to: to, diff: lendiff}); + } + + // INPUT HANDLING + + function slowPoll(cm) { + if (cm.view.pollingFast) return; + cm.display.poll.set(cm.options.pollInterval, function() { + readInput(cm); + if (cm.view.focused) slowPoll(cm); + }); + } + + function fastPoll(cm) { + var missed = false; + cm.display.pollingFast = true; + function p() { + var changed = readInput(cm); + if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);} + else {cm.display.pollingFast = false; slowPoll(cm);} + } + cm.display.poll.set(20, p); + } + + // prevInput is a hack to work with IME. If we reset the textarea + // on every change, that breaks IME. So we look for changes + // compared to the previous content instead. (Modern browsers have + // events that indicate IME taking place, but these are not widely + // supported or compatible enough yet to rely on.) + function readInput(cm) { + var input = cm.display.input, prevInput = cm.display.prevInput, view = cm.view, sel = view.sel; + if (!view.focused || hasSelection(input) || isReadOnly(cm)) return false; + var text = input.value; + if (text == prevInput && posEq(sel.from, sel.to)) return false; + startOperation(cm); + view.sel.shift = false; + var same = 0, l = Math.min(prevInput.length, text.length); + while (same < l && prevInput[same] == text[same]) ++same; + var from = sel.from, to = sel.to; + if (same < prevInput.length) + from = {line: from.line, ch: from.ch - (prevInput.length - same)}; + else if (view.overwrite && posEq(from, to) && !cm.display.pasteIncoming) + to = {line: to.line, ch: Math.min(getLine(cm.view.doc, to.line).text.length, to.ch + (text.length - same))}; + var updateInput = cm.curOp.updateInput; + updateDoc(cm, from, to, splitLines(text.slice(same)), "end", + cm.display.pasteIncoming ? "paste" : "input", {from: from, to: to}); + cm.curOp.updateInput = updateInput; + if (text.length > 1000) input.value = cm.display.prevInput = ""; + else cm.display.prevInput = text; + endOperation(cm); + cm.display.pasteIncoming = false; + return true; + } + + function resetInput(cm, user) { + var view = cm.view, minimal, selected; + if (!posEq(view.sel.from, view.sel.to)) { + cm.display.prevInput = ""; + minimal = hasCopyEvent && + (view.sel.to.line - view.sel.from.line > 100 || (selected = cm.getSelection()).length > 1000); + if (minimal) cm.display.input.value = "-"; + else cm.display.input.value = selected || cm.getSelection(); + if (view.focused) selectInput(cm.display.input); + } else if (user) cm.display.prevInput = cm.display.input.value = ""; + cm.display.inaccurateSelection = minimal; + } + + function focusInput(cm) { + if (cm.options.readOnly != "nocursor" && (ie || document.activeElement != cm.display.input)) + cm.display.input.focus(); + } + + function isReadOnly(cm) { + return cm.options.readOnly || cm.view.cantEdit; + } + + // EVENT HANDLERS + + function registerEventHandlers(cm) { + var d = cm.display; + on(d.scroller, "mousedown", operation(cm, onMouseDown)); + on(d.scroller, "dblclick", operation(cm, e_preventDefault)); + on(d.lineSpace, "selectstart", function(e) { + if (!eventInWidget(d, e)) e_preventDefault(e); + }); + // Gecko browsers fire contextmenu *after* opening the menu, at + // which point we can't mess with it anymore. Context menu is + // handled in onMouseDown for Gecko. + if (!gecko) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);}); + + on(d.scroller, "scroll", function() { + setScrollTop(cm, d.scroller.scrollTop); + setScrollLeft(cm, d.scroller.scrollLeft, true); + signal(cm, "scroll", cm); + }); + on(d.scrollbarV, "scroll", function() { + setScrollTop(cm, d.scrollbarV.scrollTop); + }); + on(d.scrollbarH, "scroll", function() { + setScrollLeft(cm, d.scrollbarH.scrollLeft); + }); + + on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);}); + on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);}); + + function reFocus() { if (cm.view.focused) setTimeout(bind(focusInput, cm), 0); } + on(d.scrollbarH, "mousedown", reFocus); + on(d.scrollbarV, "mousedown", reFocus); + // Prevent wrapper from ever scrolling + on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); + + if (!window.registered) window.registered = 0; + ++window.registered; + function onResize() { + // Might be a text scaling operation, clear size caches. + d.cachedCharWidth = d.cachedTextHeight = null; + clearCaches(cm); + updateDisplay(cm, true); + } + on(window, "resize", onResize); + // Above handler holds on to the editor and its data structures. + // Here we poll to unregister it when the editor is no longer in + // the document, so that it can be garbage-collected. + setTimeout(function unregister() { + for (var p = d.wrapper.parentNode; p && p != document.body; p = p.parentNode) {} + if (p) setTimeout(unregister, 5000); + else {--window.registered; off(window, "resize", onResize);} + }, 5000); + + on(d.input, "keyup", operation(cm, function(e) { + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return; + if (e_prop(e, "keyCode") == 16) cm.view.sel.shift = false; + })); + on(d.input, "input", bind(fastPoll, cm)); + on(d.input, "keydown", operation(cm, onKeyDown)); + on(d.input, "keypress", operation(cm, onKeyPress)); + on(d.input, "focus", bind(onFocus, cm)); + on(d.input, "blur", bind(onBlur, cm)); + + function drag_(e) { + if (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))) return; + e_stop(e); + } + if (cm.options.dragDrop) { + on(d.scroller, "dragstart", function(e){onDragStart(cm, e);}); + on(d.scroller, "dragenter", drag_); + on(d.scroller, "dragover", drag_); + on(d.scroller, "drop", operation(cm, onDrop)); + } + on(d.scroller, "paste", function(e){ + if (eventInWidget(d, e)) return; + focusInput(cm); + fastPoll(cm); + }); + on(d.input, "paste", function() { + d.pasteIncoming = true; + fastPoll(cm); + }); + + function prepareCopy() { + if (d.inaccurateSelection) { + d.prevInput = ""; + d.inaccurateSelection = false; + d.input.value = cm.getSelection(); + selectInput(d.input); + } + } + on(d.input, "cut", prepareCopy); + on(d.input, "copy", prepareCopy); + + // Needed to handle Tab key in KHTML + if (khtml) on(d.sizer, "mouseup", function() { + if (document.activeElement == d.input) d.input.blur(); + focusInput(cm); + }); + } + + function eventInWidget(display, e) { + for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { + if (!n) return true; + if (/\bCodeMirror-(?:line)?widget\b/.test(n.className) || + n.parentNode == display.sizer && n != display.mover) return true; + } + } + + function posFromMouse(cm, e, liberal) { + var display = cm.display; + if (!liberal) { + var target = e_target(e); + if (target == display.scrollbarH || target == display.scrollbarH.firstChild || + target == display.scrollbarV || target == display.scrollbarV.firstChild || + target == display.scrollbarFiller) return null; + } + var x, y, space = display.lineSpace.getBoundingClientRect(); + // Fails unpredictably on IE[67] when mouse is dragged around quickly. + try { x = e.clientX; y = e.clientY; } catch (e) { return null; } + return coordsChar(cm, x - space.left, y - space.top); + } + + var lastClick, lastDoubleClick; + function onMouseDown(e) { + var cm = this, display = cm.display, view = cm.view, sel = view.sel, doc = view.doc; + sel.shift = e_prop(e, "shiftKey"); + + if (eventInWidget(display, e)) { + if (!webkit) { + display.scroller.draggable = false; + setTimeout(function(){display.scroller.draggable = true;}, 100); + } + return; + } + if (clickInGutter(cm, e)) return; + var start = posFromMouse(cm, e); + + switch (e_button(e)) { + case 3: + if (gecko) onContextMenu.call(cm, cm, e); + return; + case 2: + if (start) extendSelection(cm, start); + setTimeout(bind(focusInput, cm), 20); + e_preventDefault(e); + return; + } + // For button 1, if it was clicked inside the editor + // (posFromMouse returning non-null), we have to adjust the + // selection. + if (!start) {if (e_target(e) == display.scroller) e_preventDefault(e); return;} + + if (!view.focused) onFocus(cm); + + var now = +new Date, type = "single"; + if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) { + type = "triple"; + e_preventDefault(e); + setTimeout(bind(focusInput, cm), 20); + selectLine(cm, start.line); + } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) { + type = "double"; + lastDoubleClick = {time: now, pos: start}; + e_preventDefault(e); + var word = findWordAt(getLine(doc, start.line).text, start); + extendSelection(cm, word.from, word.to); + } else { lastClick = {time: now, pos: start}; } + + var last = start; + if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) && + !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") { + var dragEnd = operation(cm, function(e2) { + if (webkit) display.scroller.draggable = false; + view.draggingText = false; + off(document, "mouseup", dragEnd); + off(display.scroller, "drop", dragEnd); + if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { + e_preventDefault(e2); + extendSelection(cm, start); + focusInput(cm); + } + }); + // Let the drag handler handle this. + if (webkit) display.scroller.draggable = true; + view.draggingText = dragEnd; + // IE's approach to draggable + if (display.scroller.dragDrop) display.scroller.dragDrop(); + on(document, "mouseup", dragEnd); + on(display.scroller, "drop", dragEnd); + return; + } + e_preventDefault(e); + if (type == "single") extendSelection(cm, clipPos(doc, start)); + + var startstart = sel.from, startend = sel.to; + + function doSelect(cur) { + if (type == "single") { + extendSelection(cm, clipPos(doc, start), cur); + return; + } + + startstart = clipPos(doc, startstart); + startend = clipPos(doc, startend); + if (type == "double") { + var word = findWordAt(getLine(doc, cur.line).text, cur); + if (posLess(cur, startstart)) extendSelection(cm, word.from, startend); + else extendSelection(cm, startstart, word.to); + } else if (type == "triple") { + if (posLess(cur, startstart)) extendSelection(cm, startend, clipPos(doc, {line: cur.line, ch: 0})); + else extendSelection(cm, startstart, clipPos(doc, {line: cur.line + 1, ch: 0})); + } + } + + var editorSize = display.wrapper.getBoundingClientRect(); + // Used to ensure timeout re-tries don't fire when another extend + // happened in the meantime (clearTimeout isn't reliable -- at + // least on Chrome, the timeouts still happen even when cleared, + // if the clear happens after their scheduled firing time). + var counter = 0; + + function extend(e) { + var curCount = ++counter; + var cur = posFromMouse(cm, e, true); + if (!cur) return; + if (!posEq(cur, last)) { + if (!view.focused) onFocus(cm); + last = cur; + doSelect(cur); + var visible = visibleLines(display, doc); + if (cur.line >= visible.to || cur.line < visible.from) + setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); + } else { + var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; + if (outside) setTimeout(operation(cm, function() { + if (counter != curCount) return; + display.scroller.scrollTop += outside; + extend(e); + }), 50); + } + } + + function done(e) { + counter = Infinity; + var cur = posFromMouse(cm, e); + if (cur) doSelect(cur); + e_preventDefault(e); + focusInput(cm); + off(document, "mousemove", move); + off(document, "mouseup", up); + } + + var move = operation(cm, function(e) { + if (!ie && !e_button(e)) done(e); + else extend(e); + }); + var up = operation(cm, done); + on(document, "mousemove", move); + on(document, "mouseup", up); + } + + function onDrop(e) { + var cm = this; + if (eventInWidget(cm.display, e) || (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e)))) + return; + e_preventDefault(e); + var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; + if (!pos || isReadOnly(cm)) return; + if (files && files.length && window.FileReader && window.File) { + var n = files.length, text = Array(n), read = 0; + var loadFile = function(file, i) { + var reader = new FileReader; + reader.onload = function() { + text[i] = reader.result; + if (++read == n) { + pos = clipPos(cm.view.doc, pos); + operation(cm, function() { + var end = replaceRange(cm, text.join(""), pos, pos, "paste"); + setSelection(cm, pos, end); + })(); + } + }; + reader.readAsText(file); + }; + for (var i = 0; i < n; ++i) loadFile(files[i], i); + } else { + // Don't do a replace if the drop happened inside of the selected text. + if (cm.view.draggingText && !(posLess(pos, cm.view.sel.from) || posLess(cm.view.sel.to, pos))) { + cm.view.draggingText(e); + // Ensure the editor is re-focused + setTimeout(bind(focusInput, cm), 20); + return; + } + try { + var text = e.dataTransfer.getData("Text"); + if (text) { + var curFrom = cm.view.sel.from, curTo = cm.view.sel.to; + setSelection(cm, pos, pos); + if (cm.view.draggingText) replaceRange(cm, "", curFrom, curTo, "paste"); + cm.replaceSelection(text, null, "paste"); + focusInput(cm); + onFocus(cm); + } + } + catch(e){} + } + } + + function clickInGutter(cm, e) { + var display = cm.display; + try { var mX = e.clientX, mY = e.clientY; } + catch(e) { return false; } + + if (mX >= Math.floor(display.gutters.getBoundingClientRect().right)) return false; + e_preventDefault(e); + if (!hasHandler(cm, "gutterClick")) return true; + + var lineBox = display.lineDiv.getBoundingClientRect(); + if (mY > lineBox.bottom) return true; + mY -= lineBox.top - display.viewOffset; + + for (var i = 0; i < cm.options.gutters.length; ++i) { + var g = display.gutters.childNodes[i]; + if (g && g.getBoundingClientRect().right >= mX) { + var line = lineAtHeight(cm.view.doc, mY); + var gutter = cm.options.gutters[i]; + signalLater(cm, cm, "gutterClick", cm, line, gutter, e); + break; + } + } + return true; + } + + function onDragStart(cm, e) { + if (eventInWidget(cm.display, e)) return; + + var txt = cm.getSelection(); + e.dataTransfer.setData("Text", txt); + + // Use dummy image instead of default browsers image. + // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. + if (e.dataTransfer.setDragImage && !safari) { + var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); + if (opera) { + img.width = img.height = 1; + cm.display.wrapper.appendChild(img); + // Force a relayout, or Opera won't use our image for some obscure reason + img._top = img.offsetTop; + } + e.dataTransfer.setDragImage(img, 0, 0); + if (opera) img.parentNode.removeChild(img); + } + } + + function setScrollTop(cm, val) { + if (Math.abs(cm.view.scrollTop - val) < 2) return; + cm.view.scrollTop = val; + if (!gecko) updateDisplay(cm, [], val); + if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val; + if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val; + if (gecko) updateDisplay(cm, []); + } + function setScrollLeft(cm, val, isScroller) { + if (isScroller ? val == cm.view.scrollLeft : Math.abs(cm.view.scrollLeft - val) < 2) return; + val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); + cm.view.scrollLeft = val; + alignHorizontally(cm); + if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val; + if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val; + } + + // Since the delta values reported on mouse wheel events are + // unstandardized between browsers and even browser versions, and + // generally horribly unpredictable, this code starts by measuring + // the scroll effect that the first few mouse wheel events have, + // and, from that, detects the way it can convert deltas to pixel + // offsets afterwards. + // + // The reason we want to know the amount a wheel event will scroll + // is that it gives us a chance to update the display before the + // actual scrolling happens, reducing flickering. + + var wheelSamples = 0, wheelPixelsPerUnit = null; + // Fill in a browser-detected starting value on browsers where we + // know one. These don't have to be accurate -- the result of them + // being wrong would just be a slight flicker on the first wheel + // scroll (if it is large enough). + if (ie) wheelPixelsPerUnit = -.53; + else if (gecko) wheelPixelsPerUnit = 15; + else if (chrome) wheelPixelsPerUnit = -.7; + else if (safari) wheelPixelsPerUnit = -1/3; + + function onScrollWheel(cm, e) { + var dx = e.wheelDeltaX, dy = e.wheelDeltaY; + if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail; + if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail; + else if (dy == null) dy = e.wheelDelta; + + // Webkit browsers on OS X abort momentum scrolls when the target + // of the scroll event is removed from the scrollable element. + // This hack (see related code in patchDisplay) makes sure the + // element is kept around. + if (dy && mac && webkit) { + for (var cur = e.target; cur != scroll; cur = cur.parentNode) { + if (cur.lineObj) { + cm.display.currentWheelTarget = cur; + break; + } + } + } + + var display = cm.display, scroll = display.scroller; + // On some browsers, horizontal scrolling will cause redraws to + // happen before the gutter has been realigned, causing it to + // wriggle around in a most unseemly way. When we have an + // estimated pixels/delta value, we just handle horizontal + // scrolling entirely here. It'll be slightly off from native, but + // better than glitching out. + if (dx && !gecko && !opera && wheelPixelsPerUnit != null) { + if (dy) + setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); + setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); + e_preventDefault(e); + display.wheelStartX = null; // Abort measurement, if in progress + return; + } + + if (dy && wheelPixelsPerUnit != null) { + var pixels = dy * wheelPixelsPerUnit; + var top = cm.view.scrollTop, bot = top + display.wrapper.clientHeight; + if (pixels < 0) top = Math.max(0, top + pixels - 50); + else bot = Math.min(cm.view.doc.height, bot + pixels + 50); + updateDisplay(cm, [], {top: top, bottom: bot}); + } + + if (wheelSamples < 20) { + if (display.wheelStartX == null) { + display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; + display.wheelDX = dx; display.wheelDY = dy; + setTimeout(function() { + if (display.wheelStartX == null) return; + var movedX = scroll.scrollLeft - display.wheelStartX; + var movedY = scroll.scrollTop - display.wheelStartY; + var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || + (movedX && display.wheelDX && movedX / display.wheelDX); + display.wheelStartX = display.wheelStartY = null; + if (!sample) return; + wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); + ++wheelSamples; + }, 200); + } else { + display.wheelDX += dx; display.wheelDY += dy; + } + } + } + + function doHandleBinding(cm, bound, dropShift) { + if (typeof bound == "string") { + bound = commands[bound]; + if (!bound) return false; + } + // Ensure previous input has been read, so that the handler sees a + // consistent view of the document + if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false; + var view = cm.view, prevShift = view.sel.shift; + try { + if (isReadOnly(cm)) view.suppressEdits = true; + if (dropShift) view.sel.shift = false; + bound(cm); + } catch(e) { + if (e != Pass) throw e; + return false; + } finally { + view.sel.shift = prevShift; + view.suppressEdits = false; + } + return true; + } + + function allKeyMaps(cm) { + var maps = cm.view.keyMaps.slice(0); + maps.push(cm.options.keyMap); + if (cm.options.extraKeys) maps.unshift(cm.options.extraKeys); + return maps; + } + + var maybeTransition; + function handleKeyBinding(cm, e) { + // Handle auto keymap transitions + var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto; + clearTimeout(maybeTransition); + if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() { + if (getKeyMap(cm.options.keyMap) == startMap) + cm.options.keyMap = (next.call ? next.call(null, cm) : next); + }, 50); + + var name = keyNames[e_prop(e, "keyCode")], handled = false; + if (name == null || e.altGraphKey) return false; + if (e_prop(e, "altKey")) name = "Alt-" + name; + if (e_prop(e, flipCtrlCmd ? "metaKey" : "ctrlKey")) name = "Ctrl-" + name; + if (e_prop(e, flipCtrlCmd ? "ctrlKey" : "metaKey")) name = "Cmd-" + name; + + var stopped = false; + function stop() { stopped = true; } + var keymaps = allKeyMaps(cm); + + if (e_prop(e, "shiftKey")) { + handled = lookupKey("Shift-" + name, keymaps, + function(b) {return doHandleBinding(cm, b, true);}, stop) + || lookupKey(name, keymaps, function(b) { + if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(cm, b); + }, stop); + } else { + handled = lookupKey(name, keymaps, + function(b) { return doHandleBinding(cm, b); }, stop); + } + if (stopped) handled = false; + if (handled) { + e_preventDefault(e); + restartBlink(cm); + if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; } + } + return handled; + } + + function handleCharBinding(cm, e, ch) { + var handled = lookupKey("'" + ch + "'", allKeyMaps(cm), + function(b) { return doHandleBinding(cm, b, true); }); + if (handled) { + e_preventDefault(e); + restartBlink(cm); + } + return handled; + } + + var lastStoppedKey = null; + function onKeyDown(e) { + var cm = this; + if (!cm.view.focused) onFocus(cm); + if (ie && e.keyCode == 27) { e.returnValue = false; } + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return; + var code = e_prop(e, "keyCode"); + // IE does strange things with escape. + cm.view.sel.shift = code == 16 || e_prop(e, "shiftKey"); + // First give onKeyEvent option a chance to handle this. + var handled = handleKeyBinding(cm, e); + if (opera) { + lastStoppedKey = handled ? code : null; + // Opera has no cut event... we try to at least catch the key combo + if (!handled && code == 88 && !hasCopyEvent && e_prop(e, mac ? "metaKey" : "ctrlKey")) + cm.replaceSelection(""); + } + } + + function onKeyPress(e) { + var cm = this; + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return; + var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode"); + if (opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;} + if (((opera && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return; + var ch = String.fromCharCode(charCode == null ? keyCode : charCode); + if (this.options.electricChars && this.view.mode.electricChars && + this.options.smartIndent && !isReadOnly(this) && + this.view.mode.electricChars.indexOf(ch) > -1) + setTimeout(operation(cm, function() {indentLine(cm, cm.view.sel.to.line, "smart");}), 75); + if (handleCharBinding(cm, e, ch)) return; + fastPoll(cm); + } + + function onFocus(cm) { + if (cm.options.readOnly == "nocursor") return; + if (!cm.view.focused) { + signal(cm, "focus", cm); + cm.view.focused = true; + if (cm.display.scroller.className.search(/\bCodeMirror-focused\b/) == -1) + cm.display.scroller.className += " CodeMirror-focused"; + resetInput(cm, true); + } + slowPoll(cm); + restartBlink(cm); + } + function onBlur(cm) { + if (cm.view.focused) { + signal(cm, "blur", cm); + cm.view.focused = false; + cm.display.scroller.className = cm.display.scroller.className.replace(" CodeMirror-focused", ""); + } + clearInterval(cm.display.blinker); + setTimeout(function() {if (!cm.view.focused) cm.view.sel.shift = false;}, 150); + } + + var detectingSelectAll; + function onContextMenu(cm, e) { + var display = cm.display; + if (eventInWidget(display, e)) return; + + var sel = cm.view.sel; + var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; + if (!pos || opera) return; // Opera is difficult. + if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to)) + operation(cm, setSelection)(cm, pos, pos); + + var oldCSS = display.input.style.cssText; + display.inputDiv.style.position = "absolute"; + display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + + "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; outline: none;" + + "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; + focusInput(cm); + resetInput(cm, true); + // Adds "Select all" to context menu in FF + if (posEq(sel.from, sel.to)) display.input.value = display.prevInput = " "; + + function rehide() { + display.inputDiv.style.position = "relative"; + display.input.style.cssText = oldCSS; + if (ie_lt9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos; + slowPoll(cm); + + // Try to detect the user choosing select-all + if (display.input.selectionStart != null) { + clearTimeout(detectingSelectAll); + var extval = display.input.value = " " + (posEq(sel.from, sel.to) ? "" : display.input.value), i = 0; + display.prevInput = " "; + display.input.selectionStart = 1; display.input.selectionEnd = extval.length; + detectingSelectAll = setTimeout(function poll(){ + if (display.prevInput == " " && display.input.selectionStart == 0) + operation(cm, commands.selectAll)(cm); + else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500); + else resetInput(cm); + }, 200); + } + } + + if (gecko) { + e_stop(e); + on(window, "mouseup", function mouseup() { + off(window, "mouseup", mouseup); + setTimeout(rehide, 20); + }); + } else { + setTimeout(rehide, 50); + } + } + + // UPDATING + + // Replace the range from from to to by the strings in newText. + // Afterwards, set the selection to selFrom, selTo. + function updateDoc(cm, from, to, newText, selUpdate, origin) { + // Possibly split or suppress the update based on the presence + // of read-only spans in its range. + var split = sawReadOnlySpans && + removeReadOnlyRanges(cm.view.doc, from, to); + if (split) { + for (var i = split.length - 1; i >= 1; --i) + updateDocInner(cm, split[i].from, split[i].to, [""], origin); + if (split.length) + return updateDocInner(cm, split[0].from, split[0].to, newText, selUpdate, origin); + } else { + return updateDocInner(cm, from, to, newText, selUpdate, origin); + } + } + + function updateDocInner(cm, from, to, newText, selUpdate, origin) { + if (cm.view.suppressEdits) return; + + var view = cm.view, doc = view.doc, old = []; + doc.iter(from.line, to.line + 1, function(line) { + old.push(newHL(line.text, line.markedSpans)); + }); + var startSelFrom = view.sel.from, startSelTo = view.sel.to; + var lines = updateMarkedSpans(hlSpans(old[0]), hlSpans(lst(old)), from.ch, to.ch, newText); + var retval = updateDocNoUndo(cm, from, to, lines, selUpdate, origin); + if (view.history) addChange(cm, from.line, newText.length, old, origin, + startSelFrom, startSelTo, view.sel.from, view.sel.to); + return retval; + } + + function unredoHelper(cm, type) { + var doc = cm.view.doc, hist = cm.view.history; + var set = (type == "undo" ? hist.done : hist.undone).pop(); + if (!set) return; + var anti = {events: [], fromBefore: set.fromAfter, toBefore: set.toAfter, + fromAfter: set.fromBefore, toAfter: set.toBefore}; + for (var i = set.events.length - 1; i >= 0; i -= 1) { + hist.dirtyCounter += type == "undo" ? -1 : 1; + var change = set.events[i]; + var replaced = [], end = change.start + change.added; + doc.iter(change.start, end, function(line) { replaced.push(newHL(line.text, line.markedSpans)); }); + anti.events.push({start: change.start, added: change.old.length, old: replaced}); + var selPos = i ? null : {from: set.fromBefore, to: set.toBefore}; + updateDocNoUndo(cm, {line: change.start, ch: 0}, {line: end - 1, ch: getLine(doc, end-1).text.length}, + change.old, selPos, type); + } + (type == "undo" ? hist.undone : hist.done).push(anti); + } + + function updateDocNoUndo(cm, from, to, lines, selUpdate, origin) { + var view = cm.view, doc = view.doc, display = cm.display; + if (view.suppressEdits) return; + + var nlines = to.line - from.line, firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); + var recomputeMaxLength = false, checkWidthStart = from.line; + if (!cm.options.lineWrapping) { + checkWidthStart = lineNo(visualLine(doc, firstLine)); + doc.iter(checkWidthStart, to.line + 1, function(line) { + if (line == view.maxLine) { + recomputeMaxLength = true; + return true; + } + }); + } + + var lastHL = lst(lines), th = textHeight(display); + + // First adjust the line structure + if (from.ch == 0 && to.ch == 0 && hlText(lastHL) == "") { + // This is a whole-line replace. Treated specially to make + // sure line objects move the way they are supposed to. + var added = []; + for (var i = 0, e = lines.length - 1; i < e; ++i) + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th)); + updateLine(cm, lastLine, lastLine.text, hlSpans(lastHL)); + if (nlines) doc.remove(from.line, nlines, cm); + if (added.length) doc.insert(from.line, added); + } else if (firstLine == lastLine) { + if (lines.length == 1) { + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) + + firstLine.text.slice(to.ch), hlSpans(lines[0])); + } else { + for (var added = [], i = 1, e = lines.length - 1; i < e; ++i) + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th)); + added.push(makeLine(hlText(lastHL) + firstLine.text.slice(to.ch), hlSpans(lastHL), th)); + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0])); + doc.insert(from.line + 1, added); + } + } else if (lines.length == 1) { + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) + + lastLine.text.slice(to.ch), hlSpans(lines[0])); + doc.remove(from.line + 1, nlines, cm); + } else { + var added = []; + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0])); + updateLine(cm, lastLine, hlText(lastHL) + lastLine.text.slice(to.ch), hlSpans(lastHL)); + for (var i = 1, e = lines.length - 1; i < e; ++i) + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th)); + if (nlines > 1) doc.remove(from.line + 1, nlines - 1, cm); + doc.insert(from.line + 1, added); + } + + if (cm.options.lineWrapping) { + var perLine = Math.max(5, display.scroller.clientWidth / charWidth(display) - 3); + doc.iter(from.line, from.line + lines.length, function(line) { + if (line.height == 0) return; + var guess = (Math.ceil(line.text.length / perLine) || 1) * th; + if (guess != line.height) updateLineHeight(line, guess); + }); + } else { + doc.iter(checkWidthStart, from.line + lines.length, function(line) { + var len = lineLength(doc, line); + if (len > view.maxLineLength) { + view.maxLine = line; + view.maxLineLength = len; + view.maxLineChanged = true; + recomputeMaxLength = false; + } + }); + if (recomputeMaxLength) cm.curOp.updateMaxLine = true; + } + + // Adjust frontier, schedule worker + view.frontier = Math.min(view.frontier, from.line); + startWorker(cm, 400); + + var lendiff = lines.length - nlines - 1; + // Remember that these lines changed, for updating the display + regChange(cm, from.line, to.line + 1, lendiff); + if (hasHandler(cm, "change")) { + // Normalize lines to contain only strings, since that's what + // the change event handler expects + for (var i = 0; i < lines.length; ++i) + if (typeof lines[i] != "string") lines[i] = lines[i].text; + var changeObj = {from: from, to: to, text: lines, origin: origin}; + if (cm.curOp.textChanged) { + for (var cur = cm.curOp.textChanged; cur.next; cur = cur.next) {} + cur.next = changeObj; + } else cm.curOp.textChanged = changeObj; + } + + // Update the selection + var newSelFrom, newSelTo, end = {line: from.line + lines.length - 1, + ch: hlText(lastHL).length + (lines.length == 1 ? from.ch : 0)}; + if (selUpdate && typeof selUpdate != "string") { + if (selUpdate.from) { newSelFrom = selUpdate.from; newSelTo = selUpdate.to; } + else newSelFrom = newSelTo = selUpdate; + } else if (selUpdate == "end") { + newSelFrom = newSelTo = end; + } else if (selUpdate == "start") { + newSelFrom = newSelTo = from; + } else if (selUpdate == "around") { + newSelFrom = from; newSelTo = end; + } else { + var adjustPos = function(pos) { + if (posLess(pos, from)) return pos; + if (!posLess(to, pos)) return end; + var line = pos.line + lendiff; + var ch = pos.ch; + if (pos.line == to.line) + ch += hlText(lastHL).length - (to.ch - (to.line == from.line ? from.ch : 0)); + return {line: line, ch: ch}; + }; + newSelFrom = adjustPos(view.sel.from); + newSelTo = adjustPos(view.sel.to); + } + setSelection(cm, newSelFrom, newSelTo, null, true); + return end; + } + + function replaceRange(cm, code, from, to, origin) { + if (!to) to = from; + if (posLess(to, from)) { var tmp = to; to = from; from = tmp; } + return updateDoc(cm, from, to, splitLines(code), null, origin); + } + + // SELECTION + + function posEq(a, b) {return a.line == b.line && a.ch == b.ch;} + function posLess(a, b) {return a.line < b.line || (a.line == b.line && a.ch < b.ch);} + function copyPos(x) {return {line: x.line, ch: x.ch};} + + function clipLine(doc, n) {return Math.max(0, Math.min(n, doc.size-1));} + function clipPos(doc, pos) { + if (pos.line < 0) return {line: 0, ch: 0}; + if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc, doc.size-1).text.length}; + var ch = pos.ch, linelen = getLine(doc, pos.line).text.length; + if (ch == null || ch > linelen) return {line: pos.line, ch: linelen}; + else if (ch < 0) return {line: pos.line, ch: 0}; + else return pos; + } + function isLine(doc, l) {return l >= 0 && l < doc.size;} + + // If shift is held, this will move the selection anchor. Otherwise, + // it'll set the whole selection. + function extendSelection(cm, pos, other, bias) { + var sel = cm.view.sel; + if (sel.shift || sel.extend) { + var anchor = sel.anchor; + if (other) { + var posBefore = posLess(pos, anchor); + if (posBefore != posLess(other, anchor)) { + anchor = pos; + pos = other; + } else if (posBefore != posLess(pos, other)) { + pos = other; + } + } + setSelection(cm, anchor, pos, bias); + } else { + setSelection(cm, pos, other || pos, bias); + } + cm.curOp.userSelChange = true; + } + + // Update the selection. Last two args are only used by + // updateDoc, since they have to be expressed in the line + // numbers before the update. + function setSelection(cm, anchor, head, bias, checkAtomic) { + cm.view.goalColumn = null; + var sel = cm.view.sel; + // Skip over atomic spans. + if (checkAtomic || !posEq(anchor, sel.anchor)) + anchor = skipAtomic(cm, anchor, bias, checkAtomic != "push"); + if (checkAtomic || !posEq(head, sel.head)) + head = skipAtomic(cm, head, bias, checkAtomic != "push"); + + if (posEq(sel.anchor, anchor) && posEq(sel.head, head)) return; + + sel.anchor = anchor; sel.head = head; + var inv = posLess(head, anchor); + sel.from = inv ? head : anchor; + sel.to = inv ? anchor : head; + + cm.curOp.updateInput = true; + cm.curOp.selectionChanged = true; + } + + function reCheckSelection(cm) { + setSelection(cm, cm.view.sel.from, cm.view.sel.to, null, "push"); + } + + function skipAtomic(cm, pos, bias, mayClear) { + var doc = cm.view.doc, flipped = false, curPos = pos; + var dir = bias || 1; + cm.view.cantEdit = false; + search: for (;;) { + var line = getLine(doc, curPos.line), toClear; + if (line.markedSpans) { + for (var i = 0; i < line.markedSpans.length; ++i) { + var sp = line.markedSpans[i], m = sp.marker; + if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) && + (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { + if (mayClear && m.clearOnEnter) { + (toClear || (toClear = [])).push(m); + continue; + } else if (!m.atomic) continue; + var newPos = m.find()[dir < 0 ? "from" : "to"]; + if (posEq(newPos, curPos)) { + newPos.ch += dir; + if (newPos.ch < 0) { + if (newPos.line) newPos = clipPos(doc, {line: newPos.line - 1}); + else newPos = null; + } else if (newPos.ch > line.text.length) { + if (newPos.line < doc.size - 1) newPos = {line: newPos.line + 1, ch: 0}; + else newPos = null; + } + if (!newPos) { + if (flipped) { + // Driven in a corner -- no valid cursor position found at all + // -- try again *with* clearing, if we didn't already + if (!mayClear) return skipAtomic(cm, pos, bias, true); + // Otherwise, turn off editing until further notice, and return the start of the doc + cm.view.cantEdit = true; + return {line: 0, ch: 0}; + } + flipped = true; newPos = pos; dir = -dir; + } + } + curPos = newPos; + continue search; + } + } + if (toClear) for (var i = 0; i < toClear.length; ++i) toClear[i].clear(); + } + return curPos; + } + } + + // SCROLLING + + function scrollCursorIntoView(cm) { + var view = cm.view; + var coords = scrollPosIntoView(cm, view.sel.head); + if (!view.focused) return; + var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; + if (coords.top + box.top < 0) doScroll = true; + else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; + if (doScroll != null && !phantom) { + var hidden = display.cursor.style.display == "none"; + if (hidden) { + display.cursor.style.display = ""; + display.cursor.style.left = coords.left + "px"; + display.cursor.style.top = (coords.top - display.viewOffset) + "px"; + } + display.cursor.scrollIntoView(doScroll); + if (hidden) display.cursor.style.display = "none"; + } + } + + function scrollPosIntoView(cm, pos) { + for (;;) { + var changed = false, coords = cursorCoords(cm, pos); + var scrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom); + var startTop = cm.view.scrollTop, startLeft = cm.view.scrollLeft; + if (scrollPos.scrollTop != null) { + setScrollTop(cm, scrollPos.scrollTop); + if (Math.abs(cm.view.scrollTop - startTop) > 1) changed = true; + } + if (scrollPos.scrollLeft != null) { + setScrollLeft(cm, scrollPos.scrollLeft); + if (Math.abs(cm.view.scrollLeft - startLeft) > 1) changed = true; + } + if (!changed) return coords; + } + } + + function scrollIntoView(cm, x1, y1, x2, y2) { + var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); + if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop); + if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft); + } + + function calculateScrollPos(cm, x1, y1, x2, y2) { + var display = cm.display, pt = paddingTop(display); + y1 += pt; y2 += pt; + var screen = display.scroller.clientHeight - scrollerCutOff, screentop = display.scroller.scrollTop, result = {}; + var docBottom = cm.view.doc.height + 2 * pt; + var atTop = y1 < pt + 10, atBottom = y2 + pt > docBottom - 10; + if (y1 < screentop) result.scrollTop = atTop ? 0 : Math.max(0, y1); + else if (y2 > screentop + screen) result.scrollTop = (atBottom ? docBottom : y2) - screen; + + var screenw = display.scroller.clientWidth - scrollerCutOff, screenleft = display.scroller.scrollLeft; + x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth; + var gutterw = display.gutters.offsetWidth; + var atLeft = x1 < gutterw + 10; + if (x1 < screenleft + gutterw || atLeft) { + if (atLeft) x1 = 0; + result.scrollLeft = Math.max(0, x1 - 10 - gutterw); + } else if (x2 > screenw + screenleft - 3) { + result.scrollLeft = x2 + 10 - screenw; + } + return result; + } + + // API UTILITIES + + function indentLine(cm, n, how, aggressive) { + var doc = cm.view.doc; + if (!how) how = "add"; + if (how == "smart") { + if (!cm.view.mode.indent) how = "prev"; + else var state = getStateBefore(cm, n); + } + + var tabSize = cm.options.tabSize; + var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); + var curSpaceString = line.text.match(/^\s*/)[0], indentation; + if (how == "smart") { + indentation = cm.view.mode.indent(state, line.text.slice(curSpaceString.length), line.text); + if (indentation == Pass) { + if (!aggressive) return; + how = "prev"; + } + } + if (how == "prev") { + if (n) indentation = countColumn(getLine(doc, n-1).text, null, tabSize); + else indentation = 0; + } + else if (how == "add") indentation = curSpace + cm.options.indentUnit; + else if (how == "subtract") indentation = curSpace - cm.options.indentUnit; + indentation = Math.max(0, indentation); + + var indentString = "", pos = 0; + if (cm.options.indentWithTabs) + for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} + if (pos < indentation) indentString += spaceStr(indentation - pos); + + if (indentString != curSpaceString) + replaceRange(cm, indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length}, "input"); + line.stateAfter = null; + } + + function changeLine(cm, handle, op) { + var no = handle, line = handle, doc = cm.view.doc; + if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle)); + else no = lineNo(handle); + if (no == null) return null; + if (op(line, no)) regChange(cm, no, no + 1); + else return null; + return line; + } + + function findPosH(cm, dir, unit, visually) { + var doc = cm.view.doc, end = cm.view.sel.head, line = end.line, ch = end.ch; + var lineObj = getLine(doc, line); + function findNextLine() { + var l = line + dir; + if (l < 0 || l == doc.size) return false; + line = l; + return lineObj = getLine(doc, l); + } + function moveOnce(boundToLine) { + var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); + if (next == null) { + if (!boundToLine && findNextLine()) { + if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); + else ch = dir < 0 ? lineObj.text.length : 0; + } else return false; + } else ch = next; + return true; + } + if (unit == "char") moveOnce(); + else if (unit == "column") moveOnce(true); + else if (unit == "word") { + var sawWord = false; + for (;;) { + if (dir < 0) if (!moveOnce()) break; + if (isWordChar(lineObj.text.charAt(ch))) sawWord = true; + else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;} + if (dir > 0) if (!moveOnce()) break; + } + } + return skipAtomic(cm, {line: line, ch: ch}, dir, true); + } + + function findWordAt(line, pos) { + var start = pos.ch, end = pos.ch; + if (line) { + if (pos.after === false || end == line.length) --start; else ++end; + var startChar = line.charAt(start); + var check = isWordChar(startChar) ? isWordChar : + /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} : + function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; + while (start > 0 && check(line.charAt(start - 1))) --start; + while (end < line.length && check(line.charAt(end))) ++end; + } + return {from: {line: pos.line, ch: start}, to: {line: pos.line, ch: end}}; + } + + function selectLine(cm, line) { + extendSelection(cm, {line: line, ch: 0}, clipPos(cm.view.doc, {line: line + 1, ch: 0})); + } + + // PROTOTYPE + + // The publicly visible API. Note that operation(null, f) means + // 'wrap f in an operation, performed on its `this` parameter' + + CodeMirror.prototype = { + getValue: function(lineSep) { + var text = [], doc = this.view.doc; + doc.iter(0, doc.size, function(line) { text.push(line.text); }); + return text.join(lineSep || "\n"); + }, + + setValue: operation(null, function(code) { + var doc = this.view.doc, top = {line: 0, ch: 0}, lastLen = getLine(doc, doc.size-1).text.length; + updateDocInner(this, top, {line: doc.size - 1, ch: lastLen}, splitLines(code), top, top, "setValue"); + }), + + getSelection: function(lineSep) { return this.getRange(this.view.sel.from, this.view.sel.to, lineSep); }, + + replaceSelection: operation(null, function(code, collapse, origin) { + var sel = this.view.sel; + updateDoc(this, sel.from, sel.to, splitLines(code), collapse || "around", origin); + }), + + focus: function(){window.focus(); focusInput(this); onFocus(this); fastPoll(this);}, + + setOption: function(option, value) { + var options = this.options, old = options[option]; + if (options[option] == value && option != "mode") return; + options[option] = value; + if (optionHandlers.hasOwnProperty(option)) + operation(this, optionHandlers[option])(this, value, old); + }, + + getOption: function(option) {return this.options[option];}, + + getMode: function() {return this.view.mode;}, + + addKeyMap: function(map) { + this.view.keyMaps.push(map); + }, + + removeKeyMap: function(map) { + var maps = this.view.keyMaps; + for (var i = 0; i < maps.length; ++i) + if ((typeof map == "string" ? maps[i].name : maps[i]) == map) { + maps.splice(i, 1); + return true; + } + }, + + addOverlay: operation(null, function(spec, options) { + var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); + if (mode.startState) throw new Error("Overlays may not be stateful."); + this.view.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); + this.view.modeGen++; + regChange(this, 0, this.view.doc.size); + }), + removeOverlay: operation(null, function(spec) { + var overlays = this.view.overlays; + for (var i = 0; i < overlays.length; ++i) { + if (overlays[i].modeSpec == spec) { + overlays.splice(i, 1); + this.view.modeGen++; + regChange(this, 0, this.view.doc.size); + return; + } + } + }), + + undo: operation(null, function() {unredoHelper(this, "undo");}), + redo: operation(null, function() {unredoHelper(this, "redo");}), + + indentLine: operation(null, function(n, dir, aggressive) { + if (typeof dir != "string") { + if (dir == null) dir = this.options.smartIndent ? "smart" : "prev"; + else dir = dir ? "add" : "subtract"; + } + if (isLine(this.view.doc, n)) indentLine(this, n, dir, aggressive); + }), + + indentSelection: operation(null, function(how) { + var sel = this.view.sel; + if (posEq(sel.from, sel.to)) return indentLine(this, sel.from.line, how); + var e = sel.to.line - (sel.to.ch ? 0 : 1); + for (var i = sel.from.line; i <= e; ++i) indentLine(this, i, how); + }), + + historySize: function() { + var hist = this.view.history; + return {undo: hist.done.length, redo: hist.undone.length}; + }, + + clearHistory: function() {this.view.history = makeHistory();}, + + markClean: function() { + this.view.history.dirtyCounter = 0; + this.view.history.lastOp = this.view.history.lastOrigin = null; + }, + + isClean: function () {return this.view.history.dirtyCounter == 0;}, + + getHistory: function() { + var hist = this.view.history; + function cp(arr) { + for (var i = 0, nw = [], nwelt; i < arr.length; ++i) { + var set = arr[i]; + nw.push({events: nwelt = [], fromBefore: set.fromBefore, toBefore: set.toBefore, + fromAfter: set.fromAfter, toAfter: set.toAfter}); + for (var j = 0, elt = set.events; j < elt.length; ++j) { + var old = [], cur = elt[j]; + nwelt.push({start: cur.start, added: cur.added, old: old}); + for (var k = 0; k < cur.old.length; ++k) old.push(hlText(cur.old[k])); + } + } + return nw; + } + return {done: cp(hist.done), undone: cp(hist.undone)}; + }, + + setHistory: function(histData) { + var hist = this.view.history = makeHistory(); + hist.done = histData.done; + hist.undone = histData.undone; + }, + + // Fetch the parser token for a given character. Useful for hacks + // that want to inspect the mode state (say, for completion). + getTokenAt: function(pos) { + var doc = this.view.doc; + pos = clipPos(doc, pos); + var state = getStateBefore(this, pos.line), mode = this.view.mode; + var line = getLine(doc, pos.line); + var stream = new StringStream(line.text, this.options.tabSize); + while (stream.pos < pos.ch && !stream.eol()) { + stream.start = stream.pos; + var style = mode.token(stream, state); + } + return {start: stream.start, + end: stream.pos, + string: stream.current(), + className: style || null, // Deprecated, use 'type' instead + type: style || null, + state: state}; + }, + + getStateAfter: function(line) { + var doc = this.view.doc; + line = clipLine(doc, line == null ? doc.size - 1: line); + return getStateBefore(this, line + 1); + }, + + cursorCoords: function(start, mode) { + var pos, sel = this.view.sel; + if (start == null) pos = sel.head; + else if (typeof start == "object") pos = clipPos(this.view.doc, start); + else pos = start ? sel.from : sel.to; + return cursorCoords(this, pos, mode || "page"); + }, + + charCoords: function(pos, mode) { + return charCoords(this, clipPos(this.view.doc, pos), mode || "page"); + }, + + coordsChar: function(coords) { + var off = this.display.lineSpace.getBoundingClientRect(); + return coordsChar(this, coords.left - off.left, coords.top - off.top); + }, + + defaultTextHeight: function() { return textHeight(this.display); }, + + markText: operation(null, function(from, to, options) { + return markText(this, clipPos(this.view.doc, from), clipPos(this.view.doc, to), + options, "range"); + }), + + setBookmark: operation(null, function(pos, widget) { + pos = clipPos(this.view.doc, pos); + return markText(this, pos, pos, widget ? {replacedWith: widget} : {}, "bookmark"); + }), + + findMarksAt: function(pos) { + var doc = this.view.doc; + pos = clipPos(doc, pos); + var markers = [], spans = getLine(doc, pos.line).markedSpans; + if (spans) for (var i = 0; i < spans.length; ++i) { + var span = spans[i]; + if ((span.from == null || span.from <= pos.ch) && + (span.to == null || span.to >= pos.ch)) + markers.push(span.marker); + } + return markers; + }, + + setGutterMarker: operation(null, function(line, gutterID, value) { + return changeLine(this, line, function(line) { + var markers = line.gutterMarkers || (line.gutterMarkers = {}); + markers[gutterID] = value; + if (!value && isEmpty(markers)) line.gutterMarkers = null; + return true; + }); + }), + + clearGutter: operation(null, function(gutterID) { + var i = 0, cm = this, doc = cm.view.doc; + doc.iter(0, doc.size, function(line) { + if (line.gutterMarkers && line.gutterMarkers[gutterID]) { + line.gutterMarkers[gutterID] = null; + regChange(cm, i, i + 1); + if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null; + } + ++i; + }); + }), + + addLineClass: operation(null, function(handle, where, cls) { + return changeLine(this, handle, function(line) { + var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass"; + if (!line[prop]) line[prop] = cls; + else if (new RegExp("\\b" + cls + "\\b").test(line[prop])) return false; + else line[prop] += " " + cls; + return true; + }); + }), + + removeLineClass: operation(null, function(handle, where, cls) { + return changeLine(this, handle, function(line) { + var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass"; + var cur = line[prop]; + if (!cur) return false; + else if (cls == null) line[prop] = null; + else { + var upd = cur.replace(new RegExp("^" + cls + "\\b\\s*|\\s*\\b" + cls + "\\b"), ""); + if (upd == cur) return false; + line[prop] = upd || null; + } + return true; + }); + }), + + addLineWidget: operation(null, function(handle, node, options) { + return addLineWidget(this, handle, node, options); + }), + + removeLineWidget: function(widget) { widget.clear(); }, + + lineInfo: function(line) { + if (typeof line == "number") { + if (!isLine(this.view.doc, line)) return null; + var n = line; + line = getLine(this.view.doc, line); + if (!line) return null; + } else { + var n = lineNo(line); + if (n == null) return null; + } + return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, + textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, + widgets: line.widgets}; + }, + + getViewport: function() { return {from: this.display.showingFrom, to: this.display.showingTo};}, + + addWidget: function(pos, node, scroll, vert, horiz) { + var display = this.display; + pos = cursorCoords(this, clipPos(this.view.doc, pos)); + var top = pos.top, left = pos.left; + node.style.position = "absolute"; + display.sizer.appendChild(node); + if (vert == "over") top = pos.top; + else if (vert == "near") { + var vspace = Math.max(display.wrapper.clientHeight, this.view.doc.height), + hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); + if (pos.bottom + node.offsetHeight > vspace && pos.top > node.offsetHeight) + top = pos.top - node.offsetHeight; + if (left + node.offsetWidth > hspace) + left = hspace - node.offsetWidth; + } + node.style.top = (top + paddingTop(display)) + "px"; + node.style.left = node.style.right = ""; + if (horiz == "right") { + left = display.sizer.clientWidth - node.offsetWidth; + node.style.right = "0px"; + } else { + if (horiz == "left") left = 0; + else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2; + node.style.left = left + "px"; + } + if (scroll) + scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight); + }, + + lineCount: function() {return this.view.doc.size;}, + + clipPos: function(pos) {return clipPos(this.view.doc, pos);}, + + getCursor: function(start) { + var sel = this.view.sel, pos; + if (start == null || start == "head") pos = sel.head; + else if (start == "anchor") pos = sel.anchor; + else if (start == "end" || start === false) pos = sel.to; + else pos = sel.from; + return copyPos(pos); + }, + + somethingSelected: function() {return !posEq(this.view.sel.from, this.view.sel.to);}, + + setCursor: operation(null, function(line, ch, extend) { + var pos = clipPos(this.view.doc, typeof line == "number" ? {line: line, ch: ch || 0} : line); + if (extend) extendSelection(this, pos); + else setSelection(this, pos, pos); + }), + + setSelection: operation(null, function(anchor, head) { + var doc = this.view.doc; + setSelection(this, clipPos(doc, anchor), clipPos(doc, head || anchor)); + }), + + extendSelection: operation(null, function(from, to) { + var doc = this.view.doc; + extendSelection(this, clipPos(doc, from), to && clipPos(doc, to)); + }), + + setExtending: function(val) {this.view.sel.extend = val;}, + + getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, + + getLineHandle: function(line) { + var doc = this.view.doc; + if (isLine(doc, line)) return getLine(doc, line); + }, + + getLineNumber: function(line) {return lineNo(line);}, + + setLine: operation(null, function(line, text) { + if (isLine(this.view.doc, line)) + replaceRange(this, text, {line: line, ch: 0}, {line: line, ch: getLine(this.view.doc, line).text.length}); + }), + + removeLine: operation(null, function(line) { + if (isLine(this.view.doc, line)) + replaceRange(this, "", {line: line, ch: 0}, clipPos(this.view.doc, {line: line+1, ch: 0})); + }), + + replaceRange: operation(null, function(code, from, to) { + var doc = this.view.doc; + from = clipPos(doc, from); + to = to ? clipPos(doc, to) : from; + return replaceRange(this, code, from, to); + }), + + getRange: function(from, to, lineSep) { + var doc = this.view.doc; + from = clipPos(doc, from); to = clipPos(doc, to); + var l1 = from.line, l2 = to.line; + if (l1 == l2) return getLine(doc, l1).text.slice(from.ch, to.ch); + var code = [getLine(doc, l1).text.slice(from.ch)]; + doc.iter(l1 + 1, l2, function(line) { code.push(line.text); }); + code.push(getLine(doc, l2).text.slice(0, to.ch)); + return code.join(lineSep || "\n"); + }, + + triggerOnKeyDown: operation(null, onKeyDown), + + execCommand: function(cmd) {return commands[cmd](this);}, + + // Stuff used by commands, probably not much use to outside code. + moveH: operation(null, function(dir, unit) { + var sel = this.view.sel, pos = dir < 0 ? sel.from : sel.to; + if (sel.shift || sel.extend || posEq(sel.from, sel.to)) + pos = findPosH(this, dir, unit, this.options.rtlMoveVisually); + extendSelection(this, pos, pos, dir); + }), + + deleteH: operation(null, function(dir, unit) { + var sel = this.view.sel; + if (!posEq(sel.from, sel.to)) replaceRange(this, "", sel.from, sel.to, "delete"); + else replaceRange(this, "", sel.from, findPosH(this, dir, unit, false), "delete"); + this.curOp.userSelChange = true; + }), + + moveV: operation(null, function(dir, unit) { + var view = this.view, doc = view.doc, display = this.display; + var cur = view.sel.head, pos = cursorCoords(this, cur, "div"); + var x = pos.left, y; + if (view.goalColumn != null) x = view.goalColumn; + if (unit == "page") { + var pageSize = Math.min(display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); + y = pos.top + dir * pageSize; + } else if (unit == "line") { + y = dir > 0 ? pos.bottom + 3 : pos.top - 3; + } + do { + var target = coordsChar(this, x, y); + y += dir * 5; + } while (target.outside && (dir < 0 ? y > 0 : y < doc.height)); + + if (unit == "page") display.scrollbarV.scrollTop += charCoords(this, target, "div").top - pos.top; + extendSelection(this, target, target, dir); + view.goalColumn = x; + }), + + toggleOverwrite: function() { + if (this.view.overwrite = !this.view.overwrite) + this.display.cursor.className += " CodeMirror-overwrite"; + else + this.display.cursor.className = this.display.cursor.className.replace(" CodeMirror-overwrite", ""); + }, + + posFromIndex: function(off) { + var lineNo = 0, ch, doc = this.view.doc; + doc.iter(0, doc.size, function(line) { + var sz = line.text.length + 1; + if (sz > off) { ch = off; return true; } + off -= sz; + ++lineNo; + }); + return clipPos(doc, {line: lineNo, ch: ch}); + }, + indexFromPos: function (coords) { + coords = clipPos(this.view.doc, coords); + var index = coords.ch; + this.view.doc.iter(0, coords.line, function (line) { + index += line.text.length + 1; + }); + return index; + }, + + scrollTo: function(x, y) { + if (x != null) this.display.scrollbarH.scrollLeft = this.display.scroller.scrollLeft = x; + if (y != null) this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = y; + updateDisplay(this, []); + }, + getScrollInfo: function() { + var scroller = this.display.scroller, co = scrollerCutOff; + return {left: scroller.scrollLeft, top: scroller.scrollTop, + height: scroller.scrollHeight - co, width: scroller.scrollWidth - co, + clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co}; + }, + + scrollIntoView: function(pos) { + if (typeof pos == "number") pos = {line: pos, ch: 0}; + if (!pos || pos.line != null) { + pos = pos ? clipPos(this.view.doc, pos) : this.view.sel.head; + scrollPosIntoView(this, pos); + } else { + scrollIntoView(this, pos.left, pos.top, pos.right, pos.bottom); + } + }, + + setSize: function(width, height) { + function interpret(val) { + return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; + } + if (width != null) this.display.wrapper.style.width = interpret(width); + if (height != null) this.display.wrapper.style.height = interpret(height); + this.refresh(); + }, + + on: function(type, f) {on(this, type, f);}, + off: function(type, f) {off(this, type, f);}, + + operation: function(f){return operation(this, f)();}, + + refresh: function() { + clearCaches(this); + var sTop = this.view.scrollTop, sLeft = this.view.scrollLeft; + if (this.display.scroller.scrollHeight > sTop) + this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = sTop; + if (this.display.scroller.scrollWidth > sLeft) + this.display.scrollbarH.scrollLeft = this.display.scroller.scrollLeft = sLeft; + updateDisplay(this, true); + }, + + getInputField: function(){return this.display.input;}, + getWrapperElement: function(){return this.display.wrapper;}, + getScrollerElement: function(){return this.display.scroller;}, + getGutterElement: function(){return this.display.gutters;} + }; + + // OPTION DEFAULTS + + var optionHandlers = CodeMirror.optionHandlers = {}; + + // The default configuration options. + var defaults = CodeMirror.defaults = {}; + + function option(name, deflt, handle, notOnInit) { + CodeMirror.defaults[name] = deflt; + if (handle) optionHandlers[name] = + notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle; + } + + var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}}; + + // These two are, on init, called from the constructor because they + // have to be initialized before the editor can start at all. + option("value", "", function(cm, val) {cm.setValue(val);}, true); + option("mode", null, loadMode, true); + + option("indentUnit", 2, loadMode, true); + option("indentWithTabs", false); + option("smartIndent", true); + option("tabSize", 4, function(cm) { + loadMode(cm); + clearCaches(cm); + updateDisplay(cm, true); + }, true); + option("electricChars", true); + option("rtlMoveVisually", !windows); + + option("theme", "default", function(cm) { + themeChanged(cm); + guttersChanged(cm); + }, true); + option("keyMap", "default", keyMapChanged); + option("extraKeys", null); + + option("onKeyEvent", null); + option("onDragEvent", null); + + option("lineWrapping", false, wrappingChanged, true); + option("gutters", [], function(cm) { + setGuttersForLineNumbers(cm.options); + guttersChanged(cm); + }, true); + option("fixedGutter", true, function(cm, val) { + cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; + cm.refresh(); + }, true); + option("lineNumbers", false, function(cm) { + setGuttersForLineNumbers(cm.options); + guttersChanged(cm); + }, true); + option("firstLineNumber", 1, guttersChanged, true); + option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true); + option("showCursorWhenSelecting", false, updateSelection, true); + + option("readOnly", false, function(cm, val) { + if (val == "nocursor") {onBlur(cm); cm.display.input.blur();} + else if (!val) resetInput(cm, true); + }); + option("dragDrop", true); + + option("cursorBlinkRate", 530); + option("cursorHeight", 1); + option("workTime", 100); + option("workDelay", 100); + option("flattenSpans", true); + option("pollInterval", 100); + option("undoDepth", 40); + option("viewportMargin", 10, function(cm){cm.refresh();}, true); + + option("tabindex", null, function(cm, val) { + cm.display.input.tabIndex = val || ""; + }); + option("autofocus", null); + + // MODE DEFINITION AND QUERYING + + // Known modes, by name and by MIME + var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; + + CodeMirror.defineMode = function(name, mode) { + if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; + if (arguments.length > 2) { + mode.dependencies = []; + for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]); + } + modes[name] = mode; + }; + + CodeMirror.defineMIME = function(mime, spec) { + mimeModes[mime] = spec; + }; + + CodeMirror.resolveMode = function(spec) { + if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) + spec = mimeModes[spec]; + else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) + return CodeMirror.resolveMode("application/xml"); + if (typeof spec == "string") return {name: spec}; + else return spec || {name: "null"}; + }; + + CodeMirror.getMode = function(options, spec) { + spec = CodeMirror.resolveMode(spec); + var mfactory = modes[spec.name]; + if (!mfactory) return CodeMirror.getMode(options, "text/plain"); + var modeObj = mfactory(options, spec); + if (modeExtensions.hasOwnProperty(spec.name)) { + var exts = modeExtensions[spec.name]; + for (var prop in exts) { + if (!exts.hasOwnProperty(prop)) continue; + if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; + modeObj[prop] = exts[prop]; + } + } + modeObj.name = spec.name; + return modeObj; + }; + + CodeMirror.defineMode("null", function() { + return {token: function(stream) {stream.skipToEnd();}}; + }); + CodeMirror.defineMIME("text/plain", "null"); + + var modeExtensions = CodeMirror.modeExtensions = {}; + CodeMirror.extendMode = function(mode, properties) { + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); + for (var prop in properties) if (properties.hasOwnProperty(prop)) + exts[prop] = properties[prop]; + }; + + // EXTENSIONS + + CodeMirror.defineExtension = function(name, func) { + CodeMirror.prototype[name] = func; + }; + + CodeMirror.defineOption = option; + + var initHooks = []; + CodeMirror.defineInitHook = function(f) {initHooks.push(f);}; + + // MODE STATE HANDLING + + // Utility functions for working with state. Exported because modes + // sometimes need to do this. + function copyState(mode, state) { + if (state === true) return state; + if (mode.copyState) return mode.copyState(state); + var nstate = {}; + for (var n in state) { + var val = state[n]; + if (val instanceof Array) val = val.concat([]); + nstate[n] = val; + } + return nstate; + } + CodeMirror.copyState = copyState; + + function startState(mode, a1, a2) { + return mode.startState ? mode.startState(a1, a2) : true; + } + CodeMirror.startState = startState; + + CodeMirror.innerMode = function(mode, state) { + while (mode.innerMode) { + var info = mode.innerMode(state); + state = info.state; + mode = info.mode; + } + return info || {mode: mode, state: state}; + }; + + // STANDARD COMMANDS + + var commands = CodeMirror.commands = { + selectAll: function(cm) {cm.setSelection({line: 0, ch: 0}, {line: cm.lineCount() - 1});}, + killLine: function(cm) { + var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to); + if (!sel && cm.getLine(from.line).length == from.ch) + cm.replaceRange("", from, {line: from.line + 1, ch: 0}, "delete"); + else cm.replaceRange("", from, sel ? to : {line: from.line}, "delete"); + }, + deleteLine: function(cm) { + var l = cm.getCursor().line; + cm.replaceRange("", {line: l, ch: 0}, {line: l}, "delete"); + }, + undo: function(cm) {cm.undo();}, + redo: function(cm) {cm.redo();}, + goDocStart: function(cm) {cm.extendSelection({line: 0, ch: 0});}, + goDocEnd: function(cm) {cm.extendSelection({line: cm.lineCount() - 1});}, + goLineStart: function(cm) { + cm.extendSelection(lineStart(cm, cm.getCursor().line)); + }, + goLineStartSmart: function(cm) { + var cur = cm.getCursor(), start = lineStart(cm, cur.line); + var line = cm.getLineHandle(start.line); + var order = getOrder(line); + if (!order || order[0].level == 0) { + var firstNonWS = Math.max(0, line.text.search(/\S/)); + var inWS = cur.line == start.line && cur.ch <= firstNonWS && cur.ch; + cm.extendSelection({line: start.line, ch: inWS ? 0 : firstNonWS}); + } else cm.extendSelection(start); + }, + goLineEnd: function(cm) { + cm.extendSelection(lineEnd(cm, cm.getCursor().line)); + }, + goLineUp: function(cm) {cm.moveV(-1, "line");}, + goLineDown: function(cm) {cm.moveV(1, "line");}, + goPageUp: function(cm) {cm.moveV(-1, "page");}, + goPageDown: function(cm) {cm.moveV(1, "page");}, + goCharLeft: function(cm) {cm.moveH(-1, "char");}, + goCharRight: function(cm) {cm.moveH(1, "char");}, + goColumnLeft: function(cm) {cm.moveH(-1, "column");}, + goColumnRight: function(cm) {cm.moveH(1, "column");}, + goWordLeft: function(cm) {cm.moveH(-1, "word");}, + goWordRight: function(cm) {cm.moveH(1, "word");}, + delCharBefore: function(cm) {cm.deleteH(-1, "char");}, + delCharAfter: function(cm) {cm.deleteH(1, "char");}, + delWordBefore: function(cm) {cm.deleteH(-1, "word");}, + delWordAfter: function(cm) {cm.deleteH(1, "word");}, + indentAuto: function(cm) {cm.indentSelection("smart");}, + indentMore: function(cm) {cm.indentSelection("add");}, + indentLess: function(cm) {cm.indentSelection("subtract");}, + insertTab: function(cm) {cm.replaceSelection("\t", "end", "input");}, + defaultTab: function(cm) { + if (cm.somethingSelected()) cm.indentSelection("add"); + else cm.replaceSelection("\t", "end", "input"); + }, + transposeChars: function(cm) { + var cur = cm.getCursor(), line = cm.getLine(cur.line); + if (cur.ch > 0 && cur.ch < line.length - 1) + cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1), + {line: cur.line, ch: cur.ch - 1}, {line: cur.line, ch: cur.ch + 1}); + }, + newlineAndIndent: function(cm) { + operation(cm, function() { + cm.replaceSelection("\n", "end", "input"); + cm.indentLine(cm.getCursor().line, null, true); + })(); + }, + toggleOverwrite: function(cm) {cm.toggleOverwrite();} + }; + + // STANDARD KEYMAPS + + var keyMap = CodeMirror.keyMap = {}; + keyMap.basic = { + "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", + "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", + "Delete": "delCharAfter", "Backspace": "delCharBefore", "Tab": "defaultTab", "Shift-Tab": "indentAuto", + "Enter": "newlineAndIndent", "Insert": "toggleOverwrite" + }; + // Note that the save and find-related commands aren't defined by + // default. Unknown commands are simply ignored. + keyMap.pcDefault = { + "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", + "Ctrl-Home": "goDocStart", "Alt-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd", + "Ctrl-Left": "goWordLeft", "Ctrl-Right": "goWordRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", + "Ctrl-Backspace": "delWordBefore", "Ctrl-Delete": "delWordAfter", "Ctrl-S": "save", "Ctrl-F": "find", + "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", + "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", + fallthrough: "basic" + }; + keyMap.macDefault = { + "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", + "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goWordLeft", + "Alt-Right": "goWordRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delWordBefore", + "Ctrl-Alt-Backspace": "delWordAfter", "Alt-Delete": "delWordAfter", "Cmd-S": "save", "Cmd-F": "find", + "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", + "Cmd-[": "indentLess", "Cmd-]": "indentMore", + fallthrough: ["basic", "emacsy"] + }; + keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; + keyMap.emacsy = { + "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", + "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", + "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", + "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars" + }; + + // KEYMAP DISPATCH + + function getKeyMap(val) { + if (typeof val == "string") return keyMap[val]; + else return val; + } + + function lookupKey(name, maps, handle, stop) { + function lookup(map) { + map = getKeyMap(map); + var found = map[name]; + if (found === false) { + if (stop) stop(); + return true; + } + if (found != null && handle(found)) return true; + if (map.nofallthrough) { + if (stop) stop(); + return true; + } + var fallthrough = map.fallthrough; + if (fallthrough == null) return false; + if (Object.prototype.toString.call(fallthrough) != "[object Array]") + return lookup(fallthrough); + for (var i = 0, e = fallthrough.length; i < e; ++i) { + if (lookup(fallthrough[i])) return true; + } + return false; + } + + for (var i = 0; i < maps.length; ++i) + if (lookup(maps[i])) return true; + } + function isModifierKey(event) { + var name = keyNames[e_prop(event, "keyCode")]; + return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"; + } + CodeMirror.isModifierKey = isModifierKey; + + // FROMTEXTAREA + + CodeMirror.fromTextArea = function(textarea, options) { + if (!options) options = {}; + options.value = textarea.value; + if (!options.tabindex && textarea.tabindex) + options.tabindex = textarea.tabindex; + // Set autofocus to true if this textarea is focused, or if it has + // autofocus and no other element is focused. + if (options.autofocus == null) { + var hasFocus = document.body; + // doc.activeElement occasionally throws on IE + try { hasFocus = document.activeElement; } catch(e) {} + options.autofocus = hasFocus == textarea || + textarea.getAttribute("autofocus") != null && hasFocus == document.body; + } + + function save() {textarea.value = cm.getValue();} + if (textarea.form) { + // Deplorable hack to make the submit method do the right thing. + on(textarea.form, "submit", save); + var form = textarea.form, realSubmit = form.submit; + try { + form.submit = function wrappedSubmit() { + save(); + form.submit = realSubmit; + form.submit(); + form.submit = wrappedSubmit; + }; + } catch(e) {} + } + + textarea.style.display = "none"; + var cm = CodeMirror(function(node) { + textarea.parentNode.insertBefore(node, textarea.nextSibling); + }, options); + cm.save = save; + cm.getTextArea = function() { return textarea; }; + cm.toTextArea = function() { + save(); + textarea.parentNode.removeChild(cm.getWrapperElement()); + textarea.style.display = ""; + if (textarea.form) { + off(textarea.form, "submit", save); + if (typeof textarea.form.submit == "function") + textarea.form.submit = realSubmit; + } + }; + return cm; + }; + + // STRING STREAM + + // Fed to the mode parsers, provides helper functions to make + // parsers more succinct. + + // The character stream used by a mode's parser. + function StringStream(string, tabSize) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + } + + StringStream.prototype = { + eol: function() {return this.pos >= this.string.length;}, + sol: function() {return this.pos == 0;}, + peek: function() {return this.string.charAt(this.pos) || undefined;}, + next: function() { + if (this.pos < this.string.length) + return this.string.charAt(this.pos++); + }, + eat: function(match) { + var ch = this.string.charAt(this.pos); + if (typeof match == "string") var ok = ch == match; + else var ok = ch && (match.test ? match.test(ch) : match(ch)); + if (ok) {++this.pos; return ch;} + }, + eatWhile: function(match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start; + }, + eatSpace: function() { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; + return this.pos > start; + }, + skipToEnd: function() {this.pos = this.string.length;}, + skipTo: function(ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true;} + }, + backUp: function(n) {this.pos -= n;}, + column: function() {return countColumn(this.string, this.start, this.tabSize);}, + indentation: function() {return countColumn(this.string, null, this.tabSize);}, + match: function(pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; + if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) { + if (consume !== false) this.pos += pattern.length; + return true; + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) return null; + if (match && consume !== false) this.pos += match[0].length; + return match; + } + }, + current: function(){return this.string.slice(this.start, this.pos);} + }; + CodeMirror.StringStream = StringStream; + + // TEXTMARKERS + + function TextMarker(cm, type) { + this.lines = []; + this.type = type; + this.cm = cm; + } + CodeMirror.TextMarker = TextMarker; + + TextMarker.prototype.clear = function() { + if (this.explicitlyCleared) return; + startOperation(this.cm); + var view = this.cm.view, min = null, max = null; + for (var i = 0; i < this.lines.length; ++i) { + var line = this.lines[i]; + var span = getMarkedSpanFor(line.markedSpans, this); + if (span.to != null) max = lineNo(line); + line.markedSpans = removeMarkedSpan(line.markedSpans, span); + if (span.from != null) + min = lineNo(line); + else if (this.collapsed && !lineIsHidden(line)) + updateLineHeight(line, textHeight(this.cm.display)); + } + if (this.collapsed && !this.cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) { + var visual = visualLine(view.doc, this.lines[i]), len = lineLength(view.doc, visual); + if (len > view.maxLineLength) { + view.maxLine = visual; + view.maxLineLength = len; + view.maxLineChanged = true; + } + } + + if (min != null) regChange(this.cm, min, max + 1); + this.lines.length = 0; + this.explicitlyCleared = true; + if (this.collapsed && this.cm.view.cantEdit) { + this.cm.view.cantEdit = false; + reCheckSelection(this.cm); + } + endOperation(this.cm); + signalLater(this.cm, this, "clear"); + }; + + TextMarker.prototype.find = function() { + var from, to; + for (var i = 0; i < this.lines.length; ++i) { + var line = this.lines[i]; + var span = getMarkedSpanFor(line.markedSpans, this); + if (span.from != null || span.to != null) { + var found = lineNo(line); + if (span.from != null) from = {line: found, ch: span.from}; + if (span.to != null) to = {line: found, ch: span.to}; + } + } + if (this.type == "bookmark") return from; + return from && {from: from, to: to}; + }; + + TextMarker.prototype.getOptions = function(copyWidget) { + var repl = this.replacedWith; + return {className: this.className, + inclusiveLeft: this.inclusiveLeft, inclusiveRight: this.inclusiveRight, + atomic: this.atomic, + collapsed: this.collapsed, + clearOnEnter: this.clearOnEnter, + replacedWith: copyWidget ? repl && repl.cloneNode(true) : repl, + readOnly: this.readOnly, + startStyle: this.startStyle, endStyle: this.endStyle}; + }; + + function markText(cm, from, to, options, type) { + var doc = cm.view.doc; + var marker = new TextMarker(cm, type); + if (type == "range" && !posLess(from, to)) return marker; + if (options) for (var opt in options) if (options.hasOwnProperty(opt)) + marker[opt] = options[opt]; + if (marker.replacedWith) { + marker.collapsed = true; + marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget"); + } + if (marker.collapsed) sawCollapsedSpans = true; + + var curLine = from.line, size = 0, collapsedAtStart, collapsedAtEnd; + doc.iter(curLine, to.line + 1, function(line) { + if (marker.collapsed && !cm.options.lineWrapping && visualLine(doc, line) == cm.view.maxLine) + cm.curOp.updateMaxLine = true; + var span = {from: null, to: null, marker: marker}; + size += line.text.length; + if (curLine == from.line) {span.from = from.ch; size -= from.ch;} + if (curLine == to.line) {span.to = to.ch; size -= line.text.length - to.ch;} + if (marker.collapsed) { + if (curLine == to.line) collapsedAtEnd = collapsedSpanAt(line, to.ch); + if (curLine == from.line) collapsedAtStart = collapsedSpanAt(line, from.ch); + else updateLineHeight(line, 0); + } + addMarkedSpan(line, span); + ++curLine; + }); + if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) { + if (lineIsHidden(line)) updateLineHeight(line, 0); + }); + + if (marker.readOnly) { + sawReadOnlySpans = true; + if (cm.view.history.done.length || cm.view.history.undone.length) + cm.clearHistory(); + } + if (marker.collapsed) { + if (collapsedAtStart != collapsedAtEnd) + throw new Error("Inserting collapsed marker overlapping an existing one"); + marker.size = size; + marker.atomic = true; + } + if (marker.className || marker.startStyle || marker.endStyle || marker.collapsed) + regChange(cm, from.line, to.line + 1); + if (marker.atomic) reCheckSelection(cm); + return marker; + } + + // TEXTMARKER SPANS + + function getMarkedSpanFor(spans, marker) { + if (spans) for (var i = 0; i < spans.length; ++i) { + var span = spans[i]; + if (span.marker == marker) return span; + } + } + function removeMarkedSpan(spans, span) { + for (var r, i = 0; i < spans.length; ++i) + if (spans[i] != span) (r || (r = [])).push(spans[i]); + return r; + } + function addMarkedSpan(line, span) { + line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; + span.marker.lines.push(line); + } + + function markedSpansBefore(old, startCh) { + if (old) for (var i = 0, nw; i < old.length; ++i) { + var span = old[i], marker = span.marker; + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); + if (startsBefore || marker.type == "bookmark" && span.from == startCh) { + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); + (nw || (nw = [])).push({from: span.from, + to: endsAfter ? null : span.to, + marker: marker}); + } + } + return nw; + } + + function markedSpansAfter(old, startCh, endCh) { + if (old) for (var i = 0, nw; i < old.length; ++i) { + var span = old[i], marker = span.marker; + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); + if (endsAfter || marker.type == "bookmark" && span.from == endCh && span.from != startCh) { + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); + (nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh, + to: span.to == null ? null : span.to - endCh, + marker: marker}); + } + } + return nw; + } + + function updateMarkedSpans(oldFirst, oldLast, startCh, endCh, newText) { + if (!oldFirst && !oldLast) return newText; + // Get the spans that 'stick out' on both sides + var first = markedSpansBefore(oldFirst, startCh); + var last = markedSpansAfter(oldLast, startCh, endCh); + + // Next, merge those two ends + var sameLine = newText.length == 1, offset = lst(newText).length + (sameLine ? startCh : 0); + if (first) { + // Fix up .to properties of first + for (var i = 0; i < first.length; ++i) { + var span = first[i]; + if (span.to == null) { + var found = getMarkedSpanFor(last, span.marker); + if (!found) span.to = startCh; + else if (sameLine) span.to = found.to == null ? null : found.to + offset; + } + } + } + if (last) { + // Fix up .from in last (or move them into first in case of sameLine) + for (var i = 0; i < last.length; ++i) { + var span = last[i]; + if (span.to != null) span.to += offset; + if (span.from == null) { + var found = getMarkedSpanFor(first, span.marker); + if (!found) { + span.from = offset; + if (sameLine) (first || (first = [])).push(span); + } + } else { + span.from += offset; + if (sameLine) (first || (first = [])).push(span); + } + } + } + + var newMarkers = [newHL(newText[0], first)]; + if (!sameLine) { + // Fill gap with whole-line-spans + var gap = newText.length - 2, gapMarkers; + if (gap > 0 && first) + for (var i = 0; i < first.length; ++i) + if (first[i].to == null) + (gapMarkers || (gapMarkers = [])).push({from: null, to: null, marker: first[i].marker}); + for (var i = 0; i < gap; ++i) + newMarkers.push(newHL(newText[i+1], gapMarkers)); + newMarkers.push(newHL(lst(newText), last)); + } + return newMarkers; + } + + function removeReadOnlyRanges(doc, from, to) { + var markers = null; + doc.iter(from.line, to.line + 1, function(line) { + if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) { + var mark = line.markedSpans[i].marker; + if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) + (markers || (markers = [])).push(mark); + } + }); + if (!markers) return null; + var parts = [{from: from, to: to}]; + for (var i = 0; i < markers.length; ++i) { + var m = markers[i].find(); + for (var j = 0; j < parts.length; ++j) { + var p = parts[j]; + if (!posLess(m.from, p.to) || posLess(m.to, p.from)) continue; + var newParts = [j, 1]; + if (posLess(p.from, m.from)) newParts.push({from: p.from, to: m.from}); + if (posLess(m.to, p.to)) newParts.push({from: m.to, to: p.to}); + parts.splice.apply(parts, newParts); + j += newParts.length - 1; + } + } + return parts; + } + + function collapsedSpanAt(line, ch) { + var sps = sawCollapsedSpans && line.markedSpans, found; + if (sps) for (var sp, i = 0; i < sps.length; ++i) { + sp = sps[i]; + if (!sp.marker.collapsed) continue; + if ((sp.from == null || sp.from < ch) && + (sp.to == null || sp.to > ch) && + (!found || found.width < sp.marker.width)) + found = sp.marker; + } + return found; + } + function collapsedSpanAtStart(line) { return collapsedSpanAt(line, -1); } + function collapsedSpanAtEnd(line) { return collapsedSpanAt(line, line.text.length + 1); } + + function visualLine(doc, line) { + var merged; + while (merged = collapsedSpanAtStart(line)) + line = getLine(doc, merged.find().from.line); + return line; + } + + function lineIsHidden(line) { + var sps = sawCollapsedSpans && line.markedSpans; + if (sps) for (var sp, i = 0; i < sps.length; ++i) { + sp = sps[i]; + if (!sp.marker.collapsed) continue; + if (sp.from == null) return true; + if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(line, sp)) + return true; + } + } + function lineIsHiddenInner(line, span) { + if (span.to == null) { + var end = span.marker.find().to, endLine = getLine(lineDoc(line), end.line); + return lineIsHiddenInner(endLine, getMarkedSpanFor(endLine.markedSpans, span.marker)); + } + if (span.marker.inclusiveRight && span.to == line.text.length) + return true; + for (var sp, i = 0; i < line.markedSpans.length; ++i) { + sp = line.markedSpans[i]; + if (sp.marker.collapsed && sp.from == span.to && + (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && + lineIsHiddenInner(line, sp)) return true; + } + } + + // hl stands for history-line, a data structure that can be either a + // string (line without markers) or a {text, markedSpans} object. + function hlText(val) { return typeof val == "string" ? val : val.text; } + function hlSpans(val) { + if (typeof val == "string") return null; + var spans = val.markedSpans, out = null; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); } + else if (out) out.push(spans[i]); + } + return !out ? spans : out.length ? out : null; + } + function newHL(text, spans) { return spans ? {text: text, markedSpans: spans} : text; } + + function detachMarkedSpans(line) { + var spans = line.markedSpans; + if (!spans) return; + for (var i = 0; i < spans.length; ++i) { + var lines = spans[i].marker.lines; + var ix = indexOf(lines, line); + lines.splice(ix, 1); + } + line.markedSpans = null; + } + + function attachMarkedSpans(line, spans) { + if (!spans) return; + for (var i = 0; i < spans.length; ++i) + spans[i].marker.lines.push(line); + line.markedSpans = spans; + } + + // LINE WIDGETS + + var LineWidget = CodeMirror.LineWidget = function(cm, node, options) { + for (var opt in options) if (options.hasOwnProperty(opt)) + this[opt] = options[opt]; + this.cm = cm; + this.node = node; + }; + function widgetOperation(f) { + return function() { + startOperation(this.cm); + try {var result = f.apply(this, arguments);} + finally {endOperation(this.cm);} + return result; + }; + } + LineWidget.prototype.clear = widgetOperation(function() { + var ws = this.line.widgets, no = lineNo(this.line); + if (no == null || !ws) return; + for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1); + updateLineHeight(this.line, Math.max(0, this.line.height - widgetHeight(this))); + regChange(this.cm, no, no + 1); + }); + LineWidget.prototype.changed = widgetOperation(function() { + var oldH = this.height; + this.height = null; + var diff = widgetHeight(this) - oldH; + if (!diff) return; + updateLineHeight(this.line, this.line.height + diff); + var no = lineNo(this.line); + regChange(this.cm, no, no + 1); + }); + + function widgetHeight(widget) { + if (widget.height != null) return widget.height; + if (!widget.node.parentNode || widget.node.parentNode.nodeType != 1) + removeChildrenAndAdd(widget.cm.display.measure, elt("div", [widget.node], null, "position: relative")); + return widget.height = widget.node.offsetHeight; + } + + function addLineWidget(cm, handle, node, options) { + var widget = new LineWidget(cm, node, options); + if (widget.noHScroll) cm.display.alignWidgets = true; + changeLine(cm, handle, function(line) { + (line.widgets || (line.widgets = [])).push(widget); + widget.line = line; + if (!lineIsHidden(line) || widget.showIfHidden) { + var aboveVisible = heightAtLine(cm, line) < cm.display.scroller.scrollTop; + updateLineHeight(line, line.height + widgetHeight(widget)); + if (aboveVisible) + setTimeout(function() {cm.display.scroller.scrollTop += widget.height;}); + } + return true; + }); + return widget; + } + + // LINE DATA STRUCTURE + + // Line objects. These hold state related to a line, including + // highlighting info (the styles array). + function makeLine(text, markedSpans, height) { + var line = {text: text, height: height}; + attachMarkedSpans(line, markedSpans); + if (lineIsHidden(line)) line.height = 0; + return line; + } + + function updateLine(cm, line, text, markedSpans) { + line.text = text; + if (line.stateAfter) line.stateAfter = null; + if (line.styles) line.styles = null; + if (line.order != null) line.order = null; + detachMarkedSpans(line); + attachMarkedSpans(line, markedSpans); + if (lineIsHidden(line)) line.height = 0; + else if (!line.height) line.height = textHeight(cm.display); + signalLater(cm, line, "change"); + } + + function cleanUpLine(line) { + line.parent = null; + detachMarkedSpans(line); + } + + // Run the given mode's parser over a line, update the styles + // array, which contains alternating fragments of text and CSS + // classes. + function runMode(cm, text, mode, state, f) { + var flattenSpans = cm.options.flattenSpans; + var curText = "", curStyle = null; + var stream = new StringStream(text, cm.options.tabSize); + if (text == "" && mode.blankLine) mode.blankLine(state); + while (!stream.eol()) { + var style = mode.token(stream, state); + if (stream.pos > 5000) { + flattenSpans = false; + // Webkit seems to refuse to render text nodes longer than 57444 characters + stream.pos = Math.min(text.length, stream.start + 50000); + style = null; + } + var substr = stream.current(); + stream.start = stream.pos; + if (!flattenSpans || curStyle != style) { + if (curText) f(curText, curStyle); + curText = substr; curStyle = style; + } else curText = curText + substr; + } + if (curText) f(curText, curStyle); + } + + function highlightLine(cm, line, state) { + // A styles array always starts with a number identifying the + // mode/overlays that it is based on (for easy invalidation). + var st = [cm.view.modeGen]; + // Compute the base array of styles + runMode(cm, line.text, cm.view.mode, state, function(txt, style) {st.push(txt, style);}); + + // Run overlays, adjust style array. + for (var o = 0; o < cm.view.overlays.length; ++o) { + var overlay = cm.view.overlays[o], i = 1; + runMode(cm, line.text, overlay.mode, true, function(txt, style) { + var start = i, len = txt.length; + // Ensure there's a token end at the current position, and that i points at it + while (len) { + var cur = st[i], len_ = cur.length; + if (len_ <= len) { + len -= len_; + } else { + st.splice(i, 1, cur.slice(0, len), st[i+1], cur.slice(len)); + len = 0; + } + i += 2; + } + if (!style) return; + if (overlay.opaque) { + st.splice(start, i - start, txt, style); + i = start + 2; + } else { + for (; start < i; start += 2) { + var cur = st[start+1]; + st[start+1] = cur ? cur + " " + style : style; + } + } + }); + } + + return st; + } + + function getLineStyles(cm, line) { + if (!line.styles || line.styles[0] != cm.view.modeGen) + line.styles = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line))); + return line.styles; + } + + // Lightweight form of highlight -- proceed over this line and + // update state, but don't save a style array. + function processLine(cm, line, state) { + var mode = cm.view.mode; + var stream = new StringStream(line.text, cm.options.tabSize); + if (line.text == "" && mode.blankLine) mode.blankLine(state); + while (!stream.eol() && stream.pos <= 5000) { + mode.token(stream, state); + stream.start = stream.pos; + } + } + + var styleToClassCache = {}; + function styleToClass(style) { + if (!style) return null; + return styleToClassCache[style] || + (styleToClassCache[style] = "cm-" + style.replace(/ +/g, " cm-")); + } + + function lineContent(cm, realLine, measure) { + var merged, line = realLine, lineBefore, sawBefore, simple = true; + while (merged = collapsedSpanAtStart(line)) { + simple = false; + line = getLine(cm.view.doc, merged.find().from.line); + if (!lineBefore) lineBefore = line; + } + + var builder = {pre: elt("pre"), col: 0, pos: 0, display: !measure, + measure: null, addedOne: false, cm: cm}; + if (line.textClass) builder.pre.className = line.textClass; + + do { + builder.measure = line == realLine && measure; + builder.pos = 0; + builder.addToken = builder.measure ? buildTokenMeasure : buildToken; + if (measure && sawBefore && line != realLine && !builder.addedOne) { + measure[0] = builder.pre.appendChild(zeroWidthElement(cm.display.measure)); + builder.addedOne = true; + } + var next = insertLineContent(line, builder, getLineStyles(cm, line)); + sawBefore = line == lineBefore; + if (next) { + line = getLine(cm.view.doc, next.to.line); + simple = false; + } + } while (next); + + if (measure && !builder.addedOne) + measure[0] = builder.pre.appendChild(simple ? elt("span", "\u00a0") : zeroWidthElement(cm.display.measure)); + if (!builder.pre.firstChild && !lineIsHidden(realLine)) + builder.pre.appendChild(document.createTextNode("\u00a0")); + + return builder.pre; + } + + var tokenSpecialChars = /[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g; + function buildToken(builder, text, style, startStyle, endStyle) { + if (!text) return; + if (!tokenSpecialChars.test(text)) { + builder.col += text.length; + var content = document.createTextNode(text); + } else { + var content = document.createDocumentFragment(), pos = 0; + while (true) { + tokenSpecialChars.lastIndex = pos; + var m = tokenSpecialChars.exec(text); + var skipped = m ? m.index - pos : text.length - pos; + if (skipped) { + content.appendChild(document.createTextNode(text.slice(pos, pos + skipped))); + builder.col += skipped; + } + if (!m) break; + pos += skipped + 1; + if (m[0] == "\t") { + var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; + content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); + builder.col += tabWidth; + } else { + var token = elt("span", "\u2022", "cm-invalidchar"); + token.title = "\\u" + m[0].charCodeAt(0).toString(16); + content.appendChild(token); + builder.col += 1; + } + } + } + if (style || startStyle || endStyle || builder.measure) { + var fullStyle = style || ""; + if (startStyle) fullStyle += startStyle; + if (endStyle) fullStyle += endStyle; + return builder.pre.appendChild(elt("span", [content], fullStyle)); + } + builder.pre.appendChild(content); + } + + function buildTokenMeasure(builder, text, style, startStyle, endStyle) { + for (var i = 0; i < text.length; ++i) { + if (i && i < text.length && + builder.cm.options.lineWrapping && + spanAffectsWrapping.test(text.slice(i - 1, i + 1))) + builder.pre.appendChild(elt("wbr")); + builder.measure[builder.pos++] = + buildToken(builder, text.charAt(i), style, + i == 0 && startStyle, i == text.length - 1 && endStyle); + } + if (text.length) builder.addedOne = true; + } + + function buildCollapsedSpan(builder, size, widget) { + if (widget) { + if (!builder.display) widget = widget.cloneNode(true); + builder.pre.appendChild(widget); + if (builder.measure && size) { + builder.measure[builder.pos] = widget; + builder.addedOne = true; + } + } + builder.pos += size; + } + + // Outputs a number of spans to make up a line, taking highlighting + // and marked text into account. + function insertLineContent(line, builder, styles) { + var spans = line.markedSpans; + if (!spans) { + for (var i = 1; i < styles.length; i+=2) + builder.addToken(builder, styles[i], styleToClass(styles[i+1])); + return; + } + + var allText = line.text, len = allText.length; + var pos = 0, i = 1, text = "", style; + var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed; + for (;;) { + if (nextChange == pos) { // Update current marker set + spanStyle = spanEndStyle = spanStartStyle = ""; + collapsed = null; nextChange = Infinity; + var foundBookmark = null; + for (var j = 0; j < spans.length; ++j) { + var sp = spans[j], m = sp.marker; + if (sp.from <= pos && (sp.to == null || sp.to > pos)) { + if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } + if (m.className) spanStyle += " " + m.className; + if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; + if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle; + if (m.collapsed && (!collapsed || collapsed.marker.width < m.width)) + collapsed = sp; + } else if (sp.from > pos && nextChange > sp.from) { + nextChange = sp.from; + } + if (m.type == "bookmark" && sp.from == pos && m.replacedWith) + foundBookmark = m.replacedWith; + } + if (collapsed && (collapsed.from || 0) == pos) { + buildCollapsedSpan(builder, (collapsed.to == null ? len : collapsed.to) - pos, + collapsed.from != null && collapsed.marker.replacedWith); + if (collapsed.to == null) return collapsed.marker.find(); + } + if (foundBookmark && !collapsed) buildCollapsedSpan(builder, 0, foundBookmark); + } + if (pos >= len) break; + + var upto = Math.min(len, nextChange); + while (true) { + if (text) { + var end = pos + text.length; + if (!collapsed) { + var tokenText = end > upto ? text.slice(0, upto - pos) : text; + builder.addToken(builder, tokenText, style + spanStyle, + spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : ""); + } + if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;} + pos = end; + spanStartStyle = ""; + } + text = styles[i++]; style = styleToClass(styles[i++]); + } + } + } + + // DOCUMENT DATA STRUCTURE + + function LeafChunk(lines) { + this.lines = lines; + this.parent = null; + for (var i = 0, e = lines.length, height = 0; i < e; ++i) { + lines[i].parent = this; + height += lines[i].height; + } + this.height = height; + } + + LeafChunk.prototype = { + chunkSize: function() { return this.lines.length; }, + remove: function(at, n, cm) { + for (var i = at, e = at + n; i < e; ++i) { + var line = this.lines[i]; + this.height -= line.height; + cleanUpLine(line); + signalLater(cm, line, "delete"); + } + this.lines.splice(at, n); + }, + collapse: function(lines) { + lines.splice.apply(lines, [lines.length, 0].concat(this.lines)); + }, + insertHeight: function(at, lines, height) { + this.height += height; + this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); + for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this; + }, + iterN: function(at, n, op) { + for (var e = at + n; at < e; ++at) + if (op(this.lines[at])) return true; + } + }; + + function BranchChunk(children) { + this.children = children; + var size = 0, height = 0; + for (var i = 0, e = children.length; i < e; ++i) { + var ch = children[i]; + size += ch.chunkSize(); height += ch.height; + ch.parent = this; + } + this.size = size; + this.height = height; + this.parent = null; + } + + BranchChunk.prototype = { + chunkSize: function() { return this.size; }, + remove: function(at, n, callbacks) { + this.size -= n; + for (var i = 0; i < this.children.length; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at < sz) { + var rm = Math.min(n, sz - at), oldHeight = child.height; + child.remove(at, rm, callbacks); + this.height -= oldHeight - child.height; + if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } + if ((n -= rm) == 0) break; + at = 0; + } else at -= sz; + } + if (this.size - n < 25) { + var lines = []; + this.collapse(lines); + this.children = [new LeafChunk(lines)]; + this.children[0].parent = this; + } + }, + collapse: function(lines) { + for (var i = 0, e = this.children.length; i < e; ++i) this.children[i].collapse(lines); + }, + insert: function(at, lines) { + var height = 0; + for (var i = 0, e = lines.length; i < e; ++i) height += lines[i].height; + this.insertHeight(at, lines, height); + }, + insertHeight: function(at, lines, height) { + this.size += lines.length; + this.height += height; + for (var i = 0, e = this.children.length; i < e; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at <= sz) { + child.insertHeight(at, lines, height); + if (child.lines && child.lines.length > 50) { + while (child.lines.length > 50) { + var spilled = child.lines.splice(child.lines.length - 25, 25); + var newleaf = new LeafChunk(spilled); + child.height -= newleaf.height; + this.children.splice(i + 1, 0, newleaf); + newleaf.parent = this; + } + this.maybeSpill(); + } + break; + } + at -= sz; + } + }, + maybeSpill: function() { + if (this.children.length <= 10) return; + var me = this; + do { + var spilled = me.children.splice(me.children.length - 5, 5); + var sibling = new BranchChunk(spilled); + if (!me.parent) { // Become the parent node + var copy = new BranchChunk(me.children); + copy.parent = me; + me.children = [copy, sibling]; + me = copy; + } else { + me.size -= sibling.size; + me.height -= sibling.height; + var myIndex = indexOf(me.parent.children, me); + me.parent.children.splice(myIndex + 1, 0, sibling); + } + sibling.parent = me.parent; + } while (me.children.length > 10); + me.parent.maybeSpill(); + }, + iter: function(from, to, op) { this.iterN(from, to - from, op); }, + iterN: function(at, n, op) { + for (var i = 0, e = this.children.length; i < e; ++i) { + var child = this.children[i], sz = child.chunkSize(); + if (at < sz) { + var used = Math.min(n, sz - at); + if (child.iterN(at, used, op)) return true; + if ((n -= used) == 0) break; + at = 0; + } else at -= sz; + } + } + }; + + // LINE UTILITIES + + function getLine(chunk, n) { + while (!chunk.lines) { + for (var i = 0;; ++i) { + var child = chunk.children[i], sz = child.chunkSize(); + if (n < sz) { chunk = child; break; } + n -= sz; + } + } + return chunk.lines[n]; + } + + function updateLineHeight(line, height) { + var diff = height - line.height; + for (var n = line; n; n = n.parent) n.height += diff; + } + + function lineNo(line) { + if (line.parent == null) return null; + var cur = line.parent, no = indexOf(cur.lines, line); + for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { + for (var i = 0;; ++i) { + if (chunk.children[i] == cur) break; + no += chunk.children[i].chunkSize(); + } + } + return no; + } + + function lineDoc(line) { + for (var d = line.parent; d.parent; d = d.parent) {} + return d; + } + + function lineAtHeight(chunk, h) { + var n = 0; + outer: do { + for (var i = 0, e = chunk.children.length; i < e; ++i) { + var child = chunk.children[i], ch = child.height; + if (h < ch) { chunk = child; continue outer; } + h -= ch; + n += child.chunkSize(); + } + return n; + } while (!chunk.lines); + for (var i = 0, e = chunk.lines.length; i < e; ++i) { + var line = chunk.lines[i], lh = line.height; + if (h < lh) break; + h -= lh; + } + return n + i; + } + + function heightAtLine(cm, lineObj) { + lineObj = visualLine(cm.view.doc, lineObj); + + var h = 0, chunk = lineObj.parent; + for (var i = 0; i < chunk.lines.length; ++i) { + var line = chunk.lines[i]; + if (line == lineObj) break; + else h += line.height; + } + for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { + for (var i = 0; i < p.children.length; ++i) { + var cur = p.children[i]; + if (cur == chunk) break; + else h += cur.height; + } + } + return h; + } + + function getOrder(line) { + var order = line.order; + if (order == null) order = line.order = bidiOrdering(line.text); + return order; + } + + // HISTORY + + function makeHistory() { + return { + // Arrays of history events. Doing something adds an event to + // done and clears undo. Undoing moves events from done to + // undone, redoing moves them in the other direction. + done: [], undone: [], + // Used to track when changes can be merged into a single undo + // event + lastTime: 0, lastOp: null, lastOrigin: null, + // Used by the isClean() method + dirtyCounter: 0 + }; + } + + function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) { + var history = cm.view.history; + history.undone.length = 0; + var time = +new Date, cur = lst(history.done); + + if (cur && + (history.lastOp == cm.curOp.id || + history.lastOrigin == origin && (origin == "input" || origin == "delete") && + history.lastTime > time - 600)) { + // Merge this change into the last event + var last = lst(cur.events); + if (last.start > start + old.length || last.start + last.added < start) { + // Doesn't intersect with last sub-event, add new sub-event + cur.events.push({start: start, added: added, old: old}); + } else { + // Patch up the last sub-event + var startBefore = Math.max(0, last.start - start), + endAfter = Math.max(0, (start + old.length) - (last.start + last.added)); + for (var i = startBefore; i > 0; --i) last.old.unshift(old[i - 1]); + for (var i = endAfter; i > 0; --i) last.old.push(old[old.length - i]); + if (startBefore) last.start = start; + last.added += added - (old.length - startBefore - endAfter); + } + cur.fromAfter = fromAfter; cur.toAfter = toAfter; + } else { + // Can not be merged, start a new event. + cur = {events: [{start: start, added: added, old: old}], + fromBefore: fromBefore, toBefore: toBefore, fromAfter: fromAfter, toAfter: toAfter}; + history.done.push(cur); + while (history.done.length > cm.options.undoDepth) + history.done.shift(); + if (history.dirtyCounter < 0) + // The user has made a change after undoing past the last clean state. + // We can never get back to a clean state now until markClean() is called. + history.dirtyCounter = NaN; + else + history.dirtyCounter++; + } + history.lastTime = time; + history.lastOp = cm.curOp.id; + history.lastOrigin = origin; + } + + // EVENT OPERATORS + + function stopMethod() {e_stop(this);} + // Ensure an event has a stop method. + function addStop(event) { + if (!event.stop) event.stop = stopMethod; + return event; + } + + function e_preventDefault(e) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + function e_stopPropagation(e) { + if (e.stopPropagation) e.stopPropagation(); + else e.cancelBubble = true; + } + function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);} + CodeMirror.e_stop = e_stop; + CodeMirror.e_preventDefault = e_preventDefault; + CodeMirror.e_stopPropagation = e_stopPropagation; + + function e_target(e) {return e.target || e.srcElement;} + function e_button(e) { + var b = e.which; + if (b == null) { + if (e.button & 1) b = 1; + else if (e.button & 2) b = 3; + else if (e.button & 4) b = 2; + } + if (mac && e.ctrlKey && b == 1) b = 3; + return b; + } + + // Allow 3rd-party code to override event properties by adding an override + // object to an event object. + function e_prop(e, prop) { + var overridden = e.override && e.override.hasOwnProperty(prop); + return overridden ? e.override[prop] : e[prop]; + } + + // EVENT HANDLING + + function on(emitter, type, f) { + if (emitter.addEventListener) + emitter.addEventListener(type, f, false); + else if (emitter.attachEvent) + emitter.attachEvent("on" + type, f); + else { + var map = emitter._handlers || (emitter._handlers = {}); + var arr = map[type] || (map[type] = []); + arr.push(f); + } + } + + function off(emitter, type, f) { + if (emitter.removeEventListener) + emitter.removeEventListener(type, f, false); + else if (emitter.detachEvent) + emitter.detachEvent("on" + type, f); + else { + var arr = emitter._handlers && emitter._handlers[type]; + if (!arr) return; + for (var i = 0; i < arr.length; ++i) + if (arr[i] == f) { arr.splice(i, 1); break; } + } + } + + function signal(emitter, type /*, values...*/) { + var arr = emitter._handlers && emitter._handlers[type]; + if (!arr) return; + var args = Array.prototype.slice.call(arguments, 2); + for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args); + } + + function signalLater(cm, emitter, type /*, values...*/) { + var arr = emitter._handlers && emitter._handlers[type]; + if (!arr) return; + var args = Array.prototype.slice.call(arguments, 3), flist = cm.curOp && cm.curOp.delayedCallbacks; + function bnd(f) {return function(){f.apply(null, args);};}; + for (var i = 0; i < arr.length; ++i) + if (flist) flist.push(bnd(arr[i])); + else arr[i].apply(null, args); + } + + function hasHandler(emitter, type) { + var arr = emitter._handlers && emitter._handlers[type]; + return arr && arr.length > 0; + } + + CodeMirror.on = on; CodeMirror.off = off; CodeMirror.signal = signal; + + // MISC UTILITIES + + // Number of pixels added to scroller and sizer to hide scrollbar + var scrollerCutOff = 30; + + // Returned or thrown by various protocols to signal 'I'm not + // handling this'. + var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}}; + + function Delayed() {this.id = null;} + Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}}; + + // Counts the column offset in a string, taking tabs into account. + // Used mostly to find indentation. + function countColumn(string, end, tabSize) { + if (end == null) { + end = string.search(/[^\s\u00a0]/); + if (end == -1) end = string.length; + } + for (var i = 0, n = 0; i < end; ++i) { + if (string.charAt(i) == "\t") n += tabSize - (n % tabSize); + else ++n; + } + return n; + } + CodeMirror.countColumn = countColumn; + + var spaceStrs = [""]; + function spaceStr(n) { + while (spaceStrs.length <= n) + spaceStrs.push(lst(spaceStrs) + " "); + return spaceStrs[n]; + } + + function lst(arr) { return arr[arr.length-1]; } + + function selectInput(node) { + if (ios) { // Mobile Safari apparently has a bug where select() is broken. + node.selectionStart = 0; + node.selectionEnd = node.value.length; + } else node.select(); + } + + function indexOf(collection, elt) { + if (collection.indexOf) return collection.indexOf(elt); + for (var i = 0, e = collection.length; i < e; ++i) + if (collection[i] == elt) return i; + return -1; + } + + function emptyArray(size) { + for (var a = [], i = 0; i < size; ++i) a.push(undefined); + return a; + } + + function bind(f) { + var args = Array.prototype.slice.call(arguments, 1); + return function(){return f.apply(null, args);}; + } + + var nonASCIISingleCaseWordChar = /[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/; + function isWordChar(ch) { + return /\w/.test(ch) || ch > "\x80" && + (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); + } + + function isEmpty(obj) { + var c = 0; + for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) ++c; + return !c; + } + + var isExtendingChar = /[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F]/; + + // DOM UTILITIES + + function elt(tag, content, className, style) { + var e = document.createElement(tag); + if (className) e.className = className; + if (style) e.style.cssText = style; + if (typeof content == "string") setTextContent(e, content); + else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); + return e; + } + + function removeChildren(e) { + // IE will break all parent-child relations in subnodes when setting innerHTML + if (!ie) e.innerHTML = ""; + else while (e.firstChild) e.removeChild(e.firstChild); + return e; + } + + function removeChildrenAndAdd(parent, e) { + return removeChildren(parent).appendChild(e); + } + + function setTextContent(e, str) { + if (ie_lt9) { + e.innerHTML = ""; + e.appendChild(document.createTextNode(str)); + } else e.textContent = str; + } + + // FEATURE DETECTION + + // Detect drag-and-drop + var dragAndDrop = function() { + // There is *some* kind of drag-and-drop support in IE6-8, but I + // couldn't get it to work yet. + if (ie_lt9) return false; + var div = elt('div'); + return "draggable" in div || "dragDrop" in div; + }(); + + // For a reason I have yet to figure out, some browsers disallow + // word wrapping between certain characters *only* if a new inline + // element is started between them. This makes it hard to reliably + // measure the position of things, since that requires inserting an + // extra span. This terribly fragile set of regexps matches the + // character combinations that suffer from this phenomenon on the + // various browsers. + var spanAffectsWrapping = /^$/; // Won't match any two-character string + if (gecko) spanAffectsWrapping = /$'/; + else if (safari) spanAffectsWrapping = /\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/; + else if (chrome) spanAffectsWrapping = /\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/; + + var knownScrollbarWidth; + function scrollbarWidth(measure) { + if (knownScrollbarWidth != null) return knownScrollbarWidth; + var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll"); + removeChildrenAndAdd(measure, test); + if (test.offsetWidth) + knownScrollbarWidth = test.offsetHeight - test.clientHeight; + return knownScrollbarWidth || 0; + } + + var zwspSupported; + function zeroWidthElement(measure) { + if (zwspSupported == null) { + var test = elt("span", "\u200b"); + removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); + if (measure.firstChild.offsetHeight != 0) + zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_lt8; + } + if (zwspSupported) return elt("span", "\u200b"); + else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); + } + + // See if "".split is the broken IE version, if so, provide an + // alternative way to split lines. + var splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { + var pos = 0, result = [], l = string.length; + while (pos <= l) { + var nl = string.indexOf("\n", pos); + if (nl == -1) nl = string.length; + var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); + var rt = line.indexOf("\r"); + if (rt != -1) { + result.push(line.slice(0, rt)); + pos += rt + 1; + } else { + result.push(line); + pos = nl + 1; + } + } + return result; + } : function(string){return string.split(/\r\n?|\n/);}; + CodeMirror.splitLines = splitLines; + + var hasSelection = window.getSelection ? function(te) { + try { return te.selectionStart != te.selectionEnd; } + catch(e) { return false; } + } : function(te) { + try {var range = te.ownerDocument.selection.createRange();} + catch(e) {} + if (!range || range.parentElement() != te) return false; + return range.compareEndPoints("StartToEnd", range) != 0; + }; + + var hasCopyEvent = (function() { + var e = elt("div"); + if ("oncopy" in e) return true; + e.setAttribute("oncopy", "return;"); + return typeof e.oncopy == 'function'; + })(); + + // KEY NAMING + + var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", + 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", + 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", + 46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 109: "-", 107: "=", 127: "Delete", + 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", + 221: "]", 222: "'", 63276: "PageUp", 63277: "PageDown", 63275: "End", 63273: "Home", + 63234: "Left", 63232: "Up", 63235: "Right", 63233: "Down", 63302: "Insert", 63272: "Delete"}; + CodeMirror.keyNames = keyNames; + (function() { + // Number keys + for (var i = 0; i < 10; i++) keyNames[i + 48] = String(i); + // Alphabetic keys + for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i); + // Function keys + for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i; + })(); + + // BIDI HELPERS + + function iterateBidiSections(order, from, to, f) { + if (!order) return f(from, to, "ltr"); + for (var i = 0; i < order.length; ++i) { + var part = order[i]; + if (part.from < to && part.to > from || from == to && part.to == from) + f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr"); + } + } + + function bidiLeft(part) { return part.level % 2 ? part.to : part.from; } + function bidiRight(part) { return part.level % 2 ? part.from : part.to; } + + function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; } + function lineRight(line) { + var order = getOrder(line); + if (!order) return line.text.length; + return bidiRight(lst(order)); + } + + function lineStart(cm, lineN) { + var line = getLine(cm.view.doc, lineN); + var visual = visualLine(cm.view.doc, line); + if (visual != line) lineN = lineNo(visual); + var order = getOrder(visual); + var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual); + return {line: lineN, ch: ch}; + } + function lineEnd(cm, lineNo) { + var merged, line; + while (merged = collapsedSpanAtEnd(line = getLine(cm.view.doc, lineNo))) + lineNo = merged.find().to.line; + var order = getOrder(line); + var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); + return {line: lineNo, ch: ch}; + } + + // This is somewhat involved. It is needed in order to move + // 'visually' through bi-directional text -- i.e., pressing left + // should make the cursor go left, even when in RTL text. The + // tricky part is the 'jumps', where RTL and LTR text touch each + // other. This often requires the cursor offset to move more than + // one unit, in order to visually move one unit. + function moveVisually(line, start, dir, byUnit) { + var bidi = getOrder(line); + if (!bidi) return moveLogically(line, start, dir, byUnit); + var moveOneUnit = byUnit ? function(pos, dir) { + do pos += dir; + while (pos > 0 && isExtendingChar.test(line.text.charAt(pos))); + return pos; + } : function(pos, dir) { return pos + dir; }; + var linedir = bidi[0].level; + for (var i = 0; i < bidi.length; ++i) { + var part = bidi[i], sticky = part.level % 2 == linedir; + if ((part.from < start && part.to > start) || + (sticky && (part.from == start || part.to == start))) break; + } + var target = moveOneUnit(start, part.level % 2 ? -dir : dir); + + while (target != null) { + if (part.level % 2 == linedir) { + if (target < part.from || target > part.to) { + part = bidi[i += dir]; + target = part && (dir > 0 == part.level % 2 ? moveOneUnit(part.to, -1) : moveOneUnit(part.from, 1)); + } else break; + } else { + if (target == bidiLeft(part)) { + part = bidi[--i]; + target = part && bidiRight(part); + } else if (target == bidiRight(part)) { + part = bidi[++i]; + target = part && bidiLeft(part); + } else break; + } + } + + return target < 0 || target > line.text.length ? null : target; + } + + function moveLogically(line, start, dir, byUnit) { + var target = start + dir; + if (byUnit) while (target > 0 && isExtendingChar.test(line.text.charAt(target))) target += dir; + return target < 0 || target > line.text.length ? null : target; + } + + // Bidirectional ordering algorithm + // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm + // that this (partially) implements. + + // One-char codes used for character types: + // L (L): Left-to-Right + // R (R): Right-to-Left + // r (AL): Right-to-Left Arabic + // 1 (EN): European Number + // + (ES): European Number Separator + // % (ET): European Number Terminator + // n (AN): Arabic Number + // , (CS): Common Number Separator + // m (NSM): Non-Spacing Mark + // b (BN): Boundary Neutral + // s (B): Paragraph Separator + // t (S): Segment Separator + // w (WS): Whitespace + // N (ON): Other Neutrals + + // Returns null if characters are ordered as they appear + // (left-to-right), or an array of sections ({from, to, level} + // objects) in the order in which they occur visually. + var bidiOrdering = (function() { + // Character types for codepoints 0 to 0xff + var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL"; + // Character types for codepoints 0x600 to 0x6ff + var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr"; + function charType(code) { + if (code <= 0xff) return lowTypes.charAt(code); + else if (0x590 <= code && code <= 0x5f4) return "R"; + else if (0x600 <= code && code <= 0x6ff) return arabicTypes.charAt(code - 0x600); + else if (0x700 <= code && code <= 0x8ac) return "r"; + else return "L"; + } + + var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; + var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; + // Browsers seem to always treat the boundaries of block elements as being L. + var outerType = "L"; + + return function charOrdering(str) { + if (!bidiRE.test(str)) return false; + var len = str.length, types = []; + for (var i = 0, type; i < len; ++i) + types.push(type = charType(str.charCodeAt(i))); + + // W1. Examine each non-spacing mark (NSM) in the level run, and + // change the type of the NSM to the type of the previous + // character. If the NSM is at the start of the level run, it will + // get the type of sor. + for (var i = 0, prev = outerType; i < len; ++i) { + var type = types[i]; + if (type == "m") types[i] = prev; + else prev = type; + } + + // W2. Search backwards from each instance of a European number + // until the first strong type (R, L, AL, or sor) is found. If an + // AL is found, change the type of the European number to Arabic + // number. + // W3. Change all ALs to R. + for (var i = 0, cur = outerType; i < len; ++i) { + var type = types[i]; + if (type == "1" && cur == "r") types[i] = "n"; + else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; } + } + + // W4. A single European separator between two European numbers + // changes to a European number. A single common separator between + // two numbers of the same type changes to that type. + for (var i = 1, prev = types[0]; i < len - 1; ++i) { + var type = types[i]; + if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1"; + else if (type == "," && prev == types[i+1] && + (prev == "1" || prev == "n")) types[i] = prev; + prev = type; + } + + // W5. A sequence of European terminators adjacent to European + // numbers changes to all European numbers. + // W6. Otherwise, separators and terminators change to Other + // Neutral. + for (var i = 0; i < len; ++i) { + var type = types[i]; + if (type == ",") types[i] = "N"; + else if (type == "%") { + for (var end = i + 1; end < len && types[end] == "%"; ++end) {} + var replace = (i && types[i-1] == "!") || (end < len - 1 && types[end] == "1") ? "1" : "N"; + for (var j = i; j < end; ++j) types[j] = replace; + i = end - 1; + } + } + + // W7. Search backwards from each instance of a European number + // until the first strong type (R, L, or sor) is found. If an L is + // found, then change the type of the European number to L. + for (var i = 0, cur = outerType; i < len; ++i) { + var type = types[i]; + if (cur == "L" && type == "1") types[i] = "L"; + else if (isStrong.test(type)) cur = type; + } + + // N1. A sequence of neutrals takes the direction of the + // surrounding strong text if the text on both sides has the same + // direction. European and Arabic numbers act as if they were R in + // terms of their influence on neutrals. Start-of-level-run (sor) + // and end-of-level-run (eor) are used at level run boundaries. + // N2. Any remaining neutrals take the embedding direction. + for (var i = 0; i < len; ++i) { + if (isNeutral.test(types[i])) { + for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {} + var before = (i ? types[i-1] : outerType) == "L"; + var after = (end < len - 1 ? types[end] : outerType) == "L"; + var replace = before || after ? "L" : "R"; + for (var j = i; j < end; ++j) types[j] = replace; + i = end - 1; + } + } + + // Here we depart from the documented algorithm, in order to avoid + // building up an actual levels array. Since there are only three + // levels (0, 1, 2) in an implementation that doesn't take + // explicit embedding into account, we can build up the order on + // the fly, without following the level-based algorithm. + var order = [], m; + for (var i = 0; i < len;) { + if (countsAsLeft.test(types[i])) { + var start = i; + for (++i; i < len && countsAsLeft.test(types[i]); ++i) {} + order.push({from: start, to: i, level: 0}); + } else { + var pos = i, at = order.length; + for (++i; i < len && types[i] != "L"; ++i) {} + for (var j = pos; j < i;) { + if (countsAsNum.test(types[j])) { + if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1}); + var nstart = j; + for (++j; j < i && countsAsNum.test(types[j]); ++j) {} + order.splice(at, 0, {from: nstart, to: j, level: 2}); + pos = j; + } else ++j; + } + if (pos < i) order.splice(at, 0, {from: pos, to: i, level: 1}); + } + } + if (order[0].level == 1 && (m = str.match(/^\s+/))) { + order[0].from = m[0].length; + order.unshift({from: 0, to: m[0].length, level: 0}); + } + if (lst(order).level == 1 && (m = str.match(/\s+$/))) { + lst(order).to -= m[0].length; + order.push({from: len - m[0].length, to: len, level: 0}); + } + if (order[0].level != lst(order).level) + order.push({from: len, to: len, level: order[0].level}); + + return order; + }; + })(); + + // THE END + + CodeMirror.version = "3.02"; + + return CodeMirror; +})(); diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/LICENSE b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/LICENSE new file mode 100644 index 0000000..977e284 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2011 Jeff Pickhardt +Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/coffeescript.js b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/coffeescript.js new file mode 100644 index 0000000..670e01f --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/coffeescript.js @@ -0,0 +1,346 @@ +/** + * Link to the project's GitHub page: + * https://github.com/pickhardt/coffeescript-codemirror-mode + */ +CodeMirror.defineMode('coffeescript', function(conf) { + var ERRORCLASS = 'error'; + + function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b"); + } + + var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]"); + var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\},:`=;\\.]'); + var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))"); + var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"); + var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))"); + var identifiers = new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*"); + var properties = new RegExp("^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*"); + + var wordOperators = wordRegexp(['and', 'or', 'not', + 'is', 'isnt', 'in', + 'instanceof', 'typeof']); + var indentKeywords = ['for', 'while', 'loop', 'if', 'unless', 'else', + 'switch', 'try', 'catch', 'finally', 'class']; + var commonKeywords = ['break', 'by', 'continue', 'debugger', 'delete', + 'do', 'in', 'of', 'new', 'return', 'then', + 'this', 'throw', 'when', 'until']; + + var keywords = wordRegexp(indentKeywords.concat(commonKeywords)); + + indentKeywords = wordRegexp(indentKeywords); + + + var stringPrefixes = new RegExp("^('{3}|\"{3}|['\"])"); + var regexPrefixes = new RegExp("^(/{3}|/)"); + var commonConstants = ['Infinity', 'NaN', 'undefined', 'null', 'true', 'false', 'on', 'off', 'yes', 'no']; + var constants = wordRegexp(commonConstants); + + // Tokenizers + function tokenBase(stream, state) { + // Handle scope changes + if (stream.sol()) { + var scopeOffset = state.scopes[0].offset; + if (stream.eatSpace()) { + var lineOffset = stream.indentation(); + if (lineOffset > scopeOffset) { + return 'indent'; + } else if (lineOffset < scopeOffset) { + return 'dedent'; + } + return null; + } else { + if (scopeOffset > 0) { + dedent(stream, state); + } + } + } + if (stream.eatSpace()) { + return null; + } + + var ch = stream.peek(); + + // Handle docco title comment (single line) + if (stream.match("####")) { + stream.skipToEnd(); + return 'comment'; + } + + // Handle multi line comments + if (stream.match("###")) { + state.tokenize = longComment; + return state.tokenize(stream, state); + } + + // Single line comment + if (ch === '#') { + stream.skipToEnd(); + return 'comment'; + } + + // Handle number literals + if (stream.match(/^-?[0-9\.]/, false)) { + var floatLiteral = false; + // Floats + if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) { + floatLiteral = true; + } + if (stream.match(/^-?\d+\.\d*/)) { + floatLiteral = true; + } + if (stream.match(/^-?\.\d+/)) { + floatLiteral = true; + } + + if (floatLiteral) { + // prevent from getting extra . on 1.. + if (stream.peek() == "."){ + stream.backUp(1); + } + return 'number'; + } + // Integers + var intLiteral = false; + // Hex + if (stream.match(/^-?0x[0-9a-f]+/i)) { + intLiteral = true; + } + // Decimal + if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) { + intLiteral = true; + } + // Zero by itself with no other piece of number. + if (stream.match(/^-?0(?![\dx])/i)) { + intLiteral = true; + } + if (intLiteral) { + return 'number'; + } + } + + // Handle strings + if (stream.match(stringPrefixes)) { + state.tokenize = tokenFactory(stream.current(), 'string'); + return state.tokenize(stream, state); + } + // Handle regex literals + if (stream.match(regexPrefixes)) { + if (stream.current() != '/' || stream.match(/^.*\//, false)) { // prevent highlight of division + state.tokenize = tokenFactory(stream.current(), 'string-2'); + return state.tokenize(stream, state); + } else { + stream.backUp(1); + } + } + + // Handle operators and delimiters + if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) { + return 'punctuation'; + } + if (stream.match(doubleOperators) + || stream.match(singleOperators) + || stream.match(wordOperators)) { + return 'operator'; + } + if (stream.match(singleDelimiters)) { + return 'punctuation'; + } + + if (stream.match(constants)) { + return 'atom'; + } + + if (stream.match(keywords)) { + return 'keyword'; + } + + if (stream.match(identifiers)) { + return 'variable'; + } + + if (stream.match(properties)) { + return 'property'; + } + + // Handle non-detected items + stream.next(); + return ERRORCLASS; + } + + function tokenFactory(delimiter, outclass) { + var singleline = delimiter.length == 1; + return function tokenString(stream, state) { + while (!stream.eol()) { + stream.eatWhile(/[^'"\/\\]/); + if (stream.eat('\\')) { + stream.next(); + if (singleline && stream.eol()) { + return outclass; + } + } else if (stream.match(delimiter)) { + state.tokenize = tokenBase; + return outclass; + } else { + stream.eat(/['"\/]/); + } + } + if (singleline) { + if (conf.mode.singleLineStringErrors) { + outclass = ERRORCLASS; + } else { + state.tokenize = tokenBase; + } + } + return outclass; + }; + } + + function longComment(stream, state) { + while (!stream.eol()) { + stream.eatWhile(/[^#]/); + if (stream.match("###")) { + state.tokenize = tokenBase; + break; + } + stream.eatWhile("#"); + } + return "comment"; + } + + function indent(stream, state, type) { + type = type || 'coffee'; + var indentUnit = 0; + if (type === 'coffee') { + for (var i = 0; i < state.scopes.length; i++) { + if (state.scopes[i].type === 'coffee') { + indentUnit = state.scopes[i].offset + conf.indentUnit; + break; + } + } + } else { + indentUnit = stream.column() + stream.current().length; + } + state.scopes.unshift({ + offset: indentUnit, + type: type + }); + } + + function dedent(stream, state) { + if (state.scopes.length == 1) return; + if (state.scopes[0].type === 'coffee') { + var _indent = stream.indentation(); + var _indent_index = -1; + for (var i = 0; i < state.scopes.length; ++i) { + if (_indent === state.scopes[i].offset) { + _indent_index = i; + break; + } + } + if (_indent_index === -1) { + return true; + } + while (state.scopes[0].offset !== _indent) { + state.scopes.shift(); + } + return false; + } else { + state.scopes.shift(); + return false; + } + } + + function tokenLexer(stream, state) { + var style = state.tokenize(stream, state); + var current = stream.current(); + + // Handle '.' connected identifiers + if (current === '.') { + style = state.tokenize(stream, state); + current = stream.current(); + if (style === 'variable') { + return 'variable'; + } else { + return ERRORCLASS; + } + } + + // Handle scope changes. + if (current === 'return') { + state.dedent += 1; + } + if (((current === '->' || current === '=>') && + !state.lambda && + state.scopes[0].type == 'coffee' && + stream.peek() === '') + || style === 'indent') { + indent(stream, state); + } + var delimiter_index = '[({'.indexOf(current); + if (delimiter_index !== -1) { + indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1)); + } + if (indentKeywords.exec(current)){ + indent(stream, state); + } + if (current == 'then'){ + dedent(stream, state); + } + + + if (style === 'dedent') { + if (dedent(stream, state)) { + return ERRORCLASS; + } + } + delimiter_index = '])}'.indexOf(current); + if (delimiter_index !== -1) { + if (dedent(stream, state)) { + return ERRORCLASS; + } + } + if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'coffee') { + if (state.scopes.length > 1) state.scopes.shift(); + state.dedent -= 1; + } + + return style; + } + + var external = { + startState: function(basecolumn) { + return { + tokenize: tokenBase, + scopes: [{offset:basecolumn || 0, type:'coffee'}], + lastToken: null, + lambda: false, + dedent: 0 + }; + }, + + token: function(stream, state) { + var style = tokenLexer(stream, state); + + state.lastToken = {style:style, content: stream.current()}; + + if (stream.eol() && stream.lambda) { + state.lambda = false; + } + + return style; + }, + + indent: function(state) { + if (state.tokenize != tokenBase) { + return 0; + } + + return state.scopes[0].offset; + } + + }; + return external; +}); + +CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript'); diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/index.html b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/index.html new file mode 100644 index 0000000..ee72b8d --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/coffeescript/index.html @@ -0,0 +1,728 @@ + + + + + CodeMirror: CoffeeScript mode + + + + + + + +

          CodeMirror: CoffeeScript mode

          +
          + + +

          MIME types defined: text/x-coffeescript.

          + +

          The CoffeeScript mode was written by Jeff Pickhardt (license).

          + + + diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/index.html b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/index.html new file mode 100644 index 0000000..9222ddf --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/index.html @@ -0,0 +1,88 @@ + + + + + CodeMirror: JavaScript mode + + + + + + + + + +

          CodeMirror: JavaScript mode

          + +
          + + + +

          + JavaScript mode supports a two configuration + options: +

            +
          • json which will set the mode to expect JSON data rather than a JavaScript program.
          • +
          • + typescript which will activate additional syntax highlighting and some other things for TypeScript code (demo). +
          • +
          +

          + +

          MIME types defined: text/javascript, application/json, text/typescript, application/typescript.

          + + diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/javascript.js b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/javascript.js new file mode 100644 index 0000000..565513f --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/javascript.js @@ -0,0 +1,422 @@ +// TODO actually recognize syntax of TypeScript constructs + +CodeMirror.defineMode("javascript", function(config, parserConfig) { + var indentUnit = config.indentUnit; + var jsonMode = parserConfig.json; + var isTS = parserConfig.typescript; + + // Tokenizer + + var keywords = function(){ + function kw(type) {return {type: type, style: "keyword"};} + var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"); + var operator = kw("operator"), atom = {type: "atom", style: "atom"}; + + var jsKeywords = { + "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, + "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, + "var": kw("var"), "const": kw("var"), "let": kw("var"), + "function": kw("function"), "catch": kw("catch"), + "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), + "in": operator, "typeof": operator, "instanceof": operator, + "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom + }; + + // Extend the 'normal' keywords with the TypeScript language extensions + if (isTS) { + var type = {type: "variable", style: "variable-3"}; + var tsKeywords = { + // object-like things + "interface": kw("interface"), + "class": kw("class"), + "extends": kw("extends"), + "constructor": kw("constructor"), + + // scope modifiers + "public": kw("public"), + "private": kw("private"), + "protected": kw("protected"), + "static": kw("static"), + + "super": kw("super"), + + // types + "string": type, "number": type, "bool": type, "any": type + }; + + for (var attr in tsKeywords) { + jsKeywords[attr] = tsKeywords[attr]; + } + } + + return jsKeywords; + }(); + + var isOperatorChar = /[+\-*&%=<>!?|]/; + + function chain(stream, state, f) { + state.tokenize = f; + return f(stream, state); + } + + function nextUntilUnescaped(stream, end) { + var escaped = false, next; + while ((next = stream.next()) != null) { + if (next == end && !escaped) + return false; + escaped = !escaped && next == "\\"; + } + return escaped; + } + + // Used as scratch variables to communicate multiple values without + // consing up tons of objects. + var type, content; + function ret(tp, style, cont) { + type = tp; content = cont; + return style; + } + + function jsTokenBase(stream, state) { + var ch = stream.next(); + if (ch == '"' || ch == "'") + return chain(stream, state, jsTokenString(ch)); + else if (/[\[\]{}\(\),;\:\.]/.test(ch)) + return ret(ch); + else if (ch == "0" && stream.eat(/x/i)) { + stream.eatWhile(/[\da-f]/i); + return ret("number", "number"); + } + else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { + stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); + return ret("number", "number"); + } + else if (ch == "/") { + if (stream.eat("*")) { + return chain(stream, state, jsTokenComment); + } + else if (stream.eat("/")) { + stream.skipToEnd(); + return ret("comment", "comment"); + } + else if (state.lastType == "operator" || state.lastType == "keyword c" || + /^[\[{}\(,;:]$/.test(state.lastType)) { + nextUntilUnescaped(stream, "/"); + stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla + return ret("regexp", "string-2"); + } + else { + stream.eatWhile(isOperatorChar); + return ret("operator", null, stream.current()); + } + } + else if (ch == "#") { + stream.skipToEnd(); + return ret("error", "error"); + } + else if (isOperatorChar.test(ch)) { + stream.eatWhile(isOperatorChar); + return ret("operator", null, stream.current()); + } + else { + stream.eatWhile(/[\w\$_]/); + var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; + return (known && state.lastType != ".") ? ret(known.type, known.style, word) : + ret("variable", "variable", word); + } + } + + function jsTokenString(quote) { + return function(stream, state) { + if (!nextUntilUnescaped(stream, quote)) + state.tokenize = jsTokenBase; + return ret("string", "string"); + }; + } + + function jsTokenComment(stream, state) { + var maybeEnd = false, ch; + while (ch = stream.next()) { + if (ch == "/" && maybeEnd) { + state.tokenize = jsTokenBase; + break; + } + maybeEnd = (ch == "*"); + } + return ret("comment", "comment"); + } + + // Parser + + var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true}; + + function JSLexical(indented, column, type, align, prev, info) { + this.indented = indented; + this.column = column; + this.type = type; + this.prev = prev; + this.info = info; + if (align != null) this.align = align; + } + + function inScope(state, varname) { + for (var v = state.localVars; v; v = v.next) + if (v.name == varname) return true; + } + + function parseJS(state, style, type, content, stream) { + var cc = state.cc; + // Communicate our context to the combinators. + // (Less wasteful than consing up a hundred closures on every call.) + cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; + + if (!state.lexical.hasOwnProperty("align")) + state.lexical.align = true; + + while(true) { + var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement; + if (combinator(type, content)) { + while(cc.length && cc[cc.length - 1].lex) + cc.pop()(); + if (cx.marked) return cx.marked; + if (type == "variable" && inScope(state, content)) return "variable-2"; + return style; + } + } + } + + // Combinator utils + + var cx = {state: null, column: null, marked: null, cc: null}; + function pass() { + for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); + } + function cont() { + pass.apply(null, arguments); + return true; + } + function register(varname) { + function inList(list) { + for (var v = list; v; v = v.next) + if (v.name == varname) return true; + return false; + } + var state = cx.state; + if (state.context) { + cx.marked = "def"; + if (inList(state.localVars)) return; + state.localVars = {name: varname, next: state.localVars}; + } else { + if (inList(state.globalVars)) return; + state.globalVars = {name: varname, next: state.globalVars}; + } + } + + // Combinators + + var defaultVars = {name: "this", next: {name: "arguments"}}; + function pushcontext() { + cx.state.context = {prev: cx.state.context, vars: cx.state.localVars}; + cx.state.localVars = defaultVars; + } + function popcontext() { + cx.state.localVars = cx.state.context.vars; + cx.state.context = cx.state.context.prev; + } + function pushlex(type, info) { + var result = function() { + var state = cx.state; + state.lexical = new JSLexical(state.indented, cx.stream.column(), type, null, state.lexical, info); + }; + result.lex = true; + return result; + } + function poplex() { + var state = cx.state; + if (state.lexical.prev) { + if (state.lexical.type == ")") + state.indented = state.lexical.indented; + state.lexical = state.lexical.prev; + } + } + poplex.lex = true; + + function expect(wanted) { + return function expecting(type) { + if (type == wanted) return cont(); + else if (wanted == ";") return pass(); + else return cont(arguments.callee); + }; + } + + function statement(type) { + if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex); + if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex); + if (type == "keyword b") return cont(pushlex("form"), statement, poplex); + if (type == "{") return cont(pushlex("}"), block, poplex); + if (type == ";") return cont(); + if (type == "function") return cont(functiondef); + if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), + poplex, statement, poplex); + if (type == "variable") return cont(pushlex("stat"), maybelabel); + if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), + block, poplex, poplex); + if (type == "case") return cont(expression, expect(":")); + if (type == "default") return cont(expect(":")); + if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), + statement, poplex, popcontext); + return pass(pushlex("stat"), expression, expect(";"), poplex); + } + function expression(type) { + if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator); + if (type == "function") return cont(functiondef); + if (type == "keyword c") return cont(maybeexpression); + if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator); + if (type == "operator") return cont(expression); + if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator); + if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator); + return cont(); + } + function maybeexpression(type) { + if (type.match(/[;\}\)\],]/)) return pass(); + return pass(expression); + } + + function maybeoperator(type, value) { + if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator); + if (type == "operator" && value == "?") return cont(expression, expect(":"), expression); + if (type == ";") return; + if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator); + if (type == ".") return cont(property, maybeoperator); + if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator); + } + function maybelabel(type) { + if (type == ":") return cont(poplex, statement); + return pass(maybeoperator, expect(";"), poplex); + } + function property(type) { + if (type == "variable") {cx.marked = "property"; return cont();} + } + function objprop(type) { + if (type == "variable") cx.marked = "property"; + if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression); + } + function commasep(what, end) { + function proceed(type) { + if (type == ",") return cont(what, proceed); + if (type == end) return cont(); + return cont(expect(end)); + } + return function commaSeparated(type) { + if (type == end) return cont(); + else return pass(what, proceed); + }; + } + function block(type) { + if (type == "}") return cont(); + return pass(statement, block); + } + function maybetype(type) { + if (type == ":") return cont(typedef); + return pass(); + } + function typedef(type) { + if (type == "variable"){cx.marked = "variable-3"; return cont();} + return pass(); + } + function vardef1(type, value) { + if (type == "variable") { + register(value); + return isTS ? cont(maybetype, vardef2) : cont(vardef2); + } + return pass(); + } + function vardef2(type, value) { + if (value == "=") return cont(expression, vardef2); + if (type == ",") return cont(vardef1); + } + function forspec1(type) { + if (type == "var") return cont(vardef1, expect(";"), forspec2); + if (type == ";") return cont(forspec2); + if (type == "variable") return cont(formaybein); + return cont(forspec2); + } + function formaybein(_type, value) { + if (value == "in") return cont(expression); + return cont(maybeoperator, forspec2); + } + function forspec2(type, value) { + if (type == ";") return cont(forspec3); + if (value == "in") return cont(expression); + return cont(expression, expect(";"), forspec3); + } + function forspec3(type) { + if (type != ")") cont(expression); + } + function functiondef(type, value) { + if (type == "variable") {register(value); return cont(functiondef);} + if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext); + } + function funarg(type, value) { + if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();} + } + + // Interface + + return { + startState: function(basecolumn) { + return { + tokenize: jsTokenBase, + lastType: null, + cc: [], + lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), + localVars: parserConfig.localVars, + globalVars: parserConfig.globalVars, + context: parserConfig.localVars && {vars: parserConfig.localVars}, + indented: 0 + }; + }, + + token: function(stream, state) { + if (stream.sol()) { + if (!state.lexical.hasOwnProperty("align")) + state.lexical.align = false; + state.indented = stream.indentation(); + } + if (stream.eatSpace()) return null; + var style = state.tokenize(stream, state); + if (type == "comment") return style; + state.lastType = type; + return parseJS(state, style, type, content, stream); + }, + + indent: function(state, textAfter) { + if (state.tokenize == jsTokenComment) return CodeMirror.Pass; + if (state.tokenize != jsTokenBase) return 0; + var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical; + if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev; + var type = lexical.type, closing = firstChar == type; + if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0); + else if (type == "form" && firstChar == "{") return lexical.indented; + else if (type == "form") return lexical.indented + indentUnit; + else if (type == "stat") + return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? indentUnit : 0); + else if (lexical.info == "switch" && !closing) + return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit); + else if (lexical.align) return lexical.column + (closing ? 0 : 1); + else return lexical.indented + (closing ? 0 : indentUnit); + }, + + electricChars: ":{}", + + jsonMode: jsonMode + }; +}); + +CodeMirror.defineMIME("text/javascript", "javascript"); +CodeMirror.defineMIME("text/ecmascript", "javascript"); +CodeMirror.defineMIME("application/javascript", "javascript"); +CodeMirror.defineMIME("application/ecmascript", "javascript"); +CodeMirror.defineMIME("application/json", {name: "javascript", json: true}); +CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); +CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/typescript.html b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/typescript.html new file mode 100644 index 0000000..58315e7 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/CodeMirror/mode/javascript/typescript.html @@ -0,0 +1,48 @@ + + + + + CodeMirror: TypeScript mode + + + + + + + +

          CodeMirror: TypeScript mode

          + +
          + + + +

          This is a specialization of the JavaScript mode.

          + + diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/coffee-script.js b/bower_components/messenger/docs/welcome/lib/executr/lib/coffee-script.js new file mode 100644 index 0000000..66c387f --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/coffee-script.js @@ -0,0 +1,8 @@ +/** + * CoffeeScript Compiler v1.4.0 + * http://coffeescript.org + * + * Copyright 2011, Jeremy Ashkenas + * Released under the MIT License + */ +(function(root){var CoffeeScript=function(){function require(a){return require[a]}return require["./helpers"]=new function(){var a=this;((function(){var b,c,d;a.starts=function(a,b,c){return b===a.substr(c,b.length)},a.ends=function(a,b,c){var d;return d=b.length,b===a.substr(a.length-d-(c||0),d)},a.compact=function(a){var b,c,d,e;e=[];for(c=0,d=a.length;c=0)f+=1;else if(j=g[0],t.call(d,j)>=0)f-=1;a+=1}return a-1},a.prototype.removeLeadingNewlines=function(){var a,b,c,d,e;e=this.tokens;for(a=c=0,d=e.length;c=0)?(d.splice(b,1),0):1})},a.prototype.closeOpenCalls=function(){var a,b;return b=function(a,b){var c;return(c=a[0])===")"||c==="CALL_END"||a[0]==="OUTDENT"&&this.tag(b-1)===")"},a=function(a,b){return this.tokens[a[0]==="OUTDENT"?b-1:b][0]="CALL_END"},this.scanTokens(function(c,d){return c[0]==="CALL_START"&&this.detectEnd(d+1,b,a),1})},a.prototype.closeOpenIndexes=function(){var a,b;return b=function(a,b){var c;return(c=a[0])==="]"||c==="INDEX_END"},a=function(a,b){return a[0]="INDEX_END"},this.scanTokens(function(c,d){return c[0]==="INDEX_START"&&this.detectEnd(d+1,b,a),1})},a.prototype.addImplicitBraces=function(){var a,b,c,f,g,i,j,k;return f=[],g=null,k=null,c=!0,i=0,j=0,b=function(a,b){var d,e,f,g,i,m;return i=this.tokens.slice(b+1,+(b+3)+1||9e9),d=i[0],g=i[1],f=i[2],"HERECOMMENT"===(d!=null?d[0]:void 0)?!1:(e=a[0],t.call(l,e)>=0&&(c=!1),(e==="TERMINATOR"||e==="OUTDENT"||t.call(h,e)>=0&&c&&b-j!==1)&&(!k&&this.tag(b-1)!==","||(g!=null?g[0]:void 0)!==":"&&((d!=null?d[0]:void 0)!=="@"||(f!=null?f[0]:void 0)!==":"))||e===","&&d&&(m=d[0])!=="IDENTIFIER"&&m!=="NUMBER"&&m!=="STRING"&&m!=="@"&&m!=="TERMINATOR"&&m!=="OUTDENT")},a=function(a,b){var c;return c=this.generate("}","}",a[2]),this.tokens.splice(b,0,c)},this.scanTokens(function(h,i,m){var n,o,p,q,r,s,u,v;if(u=q=h[0],t.call(e,u)>=0)return f.push([q==="INDENT"&&this.tag(i-1)==="{"?"{":q,i]),1;if(t.call(d,q)>=0)return g=f.pop(),1;if(q!==":"||(n=this.tag(i-2))!==":"&&((v=f[f.length-1])!=null?v[0]:void 0)==="{")return 1;c=!0,j=i+1,f.push(["{"]),o=n==="@"?i-2:i-1;while(this.tag(o-2)==="HERECOMMENT")o-=2;return p=this.tag(o-1),k=!p||t.call(l,p)>=0,s=new String("{"),s.generated=!0,r=this.generate("{",s,h[2]),m.splice(o,0,r),this.detectEnd(i+2,b,a),2})},a.prototype.addImplicitParentheses=function(){var a,b,c,d,e;return c=e=d=!1,b=function(a,b){var c,g,i,j;g=a[0];if(!e&&a.fromThen)return!0;if(g==="IF"||g==="ELSE"||g==="CATCH"||g==="->"||g==="=>"||g==="CLASS")e=!0;if(g==="IF"||g==="ELSE"||g==="SWITCH"||g==="TRY"||g==="=")d=!0;return g!=="."&&g!=="?."&&g!=="::"||this.tag(b-1)!=="OUTDENT"?!a.generated&&this.tag(b-1)!==","&&(t.call(h,g)>=0||g==="INDENT"&&!d)&&(g!=="INDENT"||(i=this.tag(b-2))!=="CLASS"&&i!=="EXTENDS"&&(j=this.tag(b-1),t.call(f,j)<0)&&(!(c=this.tokens[b+1])||!c.generated||c[0]!=="{")):!0},a=function(a,b){return this.tokens.splice(b,0,this.generate("CALL_END",")",a[2]))},this.scanTokens(function(f,h,k){var m,n,o,p,q,r,s,u;q=f[0];if(q==="CLASS"||q==="IF"||q==="FOR"||q==="WHILE")c=!0;return r=k.slice(h-1,+(h+1)+1||9e9),p=r[0],n=r[1],o=r[2],m=!c&&q==="INDENT"&&o&&o.generated&&o[0]==="{"&&p&&(s=p[0],t.call(i,s)>=0),e=!1,d=!1,t.call(l,q)>=0&&(c=!1),p&&!p.spaced&&q==="?"&&(f.call=!0),f.fromThen?1:m||(p!=null?p.spaced:void 0)&&(p.call||(u=p[0],t.call(i,u)>=0))&&(t.call(g,q)>=0||!f.spaced&&!f.newLine&&t.call(j,q)>=0)?(k.splice(h,0,this.generate("CALL_START","(",f[2])),this.detectEnd(h+1,b,a),p[0]==="?"&&(p[0]="FUNC_EXIST"),2):1})},a.prototype.addImplicitIndentation=function(){var a,b,c,d,e;return e=c=d=null,b=function(a,b){var c;return a[1]!==";"&&(c=a[0],t.call(m,c)>=0)&&(a[0]!=="ELSE"||e==="IF"||e==="THEN")},a=function(a,b){return this.tokens.splice(this.tag(b-1)===","?b-1:b,0,d)},this.scanTokens(function(f,g,h){var i,j,k;return i=f[0],i==="TERMINATOR"&&this.tag(g+1)==="THEN"?(h.splice(g,1),0):i==="ELSE"&&this.tag(g-1)!=="OUTDENT"?(h.splice.apply(h,[g,0].concat(u.call(this.indentation(f)))),2):i!=="CATCH"||(j=this.tag(g+2))!=="OUTDENT"&&j!=="TERMINATOR"&&j!=="FINALLY"?t.call(n,i)>=0&&this.tag(g+1)!=="INDENT"&&(i!=="ELSE"||this.tag(g+1)!=="IF")?(e=i,k=this.indentation(f,!0),c=k[0],d=k[1],e==="THEN"&&(c.fromThen=!0),h.splice(g+1,0,c),this.detectEnd(g+2,b,a),i==="THEN"&&h.splice(g,1),1):1:(h.splice.apply(h,[g+2,0].concat(u.call(this.indentation(f)))),4)})},a.prototype.tagPostfixConditionals=function(){var a,b,c;return c=null,b=function(a,b){var c;return(c=a[0])==="TERMINATOR"||c==="INDENT"},a=function(a,b){if(a[0]!=="INDENT"||a.generated&&!a.fromThen)return c[0]="POST_"+c[0]},this.scanTokens(function(d,e){return d[0]!=="IF"?1:(c=d,this.detectEnd(e+1,b,a),1)})},a.prototype.indentation=function(a,b){var c,d;return b==null&&(b=!1),c=["INDENT",2,a[2]],d=["OUTDENT",2,a[2]],b&&(c.generated=d.generated=!0),[c,d]},a.prototype.generate=function(a,b,c){var d;return d=[a,b,c],d.generated=!0,d},a.prototype.tag=function(a){var b;return(b=this.tokens[a])!=null?b[0]:void 0},a}(),b=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"]],a.INVERSES=k={},e=[],d=[];for(q=0,r=b.length;q","=>","[","(","{","--","++"],j=["+","-"],f=["->","=>","{","[",","],h=["POST_IF","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR"],n=["ELSE","->","=>","TRY","FINALLY","THEN"],m=["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"],l=["TERMINATOR","INDENT","OUTDENT"]})).call(this)},require["./lexer"]=new function(){var a=this;((function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X=[].indexOf||function(a){for(var b=0,c=this.length;b=0||X.call(g,c)>=0)&&(j=c.toUpperCase(),j==="WHEN"&&(l=this.tag(),X.call(v,l)>=0)?j="LEADING_WHEN":j==="FOR"?this.seenFor=!0:j==="UNLESS"?j="IF":X.call(O,j)>=0?j="UNARY":X.call(H,j)>=0&&(j!=="INSTANCEOF"&&this.seenFor?(j="FOR"+j,this.seenFor=!1):(j="RELATION",this.value()==="!"&&(this.tokens.pop(),c="!"+c)))),X.call(t,c)>=0&&(b?(j="IDENTIFIER",c=new String(c),c.reserved=!0):X.call(I,c)>=0&&this.error('reserved word "'+c+'"')),b||(X.call(e,c)>=0&&(c=f[c]),j=function(){switch(c){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"&&":case"||":return"LOGIC";case"true":case"false":return"BOOL";case"break":case"continue":return"STATEMENT";default:return j}}()),this.token(j,c),a&&this.token(":",":"),d.length)):0},a.prototype.numberToken=function(){var a,b,c,d,e;if(!(c=E.exec(this.chunk)))return 0;d=c[0],/^0[BOX]/.test(d)?this.error("radix prefix '"+d+"' must be lowercase"):/E/.test(d)&&!/^0x/.test(d)?this.error("exponential notation '"+d+"' must be indicated with a lowercase 'e'"):/^0\d*[89]/.test(d)?this.error("decimal literal '"+d+"' must not be prefixed with '0'"):/^0\d+/.test(d)&&this.error("octal literal '"+d+"' must be prefixed with '0o'"),b=d.length;if(e=/^0o([0-7]+)/.exec(d))d="0x"+parseInt(e[1],8).toString(16);if(a=/^0b([01]+)/.exec(d))d="0x"+parseInt(a[1],2).toString(16);return this.token("NUMBER",d),b},a.prototype.stringToken=function(){var a,b,c;switch(this.chunk.charAt(0)){case"'":if(!(a=L.exec(this.chunk)))return 0;this.token("STRING",(c=a[0]).replace(A,"\\\n"));break;case'"':if(!(c=this.balancedString(this.chunk,'"')))return 0;0=0)?0:(c=G.exec(this.chunk))?(g=c,c=g[0],e=g[1],a=g[2],e.slice(0,2)==="/*"&&this.error("regular expressions cannot begin with `*`"),e==="//"&&(e="/(?:)/"),this.token("REGEX",""+e+a),c.length):0)},a.prototype.heregexToken=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;d=a[0],b=a[1],c=a[2];if(0>b.indexOf("#{"))return e=b.replace(o,"").replace(/\//g,"\\/"),e.match(/^\*/)&&this.error("regular expressions cannot begin with `*`"),this.token("REGEX","/"+(e||"(?:)")+"/"+c),d.length;this.token("IDENTIFIER","RegExp"),this.tokens.push(["CALL_START","("]),g=[],k=this.interpolateString(b,{regex:!0});for(i=0,j=k.length;ithis.indent){if(d)return this.indebt=e-this.indent,this.suppressNewlines(),b.length;a=e-this.indent+this.outdebt,this.token("INDENT",a),this.indents.push(a),this.ends.push("OUTDENT"),this.outdebt=this.indebt=0}else this.indebt=0,this.outdentToken(this.indent-e,d);return this.indent=e,b.length},a.prototype.outdentToken=function(a,b){var c,d;while(a>0)d=this.indents.length-1,this.indents[d]===void 0?a=0:this.indents[d]===this.outdebt?(a-=this.outdebt,this.outdebt=0):this.indents[d]=0)&&this.error('reserved word "'+this.value()+"\" can't be assigned");if((h=b[1])==="||"||h==="&&")return b[0]="COMPOUND_ASSIGN",b[1]+="=",f.length}if(f===";")this.seenFor=!1,e="TERMINATOR";else if(X.call(z,f)>=0)e="MATH";else if(X.call(i,f)>=0)e="COMPARE";else if(X.call(j,f)>=0)e="COMPOUND_ASSIGN";else if(X.call(O,f)>=0)e="UNARY";else if(X.call(K,f)>=0)e="SHIFT";else if(X.call(x,f)>=0||f==="?"&&(b!=null?b.spaced:void 0))e="LOGIC";else if(b&&!b.spaced)if(f==="("&&(k=b[0],X.call(c,k)>=0))b[0]==="?"&&(b[0]="FUNC_EXIST"),e="CALL_START";else if(f==="["&&(l=b[0],X.call(q,l)>=0)){e="INDEX_START";switch(b[0]){case"?":b[0]="INDEX_SOAK"}}switch(f){case"(":case"{":case"[":this.ends.push(r[f]);break;case")":case"}":case"]":this.pair(f)}return this.token(e,f),f.length},a.prototype.sanitizeHeredoc=function(a,b){var c,d,e,f,g;e=b.indent,d=b.herecomment;if(d){l.test(a)&&this.error('block comment cannot contain "*/", starting');if(a.indexOf("\n")<=0)return a}else while(f=m.exec(a)){c=f[1];if(e===null||0<(g=c.length)&&gj;d=1<=j?++i:--i){if(c){--c;continue}switch(e=a.charAt(d)){case"\\":++c;continue;case b:h.pop();if(!h.length)return a.slice(0,+d+1||9e9);b=h[h.length-1];continue}b!=="}"||e!=='"'&&e!=="'"?b==="}"&&e==="/"&&(f=n.exec(a.slice(d))||G.exec(a.slice(d)))?c+=f[0].length-1:b==="}"&&e==="{"?h.push(b="}"):b==='"'&&g==="#"&&e==="{"&&h.push(b="}"):h.push(b=e),g=e}return this.error("missing "+h.pop()+", starting")},a.prototype.interpolateString=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;c==null&&(c={}),e=c.heredoc,m=c.regex,o=[],l=0,f=-1;while(j=b.charAt(f+=1)){if(j==="\\"){f+=1;continue}if(j!=="#"||b.charAt(f+1)!=="{"||!(d=this.balancedString(b.slice(f+1),"}")))continue;l1&&(k.unshift(["(","(",this.line]),k.push([")",")",this.line])),o.push(["TOKENS",k])}f+=d.length,l=f+1}f>l&&l1)&&this.token("(","(");for(f=q=0,r=o.length;q|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/,P=/^[^\n\S]+/,h=/^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/,d=/^[-=]>/,B=/^(?:\n[^\n\S]*)+/,L=/^'[^\\']*(?:\\.[^\\']*)*'/,s=/^`[^\\`]*(?:\\.[^\\`]*)*`/,G=/^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/,n=/^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/,o=/\s+(?:#.*)?/g,A=/\n/g,m=/\n+([^\n\S]*)/g,l=/\*\//,w=/^\s*(?:,|\??\.(?![.\d])|::)/,N=/\s+$/,j=["-=","+=","/=","*=","%=","||=","&&=","?=","<<=",">>=",">>>=","&=","^=","|="],O=["!","~","NEW","TYPEOF","DELETE","DO"],x=["&&","||","&","|","^"],K=["<<",">>",">>>"],i=["==","!=","<",">","<=",">="],z=["*","/","%"],H=["IN","OF","INSTANCEOF"],b=["TRUE","FALSE"],C=["NUMBER","REGEX","BOOL","NULL","UNDEFINED","++","--","]"],D=C.concat(")","}","THIS","IDENTIFIER","STRING"),c=["IDENTIFIER","STRING","REGEX",")","]","}","?","::","@","THIS","SUPER"],q=c.concat("NUMBER","BOOL","NULL","UNDEFINED"),v=["INDENT","OUTDENT","TERMINATOR"]})).call(this)},require["./parser"]=new function(){var a=this,b=function(){var a={trace:function(){},yy:{},symbols_:{error:2,Root:3,Body:4,Block:5,TERMINATOR:6,Line:7,Expression:8,Statement:9,Return:10,Comment:11,STATEMENT:12,Value:13,Invocation:14,Code:15,Operation:16,Assign:17,If:18,Try:19,While:20,For:21,Switch:22,Class:23,Throw:24,INDENT:25,OUTDENT:26,Identifier:27,IDENTIFIER:28,AlphaNumeric:29,NUMBER:30,STRING:31,Literal:32,JS:33,REGEX:34,DEBUGGER:35,UNDEFINED:36,NULL:37,BOOL:38,Assignable:39,"=":40,AssignObj:41,ObjAssignable:42,":":43,ThisProperty:44,RETURN:45,HERECOMMENT:46,PARAM_START:47,ParamList:48,PARAM_END:49,FuncGlyph:50,"->":51,"=>":52,OptComma:53,",":54,Param:55,ParamVar:56,"...":57,Array:58,Object:59,Splat:60,SimpleAssignable:61,Accessor:62,Parenthetical:63,Range:64,This:65,".":66,"?.":67,"::":68,Index:69,INDEX_START:70,IndexValue:71,INDEX_END:72,INDEX_SOAK:73,Slice:74,"{":75,AssignList:76,"}":77,CLASS:78,EXTENDS:79,OptFuncExist:80,Arguments:81,SUPER:82,FUNC_EXIST:83,CALL_START:84,CALL_END:85,ArgList:86,THIS:87,"@":88,"[":89,"]":90,RangeDots:91,"..":92,Arg:93,SimpleArgs:94,TRY:95,Catch:96,FINALLY:97,CATCH:98,THROW:99,"(":100,")":101,WhileSource:102,WHILE:103,WHEN:104,UNTIL:105,Loop:106,LOOP:107,ForBody:108,FOR:109,ForStart:110,ForSource:111,ForVariables:112,OWN:113,ForValue:114,FORIN:115,FOROF:116,BY:117,SWITCH:118,Whens:119,ELSE:120,When:121,LEADING_WHEN:122,IfBlock:123,IF:124,POST_IF:125,UNARY:126,"-":127,"+":128,"--":129,"++":130,"?":131,MATH:132,SHIFT:133,COMPARE:134,LOGIC:135,RELATION:136,COMPOUND_ASSIGN:137,$accept:0,$end:1},terminals_:{2:"error",6:"TERMINATOR",12:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"UNDEFINED",37:"NULL",38:"BOOL",40:"=",43:":",45:"RETURN",46:"HERECOMMENT",47:"PARAM_START",49:"PARAM_END",51:"->",52:"=>",54:",",57:"...",66:".",67:"?.",68:"::",70:"INDEX_START",72:"INDEX_END",73:"INDEX_SOAK",75:"{",77:"}",78:"CLASS",79:"EXTENDS",82:"SUPER",83:"FUNC_EXIST",84:"CALL_START",85:"CALL_END",87:"THIS",88:"@",89:"[",90:"]",92:"..",95:"TRY",97:"FINALLY",98:"CATCH",99:"THROW",100:"(",101:")",103:"WHILE",104:"WHEN",105:"UNTIL",107:"LOOP",109:"FOR",113:"OWN",115:"FORIN",116:"FOROF",117:"BY",118:"SWITCH",120:"ELSE",122:"LEADING_WHEN",124:"IF",125:"POST_IF",126:"UNARY",127:"-",128:"+",129:"--",130:"++",131:"?",132:"MATH",133:"SHIFT",134:"COMPARE",135:"LOGIC",136:"RELATION",137:"COMPOUND_ASSIGN"},productions_:[0,[3,0],[3,1],[3,2],[4,1],[4,3],[4,2],[7,1],[7,1],[9,1],[9,1],[9,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[5,2],[5,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[17,3],[17,4],[17,5],[41,1],[41,3],[41,5],[41,1],[42,1],[42,1],[42,1],[10,2],[10,1],[11,1],[15,5],[15,2],[50,1],[50,1],[53,0],[53,1],[48,0],[48,1],[48,3],[48,4],[48,6],[55,1],[55,2],[55,3],[56,1],[56,1],[56,1],[56,1],[60,2],[61,1],[61,2],[61,2],[61,1],[39,1],[39,1],[39,1],[13,1],[13,1],[13,1],[13,1],[13,1],[62,2],[62,2],[62,2],[62,1],[62,1],[69,3],[69,2],[71,1],[71,1],[59,4],[76,0],[76,1],[76,3],[76,4],[76,6],[23,1],[23,2],[23,3],[23,4],[23,2],[23,3],[23,4],[23,5],[14,3],[14,3],[14,1],[14,2],[80,0],[80,1],[81,2],[81,4],[65,1],[65,1],[44,2],[58,2],[58,4],[91,1],[91,1],[64,5],[74,3],[74,2],[74,2],[74,1],[86,1],[86,3],[86,4],[86,4],[86,6],[93,1],[93,1],[94,1],[94,3],[19,2],[19,3],[19,4],[19,5],[96,3],[24,2],[63,3],[63,5],[102,2],[102,4],[102,2],[102,4],[20,2],[20,2],[20,2],[20,1],[106,2],[106,2],[21,2],[21,2],[21,2],[108,2],[108,2],[110,2],[110,3],[114,1],[114,1],[114,1],[114,1],[112,1],[112,3],[111,2],[111,2],[111,4],[111,4],[111,4],[111,6],[111,6],[22,5],[22,7],[22,4],[22,6],[119,1],[119,2],[121,3],[121,4],[123,3],[123,5],[18,1],[18,3],[18,3],[18,3],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,5],[16,3]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:return this.$=new e.Block;case 2:return this.$=g[i];case 3:return this.$=g[i-1];case 4:this.$=e.Block.wrap([g[i]]);break;case 5:this.$=g[i-2].push(g[i]);break;case 6:this.$=g[i-1];break;case 7:this.$=g[i];break;case 8:this.$=g[i];break;case 9:this.$=g[i];break;case 10:this.$=g[i];break;case 11:this.$=new e.Literal(g[i]);break;case 12:this.$=g[i];break;case 13:this.$=g[i];break;case 14:this.$=g[i];break;case 15:this.$=g[i];break;case 16:this.$=g[i];break;case 17:this.$=g[i];break;case 18:this.$=g[i];break;case 19:this.$=g[i];break;case 20:this.$=g[i];break;case 21:this.$=g[i];break;case 22:this.$=g[i];break;case 23:this.$=g[i];break;case 24:this.$=new e.Block;break;case 25:this.$=g[i-1];break;case 26:this.$=new e.Literal(g[i]);break;case 27:this.$=new e.Literal(g[i]);break;case 28:this.$=new e.Literal(g[i]);break;case 29:this.$=g[i];break;case 30:this.$=new e.Literal(g[i]);break;case 31:this.$=new e.Literal(g[i]);break;case 32:this.$=new e.Literal(g[i]);break;case 33:this.$=new e.Undefined;break;case 34:this.$=new e.Null;break;case 35:this.$=new e.Bool(g[i]);break;case 36:this.$=new e.Assign(g[i-2],g[i]);break;case 37:this.$=new e.Assign(g[i-3],g[i]);break;case 38:this.$=new e.Assign(g[i-4],g[i-1]);break;case 39:this.$=new e.Value(g[i]);break;case 40:this.$=new e.Assign(new e.Value(g[i-2]),g[i],"object");break;case 41:this.$=new e.Assign(new e.Value(g[i-4]),g[i-1],"object");break;case 42:this.$=g[i];break;case 43:this.$=g[i];break;case 44:this.$=g[i];break;case 45:this.$=g[i];break;case 46:this.$=new e.Return(g[i]);break;case 47:this.$=new e.Return;break;case 48:this.$=new e.Comment(g[i]);break;case 49:this.$=new e.Code(g[i-3],g[i],g[i-1]);break;case 50:this.$=new e.Code([],g[i],g[i-1]);break;case 51:this.$="func";break;case 52:this.$="boundfunc";break;case 53:this.$=g[i];break;case 54:this.$=g[i];break;case 55:this.$=[];break;case 56:this.$=[g[i]];break;case 57:this.$=g[i-2].concat(g[i]);break;case 58:this.$=g[i-3].concat(g[i]);break;case 59:this.$=g[i-5].concat(g[i-2]);break;case 60:this.$=new e.Param(g[i]);break;case 61:this.$=new e.Param(g[i-1],null,!0);break;case 62:this.$=new e.Param(g[i-2],g[i]);break;case 63:this.$=g[i];break;case 64:this.$=g[i];break;case 65:this.$=g[i];break;case 66:this.$=g[i];break;case 67:this.$=new e.Splat(g[i-1]);break;case 68:this.$=new e.Value(g[i]);break;case 69:this.$=g[i-1].add(g[i]);break;case 70:this.$=new e.Value(g[i-1],[].concat(g[i]));break;case 71:this.$=g[i];break;case 72:this.$=g[i];break;case 73:this.$=new e.Value(g[i]);break;case 74:this.$=new e.Value(g[i]);break;case 75:this.$=g[i];break;case 76:this.$=new e.Value(g[i]);break;case 77:this.$=new e.Value(g[i]);break;case 78:this.$=new e.Value(g[i]);break;case 79:this.$=g[i];break;case 80:this.$=new e.Access(g[i]);break;case 81:this.$=new e.Access(g[i],"soak");break;case 82:this.$=[new e.Access(new e.Literal("prototype")),new e.Access(g[i])];break;case 83:this.$=new e.Access(new e.Literal("prototype"));break;case 84:this.$=g[i];break;case 85:this.$=g[i-1];break;case 86:this.$=e.extend(g[i],{soak:!0});break;case 87:this.$=new e.Index(g[i]);break;case 88:this.$=new e.Slice(g[i]);break;case 89:this.$=new e.Obj(g[i-2],g[i-3].generated);break;case 90:this.$=[];break;case 91:this.$=[g[i]];break;case 92:this.$=g[i-2].concat(g[i]);break;case 93:this.$=g[i-3].concat(g[i]);break;case 94:this.$=g[i-5].concat(g[i-2]);break;case 95:this.$=new e.Class;break;case 96:this.$=new e.Class(null,null,g[i]);break;case 97:this.$=new e.Class(null,g[i]);break;case 98:this.$=new e.Class(null,g[i-1],g[i]);break;case 99:this.$=new e.Class(g[i]);break;case 100:this.$=new e.Class(g[i-1],null,g[i]);break;case 101:this.$=new e.Class(g[i-2],g[i]);break;case 102:this.$=new e.Class(g[i-3],g[i-1],g[i]);break;case 103:this.$=new e.Call(g[i-2],g[i],g[i-1]);break;case 104:this.$=new e.Call(g[i-2],g[i],g[i-1]);break;case 105:this.$=new e.Call("super",[new e.Splat(new e.Literal("arguments"))]);break;case 106:this.$=new e.Call("super",g[i]);break;case 107:this.$=!1;break;case 108:this.$=!0;break;case 109:this.$=[];break;case 110:this.$=g[i-2];break;case 111:this.$=new e.Value(new e.Literal("this"));break;case 112:this.$=new e.Value(new e.Literal("this"));break;case 113:this.$=new e.Value(new e.Literal("this"),[new e.Access(g[i])],"this");break;case 114:this.$=new e.Arr([]);break;case 115:this.$=new e.Arr(g[i-2]);break;case 116:this.$="inclusive";break;case 117:this.$="exclusive";break;case 118:this.$=new e.Range(g[i-3],g[i-1],g[i-2]);break;case 119:this.$=new e.Range(g[i-2],g[i],g[i-1]);break;case 120:this.$=new e.Range(g[i-1],null,g[i]);break;case 121:this.$=new e.Range(null,g[i],g[i-1]);break;case 122:this.$=new e.Range(null,null,g[i]);break;case 123:this.$=[g[i]];break;case 124:this.$=g[i-2].concat(g[i]);break;case 125:this.$=g[i-3].concat(g[i]);break;case 126:this.$=g[i-2];break;case 127:this.$=g[i-5].concat(g[i-2]);break;case 128:this.$=g[i];break;case 129:this.$=g[i];break;case 130:this.$=g[i];break;case 131:this.$=[].concat(g[i-2],g[i]);break;case 132:this.$=new e.Try(g[i]);break;case 133:this.$=new e.Try(g[i-1],g[i][0],g[i][1]);break;case 134:this.$=new e.Try(g[i-2],null,null,g[i]);break;case 135:this.$=new e.Try(g[i-3],g[i-2][0],g[i-2][1],g[i]);break;case 136:this.$=[g[i-1],g[i]];break;case 137:this.$=new e.Throw(g[i]);break;case 138:this.$=new e.Parens(g[i-1]);break;case 139:this.$=new e.Parens(g[i-2]);break;case 140:this.$=new e.While(g[i]);break;case 141:this.$=new e.While(g[i-2],{guard:g[i]});break;case 142:this.$=new e.While(g[i],{invert:!0});break;case 143:this.$=new e.While(g[i-2],{invert:!0,guard:g[i]});break;case 144:this.$=g[i-1].addBody(g[i]);break;case 145:this.$=g[i].addBody(e.Block.wrap([g[i-1]]));break;case 146:this.$=g[i].addBody(e.Block.wrap([g[i-1]]));break;case 147:this.$=g[i];break;case 148:this.$=(new e.While(new e.Literal("true"))).addBody(g[i]);break;case 149:this.$=(new e.While(new e.Literal("true"))).addBody(e.Block.wrap([g[i]]));break;case 150:this.$=new e.For(g[i-1],g[i]);break;case 151:this.$=new e.For(g[i-1],g[i]);break;case 152:this.$=new e.For(g[i],g[i-1]);break;case 153:this.$={source:new e.Value(g[i])};break;case 154:this.$=function(){return g[i].own=g[i-1].own,g[i].name=g[i-1][0],g[i].index=g[i-1][1],g[i]}();break;case 155:this.$=g[i];break;case 156:this.$=function(){return g[i].own=!0,g[i]}();break;case 157:this.$=g[i];break;case 158:this.$=g[i];break;case 159:this.$=new e.Value(g[i]);break;case 160:this.$=new e.Value(g[i]);break;case 161:this.$=[g[i]];break;case 162:this.$=[g[i-2],g[i]];break;case 163:this.$={source:g[i]};break;case 164:this.$={source:g[i],object:!0};break;case 165:this.$={source:g[i-2],guard:g[i]};break;case 166:this.$={source:g[i-2],guard:g[i],object:!0};break;case 167:this.$={source:g[i-2],step:g[i]};break;case 168:this.$={source:g[i-4],guard:g[i-2],step:g[i]};break;case 169:this.$={source:g[i-4],step:g[i-2],guard:g[i]};break;case 170:this.$=new e.Switch(g[i-3],g[i-1]);break;case 171:this.$=new e.Switch(g[i-5],g[i-3],g[i-1]);break;case 172:this.$=new e.Switch(null,g[i-1]);break;case 173:this.$=new e.Switch(null,g[i-3],g[i-1]);break;case 174:this.$=g[i];break;case 175:this.$=g[i-1].concat(g[i]);break;case 176:this.$=[[g[i-1],g[i]]];break;case 177:this.$=[[g[i-2],g[i-1]]];break;case 178:this.$=new e.If(g[i-1],g[i],{type:g[i-2]});break;case 179:this.$=g[i-4].addElse(new e.If(g[i-1],g[i],{type:g[i-2]}));break;case 180:this.$=g[i];break;case 181:this.$=g[i-2].addElse(g[i]);break;case 182:this.$=new e.If(g[i],e.Block.wrap([g[i-2]]),{type:g[i-1],statement:!0});break;case 183:this.$=new e.If(g[i],e.Block.wrap([g[i-2]]),{type:g[i-1],statement:!0});break;case 184:this.$=new e.Op(g[i-1],g[i]);break;case 185:this.$=new e.Op("-",g[i]);break;case 186:this.$=new e.Op("+",g[i]);break;case 187:this.$=new e.Op("--",g[i]);break;case 188:this.$=new e.Op("++",g[i]);break;case 189:this.$=new e.Op("--",g[i-1],null,!0);break;case 190:this.$=new e.Op("++",g[i-1],null,!0);break;case 191:this.$=new e.Existence(g[i-1]);break;case 192:this.$=new e.Op("+",g[i-2],g[i]);break;case 193:this.$=new e.Op("-",g[i-2],g[i]);break;case 194:this.$=new e.Op(g[i-1],g[i-2],g[i]);break;case 195:this.$=new e.Op(g[i-1],g[i-2],g[i]);break;case 196:this.$=new e.Op(g[i-1],g[i-2],g[i]);break;case 197:this.$=new e.Op(g[i-1],g[i-2],g[i]);break;case 198:this.$=function(){return g[i-1].charAt(0)==="!"?(new e.Op(g[i-1].slice(1),g[i-2],g[i])).invert():new e.Op(g[i-1],g[i-2],g[i])}();break;case 199:this.$=new e.Assign(g[i-2],g[i],g[i-1]);break;case 200:this.$=new e.Assign(g[i-4],g[i-1],g[i-3]);break;case 201:this.$=new e.Extends(g[i-2],g[i])}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[3]},{1:[2,2],6:[1,74]},{6:[1,75]},{1:[2,4],6:[2,4],26:[2,4],101:[2,4]},{4:77,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[1,76],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,7],6:[2,7],26:[2,7],101:[2,7],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,8],6:[2,8],26:[2,8],101:[2,8],102:90,103:[1,65],105:[1,66],108:91,109:[1,68],110:69,125:[1,89]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],49:[2,12],54:[2,12],57:[2,12],62:93,66:[1,95],67:[1,96],68:[1,97],69:98,70:[1,99],72:[2,12],73:[1,100],77:[2,12],80:92,83:[1,94],84:[2,107],85:[2,12],90:[2,12],92:[2,12],101:[2,12],103:[2,12],104:[2,12],105:[2,12],109:[2,12],117:[2,12],125:[2,12],127:[2,12],128:[2,12],131:[2,12],132:[2,12],133:[2,12],134:[2,12],135:[2,12],136:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],49:[2,13],54:[2,13],57:[2,13],62:102,66:[1,95],67:[1,96],68:[1,97],69:98,70:[1,99],72:[2,13],73:[1,100],77:[2,13],80:101,83:[1,94],84:[2,107],85:[2,13],90:[2,13],92:[2,13],101:[2,13],103:[2,13],104:[2,13],105:[2,13],109:[2,13],117:[2,13],125:[2,13],127:[2,13],128:[2,13],131:[2,13],132:[2,13],133:[2,13],134:[2,13],135:[2,13],136:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],49:[2,14],54:[2,14],57:[2,14],72:[2,14],77:[2,14],85:[2,14],90:[2,14],92:[2,14],101:[2,14],103:[2,14],104:[2,14],105:[2,14],109:[2,14],117:[2,14],125:[2,14],127:[2,14],128:[2,14],131:[2,14],132:[2,14],133:[2,14],134:[2,14],135:[2,14],136:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],49:[2,15],54:[2,15],57:[2,15],72:[2,15],77:[2,15],85:[2,15],90:[2,15],92:[2,15],101:[2,15],103:[2,15],104:[2,15],105:[2,15],109:[2,15],117:[2,15],125:[2,15],127:[2,15],128:[2,15],131:[2,15],132:[2,15],133:[2,15],134:[2,15],135:[2,15],136:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],49:[2,16],54:[2,16],57:[2,16],72:[2,16],77:[2,16],85:[2,16],90:[2,16],92:[2,16],101:[2,16],103:[2,16],104:[2,16],105:[2,16],109:[2,16],117:[2,16],125:[2,16],127:[2,16],128:[2,16],131:[2,16],132:[2,16],133:[2,16],134:[2,16],135:[2,16],136:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],49:[2,17],54:[2,17],57:[2,17],72:[2,17],77:[2,17],85:[2,17],90:[2,17],92:[2,17],101:[2,17],103:[2,17],104:[2,17],105:[2,17],109:[2,17],117:[2,17],125:[2,17],127:[2,17],128:[2,17],131:[2,17],132:[2,17],133:[2,17],134:[2,17],135:[2,17],136:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],49:[2,18],54:[2,18],57:[2,18],72:[2,18],77:[2,18],85:[2,18],90:[2,18],92:[2,18],101:[2,18],103:[2,18],104:[2,18],105:[2,18],109:[2,18],117:[2,18],125:[2,18],127:[2,18],128:[2,18],131:[2,18],132:[2,18],133:[2,18],134:[2,18],135:[2,18],136:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],49:[2,19],54:[2,19],57:[2,19],72:[2,19],77:[2,19],85:[2,19],90:[2,19],92:[2,19],101:[2,19],103:[2,19],104:[2,19],105:[2,19],109:[2,19],117:[2,19],125:[2,19],127:[2,19],128:[2,19],131:[2,19],132:[2,19],133:[2,19],134:[2,19],135:[2,19],136:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],49:[2,20],54:[2,20],57:[2,20],72:[2,20],77:[2,20],85:[2,20],90:[2,20],92:[2,20],101:[2,20],103:[2,20],104:[2,20],105:[2,20],109:[2,20],117:[2,20],125:[2,20],127:[2,20],128:[2,20],131:[2,20],132:[2,20],133:[2,20],134:[2,20],135:[2,20],136:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],49:[2,21],54:[2,21],57:[2,21],72:[2,21],77:[2,21],85:[2,21],90:[2,21],92:[2,21],101:[2,21],103:[2,21],104:[2,21],105:[2,21],109:[2,21],117:[2,21],125:[2,21],127:[2,21],128:[2,21],131:[2,21],132:[2,21],133:[2,21],134:[2,21],135:[2,21],136:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],49:[2,22],54:[2,22],57:[2,22],72:[2,22],77:[2,22],85:[2,22],90:[2,22],92:[2,22],101:[2,22],103:[2,22],104:[2,22],105:[2,22],109:[2,22],117:[2,22],125:[2,22],127:[2,22],128:[2,22],131:[2,22],132:[2,22],133:[2,22],134:[2,22],135:[2,22],136:[2,22]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],49:[2,23],54:[2,23],57:[2,23],72:[2,23],77:[2,23],85:[2,23],90:[2,23],92:[2,23],101:[2,23],103:[2,23],104:[2,23],105:[2,23],109:[2,23],117:[2,23],125:[2,23],127:[2,23],128:[2,23],131:[2,23],132:[2,23],133:[2,23],134:[2,23],135:[2,23],136:[2,23]},{1:[2,9],6:[2,9],26:[2,9],101:[2,9],103:[2,9],105:[2,9],109:[2,9],125:[2,9]},{1:[2,10],6:[2,10],26:[2,10],101:[2,10],103:[2,10],105:[2,10],109:[2,10],125:[2,10]},{1:[2,11],6:[2,11],26:[2,11],101:[2,11],103:[2,11],105:[2,11],109:[2,11],125:[2,11]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],40:[1,103],49:[2,75],54:[2,75],57:[2,75],66:[2,75],67:[2,75],68:[2,75],70:[2,75],72:[2,75],73:[2,75],77:[2,75],83:[2,75],84:[2,75],85:[2,75],90:[2,75],92:[2,75],101:[2,75],103:[2,75],104:[2,75],105:[2,75],109:[2,75],117:[2,75],125:[2,75],127:[2,75],128:[2,75],131:[2,75],132:[2,75],133:[2,75],134:[2,75],135:[2,75],136:[2,75]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],49:[2,76],54:[2,76],57:[2,76],66:[2,76],67:[2,76],68:[2,76],70:[2,76],72:[2,76],73:[2,76],77:[2,76],83:[2,76],84:[2,76],85:[2,76],90:[2,76],92:[2,76],101:[2,76],103:[2,76],104:[2,76],105:[2,76],109:[2,76],117:[2,76],125:[2,76],127:[2,76],128:[2,76],131:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76],136:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],49:[2,77],54:[2,77],57:[2,77],66:[2,77],67:[2,77],68:[2,77],70:[2,77],72:[2,77],73:[2,77],77:[2,77],83:[2,77],84:[2,77],85:[2,77],90:[2,77],92:[2,77],101:[2,77],103:[2,77],104:[2,77],105:[2,77],109:[2,77],117:[2,77],125:[2,77],127:[2,77],128:[2,77],131:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77],136:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],49:[2,78],54:[2,78],57:[2,78],66:[2,78],67:[2,78],68:[2,78],70:[2,78],72:[2,78],73:[2,78],77:[2,78],83:[2,78],84:[2,78],85:[2,78],90:[2,78],92:[2,78],101:[2,78],103:[2,78],104:[2,78],105:[2,78],109:[2,78],117:[2,78],125:[2,78],127:[2,78],128:[2,78],131:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78],136:[2,78]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],49:[2,79],54:[2,79],57:[2,79],66:[2,79],67:[2,79],68:[2,79],70:[2,79],72:[2,79],73:[2,79],77:[2,79],83:[2,79],84:[2,79],85:[2,79],90:[2,79],92:[2,79],101:[2,79],103:[2,79],104:[2,79],105:[2,79],109:[2,79],117:[2,79],125:[2,79],127:[2,79],128:[2,79],131:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79],136:[2,79]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],49:[2,105],54:[2,105],57:[2,105],66:[2,105],67:[2,105],68:[2,105],70:[2,105],72:[2,105],73:[2,105],77:[2,105],81:104,83:[2,105],84:[1,105],85:[2,105],90:[2,105],92:[2,105],101:[2,105],103:[2,105],104:[2,105],105:[2,105],109:[2,105],117:[2,105],125:[2,105],127:[2,105],128:[2,105],131:[2,105],132:[2,105],133:[2,105],134:[2,105],135:[2,105],136:[2,105]},{6:[2,55],25:[2,55],27:109,28:[1,73],44:110,48:106,49:[2,55],54:[2,55],55:107,56:108,58:111,59:112,75:[1,70],88:[1,113],89:[1,114]},{5:115,25:[1,5]},{8:116,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:118,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:119,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{13:121,14:122,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:123,44:63,58:47,59:48,61:120,63:25,64:26,65:27,75:[1,70],82:[1,28],87:[1,58],88:[1,59],89:[1,57],100:[1,56]},{13:121,14:122,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:123,44:63,58:47,59:48,61:124,63:25,64:26,65:27,75:[1,70],82:[1,28],87:[1,58],88:[1,59],89:[1,57],100:[1,56]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],40:[2,72],49:[2,72],54:[2,72],57:[2,72],66:[2,72],67:[2,72],68:[2,72],70:[2,72],72:[2,72],73:[2,72],77:[2,72],79:[1,128],83:[2,72],84:[2,72],85:[2,72],90:[2,72],92:[2,72],101:[2,72],103:[2,72],104:[2,72],105:[2,72],109:[2,72],117:[2,72],125:[2,72],127:[2,72],128:[2,72],129:[1,125],130:[1,126],131:[2,72],132:[2,72],133:[2,72],134:[2,72],135:[2,72],136:[2,72],137:[1,127]},{1:[2,180],6:[2,180],25:[2,180],26:[2,180],49:[2,180],54:[2,180],57:[2,180],72:[2,180],77:[2,180],85:[2,180],90:[2,180],92:[2,180],101:[2,180],103:[2,180],104:[2,180],105:[2,180],109:[2,180],117:[2,180],120:[1,129],125:[2,180],127:[2,180],128:[2,180],131:[2,180],132:[2,180],133:[2,180],134:[2,180],135:[2,180],136:[2,180]},{5:130,25:[1,5]},{5:131,25:[1,5]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],49:[2,147],54:[2,147],57:[2,147],72:[2,147],77:[2,147],85:[2,147],90:[2,147],92:[2,147],101:[2,147],103:[2,147],104:[2,147],105:[2,147],109:[2,147],117:[2,147],125:[2,147],127:[2,147],128:[2,147],131:[2,147],132:[2,147],133:[2,147],134:[2,147],135:[2,147],136:[2,147]},{5:132,25:[1,5]},{8:133,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,134],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,95],5:135,6:[2,95],13:121,14:122,25:[1,5],26:[2,95],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:123,44:63,49:[2,95],54:[2,95],57:[2,95],58:47,59:48,61:137,63:25,64:26,65:27,72:[2,95],75:[1,70],77:[2,95],79:[1,136],82:[1,28],85:[2,95],87:[1,58],88:[1,59],89:[1,57],90:[2,95],92:[2,95],100:[1,56],101:[2,95],103:[2,95],104:[2,95],105:[2,95],109:[2,95],117:[2,95],125:[2,95],127:[2,95],128:[2,95],131:[2,95],132:[2,95],133:[2,95],134:[2,95],135:[2,95],136:[2,95]},{8:138,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,47],6:[2,47],8:139,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,47],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],101:[2,47],102:39,103:[2,47],105:[2,47],106:40,107:[1,67],108:41,109:[2,47],110:69,118:[1,42],123:37,124:[1,64],125:[2,47],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],54:[2,48],77:[2,48],101:[2,48],103:[2,48],105:[2,48],109:[2,48],125:[2,48]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],40:[2,73],49:[2,73],54:[2,73],57:[2,73],66:[2,73],67:[2,73],68:[2,73],70:[2,73],72:[2,73],73:[2,73],77:[2,73],83:[2,73],84:[2,73],85:[2,73],90:[2,73],92:[2,73],101:[2,73],103:[2,73],104:[2,73],105:[2,73],109:[2,73],117:[2,73],125:[2,73],127:[2,73],128:[2,73],131:[2,73],132:[2,73],133:[2,73],134:[2,73],135:[2,73],136:[2,73]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],40:[2,74],49:[2,74],54:[2,74],57:[2,74],66:[2,74],67:[2,74],68:[2,74],70:[2,74],72:[2,74],73:[2,74],77:[2,74],83:[2,74],84:[2,74],85:[2,74],90:[2,74],92:[2,74],101:[2,74],103:[2,74],104:[2,74],105:[2,74],109:[2,74],117:[2,74],125:[2,74],127:[2,74],128:[2,74],131:[2,74],132:[2,74],133:[2,74],134:[2,74],135:[2,74],136:[2,74]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],49:[2,29],54:[2,29],57:[2,29],66:[2,29],67:[2,29],68:[2,29],70:[2,29],72:[2,29],73:[2,29],77:[2,29],83:[2,29],84:[2,29],85:[2,29],90:[2,29],92:[2,29],101:[2,29],103:[2,29],104:[2,29],105:[2,29],109:[2,29],117:[2,29],125:[2,29],127:[2,29],128:[2,29],131:[2,29],132:[2,29],133:[2,29],134:[2,29],135:[2,29],136:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],49:[2,30],54:[2,30],57:[2,30],66:[2,30],67:[2,30],68:[2,30],70:[2,30],72:[2,30],73:[2,30],77:[2,30],83:[2,30],84:[2,30],85:[2,30],90:[2,30],92:[2,30],101:[2,30],103:[2,30],104:[2,30],105:[2,30],109:[2,30],117:[2,30],125:[2,30],127:[2,30],128:[2,30],131:[2,30],132:[2,30],133:[2,30],134:[2,30],135:[2,30],136:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],49:[2,31],54:[2,31],57:[2,31],66:[2,31],67:[2,31],68:[2,31],70:[2,31],72:[2,31],73:[2,31],77:[2,31],83:[2,31],84:[2,31],85:[2,31],90:[2,31],92:[2,31],101:[2,31],103:[2,31],104:[2,31],105:[2,31],109:[2,31],117:[2,31],125:[2,31],127:[2,31],128:[2,31],131:[2,31],132:[2,31],133:[2,31],134:[2,31],135:[2,31],136:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],49:[2,32],54:[2,32],57:[2,32],66:[2,32],67:[2,32],68:[2,32],70:[2,32],72:[2,32],73:[2,32],77:[2,32],83:[2,32],84:[2,32],85:[2,32],90:[2,32],92:[2,32],101:[2,32],103:[2,32],104:[2,32],105:[2,32],109:[2,32],117:[2,32],125:[2,32],127:[2,32],128:[2,32],131:[2,32],132:[2,32],133:[2,32],134:[2,32],135:[2,32],136:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],49:[2,33],54:[2,33],57:[2,33],66:[2,33],67:[2,33],68:[2,33],70:[2,33],72:[2,33],73:[2,33],77:[2,33],83:[2,33],84:[2,33],85:[2,33],90:[2,33],92:[2,33],101:[2,33],103:[2,33],104:[2,33],105:[2,33],109:[2,33],117:[2,33],125:[2,33],127:[2,33],128:[2,33],131:[2,33],132:[2,33],133:[2,33],134:[2,33],135:[2,33],136:[2,33]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],49:[2,34],54:[2,34],57:[2,34],66:[2,34],67:[2,34],68:[2,34],70:[2,34],72:[2,34],73:[2,34],77:[2,34],83:[2,34],84:[2,34],85:[2,34],90:[2,34],92:[2,34],101:[2,34],103:[2,34],104:[2,34],105:[2,34],109:[2,34],117:[2,34],125:[2,34],127:[2,34],128:[2,34],131:[2,34],132:[2,34],133:[2,34],134:[2,34],135:[2,34],136:[2,34]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],49:[2,35],54:[2,35],57:[2,35],66:[2,35],67:[2,35],68:[2,35],70:[2,35],72:[2,35],73:[2,35],77:[2,35],83:[2,35],84:[2,35],85:[2,35],90:[2,35],92:[2,35],101:[2,35],103:[2,35],104:[2,35],105:[2,35],109:[2,35],117:[2,35],125:[2,35],127:[2,35],128:[2,35],131:[2,35],132:[2,35],133:[2,35],134:[2,35],135:[2,35],136:[2,35]},{4:140,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,141],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:142,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,146],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],86:144,87:[1,58],88:[1,59],89:[1,57],90:[1,143],93:145,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],49:[2,111],54:[2,111],57:[2,111],66:[2,111],67:[2,111],68:[2,111],70:[2,111],72:[2,111],73:[2,111],77:[2,111],83:[2,111],84:[2,111],85:[2,111],90:[2,111],92:[2,111],101:[2,111],103:[2,111],104:[2,111],105:[2,111],109:[2,111],117:[2,111],125:[2,111],127:[2,111],128:[2,111],131:[2,111],132:[2,111],133:[2,111],134:[2,111],135:[2,111],136:[2,111]},{1:[2,112],6:[2,112],25:[2,112],26:[2,112],27:148,28:[1,73],49:[2,112],54:[2,112],57:[2,112],66:[2,112],67:[2,112],68:[2,112],70:[2,112],72:[2,112],73:[2,112],77:[2,112],83:[2,112],84:[2,112],85:[2,112],90:[2,112],92:[2,112],101:[2,112],103:[2,112],104:[2,112],105:[2,112],109:[2,112],117:[2,112],125:[2,112],127:[2,112],128:[2,112],131:[2,112],132:[2,112],133:[2,112],134:[2,112],135:[2,112],136:[2,112]},{25:[2,51]},{25:[2,52]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],40:[2,68],49:[2,68],54:[2,68],57:[2,68],66:[2,68],67:[2,68],68:[2,68],70:[2,68],72:[2,68],73:[2,68],77:[2,68],79:[2,68],83:[2,68],84:[2,68],85:[2,68],90:[2,68],92:[2,68],101:[2,68],103:[2,68],104:[2,68],105:[2,68],109:[2,68],117:[2,68],125:[2,68],127:[2,68],128:[2,68],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[2,68],136:[2,68],137:[2,68]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],40:[2,71],49:[2,71],54:[2,71],57:[2,71],66:[2,71],67:[2,71],68:[2,71],70:[2,71],72:[2,71],73:[2,71],77:[2,71],79:[2,71],83:[2,71],84:[2,71],85:[2,71],90:[2,71],92:[2,71],101:[2,71],103:[2,71],104:[2,71],105:[2,71],109:[2,71],117:[2,71],125:[2,71],127:[2,71],128:[2,71],129:[2,71],130:[2,71],131:[2,71],132:[2,71],133:[2,71],134:[2,71],135:[2,71],136:[2,71],137:[2,71]},{8:149,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:150,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:151,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{5:152,8:153,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{27:158,28:[1,73],44:159,58:160,59:161,64:154,75:[1,70],88:[1,113],89:[1,57],112:155,113:[1,156],114:157},{111:162,115:[1,163],116:[1,164]},{6:[2,90],11:168,25:[2,90],27:169,28:[1,73],29:170,30:[1,71],31:[1,72],41:166,42:167,44:171,46:[1,46],54:[2,90],76:165,77:[2,90],88:[1,113]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],43:[2,27],49:[2,27],54:[2,27],57:[2,27],66:[2,27],67:[2,27],68:[2,27],70:[2,27],72:[2,27],73:[2,27],77:[2,27],83:[2,27],84:[2,27],85:[2,27],90:[2,27],92:[2,27],101:[2,27],103:[2,27],104:[2,27],105:[2,27],109:[2,27],117:[2,27],125:[2,27],127:[2,27],128:[2,27],131:[2,27],132:[2,27],133:[2,27],134:[2,27],135:[2,27],136:[2,27]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],43:[2,28],49:[2,28],54:[2,28],57:[2,28],66:[2,28],67:[2,28],68:[2,28],70:[2,28],72:[2,28],73:[2,28],77:[2,28],83:[2,28],84:[2,28],85:[2,28],90:[2,28],92:[2,28],101:[2,28],103:[2,28],104:[2,28],105:[2,28],109:[2,28],117:[2,28],125:[2,28],127:[2,28],128:[2,28],131:[2,28],132:[2,28],133:[2,28],134:[2,28],135:[2,28],136:[2,28]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],40:[2,26],43:[2,26],49:[2,26],54:[2,26],57:[2,26],66:[2,26],67:[2,26],68:[2,26],70:[2,26],72:[2,26],73:[2,26],77:[2,26],79:[2,26],83:[2,26],84:[2,26],85:[2,26],90:[2,26],92:[2,26],101:[2,26],103:[2,26],104:[2,26],105:[2,26],109:[2,26],115:[2,26],116:[2,26],117:[2,26],125:[2,26],127:[2,26],128:[2,26],129:[2,26],130:[2,26],131:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26],136:[2,26],137:[2,26]},{1:[2,6],6:[2,6],7:172,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,6],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],101:[2,6],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,3]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],49:[2,24],54:[2,24],57:[2,24],72:[2,24],77:[2,24],85:[2,24],90:[2,24],92:[2,24],97:[2,24],98:[2,24],101:[2,24],103:[2,24],104:[2,24],105:[2,24],109:[2,24],117:[2,24],120:[2,24],122:[2,24],125:[2,24],127:[2,24],128:[2,24],131:[2,24],132:[2,24],133:[2,24],134:[2,24],135:[2,24],136:[2,24]},{6:[1,74],26:[1,173]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],49:[2,191],54:[2,191],57:[2,191],72:[2,191],77:[2,191],85:[2,191],90:[2,191],92:[2,191],101:[2,191],103:[2,191],104:[2,191],105:[2,191],109:[2,191],117:[2,191],125:[2,191],127:[2,191],128:[2,191],131:[2,191],132:[2,191],133:[2,191],134:[2,191],135:[2,191],136:[2,191]},{8:174,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:175,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:176,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:177,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:178,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:179,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:180,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:181,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],49:[2,146],54:[2,146],57:[2,146],72:[2,146],77:[2,146],85:[2,146],90:[2,146],92:[2,146],101:[2,146],103:[2,146],104:[2,146],105:[2,146],109:[2,146],117:[2,146],125:[2,146],127:[2,146],128:[2,146],131:[2,146],132:[2,146],133:[2,146],134:[2,146],135:[2,146],136:[2,146]},{1:[2,151],6:[2,151],25:[2,151],26:[2,151],49:[2,151],54:[2,151],57:[2,151],72:[2,151],77:[2,151],85:[2,151],90:[2,151],92:[2,151],101:[2,151],103:[2,151],104:[2,151],105:[2,151],109:[2,151],117:[2,151],125:[2,151],127:[2,151],128:[2,151],131:[2,151],132:[2,151],133:[2,151],134:[2,151],135:[2,151],136:[2,151]},{8:182,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],49:[2,145],54:[2,145],57:[2,145],72:[2,145],77:[2,145],85:[2,145],90:[2,145],92:[2,145],101:[2,145],103:[2,145],104:[2,145],105:[2,145],109:[2,145],117:[2,145],125:[2,145],127:[2,145],128:[2,145],131:[2,145],132:[2,145],133:[2,145],134:[2,145],135:[2,145],136:[2,145]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],49:[2,150],54:[2,150],57:[2,150],72:[2,150],77:[2,150],85:[2,150],90:[2,150],92:[2,150],101:[2,150],103:[2,150],104:[2,150],105:[2,150],109:[2,150],117:[2,150],125:[2,150],127:[2,150],128:[2,150],131:[2,150],132:[2,150],133:[2,150],134:[2,150],135:[2,150],136:[2,150]},{81:183,84:[1,105]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],40:[2,69],49:[2,69],54:[2,69],57:[2,69],66:[2,69],67:[2,69],68:[2,69],70:[2,69],72:[2,69],73:[2,69],77:[2,69],79:[2,69],83:[2,69],84:[2,69],85:[2,69],90:[2,69],92:[2,69],101:[2,69],103:[2,69],104:[2,69],105:[2,69],109:[2,69],117:[2,69],125:[2,69],127:[2,69],128:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69],135:[2,69],136:[2,69],137:[2,69]},{84:[2,108]},{27:184,28:[1,73]},{27:185,28:[1,73]},{1:[2,83],6:[2,83],25:[2,83],26:[2,83],27:186,28:[1,73],40:[2,83],49:[2,83],54:[2,83],57:[2,83],66:[2,83],67:[2,83],68:[2,83],70:[2,83],72:[2,83],73:[2,83],77:[2,83],79:[2,83],83:[2,83],84:[2,83],85:[2,83],90:[2,83],92:[2,83],101:[2,83],103:[2,83],104:[2,83],105:[2,83],109:[2,83],117:[2,83],125:[2,83],127:[2,83],128:[2,83],129:[2,83],130:[2,83],131:[2,83],132:[2,83],133:[2,83],134:[2,83],135:[2,83],136:[2,83],137:[2,83]},{1:[2,84],6:[2,84],25:[2,84],26:[2,84],40:[2,84],49:[2,84],54:[2,84],57:[2,84],66:[2,84],67:[2,84],68:[2,84],70:[2,84],72:[2,84],73:[2,84],77:[2,84],79:[2,84],83:[2,84],84:[2,84],85:[2,84],90:[2,84],92:[2,84],101:[2,84],103:[2,84],104:[2,84],105:[2,84],109:[2,84],117:[2,84],125:[2,84],127:[2,84],128:[2,84],129:[2,84],130:[2,84],131:[2,84],132:[2,84],133:[2,84],134:[2,84],135:[2,84],136:[2,84],137:[2,84]},{8:188,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],57:[1,192],58:47,59:48,61:36,63:25,64:26,65:27,71:187,74:189,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],91:190,92:[1,191],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{69:193,70:[1,99],73:[1,100]},{81:194,84:[1,105]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],40:[2,70],49:[2,70],54:[2,70],57:[2,70],66:[2,70],67:[2,70],68:[2,70],70:[2,70],72:[2,70],73:[2,70],77:[2,70],79:[2,70],83:[2,70],84:[2,70],85:[2,70],90:[2,70],92:[2,70],101:[2,70],103:[2,70],104:[2,70],105:[2,70],109:[2,70],117:[2,70],125:[2,70],127:[2,70],128:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70],135:[2,70],136:[2,70],137:[2,70]},{6:[1,196],8:195,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,197],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],49:[2,106],54:[2,106],57:[2,106],66:[2,106],67:[2,106],68:[2,106],70:[2,106],72:[2,106],73:[2,106],77:[2,106],83:[2,106],84:[2,106],85:[2,106],90:[2,106],92:[2,106],101:[2,106],103:[2,106],104:[2,106],105:[2,106],109:[2,106],117:[2,106],125:[2,106],127:[2,106],128:[2,106],131:[2,106],132:[2,106],133:[2,106],134:[2,106],135:[2,106],136:[2,106]},{8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,146],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],85:[1,198],86:199,87:[1,58],88:[1,59],89:[1,57],93:145,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,53],25:[2,53],49:[1,201],53:203,54:[1,202]},{6:[2,56],25:[2,56],26:[2,56],49:[2,56],54:[2,56]},{6:[2,60],25:[2,60],26:[2,60],40:[1,205],49:[2,60],54:[2,60],57:[1,204]},{6:[2,63],25:[2,63],26:[2,63],40:[2,63],49:[2,63],54:[2,63],57:[2,63]},{6:[2,64],25:[2,64],26:[2,64],40:[2,64],49:[2,64],54:[2,64],57:[2,64]},{6:[2,65],25:[2,65],26:[2,65],40:[2,65],49:[2,65],54:[2,65],57:[2,65]},{6:[2,66],25:[2,66],26:[2,66],40:[2,66],49:[2,66],54:[2,66],57:[2,66]},{27:148,28:[1,73]},{8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,146],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],86:144,87:[1,58],88:[1,59],89:[1,57],90:[1,143],93:145,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,50],6:[2,50],25:[2,50],26:[2,50],49:[2,50],54:[2,50],57:[2,50],72:[2,50],77:[2,50],85:[2,50],90:[2,50],92:[2,50],101:[2,50],103:[2,50],104:[2,50],105:[2,50],109:[2,50],117:[2,50],125:[2,50],127:[2,50],128:[2,50],131:[2,50],132:[2,50],133:[2,50],134:[2,50],135:[2,50],136:[2,50]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],49:[2,184],54:[2,184],57:[2,184],72:[2,184],77:[2,184],85:[2,184],90:[2,184],92:[2,184],101:[2,184],102:87,103:[2,184],104:[2,184],105:[2,184],108:88,109:[2,184],110:69,117:[2,184],125:[2,184],127:[2,184],128:[2,184],131:[1,78],132:[2,184],133:[2,184],134:[2,184],135:[2,184],136:[2,184]},{102:90,103:[1,65],105:[1,66],108:91,109:[1,68],110:69,125:[1,89]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],49:[2,185],54:[2,185],57:[2,185],72:[2,185],77:[2,185],85:[2,185],90:[2,185],92:[2,185],101:[2,185],102:87,103:[2,185],104:[2,185],105:[2,185],108:88,109:[2,185],110:69,117:[2,185],125:[2,185],127:[2,185],128:[2,185],131:[1,78],132:[2,185],133:[2,185],134:[2,185],135:[2,185],136:[2,185]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],49:[2,186],54:[2,186],57:[2,186],72:[2,186],77:[2,186],85:[2,186],90:[2,186],92:[2,186],101:[2,186],102:87,103:[2,186],104:[2,186],105:[2,186],108:88,109:[2,186],110:69,117:[2,186],125:[2,186],127:[2,186],128:[2,186],131:[1,78],132:[2,186],133:[2,186],134:[2,186],135:[2,186],136:[2,186]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],49:[2,187],54:[2,187],57:[2,187],66:[2,72],67:[2,72],68:[2,72],70:[2,72],72:[2,187],73:[2,72],77:[2,187],83:[2,72],84:[2,72],85:[2,187],90:[2,187],92:[2,187],101:[2,187],103:[2,187],104:[2,187],105:[2,187],109:[2,187],117:[2,187],125:[2,187],127:[2,187],128:[2,187],131:[2,187],132:[2,187],133:[2,187],134:[2,187],135:[2,187],136:[2,187]},{62:93,66:[1,95],67:[1,96],68:[1,97],69:98,70:[1,99],73:[1,100],80:92,83:[1,94],84:[2,107]},{62:102,66:[1,95],67:[1,96],68:[1,97],69:98,70:[1,99],73:[1,100],80:101,83:[1,94],84:[2,107]},{66:[2,75],67:[2,75],68:[2,75],70:[2,75],73:[2,75],83:[2,75],84:[2,75]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],49:[2,188],54:[2,188],57:[2,188],66:[2,72],67:[2,72],68:[2,72],70:[2,72],72:[2,188],73:[2,72],77:[2,188],83:[2,72],84:[2,72],85:[2,188],90:[2,188],92:[2,188],101:[2,188],103:[2,188],104:[2,188],105:[2,188],109:[2,188],117:[2,188],125:[2,188],127:[2,188],128:[2,188],131:[2,188],132:[2,188],133:[2,188],134:[2,188],135:[2,188],136:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],49:[2,189],54:[2,189],57:[2,189],72:[2,189],77:[2,189],85:[2,189],90:[2,189],92:[2,189],101:[2,189],103:[2,189],104:[2,189],105:[2,189],109:[2,189],117:[2,189],125:[2,189],127:[2,189],128:[2,189],131:[2,189],132:[2,189],133:[2,189],134:[2,189],135:[2,189],136:[2,189]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],49:[2,190],54:[2,190],57:[2,190],72:[2,190],77:[2,190],85:[2,190],90:[2,190],92:[2,190],101:[2,190],103:[2,190],104:[2,190],105:[2,190],109:[2,190],117:[2,190],125:[2,190],127:[2,190],128:[2,190],131:[2,190],132:[2,190],133:[2,190],134:[2,190],135:[2,190],136:[2,190]},{8:206,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,207],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:208,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{5:209,25:[1,5],124:[1,210]},{1:[2,132],6:[2,132],25:[2,132],26:[2,132],49:[2,132],54:[2,132],57:[2,132],72:[2,132],77:[2,132],85:[2,132],90:[2,132],92:[2,132],96:211,97:[1,212],98:[1,213],101:[2,132],103:[2,132],104:[2,132],105:[2,132],109:[2,132],117:[2,132],125:[2,132],127:[2,132],128:[2,132],131:[2,132],132:[2,132],133:[2,132],134:[2,132],135:[2,132],136:[2,132]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],49:[2,144],54:[2,144],57:[2,144],72:[2,144],77:[2,144],85:[2,144],90:[2,144],92:[2,144],101:[2,144],103:[2,144],104:[2,144],105:[2,144],109:[2,144],117:[2,144],125:[2,144],127:[2,144],128:[2,144],131:[2,144],132:[2,144],133:[2,144],134:[2,144],135:[2,144],136:[2,144]},{1:[2,152],6:[2,152],25:[2,152],26:[2,152],49:[2,152],54:[2,152],57:[2,152],72:[2,152],77:[2,152],85:[2,152],90:[2,152],92:[2,152],101:[2,152],103:[2,152],104:[2,152],105:[2,152],109:[2,152],117:[2,152],125:[2,152],127:[2,152],128:[2,152],131:[2,152],132:[2,152],133:[2,152],134:[2,152],135:[2,152],136:[2,152]},{25:[1,214],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{119:215,121:216,122:[1,217]},{1:[2,96],6:[2,96],25:[2,96],26:[2,96],49:[2,96],54:[2,96],57:[2,96],72:[2,96],77:[2,96],85:[2,96],90:[2,96],92:[2,96],101:[2,96],103:[2,96],104:[2,96],105:[2,96],109:[2,96],117:[2,96],125:[2,96],127:[2,96],128:[2,96],131:[2,96],132:[2,96],133:[2,96],134:[2,96],135:[2,96],136:[2,96]},{8:218,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,99],5:219,6:[2,99],25:[1,5],26:[2,99],49:[2,99],54:[2,99],57:[2,99],66:[2,72],67:[2,72],68:[2,72],70:[2,72],72:[2,99],73:[2,72],77:[2,99],79:[1,220],83:[2,72],84:[2,72],85:[2,99],90:[2,99],92:[2,99],101:[2,99],103:[2,99],104:[2,99],105:[2,99],109:[2,99],117:[2,99],125:[2,99],127:[2,99],128:[2,99],131:[2,99],132:[2,99],133:[2,99],134:[2,99],135:[2,99],136:[2,99]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],49:[2,137],54:[2,137],57:[2,137],72:[2,137],77:[2,137],85:[2,137],90:[2,137],92:[2,137],101:[2,137],102:87,103:[2,137],104:[2,137],105:[2,137],108:88,109:[2,137],110:69,117:[2,137],125:[2,137],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,46],6:[2,46],26:[2,46],101:[2,46],102:87,103:[2,46],105:[2,46],108:88,109:[2,46],110:69,125:[2,46],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[1,74],101:[1,221]},{4:222,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,128],25:[2,128],54:[2,128],57:[1,224],90:[2,128],91:223,92:[1,191],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],40:[2,114],49:[2,114],54:[2,114],57:[2,114],66:[2,114],67:[2,114],68:[2,114],70:[2,114],72:[2,114],73:[2,114],77:[2,114],83:[2,114],84:[2,114],85:[2,114],90:[2,114],92:[2,114],101:[2,114],103:[2,114],104:[2,114],105:[2,114],109:[2,114],115:[2,114],116:[2,114],117:[2,114],125:[2,114],127:[2,114],128:[2,114],131:[2,114],132:[2,114],133:[2,114],134:[2,114],135:[2,114],136:[2,114]},{6:[2,53],25:[2,53],53:225,54:[1,226],90:[2,53]},{6:[2,123],25:[2,123],26:[2,123],54:[2,123],85:[2,123],90:[2,123]},{8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,146],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],86:227,87:[1,58],88:[1,59],89:[1,57],93:145,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,129],25:[2,129],26:[2,129],54:[2,129],85:[2,129],90:[2,129]},{1:[2,113],6:[2,113],25:[2,113],26:[2,113],40:[2,113],43:[2,113],49:[2,113],54:[2,113],57:[2,113],66:[2,113],67:[2,113],68:[2,113],70:[2,113],72:[2,113],73:[2,113],77:[2,113],79:[2,113],83:[2,113],84:[2,113],85:[2,113],90:[2,113],92:[2,113],101:[2,113],103:[2,113],104:[2,113],105:[2,113],109:[2,113],115:[2,113],116:[2,113],117:[2,113],125:[2,113],127:[2,113],128:[2,113],129:[2,113],130:[2,113],131:[2,113],132:[2,113],133:[2,113],134:[2,113],135:[2,113],136:[2,113],137:[2,113]},{5:228,25:[1,5],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],49:[2,140],54:[2,140],57:[2,140],72:[2,140],77:[2,140],85:[2,140],90:[2,140],92:[2,140],101:[2,140],102:87,103:[1,65],104:[1,229],105:[1,66],108:88,109:[1,68],110:69,117:[2,140],125:[2,140],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],49:[2,142],54:[2,142],57:[2,142],72:[2,142],77:[2,142],85:[2,142],90:[2,142],92:[2,142],101:[2,142],102:87,103:[1,65],104:[1,230],105:[1,66],108:88,109:[1,68],110:69,117:[2,142],125:[2,142],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],49:[2,148],54:[2,148],57:[2,148],72:[2,148],77:[2,148],85:[2,148],90:[2,148],92:[2,148],101:[2,148],103:[2,148],104:[2,148],105:[2,148],109:[2,148],117:[2,148],125:[2,148],127:[2,148],128:[2,148],131:[2,148],132:[2,148],133:[2,148],134:[2,148],135:[2,148],136:[2,148]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],49:[2,149],54:[2,149],57:[2,149],72:[2,149],77:[2,149],85:[2,149],90:[2,149],92:[2,149],101:[2,149],102:87,103:[1,65],104:[2,149],105:[1,66],108:88,109:[1,68],110:69,117:[2,149],125:[2,149],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,153],6:[2,153],25:[2,153],26:[2,153],49:[2,153],54:[2,153],57:[2,153],72:[2,153],77:[2,153],85:[2,153],90:[2,153],92:[2,153],101:[2,153],103:[2,153],104:[2,153],105:[2,153],109:[2,153],117:[2,153],125:[2,153],127:[2,153],128:[2,153],131:[2,153],132:[2,153],133:[2,153],134:[2,153],135:[2,153],136:[2,153]},{115:[2,155],116:[2,155]},{27:158,28:[1,73],44:159,58:160,59:161,75:[1,70],88:[1,113],89:[1,114],112:231,114:157},{54:[1,232],115:[2,161],116:[2,161]},{54:[2,157],115:[2,157],116:[2,157]},{54:[2,158],115:[2,158],116:[2,158]},{54:[2,159],115:[2,159],116:[2,159]},{54:[2,160],115:[2,160],116:[2,160]},{1:[2,154],6:[2,154],25:[2,154],26:[2,154],49:[2,154],54:[2,154],57:[2,154],72:[2,154],77:[2,154],85:[2,154],90:[2,154],92:[2,154],101:[2,154],103:[2,154],104:[2,154],105:[2,154],109:[2,154],117:[2,154],125:[2,154],127:[2,154],128:[2,154],131:[2,154],132:[2,154],133:[2,154],134:[2,154],135:[2,154],136:[2,154]},{8:233,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:234,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,53],25:[2,53],53:235,54:[1,236],77:[2,53]},{6:[2,91],25:[2,91],26:[2,91],54:[2,91],77:[2,91]},{6:[2,39],25:[2,39],26:[2,39],43:[1,237],54:[2,39],77:[2,39]},{6:[2,42],25:[2,42],26:[2,42],54:[2,42],77:[2,42]},{6:[2,43],25:[2,43],26:[2,43],43:[2,43],54:[2,43],77:[2,43]},{6:[2,44],25:[2,44],26:[2,44],43:[2,44],54:[2,44],77:[2,44]},{6:[2,45],25:[2,45],26:[2,45],43:[2,45],54:[2,45],77:[2,45]},{1:[2,5],6:[2,5],26:[2,5],101:[2,5]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],49:[2,25],54:[2,25],57:[2,25],72:[2,25],77:[2,25],85:[2,25],90:[2,25],92:[2,25],97:[2,25],98:[2,25],101:[2,25],103:[2,25],104:[2,25],105:[2,25],109:[2,25],117:[2,25],120:[2,25],122:[2,25],125:[2,25],127:[2,25],128:[2,25],131:[2,25],132:[2,25],133:[2,25],134:[2,25],135:[2,25],136:[2,25]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],49:[2,192],54:[2,192],57:[2,192],72:[2,192],77:[2,192],85:[2,192],90:[2,192],92:[2,192],101:[2,192],102:87,103:[2,192],104:[2,192],105:[2,192],108:88,109:[2,192],110:69,117:[2,192],125:[2,192],127:[2,192],128:[2,192],131:[1,78],132:[1,81],133:[2,192],134:[2,192],135:[2,192],136:[2,192]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],49:[2,193],54:[2,193],57:[2,193],72:[2,193],77:[2,193],85:[2,193],90:[2,193],92:[2,193],101:[2,193],102:87,103:[2,193],104:[2,193],105:[2,193],108:88,109:[2,193],110:69,117:[2,193],125:[2,193],127:[2,193],128:[2,193],131:[1,78],132:[1,81],133:[2,193],134:[2,193],135:[2,193],136:[2,193]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],49:[2,194],54:[2,194],57:[2,194],72:[2,194],77:[2,194],85:[2,194],90:[2,194],92:[2,194],101:[2,194],102:87,103:[2,194],104:[2,194],105:[2,194],108:88,109:[2,194],110:69,117:[2,194],125:[2,194],127:[2,194],128:[2,194],131:[1,78],132:[2,194],133:[2,194],134:[2,194],135:[2,194],136:[2,194]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],49:[2,195],54:[2,195],57:[2,195],72:[2,195],77:[2,195],85:[2,195],90:[2,195],92:[2,195],101:[2,195],102:87,103:[2,195],104:[2,195],105:[2,195],108:88,109:[2,195],110:69,117:[2,195],125:[2,195],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[2,195],134:[2,195],135:[2,195],136:[2,195]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],49:[2,196],54:[2,196],57:[2,196],72:[2,196],77:[2,196],85:[2,196],90:[2,196],92:[2,196],101:[2,196],102:87,103:[2,196],104:[2,196],105:[2,196],108:88,109:[2,196],110:69,117:[2,196],125:[2,196],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[2,196],135:[2,196],136:[1,85]},{1:[2,197],6:[2,197],25:[2,197],26:[2,197],49:[2,197],54:[2,197],57:[2,197],72:[2,197],77:[2,197],85:[2,197],90:[2,197],92:[2,197],101:[2,197],102:87,103:[2,197],104:[2,197],105:[2,197],108:88,109:[2,197],110:69,117:[2,197],125:[2,197],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[2,197],136:[1,85]},{1:[2,198],6:[2,198],25:[2,198],26:[2,198],49:[2,198],54:[2,198],57:[2,198],72:[2,198],77:[2,198],85:[2,198],90:[2,198],92:[2,198],101:[2,198],102:87,103:[2,198],104:[2,198],105:[2,198],108:88,109:[2,198],110:69,117:[2,198],125:[2,198],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[2,198],135:[2,198],136:[2,198]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],49:[2,183],54:[2,183],57:[2,183],72:[2,183],77:[2,183],85:[2,183],90:[2,183],92:[2,183],101:[2,183],102:87,103:[1,65],104:[2,183],105:[1,66],108:88,109:[1,68],110:69,117:[2,183],125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],49:[2,182],54:[2,182],57:[2,182],72:[2,182],77:[2,182],85:[2,182],90:[2,182],92:[2,182],101:[2,182],102:87,103:[1,65],104:[2,182],105:[1,66],108:88,109:[1,68],110:69,117:[2,182],125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,103],6:[2,103],25:[2,103],26:[2,103],49:[2,103],54:[2,103],57:[2,103],66:[2,103],67:[2,103],68:[2,103],70:[2,103],72:[2,103],73:[2,103],77:[2,103],83:[2,103],84:[2,103],85:[2,103],90:[2,103],92:[2,103],101:[2,103],103:[2,103],104:[2,103],105:[2,103],109:[2,103],117:[2,103],125:[2,103],127:[2,103],128:[2,103],131:[2,103],132:[2,103],133:[2,103],134:[2,103],135:[2,103],136:[2,103]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],40:[2,80],49:[2,80],54:[2,80],57:[2,80],66:[2,80],67:[2,80],68:[2,80],70:[2,80],72:[2,80],73:[2,80],77:[2,80],79:[2,80],83:[2,80],84:[2,80],85:[2,80],90:[2,80],92:[2,80],101:[2,80],103:[2,80],104:[2,80],105:[2,80],109:[2,80],117:[2,80],125:[2,80],127:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80],136:[2,80],137:[2,80]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],40:[2,81],49:[2,81],54:[2,81],57:[2,81],66:[2,81],67:[2,81],68:[2,81],70:[2,81],72:[2,81],73:[2,81],77:[2,81],79:[2,81],83:[2,81],84:[2,81],85:[2,81],90:[2,81],92:[2,81],101:[2,81],103:[2,81],104:[2,81],105:[2,81],109:[2,81],117:[2,81],125:[2,81],127:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81],136:[2,81],137:[2,81]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],40:[2,82],49:[2,82],54:[2,82],57:[2,82],66:[2,82],67:[2,82],68:[2,82],70:[2,82],72:[2,82],73:[2,82],77:[2,82],79:[2,82],83:[2,82],84:[2,82],85:[2,82],90:[2,82],92:[2,82],101:[2,82],103:[2,82],104:[2,82],105:[2,82],109:[2,82],117:[2,82],125:[2,82],127:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82],136:[2,82],137:[2,82]},{72:[1,238]},{57:[1,192],72:[2,87],91:239,92:[1,191],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{72:[2,88]},{8:240,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,72:[2,122],75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{12:[2,116],28:[2,116],30:[2,116],31:[2,116],33:[2,116],34:[2,116],35:[2,116],36:[2,116],37:[2,116],38:[2,116],45:[2,116],46:[2,116],47:[2,116],51:[2,116],52:[2,116],72:[2,116],75:[2,116],78:[2,116],82:[2,116],87:[2,116],88:[2,116],89:[2,116],95:[2,116],99:[2,116],100:[2,116],103:[2,116],105:[2,116],107:[2,116],109:[2,116],118:[2,116],124:[2,116],126:[2,116],127:[2,116],128:[2,116],129:[2,116],130:[2,116]},{12:[2,117],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],72:[2,117],75:[2,117],78:[2,117],82:[2,117],87:[2,117],88:[2,117],89:[2,117],95:[2,117],99:[2,117],100:[2,117],103:[2,117],105:[2,117],107:[2,117],109:[2,117],118:[2,117],124:[2,117],126:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117]},{1:[2,86],6:[2,86],25:[2,86],26:[2,86],40:[2,86],49:[2,86],54:[2,86],57:[2,86],66:[2,86],67:[2,86],68:[2,86],70:[2,86],72:[2,86],73:[2,86],77:[2,86],79:[2,86],83:[2,86],84:[2,86],85:[2,86],90:[2,86],92:[2,86],101:[2,86],103:[2,86],104:[2,86],105:[2,86],109:[2,86],117:[2,86],125:[2,86],127:[2,86],128:[2,86],129:[2,86],130:[2,86],131:[2,86],132:[2,86],133:[2,86],134:[2,86],135:[2,86],136:[2,86],137:[2,86]},{1:[2,104],6:[2,104],25:[2,104],26:[2,104],49:[2,104],54:[2,104],57:[2,104],66:[2,104],67:[2,104],68:[2,104],70:[2,104],72:[2,104],73:[2,104],77:[2,104],83:[2,104],84:[2,104],85:[2,104],90:[2,104],92:[2,104],101:[2,104],103:[2,104],104:[2,104],105:[2,104],109:[2,104],117:[2,104],125:[2,104],127:[2,104],128:[2,104],131:[2,104],132:[2,104],133:[2,104],134:[2,104],135:[2,104],136:[2,104]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],49:[2,36],54:[2,36],57:[2,36],72:[2,36],77:[2,36],85:[2,36],90:[2,36],92:[2,36],101:[2,36],102:87,103:[2,36],104:[2,36],105:[2,36],108:88,109:[2,36],110:69,117:[2,36],125:[2,36],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{8:241,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:242,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,109],6:[2,109],25:[2,109],26:[2,109],49:[2,109],54:[2,109],57:[2,109],66:[2,109],67:[2,109],68:[2,109],70:[2,109],72:[2,109],73:[2,109],77:[2,109],83:[2,109],84:[2,109],85:[2,109],90:[2,109],92:[2,109],101:[2,109],103:[2,109],104:[2,109],105:[2,109],109:[2,109],117:[2,109],125:[2,109],127:[2,109],128:[2,109],131:[2,109],132:[2,109],133:[2,109],134:[2,109],135:[2,109],136:[2,109]},{6:[2,53],25:[2,53],53:243,54:[1,226],85:[2,53]},{6:[2,128],25:[2,128],26:[2,128],54:[2,128],57:[1,244],85:[2,128],90:[2,128],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{50:245,51:[1,60],52:[1,61]},{6:[2,54],25:[2,54],26:[2,54],27:109,28:[1,73],44:110,55:246,56:108,58:111,59:112,75:[1,70],88:[1,113],89:[1,114]},{6:[1,247],25:[1,248]},{6:[2,61],25:[2,61],26:[2,61],49:[2,61],54:[2,61]},{8:249,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,199],6:[2,199],25:[2,199],26:[2,199],49:[2,199],54:[2,199],57:[2,199],72:[2,199],77:[2,199],85:[2,199],90:[2,199],92:[2,199],101:[2,199],102:87,103:[2,199],104:[2,199],105:[2,199],108:88,109:[2,199],110:69,117:[2,199],125:[2,199],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{8:250,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,201],6:[2,201],25:[2,201],26:[2,201],49:[2,201],54:[2,201],57:[2,201],72:[2,201],77:[2,201],85:[2,201],90:[2,201],92:[2,201],101:[2,201],102:87,103:[2,201],104:[2,201],105:[2,201],108:88,109:[2,201],110:69,117:[2,201],125:[2,201],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],49:[2,181],54:[2,181],57:[2,181],72:[2,181],77:[2,181],85:[2,181],90:[2,181],92:[2,181],101:[2,181],103:[2,181],104:[2,181],105:[2,181],109:[2,181],117:[2,181],125:[2,181],127:[2,181],128:[2,181],131:[2,181],132:[2,181],133:[2,181],134:[2,181],135:[2,181],136:[2,181]},{8:251,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],49:[2,133],54:[2,133],57:[2,133],72:[2,133],77:[2,133],85:[2,133],90:[2,133],92:[2,133],97:[1,252],101:[2,133],103:[2,133],104:[2,133],105:[2,133],109:[2,133],117:[2,133],125:[2,133],127:[2,133],128:[2,133],131:[2,133],132:[2,133],133:[2,133],134:[2,133],135:[2,133],136:[2,133]},{5:253,25:[1,5]},{27:254,28:[1,73]},{119:255,121:216,122:[1,217]},{26:[1,256],120:[1,257],121:258,122:[1,217]},{26:[2,174],120:[2,174],122:[2,174]},{8:260,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],94:259,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,97],5:261,6:[2,97],25:[1,5],26:[2,97],49:[2,97],54:[2,97],57:[2,97],72:[2,97],77:[2,97],85:[2,97],90:[2,97],92:[2,97],101:[2,97],102:87,103:[1,65],104:[2,97],105:[1,66],108:88,109:[1,68],110:69,117:[2,97],125:[2,97],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,100],6:[2,100],25:[2,100],26:[2,100],49:[2,100],54:[2,100],57:[2,100],72:[2,100],77:[2,100],85:[2,100],90:[2,100],92:[2,100],101:[2,100],103:[2,100],104:[2,100],105:[2,100],109:[2,100],117:[2,100],125:[2,100],127:[2,100],128:[2,100],131:[2,100],132:[2,100],133:[2,100],134:[2,100],135:[2,100],136:[2,100]},{8:262,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],49:[2,138],54:[2,138],57:[2,138],66:[2,138],67:[2,138],68:[2,138],70:[2,138],72:[2,138],73:[2,138],77:[2,138],83:[2,138],84:[2,138],85:[2,138],90:[2,138],92:[2,138],101:[2,138],103:[2,138],104:[2,138],105:[2,138],109:[2,138],117:[2,138],125:[2,138],127:[2,138],128:[2,138],131:[2,138],132:[2,138],133:[2,138],134:[2,138],135:[2,138],136:[2,138]},{6:[1,74],26:[1,263]},{8:264,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,67],12:[2,117],25:[2,67],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],54:[2,67],75:[2,117],78:[2,117],82:[2,117],87:[2,117],88:[2,117],89:[2,117],90:[2,67],95:[2,117],99:[2,117],100:[2,117],103:[2,117],105:[2,117],107:[2,117],109:[2,117],118:[2,117],124:[2,117],126:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117]},{6:[1,266],25:[1,267],90:[1,265]},{6:[2,54],8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[2,54],26:[2,54],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],85:[2,54],87:[1,58],88:[1,59],89:[1,57],90:[2,54],93:268,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,53],25:[2,53],26:[2,53],53:269,54:[1,226]},{1:[2,178],6:[2,178],25:[2,178],26:[2,178],49:[2,178],54:[2,178],57:[2,178],72:[2,178],77:[2,178],85:[2,178],90:[2,178],92:[2,178],101:[2,178],103:[2,178],104:[2,178],105:[2,178],109:[2,178],117:[2,178],120:[2,178],125:[2,178],127:[2,178],128:[2,178],131:[2,178],132:[2,178],133:[2,178],134:[2,178],135:[2,178],136:[2,178]},{8:270,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:271,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{115:[2,156],116:[2,156]},{27:158,28:[1,73],44:159,58:160,59:161,75:[1,70],88:[1,113],89:[1,114],114:272},{1:[2,163],6:[2,163],25:[2,163],26:[2,163],49:[2,163],54:[2,163],57:[2,163],72:[2,163],77:[2,163],85:[2,163],90:[2,163],92:[2,163],101:[2,163],102:87,103:[2,163],104:[1,273],105:[2,163],108:88,109:[2,163],110:69,117:[1,274],125:[2,163],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,164],6:[2,164],25:[2,164],26:[2,164],49:[2,164],54:[2,164],57:[2,164],72:[2,164],77:[2,164],85:[2,164],90:[2,164],92:[2,164],101:[2,164],102:87,103:[2,164],104:[1,275],105:[2,164],108:88,109:[2,164],110:69,117:[2,164],125:[2,164],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[1,277],25:[1,278],77:[1,276]},{6:[2,54],11:168,25:[2,54],26:[2,54],27:169,28:[1,73],29:170,30:[1,71],31:[1,72],41:279,42:167,44:171,46:[1,46],77:[2,54],88:[1,113]},{8:280,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,281],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],40:[2,85],49:[2,85],54:[2,85],57:[2,85],66:[2,85],67:[2,85],68:[2,85],70:[2,85],72:[2,85],73:[2,85],77:[2,85],79:[2,85],83:[2,85],84:[2,85],85:[2,85],90:[2,85],92:[2,85],101:[2,85],103:[2,85],104:[2,85],105:[2,85],109:[2,85],117:[2,85],125:[2,85],127:[2,85],128:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85],135:[2,85],136:[2,85],137:[2,85]},{8:282,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,72:[2,120],75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{72:[2,121],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,37],6:[2,37],25:[2,37],26:[2,37],49:[2,37],54:[2,37],57:[2,37],72:[2,37],77:[2,37],85:[2,37],90:[2,37],92:[2,37],101:[2,37],102:87,103:[2,37],104:[2,37],105:[2,37],108:88,109:[2,37],110:69,117:[2,37],125:[2,37],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{26:[1,283],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[1,266],25:[1,267],85:[1,284]},{6:[2,67],25:[2,67],26:[2,67],54:[2,67],85:[2,67],90:[2,67]},{5:285,25:[1,5]},{6:[2,57],25:[2,57],26:[2,57],49:[2,57],54:[2,57]},{27:109,28:[1,73],44:110,55:286,56:108,58:111,59:112,75:[1,70],88:[1,113],89:[1,114]},{6:[2,55],25:[2,55],26:[2,55],27:109,28:[1,73],44:110,48:287,54:[2,55],55:107,56:108,58:111,59:112,75:[1,70],88:[1,113],89:[1,114]},{6:[2,62],25:[2,62],26:[2,62],49:[2,62],54:[2,62],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{26:[1,288],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{5:289,25:[1,5],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{5:290,25:[1,5]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],49:[2,134],54:[2,134],57:[2,134],72:[2,134],77:[2,134],85:[2,134],90:[2,134],92:[2,134],101:[2,134],103:[2,134],104:[2,134],105:[2,134],109:[2,134],117:[2,134],125:[2,134],127:[2,134],128:[2,134],131:[2,134],132:[2,134],133:[2,134],134:[2,134],135:[2,134],136:[2,134]},{5:291,25:[1,5]},{26:[1,292],120:[1,293],121:258,122:[1,217]},{1:[2,172],6:[2,172],25:[2,172],26:[2,172],49:[2,172],54:[2,172],57:[2,172],72:[2,172],77:[2,172],85:[2,172],90:[2,172],92:[2,172],101:[2,172],103:[2,172],104:[2,172],105:[2,172],109:[2,172],117:[2,172],125:[2,172],127:[2,172],128:[2,172],131:[2,172],132:[2,172],133:[2,172],134:[2,172],135:[2,172],136:[2,172]},{5:294,25:[1,5]},{26:[2,175],120:[2,175],122:[2,175]},{5:295,25:[1,5],54:[1,296]},{25:[2,130],54:[2,130],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,98],6:[2,98],25:[2,98],26:[2,98],49:[2,98],54:[2,98],57:[2,98],72:[2,98],77:[2,98],85:[2,98],90:[2,98],92:[2,98],101:[2,98],103:[2,98],104:[2,98],105:[2,98],109:[2,98],117:[2,98],125:[2,98],127:[2,98],128:[2,98],131:[2,98],132:[2,98],133:[2,98],134:[2,98],135:[2,98],136:[2,98]},{1:[2,101],5:297,6:[2,101],25:[1,5],26:[2,101],49:[2,101],54:[2,101],57:[2,101],72:[2,101],77:[2,101],85:[2,101],90:[2,101],92:[2,101],101:[2,101],102:87,103:[1,65],104:[2,101],105:[1,66],108:88,109:[1,68],110:69,117:[2,101],125:[2,101],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{101:[1,298]},{90:[1,299],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,115],6:[2,115],25:[2,115],26:[2,115],40:[2,115],49:[2,115],54:[2,115],57:[2,115],66:[2,115],67:[2,115],68:[2,115],70:[2,115],72:[2,115],73:[2,115],77:[2,115],83:[2,115],84:[2,115],85:[2,115],90:[2,115],92:[2,115],101:[2,115],103:[2,115],104:[2,115],105:[2,115],109:[2,115],115:[2,115],116:[2,115],117:[2,115],125:[2,115],127:[2,115],128:[2,115],131:[2,115],132:[2,115],133:[2,115],134:[2,115],135:[2,115],136:[2,115]},{8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],93:300,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:200,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,146],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:147,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],86:301,87:[1,58],88:[1,59],89:[1,57],93:145,95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[2,124],25:[2,124],26:[2,124],54:[2,124],85:[2,124],90:[2,124]},{6:[1,266],25:[1,267],26:[1,302]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],49:[2,141],54:[2,141],57:[2,141],72:[2,141],77:[2,141],85:[2,141],90:[2,141],92:[2,141],101:[2,141],102:87,103:[1,65],104:[2,141],105:[1,66],108:88,109:[1,68],110:69,117:[2,141],125:[2,141],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],49:[2,143],54:[2,143],57:[2,143],72:[2,143],77:[2,143],85:[2,143],90:[2,143],92:[2,143],101:[2,143],102:87,103:[1,65],104:[2,143],105:[1,66],108:88,109:[1,68],110:69,117:[2,143],125:[2,143],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{115:[2,162],116:[2,162]},{8:303,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:304,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:305,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,89],6:[2,89],25:[2,89],26:[2,89],40:[2,89],49:[2,89],54:[2,89],57:[2,89],66:[2,89],67:[2,89],68:[2,89],70:[2,89],72:[2,89],73:[2,89],77:[2,89],83:[2,89],84:[2,89],85:[2,89],90:[2,89],92:[2,89],101:[2,89],103:[2,89],104:[2,89],105:[2,89],109:[2,89],115:[2,89],116:[2,89],117:[2,89],125:[2,89],127:[2,89],128:[2,89],131:[2,89],132:[2,89],133:[2,89],134:[2,89],135:[2,89],136:[2,89]},{11:168,27:169,28:[1,73],29:170,30:[1,71],31:[1,72],41:306,42:167,44:171,46:[1,46],88:[1,113]},{6:[2,90],11:168,25:[2,90],26:[2,90],27:169,28:[1,73],29:170,30:[1,71],31:[1,72],41:166,42:167,44:171,46:[1,46],54:[2,90],76:307,88:[1,113]},{6:[2,92],25:[2,92],26:[2,92],54:[2,92],77:[2,92]},{6:[2,40],25:[2,40],26:[2,40],54:[2,40],77:[2,40],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{8:308,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{72:[2,119],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,38],6:[2,38],25:[2,38],26:[2,38],49:[2,38],54:[2,38],57:[2,38],72:[2,38],77:[2,38],85:[2,38],90:[2,38],92:[2,38],101:[2,38],103:[2,38],104:[2,38],105:[2,38],109:[2,38],117:[2,38],125:[2,38],127:[2,38],128:[2,38],131:[2,38],132:[2,38],133:[2,38],134:[2,38],135:[2,38],136:[2,38]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],49:[2,110],54:[2,110],57:[2,110],66:[2,110],67:[2,110],68:[2,110],70:[2,110],72:[2,110],73:[2,110],77:[2,110],83:[2,110],84:[2,110],85:[2,110],90:[2,110],92:[2,110],101:[2,110],103:[2,110],104:[2,110],105:[2,110],109:[2,110],117:[2,110],125:[2,110],127:[2,110],128:[2,110],131:[2,110],132:[2,110],133:[2,110],134:[2,110],135:[2,110],136:[2,110]},{1:[2,49],6:[2,49],25:[2,49],26:[2,49],49:[2,49],54:[2,49],57:[2,49],72:[2,49],77:[2,49],85:[2,49],90:[2,49],92:[2,49],101:[2,49],103:[2,49],104:[2,49],105:[2,49],109:[2,49],117:[2,49],125:[2,49],127:[2,49],128:[2,49],131:[2,49],132:[2,49],133:[2,49],134:[2,49],135:[2,49],136:[2,49]},{6:[2,58],25:[2,58],26:[2,58],49:[2,58],54:[2,58]},{6:[2,53],25:[2,53],26:[2,53],53:309,54:[1,202]},{1:[2,200],6:[2,200],25:[2,200],26:[2,200],49:[2,200],54:[2,200],57:[2,200],72:[2,200],77:[2,200],85:[2,200],90:[2,200],92:[2,200],101:[2,200],103:[2,200],104:[2,200],105:[2,200],109:[2,200],117:[2,200],125:[2,200],127:[2,200],128:[2,200],131:[2,200],132:[2,200],133:[2,200],134:[2,200],135:[2,200],136:[2,200]},{1:[2,179],6:[2,179],25:[2,179],26:[2,179],49:[2,179],54:[2,179],57:[2,179],72:[2,179],77:[2,179],85:[2,179],90:[2,179],92:[2,179],101:[2,179],103:[2,179],104:[2,179],105:[2,179],109:[2,179],117:[2,179],120:[2,179],125:[2,179],127:[2,179],128:[2,179],131:[2,179],132:[2,179],133:[2,179],134:[2,179],135:[2,179],136:[2,179]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],49:[2,135],54:[2,135],57:[2,135],72:[2,135],77:[2,135],85:[2,135],90:[2,135],92:[2,135],101:[2,135],103:[2,135],104:[2,135],105:[2,135],109:[2,135],117:[2,135],125:[2,135],127:[2,135],128:[2,135],131:[2,135],132:[2,135],133:[2,135],134:[2,135],135:[2,135],136:[2,135]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],49:[2,136],54:[2,136],57:[2,136],72:[2,136],77:[2,136],85:[2,136],90:[2,136],92:[2,136],97:[2,136],101:[2,136],103:[2,136],104:[2,136],105:[2,136],109:[2,136],117:[2,136],125:[2,136],127:[2,136],128:[2,136],131:[2,136],132:[2,136],133:[2,136],134:[2,136],135:[2,136],136:[2,136]},{1:[2,170],6:[2,170],25:[2,170],26:[2,170],49:[2,170],54:[2,170],57:[2,170],72:[2,170],77:[2,170],85:[2,170],90:[2,170],92:[2,170],101:[2,170],103:[2,170],104:[2,170],105:[2,170],109:[2,170],117:[2,170],125:[2,170],127:[2,170],128:[2,170],131:[2,170],132:[2,170],133:[2,170],134:[2,170],135:[2,170],136:[2,170]},{5:310,25:[1,5]},{26:[1,311]},{6:[1,312],26:[2,176],120:[2,176],122:[2,176]},{8:313,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{1:[2,102],6:[2,102],25:[2,102],26:[2,102],49:[2,102],54:[2,102],57:[2,102],72:[2,102],77:[2,102],85:[2,102],90:[2,102],92:[2,102],101:[2,102],103:[2,102],104:[2,102],105:[2,102],109:[2,102],117:[2,102],125:[2,102],127:[2,102],128:[2,102],131:[2,102],132:[2,102],133:[2,102],134:[2,102],135:[2,102],136:[2,102]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],49:[2,139],54:[2,139],57:[2,139],66:[2,139],67:[2,139],68:[2,139],70:[2,139],72:[2,139],73:[2,139],77:[2,139],83:[2,139],84:[2,139],85:[2,139],90:[2,139],92:[2,139],101:[2,139],103:[2,139],104:[2,139],105:[2,139],109:[2,139],117:[2,139],125:[2,139],127:[2,139],128:[2,139],131:[2,139],132:[2,139],133:[2,139],134:[2,139],135:[2,139],136:[2,139]},{1:[2,118],6:[2,118],25:[2,118],26:[2,118],49:[2,118],54:[2,118],57:[2,118],66:[2,118],67:[2,118],68:[2,118],70:[2,118],72:[2,118],73:[2,118],77:[2,118],83:[2,118],84:[2,118],85:[2,118],90:[2,118],92:[2,118],101:[2,118],103:[2,118],104:[2,118],105:[2,118],109:[2,118],117:[2,118],125:[2,118],127:[2,118],128:[2,118],131:[2,118],132:[2,118],133:[2,118],134:[2,118],135:[2,118],136:[2,118]},{6:[2,125],25:[2,125],26:[2,125],54:[2,125],85:[2,125],90:[2,125]},{6:[2,53],25:[2,53],26:[2,53],53:314,54:[1,226]},{6:[2,126],25:[2,126],26:[2,126],54:[2,126],85:[2,126],90:[2,126]},{1:[2,165],6:[2,165],25:[2,165],26:[2,165],49:[2,165],54:[2,165],57:[2,165],72:[2,165],77:[2,165],85:[2,165],90:[2,165],92:[2,165],101:[2,165],102:87,103:[2,165],104:[2,165],105:[2,165],108:88,109:[2,165],110:69,117:[1,315],125:[2,165],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],49:[2,167],54:[2,167],57:[2,167],72:[2,167],77:[2,167],85:[2,167],90:[2,167],92:[2,167],101:[2,167],102:87,103:[2,167],104:[1,316],105:[2,167],108:88,109:[2,167],110:69,117:[2,167],125:[2,167],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],49:[2,166],54:[2,166],57:[2,166],72:[2,166],77:[2,166],85:[2,166],90:[2,166],92:[2,166],101:[2,166],102:87,103:[2,166],104:[2,166],105:[2,166],108:88,109:[2,166],110:69,117:[2,166],125:[2,166],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[2,93],25:[2,93],26:[2,93],54:[2,93],77:[2,93]},{6:[2,53],25:[2,53],26:[2,53],53:317,54:[1,236]},{26:[1,318],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[1,247],25:[1,248],26:[1,319]},{26:[1,320]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],49:[2,173],54:[2,173],57:[2,173],72:[2,173],77:[2,173],85:[2,173],90:[2,173],92:[2,173],101:[2,173],103:[2,173],104:[2,173],105:[2,173],109:[2,173],117:[2,173],125:[2,173],127:[2,173],128:[2,173],131:[2,173],132:[2,173],133:[2,173],134:[2,173],135:[2,173],136:[2,173]},{26:[2,177],120:[2,177],122:[2,177]},{25:[2,131],54:[2,131],102:87,103:[1,65],105:[1,66],108:88,109:[1,68],110:69,125:[1,86],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[1,266],25:[1,267],26:[1,321]},{8:322,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{8:323,9:117,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,75:[1,70],78:[1,43],82:[1,28],87:[1,58],88:[1,59],89:[1,57],95:[1,38],99:[1,44],100:[1,56],102:39,103:[1,65],105:[1,66],106:40,107:[1,67],108:41,109:[1,68],110:69,118:[1,42],123:37,124:[1,64],126:[1,31],127:[1,32],128:[1,33],129:[1,34],130:[1,35]},{6:[1,277],25:[1,278],26:[1,324]},{6:[2,41],25:[2,41],26:[2,41],54:[2,41],77:[2,41]},{6:[2,59],25:[2,59],26:[2,59],49:[2,59],54:[2,59]},{1:[2,171],6:[2,171],25:[2,171],26:[2,171],49:[2,171],54:[2,171],57:[2,171],72:[2,171],77:[2,171],85:[2,171],90:[2,171],92:[2,171],101:[2,171],103:[2,171],104:[2,171],105:[2,171],109:[2,171],117:[2,171],125:[2,171],127:[2,171],128:[2,171],131:[2,171],132:[2,171],133:[2,171],134:[2,171],135:[2,171],136:[2,171]},{6:[2,127],25:[2,127],26:[2,127],54:[2,127],85:[2,127],90:[2,127]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],49:[2,168],54:[2,168],57:[2,168],72:[2,168],77:[2,168],85:[2,168],90:[2,168],92:[2,168],101:[2,168],102:87,103:[2,168],104:[2,168],105:[2,168],108:88,109:[2,168],110:69,117:[2,168],125:[2,168],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{1:[2,169],6:[2,169],25:[2,169],26:[2,169],49:[2,169],54:[2,169],57:[2,169],72:[2,169],77:[2,169],85:[2,169],90:[2,169],92:[2,169],101:[2,169],102:87,103:[2,169],104:[2,169],105:[2,169],108:88,109:[2,169],110:69,117:[2,169],125:[2,169],127:[1,80],128:[1,79],131:[1,78],132:[1,81],133:[1,82],134:[1,83],135:[1,84],136:[1,85]},{6:[2,94],25:[2,94],26:[2,94],54:[2,94],77:[2,94]}],defaultActions:{60:[2,51],61:[2,52],75:[2,3],94:[2,108],189:[2,88]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}};return undefined,a}();typeof require!="undefined"&&typeof a!="undefined"&&(a.parser=b,a.parse=function(){return b.parse.apply(b,arguments)},a.main=function(c){if(!c[1])throw new Error("Usage: "+c[0]+" FILE");if(typeof process!="undefined")var d=require("fs").readFileSync(require("path").join(process.cwd(),c[1]),"utf8");else var e=require("file").path(require("file").cwd()),d=e.join(c[1]).read({charset:"utf-8"});return a.parser.parse(d)},typeof module!="undefined"&&require.main===module&&a.main(typeof process!="undefined"?process.argv.slice(1):require("system").args))},require["./scope"]=new function(){var a=this;((function(){var b,c,d,e;e=require("./helpers"),c=e.extend,d=e.last,a.Scope=b=function(){function a(b,c,d){this.parent=b,this.expressions=c,this.method=d,this.variables=[{name:"arguments",type:"arguments"}],this.positions={},this.parent||(a.root=this)}return a.root=null,a.prototype.add=function(a,b,c){return this.shared&&!c?this.parent.add(a,b,c):Object.prototype.hasOwnProperty.call(this.positions,a)?this.variables[this.positions[a]].type=b:this.positions[a]=this.variables.push({name:a,type:b})-1},a.prototype.namedMethod=function(){return this.method.name||!this.parent?this.method:this.parent.namedMethod()},a.prototype.find=function(a){return this.check(a)?!0:(this.add(a,"var"),!1)},a.prototype.parameter=function(a){if(this.shared&&this.parent.check(a,!0))return;return this.add(a,"param")},a.prototype.check=function(a){var b;return!!(this.type(a)||((b=this.parent)!=null?b.check(a):void 0))},a.prototype.temporary=function(a,b){return a.length>1?"_"+a+(b>1?b-1:""):"_"+(b+parseInt(a,36)).toString(36).replace(/\d/g,"a")},a.prototype.type=function(a){var b,c,d,e;e=this.variables;for(c=0,d=e.length;c1&&a.level>=w?"("+c+")":c)},b.prototype.compileRoot=function(a){var b,c,d,e,f,g;return a.indent=a.bare?"":R,a.scope=new N(null,this,null),a.level=z,this.spaced=!0,e="",a.bare||(f=function(){var a,b,e,f;e=this.expressions,f=[];for(d=a=0,b=e.length;a=u?"(void 0)":"void 0"},b}(e),a.Null=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return bm(b,a),b.prototype.isAssignable=D,b.prototype.isComplex=D,b.prototype.compileNode=function(){return"null"},b}(e),a.Bool=function(a){function b(a){this.val=a}return bm(b,a),b.prototype.isAssignable=D,b.prototype.isComplex=D,b.prototype.compileNode=function(){return this.val},b}(e),a.Return=K=function(a){function b(a){a&&!a.unwrap().isUndefined&&(this.expression=a)}return bm(b,a),b.prototype.children=["expression"],b.prototype.isStatement=Y,b.prototype.makeReturn=S,b.prototype.jumps=S,b.prototype.compile=function(a,c){var d,e;return d=(e=this.expression)!=null?e.makeReturn():void 0,!d||d instanceof b?b.__super__.compile.call(this,a,c):d.compile(a,c)},b.prototype.compileNode=function(a){return this.tab+("return"+[this.expression?" "+this.expression.compile(a,y):void 0]+";")},b}(e),a.Value=W=function(a){function b(a,c,d){return!c&&a instanceof b?a:(this.base=a,this.properties=c||[],d&&(this[d]=!0),this)}return bm(b,a),b.prototype.children=["base","properties"],b.prototype.add=function(a){return this.properties=this.properties.concat(a),this},b.prototype.hasProperties=function(){return!!this.properties.length},b.prototype.isArray=function(){return!this.properties.length&&this.base instanceof c},b.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()},b.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()},b.prototype.isSimpleNumber=function(){return this.base instanceof A&&L.test(this.base.value)},b.prototype.isString=function(){return this.base instanceof A&&q.test(this.base.value)},b.prototype.isAtomic=function(){var a,b,c,d;d=this.properties.concat(this.base);for(b=0,c=d.length;b"+this.equals],i=n[0],e=n[1],c=this.stepNum?+this.stepNum>0?""+i+" "+this.toVar:""+e+" "+this.toVar:h?(o=[+this.fromNum,+this.toNum],d=o[0],l=o[1],o,d<=l?""+i+" "+l:""+e+" "+l):(b=""+this.fromVar+" <= "+this.toVar,""+b+" ? "+i+" "+this.toVar+" : "+e+" "+this.toVar),k=this.stepVar?""+f+" += "+this.stepVar:h?j?d<=l?"++"+f:"--"+f:d<=l?""+f+"++":""+f+"--":j?""+b+" ? ++"+f+" : --"+f:""+b+" ? "+f+"++ : "+f+"--",j&&(m=""+g+" = "+m),j&&(k=""+g+" = "+k),""+m+"; "+c+"; "+k):this.compileArray(a)},b.prototype.compileArray=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;if(this.fromNum&&this.toNum&&Math.abs(this.fromNum-this.toNum)<=20)return j=function(){p=[];for(var a=n=+this.fromNum,b=+this.toNum;n<=b?a<=b:a>=b;n<=b?a++:a--)p.push(a);return p}.apply(this),this.exclusive&&j.pop(),"["+j.join(", ")+"]";g=this.tab+R,f=a.scope.freeVariable("i"),k=a.scope.freeVariable("results"),i="\n"+g+k+" = [];",this.fromNum&&this.toNum?(a.index=f,c=this.compileNode(a)):(l=""+f+" = "+this.fromC+(this.toC!==this.toVar?", "+this.toC:""),d=""+this.fromVar+" <= "+this.toVar,c="var "+l+"; "+d+" ? "+f+" <"+this.equals+" "+this.toVar+" : "+f+" >"+this.equals+" "+this.toVar+"; "+d+" ? "+f+"++ : "+f+"--"),h="{ "+k+".push("+f+"); }\n"+g+"return "+k+";\n"+a.indent,e=function(a){return a!=null?a.contains(function(a){return a instanceof A&&a.value==="arguments"&&!a.asKey}):void 0};if(e(this.from)||e(this.to))b=", arguments";return"(function() {"+i+"\n"+g+"for ("+c+")"+h+"}).apply(this"+(b!=null?b:"")+")"},b}(e),a.Slice=O=function(a){function b(a){this.range=a,b.__super__.constructor.call(this)}return bm(b,a),b.prototype.children=["range"],b.prototype.compileNode=function(a){var b,c,d,e,f,g;return g=this.range,e=g.to,c=g.from,d=c&&c.compile(a,y)||"0",b=e&&e.compile(a,y),e&&(!!this.range.exclusive||+b!==-1)&&(f=", "+(this.range.exclusive?b:L.test(b)?""+(+b+1):(b=e.compile(a,u),"+"+b+" + 1 || 9e9"))),".slice("+d+(f||"")+")"},b}(e),a.Obj=E=function(a){function b(a,b){this.generated=b!=null?b:!1,this.objects=this.properties=a||[]}return bm(b,a),b.prototype.children=["properties"],b.prototype.compileNode=function(a){var b,c,e,f,g,h,i,j,l,m,n;l=this.properties;if(!l.length)return this.front?"({})":"{}";if(this.generated)for(m=0,n=l.length;m=0?"[\n"+a.indent+b+"\n"+this.tab+"]":"["+b+"]")):"[]"},b.prototype.assigns=function(a){var b,c,d,e;e=this.objects;for(c=0,d=e.length;c=0)throw SyntaxError("variable name may not be "+a);return a&&(a=o.test(a)&&a)},c.prototype.setContext=function(a){return this.body.traverseChildren(!1,function(b){if(b.classBody)return!1;if(b instanceof A&&b.value==="this")return b.value=a;if(b instanceof j){b.klass=a;if(b.bound)return b.context=a}})},c.prototype.addBoundFunctions=function(a){var c,d,e,f,g,h;if(this.boundFuncs.length){g=this.boundFuncs,h=[];for(e=0,f=g.length;e=0);if(e&&this.context!=="object")throw SyntaxError('variable name may not be "'+f+'"')}return bm(c,a),c.prototype.children=["variable","value"],c.prototype.isStatement=function(a){return(a!=null?a.level:void 0)===z&&this.context!=null&&bn.call(this.context,"?")>=0},c.prototype.assigns=function(a){return this[this.context==="object"?"value":"variable"].assigns(a)},c.prototype.unfoldSoak=function(a){return bh(a,this,"variable")},c.prototype.compileNode=function(a){var b,c,d,e,f,g,h,i,k;if(b=this.variable instanceof W){if(this.variable.isArray()||this.variable.isObject())return this.compilePatternMatch(a);if(this.variable.isSplice())return this.compileSplice(a);if((g=this.context)==="||="||g==="&&="||g==="?=")return this.compileConditional(a)}d=this.variable.compile(a,w);if(!this.context){if(!(f=this.variable.unwrapAll()).isAssignable())throw SyntaxError('"'+this.variable.compile(a)+'" cannot be assigned.');if(typeof f.hasProperties=="function"?!f.hasProperties():!void 0)this.param?a.scope.add(d,"var"):a.scope.find(d)}return this.value instanceof j&&(c=B.exec(d))&&(c[1]&&(this.value.klass=c[1]),this.value.name=(h=(i=(k=c[2])!=null?k:c[3])!=null?i:c[4])!=null?h:c[5]),e=this.value.compile(a,w),this.context==="object"?""+d+": "+e:(e=d+(" "+(this.context||"=")+" ")+e,a.level<=w?e:"("+e+")")},c.prototype.compilePatternMatch=function(a){var d,e,f,g,h,i,j,k,l,m,n,p,q,r,s,u,v,y,B,C,D,E,F,G,J,K,L;s=a.level===z,v=this.value,m=this.variable.base.objects;if(!(n=m.length))return f=v.compile(a),a.level>=x?"("+f+")":f;i=this.variable.isObject();if(s&&n===1&&!((l=m[0])instanceof P)){l instanceof c?(D=l,E=D.variable,h=E.base,l=D.value):l.base instanceof H?(F=(new W(l.unwrapAll())).cacheReference(a),l=F[0],h=F[1]):h=i?l["this"]?l.properties[0].name:l:new A(0),d=o.test(h.unwrap().value||0),v=new W(v),v.properties.push(new(d?b:t)(h));if(G=l.unwrap().value,bn.call(I,G)>=0)throw new SyntaxError("assignment to a reserved word: "+l.compile(a)+" = "+v.compile(a));return(new c(l,v,null,{param:this.param})).compile(a,z)}y=v.compile(a,w),e=[],r=!1;if(!o.test(y)||this.variable.assigns(y))e.push(""+(p=a.scope.freeVariable("ref"))+" = "+y),y=p;for(g=B=0,C=m.length;B=0)throw new SyntaxError("assignment to a reserved word: "+l.compile(a)+" = "+u.compile(a));e.push((new c(l,u,null,{param:this.param,subpattern:!0})).compile(a,w))}return!s&&!this.subpattern&&e.push(y),f=e.join(", "),a.level=0&&(a.isExistentialEquals=!0),(new F(this.context.slice(0,-1),b,new c(d,this.value,"="))).compile(a)},c.prototype.compileSplice=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return k=this.variable.properties.pop().range,d=k.from,h=k.to,c=k.exclusive,g=this.variable.compile(a),l=(d!=null?d.cache(a,x):void 0)||["0","0"],e=l[0],f=l[1],h?(d!=null?d.isSimpleNumber():void 0)&&h.isSimpleNumber()?(h=+h.compile(a)- +f,c||(h+=1)):(h=h.compile(a,u)+" - "+f,c||(h+=" + 1")):h="9e9",m=this.value.cache(a,w),i=m[0],j=m[1],b="[].splice.apply("+g+", ["+e+", "+h+"].concat("+i+")), "+j,a.level>z?"("+b+")":b},c}(e),a.Code=j=function(a){function b(a,b,c){this.params=a||[],this.body=b||new f,this.bound=c==="boundfunc",this.bound&&(this.context="_this")}return bm(b,a),b.prototype.children=["params","body"],b.prototype.isStatement=function(){return!!this.ctor},b.prototype.jumps=D,b.prototype.compileNode=function(a){var b,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,v,w,x,y,z,B,C,D,E,G,H,I,J,K,L,M,O;a.scope=new N(a.scope,this.body,this),a.scope.shared=$(a,"sharedScope"),a.indent+=R,delete a.bare,delete a.isExistentialEquals,l=[],e=[],H=this.paramNames();for(s=0,x=H.length;s=u?"("+b+")":b},b.prototype.paramNames=function(){var a,b,c,d,e;a=[],e=this.params;for(c=0,d=e.length;c=0)throw SyntaxError('parameter name "'+a+'" is not allowed')}return bm(b,a),b.prototype.children=["name","value"],b.prototype.compile=function(a){return this.name.compile(a,w)},b.prototype.asReference=function(a){var b;return this.reference?this.reference:(b=this.name,b["this"]?(b=b.properties[0].name,b.value.reserved&&(b=new A(a.scope.freeVariable(b.value)))):b.isComplex()&&(b=new A(a.scope.freeVariable("arg"))),b=new W(b),this.splat&&(b=new P(b)),this.reference=b)},b.prototype.isComplex=function(){return this.name.isComplex()},b.prototype.names=function(a){var b,c,e,f,g,h;a==null&&(a=this.name),b=function(a){var b;return b=a.properties[0].name.value,b.reserved?[]:[b]};if(a instanceof A)return[a.value];if(a instanceof W)return b(a);c=[],h=a.objects;for(f=0,g=h.length;f=c.length)return"";if(c.length===1)return g=c[0].compile(a,w),d?g:""+bi("slice")+".call("+g+")";e=c.slice(i);for(h=k=0,l=e.length;k1?b.expressions.unshift(new r((new H(this.guard)).invert(),new A("continue"))):this.guard&&(b=f.wrap([new r(this.guard,b)]))),b="\n"+b.compile(a,z)+"\n"+this.tab),c=e+this.tab+("while ("+this.condition.compile(a,y)+") {"+b+"}"),this.returns&&(c+="\n"+this.tab+"return "+d+";"),c},b}(e),a.Op=F=function(a){function e(a,c,d,e){if(a==="in")return new s(c,d);if(a==="do")return this.generateDo(c);if(a==="new"){if(c instanceof g&&!c["do"]&&!c.isNew)return c.newInstance();if(c instanceof j&&c.bound||c["do"])c=new H(c)}return this.operator=b[a]||a,this.first=c,this.second=d,this.flip=!!e,this}var b,c;return bm(e,a),b={"==":"===","!=":"!==",of:"in"},c={"!==":"===","===":"!=="},e.prototype.children=["first","second"],e.prototype.isSimpleNumber=D,e.prototype.isUnary=function(){return!this.second},e.prototype.isComplex=function(){var a;return!this.isUnary()||(a=this.operator)!=="+"&&a!=="-"||this.first.isComplex()},e.prototype.isChainable=function(){var a;return(a=this.operator)==="<"||a===">"||a===">="||a==="<="||a==="==="||a==="!=="},e.prototype.invert=function(){var a,b,d,f,g;if(this.isChainable()&&this.first.isChainable()){a=!0,b=this;while(b&&b.operator)a&&(a=b.operator in c),b=b.first;if(!a)return(new H(this)).invert();b=this;while(b&&b.operator)b.invert=!b.invert,b.operator=c[b.operator],b=b.first;return this}return(f=c[this.operator])?(this.operator=f,this.first.unwrap()instanceof e&&this.first.invert(),this):this.second?(new H(this)).invert():this.operator==="!"&&(d=this.first.unwrap())instanceof e&&((g=d.operator)==="!"||g==="in"||g==="instanceof")?d:new e("!",this)},e.prototype.unfoldSoak=function(a){var b;return((b=this.operator)==="++"||b==="--"||b==="delete")&&bh(a,this,"first")},e.prototype.generateDo=function(a){var b,c,e,f,h,i,k,l;f=[],c=a instanceof d&&(h=a.value.unwrap())instanceof j?h:a,l=c.params||[];for(i=0,k=l.length;i=0))throw SyntaxError("prefix increment/decrement may not have eval or arguments operand");return this.isUnary()?this.compileUnary(a):c?this.compileChain(a):this.operator==="?"?this.compileExistence(a):(b=this.first.compile(a,x)+" "+this.operator+" "+this.second.compile(a,x),a.level<=x?b:"("+b+")")},e.prototype.compileChain=function(a){var b,c,d,e;return e=this.first.second.cache(a),this.first.second=e[0],d=e[1],c=this.first.compile(a,x),b=""+c+" "+(this.invert?"&&":"||")+" "+d.compile(a)+" "+this.operator+" "+this.second.compile(a,x),"("+b+")"},e.prototype.compileExistence=function(a){var b,c;return this.first.isComplex()?(c=new A(a.scope.freeVariable("ref")),b=new H(new d(c,this.first))):(b=this.first,c=b),(new r(new l(b),c,{type:"if"})).addElse(this.second).compile(a)},e.prototype.compileUnary=function(a){var b,c,d;if(a.level>=u)return(new H(this)).compile(a);c=[b=this.operator],d=b==="+"||b==="-",(b==="new"||b==="typeof"||b==="delete"||d&&this.first instanceof e&&this.first.operator===b)&&c.push(" ");if(d&&this.first instanceof e||b==="new"&&this.first.isStatement(a))this.first=new H(this.first);return c.push(this.first.compile(a,x)),this.flip&&c.reverse(),c.join("")},e.prototype.toString=function(a){return e.__super__.toString.call(this,a,this.constructor.name+" "+this.operator)},e}(e),a.In=s=function(a){function b(a,b){this.object=a,this.array=b}return bm(b,a),b.prototype.children=["object","array"],b.prototype.invert=C,b.prototype.compileNode=function(a){var b,c,d,e,f;if(this.array instanceof W&&this.array.isArray()){f=this.array.base.objects;for(d=0,e=f.length;d= 0"),d===c?b:(b=d+", "+b,a.level=0)throw SyntaxError('catch variable may not be "'+this.error.value+'"');return a.scope.check(this.error.value)||a.scope.add(this.error.value,"param")," catch"+d+"{\n"+this.recovery.compile(a,z)+"\n"+this.tab+"}"}if(!this.ensure&&!this.recovery)return" catch (_error) {}"}.call(this),c=this.ensure?" finally {\n"+this.ensure.compile(a,z)+"\n"+this.tab+"}":"",""+this.tab+"try {\n"+e+"\n"+this.tab+"}"+(b||"")+c},b}(e),a.Throw=T=function(a){function b(a){this.expression=a}return bm(b,a),b.prototype.children=["expression"],b.prototype.isStatement=Y,b.prototype.jumps=D,b.prototype.makeReturn=S,b.prototype.compileNode=function(a){return this.tab+("throw "+this.expression.compile(a)+";")},b}(e),a.Existence=l=function(a){function b(a){this.expression=a}return bm(b,a),b.prototype.children=["expression"],b.prototype.invert=C,b.prototype.compileNode=function(a){var b,c,d,e;return this.expression.front=this.front,d=this.expression.compile(a,x),o.test(d)&&!a.scope.check(d)?(e=this.negated?["===","||"]:["!==","&&"],b=e[0],c=e[1],d="typeof "+d+" "+b+' "undefined" '+c+" "+d+" "+b+" null"):d=""+d+" "+(this.negated?"==":"!=")+" null",a.level<=v?d:"("+d+")"},b}(e),a.Parens=H=function(a){function b(a){this.body=a}return bm(b,a),b.prototype.children=["body"],b.prototype.unwrap=function(){return this.body},b.prototype.isComplex=function(){return this.body.isComplex()},b.prototype.compileNode=function(a){var b,c,d;return d=this.body.unwrap(),d instanceof W&&d.isAtomic()?(d.front=this.front,d.compile(a)):(c=d.compile(a,y),b=a.level1?b.expressions.unshift(new r((new H(this.guard)).invert(),new A("continue"))):this.guard&&(b=f.wrap([new r(this.guard,b)]))),this.pattern&&b.expressions.unshift(new d(this.name,new A(""+F+"["+l+"]"))),c+=this.pluckDirectCall(a,b),s&&(G="\n"+i+s+";"),this.object&&(e=""+l+" in "+F,this.own&&(h="\n"+i+"if (!"+bi("hasProp")+".call("+F+", "+l+")) continue;")),b=b.compile(bd(a,{indent:i}),z),b&&(b="\n"+b+"\n"),""+c+(u||"")+this.tab+"for ("+e+") {"+h+G+b+this.tab+"}"+(v||"")},b.prototype.pluckDirectCall=function(a,b){var c,e,f,h,i,k,l,m,n,o,p,q,r,s,t;e="",o=b.expressions;for(i=m=0,n=o.length;m=v?"("+d+")":d},b.prototype.unfoldSoak=function(){return this.soak&&this},b}(e),i={wrap:function(a,c,d){var e,h,i,k,l;if(a.jumps())return a;i=new j([],f.wrap([a])),e=[];if((k=a.contains(this.literalArgs))||a.contains(this.literalThis))l=new A(k?"apply":"call"),e=[new A("this")],k&&e.push(new A("arguments")),i=new W(i,[new b(l)]);return i.noReturn=d,h=new g(i,e),c?f.wrap([h]):h},literalArgs:function(a){return a instanceof A&&a.value==="arguments"&&!a.asKey},literalThis:function(a){return a instanceof A&&a.value==="this"&&!a.asKey||a instanceof j&&a.bound||a instanceof g&&a.isSuper}},bh=function(a,b,c){var d;if(!(d=b[c].unfoldSoak(a)))return;return b[c]=d.body,d.body=new W(b),d},V={"extends":function(){return"function(child, parent) { for (var key in parent) { if ("+bi("hasProp")+".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},indexOf:function(){return"[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}},z=1,y=2,w=3,v=4,x=5,u=6,R=" ",p="[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*",o=RegExp("^"+p+"$"),L=/^[+-]?\d+$/,B=RegExp("^(?:("+p+")\\.prototype(?:\\.("+p+")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|("+p+")$"),q=/^['"]/,bi=function(a){var b;return b="__"+a,N.root.assign(b,V[a]()),b},be=function(a,b){return a=a.replace(/\n/g,"$&"+b),a.replace(/\s+$/,"")}})).call(this)},require["./coffee-script"]=new function(){var a=this;((function(){var b,c,d,e,f,g,h,i,j,k,l={}.hasOwnProperty;e=require("fs"),h=require("path"),k=require("./lexer"),b=k.Lexer,c=k.RESERVED,g=require("./parser").parser,j=require("vm"),i=function(a){return a.charCodeAt(0)===65279?a.substring(1):a},require.extensions&&(require.extensions[".coffee"]=function(a,b){var c;return c=d(i(e.readFileSync(b,"utf8")),{filename:b}),a._compile(c,b)}),a.VERSION="1.4.0",a.RESERVED=c,a.helpers=require("./helpers"),a.compile=d=function(b,c){var d,e,h;c==null&&(c={}),h=a.helpers.merge;try{e=g.parse(f.tokenize(b)).compile(c);if(!c.header)return e}catch(i){throw c.filename&&(i.message="In "+c.filename+", "+i.message),i}return d="Generated by CoffeeScript "+this.VERSION,"// "+d+"\n"+e},a.tokens=function(a,b){return f.tokenize(a,b)},a.nodes=function(a,b){return typeof a=="string"?g.parse(f.tokenize(a,b)):g.parse(a)},a.run=function(a,b){var c;return b==null&&(b={}),c=require.main,c.filename=process.argv[1]=b.filename?e.realpathSync(b.filename):".",c.moduleCache&&(c.moduleCache={}),c.paths=require("module")._nodeModulePaths(h.dirname(e.realpathSync(b.filename))),h.extname(c.filename)!==".coffee"||require.extensions?c._compile(d(a,b),c.filename):c._compile(a,c.filename)},a.eval=function(a,b){var c,e,f,g,i,k,m,n,o,p,q,r,s,t;b==null&&(b={});if(!(a=a.trim()))return;e=j.Script;if(e){if(b.sandbox!=null){if(b.sandbox instanceof e.createContext().constructor)m=b.sandbox;else{m=e.createContext(),r=b.sandbox;for(g in r){if(!l.call(r,g))continue;n=r[g],m[g]=n}}m.global=m.root=m.GLOBAL=m}else m=global;m.__filename=b.filename||"eval",m.__dirname=h.dirname(m.__filename);if(m===global&&!m.module&&!m.require){c=require("module"),m.module=q=new c(b.modulename||"eval"),m.require=t=function(a){return c._load(a,q,!0)},q.filename=m.__filename,s=Object.getOwnPropertyNames(require);for(o=0,p=s.length;o=", ">", +"<<", ">>", ">>>", +"+", "-", +"*", "/", "%", +"!", "~", "UNARY_PLUS", "UNARY_MINUS", +"++", "--", +".", +"[", "]", +"{", "}", +"(", ")", +"SCRIPT", "BLOCK", "LABEL", "FOR_IN", "CALL", "NEW_WITH_ARGS", "INDEX", +"ARRAY_INIT", "OBJECT_INIT", "PROPERTY_INIT", "GETTER", "SETTER", +"GROUP", "LIST", "LET_BLOCK", "ARRAY_COMP", "GENERATOR", "COMP_TAIL", +"IDENTIFIER", "NUMBER", "STRING", "REGEXP", +"break", +"case", "catch", "const", "continue", +"debugger", "default", "delete", "do", +"else", +"false", "finally", "for", "function", +"if", "in", "instanceof", +"let", +"new", "null", +"return", +"switch", +"this", "throw", "true", "try", "typeof", +"var", "void", +"yield", +"while", "with", +]; +var statementStartTokens = [ +"break", +"const", "continue", +"debugger", "do", +"for", +"if", +"return", +"switch", +"throw", "try", +"var", +"yield", +"while", "with", +]; +var opTypeNames = { +'\n': "NEWLINE", +';': "SEMICOLON", +',': "COMMA", +'?': "HOOK", +':': "COLON", +'||': "OR", +'&&': "AND", +'|': "BITWISE_OR", +'^': "BITWISE_XOR", +'&': "BITWISE_AND", +'===': "STRICT_EQ", +'==': "EQ", +'=': "ASSIGN", +'!==': "STRICT_NE", +'!=': "NE", +'<<': "LSH", +'<=': "LE", +'<': "LT", +'>>>': "URSH", +'>>': "RSH", +'>=': "GE", +'>': "GT", +'++': "INCREMENT", +'--': "DECREMENT", +'+': "PLUS", +'-': "MINUS", +'*': "MUL", +'/': "DIV", +'%': "MOD", +'!': "NOT", +'~': "BITWISE_NOT", +'.': "DOT", +'[': "LEFT_BRACKET", +']': "RIGHT_BRACKET", +'{': "LEFT_CURLY", +'}': "RIGHT_CURLY", +'(': "LEFT_PAREN", +')': "RIGHT_PAREN" +}; +var keywords = {__proto__: null}; +var tokenIds = {}; +var consts = "const "; +for (var i = 0, j = tokens.length; i < j; i++) { +if (i > 0) +consts += ", "; +var t = tokens[i]; +var name; +if (/^[a-z]/.test(t)) { +name = t.toUpperCase(); +keywords[t] = i; +} else { +name = (/^\W/.test(t) ? opTypeNames[t] : t); +} +consts += name + " = " + i; +tokenIds[name] = i; +tokens[t] = i; +} +consts += ";"; +var isStatementStartCode = {__proto__: null}; +for (i = 0, j = statementStartTokens.length; i < j; i++) +isStatementStartCode[keywords[statementStartTokens[i]]] = true; +var assignOps = ['|', '^', '&', '<<', '>>', '>>>', '+', '-', '*', '/', '%']; +for (i = 0, j = assignOps.length; i < j; i++) { +t = assignOps[i]; +assignOps[t] = tokens[t]; +} +function defineGetter(obj, prop, fn, dontDelete, dontEnum) { +Object.defineProperty(obj, prop, +{ get: fn, configurable: !dontDelete, enumerable: !dontEnum }); +} +function defineProperty(obj, prop, val, dontDelete, readOnly, dontEnum) { +Object.defineProperty(obj, prop, +{ value: val, writable: !readOnly, configurable: !dontDelete, +enumerable: !dontEnum }); +} +function isNativeCode(fn) { +return ((typeof fn) === "function") && fn.toString().match(/\[native code\]/); +} +function getPropertyDescriptor(obj, name) { +while (obj) { +if (({}).hasOwnProperty.call(obj, name)) +return Object.getOwnPropertyDescriptor(obj, name); +obj = Object.getPrototypeOf(obj); +} +} +function getOwnProperties(obj) { +var map = {}; +for (var name in Object.getOwnPropertyNames(obj)) +map[name] = Object.getOwnPropertyDescriptor(obj, name); +return map; +} +function makePassthruHandler(obj) { +return { +getOwnPropertyDescriptor: function(name) { +var desc = Object.getOwnPropertyDescriptor(obj, name); +desc.configurable = true; +return desc; +}, +getPropertyDescriptor: function(name) { +var desc = getPropertyDescriptor(obj, name); +desc.configurable = true; +return desc; +}, +getOwnPropertyNames: function() { +return Object.getOwnPropertyNames(obj); +}, +defineProperty: function(name, desc) { +Object.defineProperty(obj, name, desc); +}, +"delete": function(name) { return delete obj[name]; }, +fix: function() { +if (Object.isFrozen(obj)) { +return getOwnProperties(obj); +} +return undefined; +}, +has: function(name) { return name in obj; }, +hasOwn: function(name) { return ({}).hasOwnProperty.call(obj, name); }, +get: function(receiver, name) { return obj[name]; }, +set: function(receiver, name, val) { obj[name] = val; return true; }, +enumerate: function() { +var result = []; +for (name in obj) { result.push(name); }; +return result; +}, +keys: function() { return Object.keys(obj); } +}; +} +function noPropFound() { return undefined; } +var hasOwnProperty = ({}).hasOwnProperty; +function StringMap() { +this.table = Object.create(null, {}); +this.size = 0; +} +StringMap.prototype = { +has: function(x) { return hasOwnProperty.call(this.table, x); }, +set: function(x, v) { +if (!hasOwnProperty.call(this.table, x)) +this.size++; +this.table[x] = v; +}, +get: function(x) { return this.table[x]; }, +getDef: function(x, thunk) { +if (!hasOwnProperty.call(this.table, x)) { +this.size++; +this.table[x] = thunk(); +} +return this.table[x]; +}, +forEach: function(f) { +var table = this.table; +for (var key in table) +f.call(this, key, table[key]); +}, +toString: function() { return "[object StringMap]" } +}; +function Stack(elts) { +this.elts = elts || null; +} +Stack.prototype = { +push: function(x) { +return new Stack({ top: x, rest: this.elts }); +}, +top: function() { +if (!this.elts) +throw new Error("empty stack"); +return this.elts.top; +}, +isEmpty: function() { +return this.top === null; +}, +find: function(test) { +for (var elts = this.elts; elts; elts = elts.rest) { +if (test(elts.top)) +return elts.top; +} +return null; +}, +has: function(x) { +return Boolean(this.find(function(elt) { return elt === x })); +}, +forEach: function(f) { +for (var elts = this.elts; elts; elts = elts.rest) { +f(elts.top); +} +} +}; +return { +tokens: tokens, +opTypeNames: opTypeNames, +keywords: keywords, +isStatementStartCode: isStatementStartCode, +tokenIds: tokenIds, +consts: consts, +assignOps: assignOps, +defineGetter: defineGetter, +defineProperty: defineProperty, +isNativeCode: isNativeCode, +makePassthruHandler: makePassthruHandler, +noPropFound: noPropFound, +StringMap: StringMap, +Stack: Stack +}; +}()); +Narcissus.lexer = (function() { +var definitions = Narcissus.definitions; +eval(definitions.consts); +var opTokens = {}; +for (var op in definitions.opTypeNames) { +if (op === '\n' || op === '.') +continue; +var node = opTokens; +for (var i = 0; i < op.length; i++) { +var ch = op[i]; +if (!(ch in node)) +node[ch] = {}; +node = node[ch]; +node.op = op; +} +} +function Tokenizer(s, f, l) { +this.cursor = 0; +this.source = String(s); +this.tokens = []; +this.tokenIndex = 0; +this.lookahead = 0; +this.scanNewlines = false; +this.unexpectedEOF = false; +this.filename = f || ""; +this.lineno = l || 1; +this.comments = []; +} +Tokenizer.prototype = { +get done() { +return this.peek(true) === END; +}, +get token() { +return this.tokens[this.tokenIndex]; +}, +match: function (tt, scanOperand) { +return this.get(scanOperand) === tt || this.unget(); +}, +mustMatch: function (tt) { +if (!this.match(tt)) { +throw this.newSyntaxError("Missing " + +definitions.tokens[tt].toLowerCase()); +} +return this.token; +}, +peek: function (scanOperand) { +var tt, next; +if (this.lookahead) { +next = this.tokens[(this.tokenIndex + this.lookahead) & 3]; +tt = (this.scanNewlines && next.lineno !== this.lineno) +? NEWLINE +: next.type; +} else { +tt = this.get(scanOperand); +this.unget(); +} +return tt; +}, +peekOnSameLine: function (scanOperand) { +this.scanNewlines = true; +var tt = this.peek(scanOperand); +this.scanNewlines = false; +return tt; +}, +skip: function () { +var input = this.source; +var cstart; +var clineno; +var comments = []; +var comment; +var nlcount = 0; +for (;;) { +var ch = input[this.cursor++]; +var next = input[this.cursor]; +if (ch === '\n' && !this.scanNewlines) { +this.lineno++; +nlcount++; +} else if (ch === '/' && next === '*') { +cstart = this.cursor; +clineno = this.lineno; +this.cursor++; +for (;;) { +ch = input[this.cursor++]; +if (ch === undefined) +throw this.newSyntaxError("Unterminated comment"); +if (ch === '*') { +next = input[this.cursor]; +if (next === '/') { +this.cursor++; +comment = { +type: "BLOCK_COMMENT", +nlcount: nlcount, +start:cstart-1, end:this.cursor, lineno:clineno, endlineno: this.lineno, +value: input.substring(cstart+1,this.cursor-2) +} +this.comments.push(comment); +nlcount = 0; +break; +} +} else if (ch === '\n') { +this.lineno++; +} +} +} else if (ch === '/' && next === '/') { +cstart = this.cursor; +this.cursor++; +for (;;) { +ch = input[this.cursor++]; +if (ch === undefined) { +comment = { +type: "LINE_COMMENT", +start: cstart, end:this.cursor, +lineno: this.lineno, nlcount: nlcount, +value: input.substring(cstart+1,this.cursor-1) +}; +this.comments.push(comment); +return; +} +if (ch === '\n') { +comment = { +type: "LINE_COMMENT", +start: cstart, end:this.cursor, +lineno: this.lineno, nlcount: nlcount, +value: input.substring(cstart+1,this.cursor-1) +}; +this.comments.push(comment); +nlcount = 0; +this.lineno++; +break; +} +} +} else if (ch !== ' ' && ch !== '\t') { +this.cursor--; +return; +} +} +}, +lexExponent: function() { +var input = this.source; +var next = input[this.cursor]; +if (next === 'e' || next === 'E') { +this.cursor++; +ch = input[this.cursor++]; +if (ch === '+' || ch === '-') +ch = input[this.cursor++]; +if (ch < '0' || ch > '9') +throw this.newSyntaxError("Missing exponent"); +do { +ch = input[this.cursor++]; +} while (ch >= '0' && ch <= '9'); +this.cursor--; +return true; +} +return false; +}, +lexZeroNumber: function (ch) { +var token = this.token, input = this.source; +token.type = NUMBER; +ch = input[this.cursor++]; +if (ch === '.') { +do { +ch = input[this.cursor++]; +} while (ch >= '0' && ch <= '9'); +this.cursor--; +this.lexExponent(); +token.value = parseFloat(token.start, this.cursor); +} else if (ch === 'x' || ch === 'X') { +do { +ch = input[this.cursor++]; +} while ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || +(ch >= 'A' && ch <= 'F')); +this.cursor--; +token.value = parseInt(input.substring(token.start, this.cursor)); +} else if (ch >= '0' && ch <= '7') { +do { +ch = input[this.cursor++]; +} while (ch >= '0' && ch <= '7'); +this.cursor--; +token.value = parseInt(input.substring(token.start, this.cursor)); +} else { +this.cursor--; +this.lexExponent(); +token.value = 0; +} +}, +lexNumber: function (ch) { +var token = this.token, input = this.source; +token.type = NUMBER; +var floating = false; +do { +ch = input[this.cursor++]; +if (ch === '.' && !floating) { +floating = true; +ch = input[this.cursor++]; +} +} while (ch >= '0' && ch <= '9'); +this.cursor--; +var exponent = this.lexExponent(); +floating = floating || exponent; +var str = input.substring(token.start, this.cursor); +token.value = floating ? parseFloat(str) : parseInt(str); +}, +lexDot: function (ch) { +var token = this.token, input = this.source; +var next = input[this.cursor]; +if (next >= '0' && next <= '9') { +do { +ch = input[this.cursor++]; +} while (ch >= '0' && ch <= '9'); +this.cursor--; +this.lexExponent(); +token.type = NUMBER; +token.value = parseFloat(token.start, this.cursor); +} else { +token.type = DOT; +token.assignOp = null; +token.value = '.'; +} +}, +lexString: function (ch) { +var token = this.token, input = this.source; +token.type = STRING; +var hasEscapes = false; +var delim = ch; +while ((ch = input[this.cursor++]) !== delim) { +if (this.cursor >= input.length) +throw this.newSyntaxError("Unterminated string literal"); +if (ch === '\\') { +hasEscapes = true; +if (++this.cursor == input.length) +throw this.newSyntaxError("Unterminated string literal"); +} +} +token.value = hasEscapes +? eval(input.substring(token.start, this.cursor)) +: input.substring(token.start + 1, this.cursor - 1); +}, +lexRegExp: function (ch) { +var token = this.token, input = this.source; +token.type = REGEXP; +do { +ch = input[this.cursor++]; +if (ch === '\\') { +this.cursor++; +} else if (ch === '[') { +do { +if (ch === undefined) +throw this.newSyntaxError("Unterminated character class"); +if (ch === '\\') +this.cursor++; +ch = input[this.cursor++]; +} while (ch !== ']'); +} else if (ch === undefined) { +throw this.newSyntaxError("Unterminated regex"); +} +} while (ch !== '/'); +do { +ch = input[this.cursor++]; +} while (ch >= 'a' && ch <= 'z'); +this.cursor--; +token.value = eval(input.substring(token.start, this.cursor)); +}, +lexOp: function (ch) { +var token = this.token, input = this.source; +var node = opTokens[ch]; +var next = input[this.cursor]; +if (next in node) { +node = node[next]; +this.cursor++; +next = input[this.cursor]; +if (next in node) { +node = node[next]; +this.cursor++; +next = input[this.cursor]; +} +} +var op = node.op; +if (definitions.assignOps[op] && input[this.cursor] === '=') { +this.cursor++; +token.type = ASSIGN; +token.assignOp = definitions.tokenIds[definitions.opTypeNames[op]]; +op += '='; +} else { +token.type = definitions.tokenIds[definitions.opTypeNames[op]]; +token.assignOp = null; +} +token.value = op; +}, +lexIdent: function (ch) { +var token = this.token, input = this.source; +do { +ch = input[this.cursor++]; +} while ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || +(ch >= '0' && ch <= '9') || ch === '$' || ch === '_'); +this.cursor--; +var id = input.substring(token.start, this.cursor); +token.type = definitions.keywords[id] || IDENTIFIER; +token.value = id; +}, +get: function (scanOperand) { +var token; +while (this.lookahead) { +--this.lookahead; +this.tokenIndex = (this.tokenIndex + 1) & 3; +token = this.tokens[this.tokenIndex]; +if (token.type !== NEWLINE || this.scanNewlines) +return token.type; +} +this.skip(); +this.tokenIndex = (this.tokenIndex + 1) & 3; +token = this.tokens[this.tokenIndex]; +if (!token) +this.tokens[this.tokenIndex] = token = {}; +var input = this.source; +if (this.cursor === input.length) +return token.type = END; +token.start = this.cursor; +token.lineno = this.lineno; +var ch = input[this.cursor++]; +if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '$' || ch === '_') { +this.lexIdent(ch); +} else if (scanOperand && ch === '/') { +this.lexRegExp(ch); +} else if (ch in opTokens) { +this.lexOp(ch); +} else if (ch === '.') { +this.lexDot(ch); +} else if (ch >= '1' && ch <= '9') { +this.lexNumber(ch); +} else if (ch === '0') { +this.lexZeroNumber(ch); +} else if (ch === '"' || ch === "'") { +this.lexString(ch); +} else if (this.scanNewlines && ch === '\n') { +token.type = NEWLINE; +token.value = '\n'; +this.lineno++; +} else { +throw this.newSyntaxError("Illegal token"); +} +token.end = this.cursor; +return token.type; +}, +unget: function () { +if (++this.lookahead === 4) throw "PANIC: too much lookahead!"; +this.tokenIndex = (this.tokenIndex - 1) & 3; +}, +newSyntaxError: function (m) { +var e = new SyntaxError(m, this.filename, this.lineno); +e.source = this.source; +e.cursor = this.lookahead +? this.tokens[(this.tokenIndex + this.lookahead) & 3].start +: this.cursor; +return e; +}, +}; +return { Tokenizer: Tokenizer }; +}()); +Narcissus.parser = (function() { +var lexer = Narcissus.lexer; +var definitions = Narcissus.definitions; +const StringMap = definitions.StringMap; +const Stack = definitions.Stack; +eval(definitions.consts); +function pushDestructuringVarDecls(n, s) { +for (var i in n) { +var sub = n[i]; +if (sub.type === IDENTIFIER) { +s.varDecls.push(sub); +} else { +pushDestructuringVarDecls(sub, s); +} +} +} +const NESTING_TOP = 0, NESTING_SHALLOW = 1, NESTING_DEEP = 2; +function StaticContext(parentScript, parentBlock, inFunction, inForLoopInit, nesting) { +this.parentScript = parentScript; +this.parentBlock = parentBlock; +this.inFunction = inFunction; +this.inForLoopInit = inForLoopInit; +this.nesting = nesting; +this.allLabels = new Stack(); +this.currentLabels = new Stack(); +this.labeledTargets = new Stack(); +this.defaultTarget = null; +Narcissus.options.ecma3OnlyMode && (this.ecma3OnlyMode = true); +Narcissus.options.parenFreeMode && (this.parenFreeMode = true); +} +StaticContext.prototype = { +ecma3OnlyMode: false, +parenFreeMode: false, +update: function(ext) { +var desc = {}; +for (var key in ext) { +desc[key] = { +value: ext[key], +writable: true, +enumerable: true, +configurable: true +} +} +return Object.create(this, desc); +}, +pushLabel: function(label) { +return this.update({ currentLabels: this.currentLabels.push(label), +allLabels: this.allLabels.push(label) }); +}, +pushTarget: function(target) { +var isDefaultTarget = target.isLoop || target.type === SWITCH; +if (this.currentLabels.isEmpty()) { +return isDefaultTarget +? this.update({ defaultTarget: target }) +: this; +} +target.labels = new StringMap(); +this.currentLabels.forEach(function(label) { +target.labels.set(label, true); +}); +return this.update({ currentLabels: new Stack(), +labeledTargets: this.labeledTargets.push(target), +defaultTarget: isDefaultTarget +? target +: this.defaultTarget }); +}, +nest: function(atLeast) { +var nesting = Math.max(this.nesting, atLeast); +return (nesting !== this.nesting) +? this.update({ nesting: nesting }) +: this; +} +}; +function Script(t, inFunction) { +var n = new Node(t, scriptInit()); +var x = new StaticContext(n, n, inFunction, false, NESTING_TOP); +Statements(t, x, n); +return n; +} +definitions.defineProperty(Array.prototype, "top", +function() { +return this.length && this[this.length-1]; +}, false, false, true); +function Node(t, init) { +var token = t.token; +if (token) { +this.type = token.type; +this.value = token.value; +this.lineno = token.lineno; +this.start = token.start; +this.end = token.end; +} else { +this.lineno = t.lineno; +} +this.tokenizer = t; +this.children = []; +for (var prop in init) +this[prop] = init[prop]; +} +var Np = Node.prototype = {}; +Np.constructor = Node; +Np.toSource = Object.prototype.toSource; +Np.push = function (kid) { +if (kid !== null) { +if (kid.start < this.start) +this.start = kid.start; +if (this.end < kid.end) +this.end = kid.end; +} +return this.children.push(kid); +} +Node.indentLevel = 0; +function tokenString(tt) { +var t = definitions.tokens[tt]; +return /^\W/.test(t) ? definitions.opTypeNames[t] : t.toUpperCase(); +} +Np.toString = function () { +var a = []; +for (var i in this) { +if (this.hasOwnProperty(i) && i !== 'type' && i !== 'target') +a.push({id: i, value: this[i]}); +} +a.sort(function (a,b) { return (a.id < b.id) ? -1 : 1; }); +const INDENTATION = " "; +var n = ++Node.indentLevel; +var s = "{\n" + INDENTATION.repeat(n) + "type: " + tokenString(this.type); +for (i = 0; i < a.length; i++) +s += ",\n" + INDENTATION.repeat(n) + a[i].id + ": " + a[i].value; +n = --Node.indentLevel; +s += "\n" + INDENTATION.repeat(n) + "}"; +return s; +} +Np.getSource = function () { +return this.tokenizer.source.slice(this.start, this.end); +}; +const LOOP_INIT = { isLoop: true }; +function blockInit() { +return { type: BLOCK, varDecls: [] }; +} +function scriptInit() { +return { type: SCRIPT, +funDecls: [], +varDecls: [], +modDecls: [], +impDecls: [], +expDecls: [], +loadDeps: [], +hasEmptyReturn: false, +hasReturnWithValue: false, +isGenerator: false }; +} +definitions.defineGetter(Np, "filename", +function() { +return this.tokenizer.filename; +}); +definitions.defineGetter(Np, "length", +function() { +throw new Error("Node.prototype.length is gone; " + +"use n.children.length instead"); +}); +definitions.defineProperty(String.prototype, "repeat", +function(n) { +var s = "", t = this + s; +while (--n >= 0) +s += t; +return s; +}, false, false, true); +function MaybeLeftParen(t, x) { +if (x.parenFreeMode) +return t.match(LEFT_PAREN) ? LEFT_PAREN : END; +return t.mustMatch(LEFT_PAREN).type; +} +function MaybeRightParen(t, p) { +if (p === LEFT_PAREN) +t.mustMatch(RIGHT_PAREN); +} +function Statements(t, x, n) { +try { +while (!t.done && t.peek(true) !== RIGHT_CURLY) +{ n.push(Statement(t, x)); } +} catch (e) { +if (t.done) +{ t.unexpectedEOF = true; } +throw(e); +} +} +function Block(t, x) { +t.mustMatch(LEFT_CURLY); +var n = new Node(t, blockInit()); +Statements(t, x.update({ parentBlock: n }).pushTarget(n), n); +t.mustMatch(RIGHT_CURLY); +return n; +} +const DECLARED_FORM = 0, EXPRESSED_FORM = 1, STATEMENT_FORM = 2; +function Statement(t, x) { +var i, label, n, n2, p, c, ss, tt = t.get(true), tt2, x2, x3; +switch (tt) { +case FUNCTION: +return FunctionDefinition(t, x, true, +(x.nesting !== NESTING_TOP) +? STATEMENT_FORM +: DECLARED_FORM); +case LEFT_CURLY: +n = new Node(t, blockInit()); +Statements(t, x.update({ parentBlock: n }).pushTarget(n).nest(NESTING_SHALLOW), n); +t.mustMatch(RIGHT_CURLY); +return n; +case IF: +n = new Node(t); +n.condition = HeadExpression(t, x); +x2 = x.pushTarget(n).nest(NESTING_DEEP); +n.thenPart = Statement(t, x2); +n.elsePart = t.match(ELSE) ? Statement(t, x2) : null; +return n; +case SWITCH: +n = new Node(t, { cases: [], defaultIndex: -1 }); +n.discriminant = HeadExpression(t, x); +x2 = x.pushTarget(n).nest(NESTING_DEEP); +t.mustMatch(LEFT_CURLY); +while ((tt = t.get()) !== RIGHT_CURLY) { +switch (tt) { +case DEFAULT: +if (n.defaultIndex >= 0) +throw t.newSyntaxError("More than one switch default"); +case CASE: +n2 = new Node(t); +if (tt === DEFAULT) +n.defaultIndex = n.cases.length; +else +n2.caseLabel = Expression(t, x2, COLON); +break; +default: +throw t.newSyntaxError("Invalid switch case"); +} +t.mustMatch(COLON); +n2.statements = new Node(t, blockInit()); +while ((tt=t.peek(true)) !== CASE && tt !== DEFAULT && +tt !== RIGHT_CURLY) +n2.statements.push(Statement(t, x2)); +n.cases.push(n2); +} +return n; +case FOR: +n = new Node(t, LOOP_INIT); +if (t.match(IDENTIFIER)) { +if (t.token.value === "each") +n.isEach = true; +else +t.unget(); +} +if (!x.parenFreeMode) +t.mustMatch(LEFT_PAREN); +x2 = x.pushTarget(n).nest(NESTING_DEEP); +x3 = x.update({ inForLoopInit: true }); +if ((tt = t.peek()) !== SEMICOLON) { +if (tt === VAR || tt === CONST) { +t.get(); +n2 = Variables(t, x3); +} else if (tt === LET) { +t.get(); +if (t.peek() === LEFT_PAREN) { +n2 = LetBlock(t, x3, false); +} else { +x3.parentBlock = n; +n.varDecls = []; +n2 = Variables(t, x3); +} +} else { +n2 = Expression(t, x3); +} +} +if (n2 && t.match(IN)) { +n.type = FOR_IN; +n.object = Expression(t, x3); +if (n2.type === VAR || n2.type === LET) { +c = n2.children; +if (c.length !== 1 && n2.destructurings.length !== 1) { +throw new SyntaxError("Invalid for..in left-hand side", +t.filename, n2.lineno); +} +if (n2.destructurings.length > 0) { +n.iterator = n2.destructurings[0]; +} else { +n.iterator = c[0]; +} +n.varDecl = n2; +} else { +if (n2.type === ARRAY_INIT || n2.type === OBJECT_INIT) { +n2.destructuredNames = checkDestructuring(t, x3, n2); +} +n.iterator = n2; +} +} else { +n.setup = n2; +t.mustMatch(SEMICOLON); +if (n.isEach) +throw t.newSyntaxError("Invalid for each..in loop"); +n.condition = (t.peek() === SEMICOLON) +? null +: Expression(t, x3); +t.mustMatch(SEMICOLON); +tt2 = t.peek(); +n.update = (x.parenFreeMode +? tt2 === LEFT_CURLY || definitions.isStatementStartCode[tt2] +: tt2 === RIGHT_PAREN) +? null +: Expression(t, x3); +} +if (!x.parenFreeMode) +t.mustMatch(RIGHT_PAREN); +n.body = Statement(t, x2); +return n; +case WHILE: +n = new Node(t, { isLoop: true }); +n.condition = HeadExpression(t, x); +n.body = Statement(t, x.pushTarget(n).nest(NESTING_DEEP)); +return n; +case DO: +n = new Node(t, { isLoop: true }); +n.body = Statement(t, x.pushTarget(n).nest(NESTING_DEEP)); +t.mustMatch(WHILE); +n.condition = HeadExpression(t, x); +if (!x.ecmaStrictMode) { +t.match(SEMICOLON); +return n; +} +break; +case BREAK: +case CONTINUE: +n = new Node(t); +x2 = x.pushTarget(n); +if (t.peekOnSameLine() === IDENTIFIER) { +t.get(); +n.label = t.token.value; +} +n.target = n.label +? x2.labeledTargets.find(function(target) { return target.labels.has(n.label) }) +: x2.defaultTarget; +if (!n.target) +throw t.newSyntaxError("Invalid " + ((tt === BREAK) ? "break" : "continue")); +if (!n.target.isLoop && tt === CONTINUE) +throw t.newSyntaxError("Invalid continue"); +break; +case TRY: +n = new Node(t, { catchClauses: [] }); +n.tryBlock = Block(t, x); +while (t.match(CATCH)) { +n2 = new Node(t); +p = MaybeLeftParen(t, x); +switch (t.get()) { +case LEFT_BRACKET: +case LEFT_CURLY: +t.unget(); +n2.varName = DestructuringExpression(t, x, true); +break; +case IDENTIFIER: +n2.varName = t.token.value; +break; +default: +throw t.newSyntaxError("missing identifier in catch"); +break; +} +if (t.match(IF)) { +if (x.ecma3OnlyMode) +throw t.newSyntaxError("Illegal catch guard"); +if (n.catchClauses.length && !n.catchClauses.top().guard) +throw t.newSyntaxError("Guarded catch after unguarded"); +n2.guard = Expression(t, x); +} +MaybeRightParen(t, p); +n2.block = Block(t, x); +n.catchClauses.push(n2); +} +if (t.match(FINALLY)) +n.finallyBlock = Block(t, x); +if (!n.catchClauses.length && !n.finallyBlock) +throw t.newSyntaxError("Invalid try statement"); +return n; +case CATCH: +case FINALLY: +throw t.newSyntaxError(definitions.tokens[tt] + " without preceding try"); +case THROW: +n = new Node(t); +n.exception = Expression(t, x); +break; +case RETURN: +n = ReturnOrYield(t, x); +break; +case WITH: +n = new Node(t); +n.object = HeadExpression(t, x); +n.body = Statement(t, x.pushTarget(n).nest(NESTING_DEEP)); +return n; +case VAR: +case CONST: +n = Variables(t, x); +break; +case LET: +if (t.peek() === LEFT_PAREN) +n = LetBlock(t, x, true); +else +n = Variables(t, x); +break; +case DEBUGGER: +n = new Node(t); +break; +case NEWLINE: +case SEMICOLON: +n = new Node(t, { type: SEMICOLON }); +n.expression = null; +return n; +default: +if (tt === IDENTIFIER) { +tt = t.peek(); +if (tt === COLON) { +label = t.token.value; +if (x.allLabels.has(label)) +throw t.newSyntaxError("Duplicate label"); +t.get(); +n = new Node(t, { type: LABEL, label: label }); +n.statement = Statement(t, x.pushLabel(label).nest(NESTING_SHALLOW)); +n.target = (n.statement.type === LABEL) ? n.statement.target : n.statement; +return n; +} +} +n = new Node(t, { type: SEMICOLON }); +t.unget(); +n.expression = Expression(t, x); +n.end = n.expression.end; +break; +} +MagicalSemicolon(t); +return n; +} +function MagicalSemicolon(t) { +var tt; +if (t.lineno === t.token.lineno) { +tt = t.peekOnSameLine(); +if (tt !== END && tt !== NEWLINE && tt !== SEMICOLON && tt !== RIGHT_CURLY) +throw t.newSyntaxError("missing ; before statement"); +} +t.match(SEMICOLON); +} +function ReturnOrYield(t, x) { +var n, b, tt = t.token.type, tt2; +var parentScript = x.parentScript; +if (tt === RETURN) { +if (!x.inFunction) +throw t.newSyntaxError("Return not in function"); +} else { +if (!x.inFunction) +throw t.newSyntaxError("Yield not in function"); +parentScript.isGenerator = true; +} +n = new Node(t, { value: undefined }); +tt2 = t.peek(true); +if (tt2 !== END && tt2 !== NEWLINE && +tt2 !== SEMICOLON && tt2 !== RIGHT_CURLY +&& (tt !== YIELD || +(tt2 !== tt && tt2 !== RIGHT_BRACKET && tt2 !== RIGHT_PAREN && +tt2 !== COLON && tt2 !== COMMA))) { +if (tt === RETURN) { +n.value = Expression(t, x); +parentScript.hasReturnWithValue = true; +} else { +n.value = AssignExpression(t, x); +} +} else if (tt === RETURN) { +parentScript.hasEmptyReturn = true; +} +if (parentScript.hasReturnWithValue && parentScript.isGenerator) +throw t.newSyntaxError("Generator returns a value"); +return n; +} +function FunctionDefinition(t, x, requireName, functionForm) { +var tt; +var f = new Node(t, { params: [] }); +if (f.type !== FUNCTION) +f.type = (f.value === "get") ? GETTER : SETTER; +if (t.match(IDENTIFIER)) +f.name = t.token.value; +else if (requireName) +throw t.newSyntaxError("missing function identifier"); +var x2 = new StaticContext(null, null, true, false, NESTING_TOP); +t.mustMatch(LEFT_PAREN); +if (!t.match(RIGHT_PAREN)) { +do { +switch (t.get()) { +case LEFT_BRACKET: +case LEFT_CURLY: +t.unget(); +f.params.push(DestructuringExpression(t, x2)); +break; +case IDENTIFIER: +f.params.push(t.token.value); +break; +default: +throw t.newSyntaxError("missing formal parameter"); +break; +} +} while (t.match(COMMA)); +t.mustMatch(RIGHT_PAREN); +} +tt = t.get(); +if (tt !== LEFT_CURLY) +t.unget(); +if (tt !== LEFT_CURLY) { +f.body = AssignExpression(t, x2); +if (f.body.isGenerator) +throw t.newSyntaxError("Generator returns a value"); +} else { +f.body = Script(t, true); +} +if (tt === LEFT_CURLY) +t.mustMatch(RIGHT_CURLY); +f.end = t.token.end; +f.functionForm = functionForm; +if (functionForm === DECLARED_FORM) +x.parentScript.funDecls.push(f); +return f; +} +function Variables(t, x, letBlock) { +var n, n2, ss, i, s, tt; +tt = t.token.type; +switch (tt) { +case VAR: +case CONST: +s = x.parentScript; +break; +case LET: +s = x.parentBlock; +break; +case LEFT_PAREN: +tt = LET; +s = letBlock; +break; +} +n = new Node(t, { type: tt, destructurings: [] }); +do { +tt = t.get(); +if (tt === LEFT_BRACKET || tt === LEFT_CURLY) { +t.unget(); +var dexp = DestructuringExpression(t, x, true); +n2 = new Node(t, { type: IDENTIFIER, +name: dexp, +readOnly: n.type === CONST }); +n.push(n2); +pushDestructuringVarDecls(n2.name.destructuredNames, s); +n.destructurings.push({ exp: dexp, decl: n2 }); +if (x.inForLoopInit && t.peek() === IN) { +continue; +} +t.mustMatch(ASSIGN); +if (t.token.assignOp) +throw t.newSyntaxError("Invalid variable initialization"); +n2.initializer = AssignExpression(t, x); +continue; +} +if (tt !== IDENTIFIER) +throw t.newSyntaxError("missing variable name"); +n2 = new Node(t, { type: IDENTIFIER, +name: t.token.value, +readOnly: n.type === CONST }); +n.push(n2); +s.varDecls.push(n2); +if (t.match(ASSIGN)) { +if (t.token.assignOp) +throw t.newSyntaxError("Invalid variable initialization"); +n2.initializer = AssignExpression(t, x); +} +} while (t.match(COMMA)); +return n; +} +function LetBlock(t, x, isStatement) { +var n, n2; +n = new Node(t, { type: LET_BLOCK, varDecls: [] }); +t.mustMatch(LEFT_PAREN); +n.variables = Variables(t, x, n); +t.mustMatch(RIGHT_PAREN); +if (isStatement && t.peek() !== LEFT_CURLY) { +n2 = new Node(t, { type: SEMICOLON, +expression: n }); +isStatement = false; +} +if (isStatement) +n.block = Block(t, x); +else +n.expression = AssignExpression(t, x); +return n; +} +function checkDestructuring(t, x, n, simpleNamesOnly) { +if (n.type === ARRAY_COMP) +throw t.newSyntaxError("Invalid array comprehension left-hand side"); +if (n.type !== ARRAY_INIT && n.type !== OBJECT_INIT) +return; +var lhss = {}; +var nn, n2, idx, sub, cc, c = n.children; +for (var i = 0, j = c.length; i < j; i++) { +if (!(nn = c[i])) +continue; +if (nn.type === PROPERTY_INIT) { +cc = nn.children; +sub = cc[1]; +idx = cc[0].value; +} else if (n.type === OBJECT_INIT) { +sub = nn; +idx = nn.value; +} else { +sub = nn; +idx = i; +} +if (sub.type === ARRAY_INIT || sub.type === OBJECT_INIT) { +lhss[idx] = checkDestructuring(t, x, sub, simpleNamesOnly); +} else { +if (simpleNamesOnly && sub.type !== IDENTIFIER) { +throw t.newSyntaxError("missing name in pattern"); +} +lhss[idx] = sub; +} +} +return lhss; +} +function DestructuringExpression(t, x, simpleNamesOnly) { +var n = PrimaryExpression(t, x); +n.destructuredNames = checkDestructuring(t, x, n, simpleNamesOnly); +return n; +} +function GeneratorExpression(t, x, e) { +return new Node(t, { type: GENERATOR, +expression: e, +tail: ComprehensionTail(t, x) }); +} +function ComprehensionTail(t, x) { +var body, n, n2, n3, p; +body = new Node(t, { type: COMP_TAIL }); +do { +n = new Node(t, { type: FOR_IN, isLoop: true }); +if (t.match(IDENTIFIER)) { +if (t.token.value === "each") +n.isEach = true; +else +t.unget(); +} +p = MaybeLeftParen(t, x); +switch(t.get()) { +case LEFT_BRACKET: +case LEFT_CURLY: +t.unget(); +n.iterator = DestructuringExpression(t, x); +break; +case IDENTIFIER: +n.iterator = n3 = new Node(t, { type: IDENTIFIER }); +n3.name = n3.value; +n.varDecl = n2 = new Node(t, { type: VAR }); +n2.push(n3); +x.parentScript.varDecls.push(n3); +break; +default: +throw t.newSyntaxError("missing identifier"); +} +t.mustMatch(IN); +n.object = Expression(t, x); +MaybeRightParen(t, p); +body.push(n); +} while (t.match(FOR)); +if (t.match(IF)) +body.guard = HeadExpression(t, x); +return body; +} +function HeadExpression(t, x) { +var p = MaybeLeftParen(t, x); +var n = ParenExpression(t, x); +MaybeRightParen(t, p); +if (p === END && !n.parenthesized) { +var tt = t.peek(); +if (tt !== LEFT_CURLY && !definitions.isStatementStartCode[tt]) +throw t.newSyntaxError("Unparenthesized head followed by unbraced body"); +} +return n; +} +function ParenExpression(t, x) { +var n = Expression(t, x.update({ inForLoopInit: x.inForLoopInit && +(t.token.type === LEFT_PAREN) })); +if (t.match(FOR)) { +if (n.type === YIELD && !n.parenthesized) +throw t.newSyntaxError("Yield expression must be parenthesized"); +if (n.type === COMMA && !n.parenthesized) +throw t.newSyntaxError("Generator expression must be parenthesized"); +n = GeneratorExpression(t, x, n); +} +return n; +} +function Expression(t, x) { +var n, n2; +n = AssignExpression(t, x); +if (t.match(COMMA)) { +n2 = new Node(t, { type: COMMA }); +n2.push(n); +n = n2; +do { +n2 = n.children[n.children.length-1]; +if (n2.type === YIELD && !n2.parenthesized) +throw t.newSyntaxError("Yield expression must be parenthesized"); +n.push(AssignExpression(t, x)); +} while (t.match(COMMA)); +} +return n; +} +function AssignExpression(t, x) { +var n, lhs; +if (t.match(YIELD, true)) +return ReturnOrYield(t, x); +n = new Node(t, { type: ASSIGN }); +lhs = ConditionalExpression(t, x); +if (!t.match(ASSIGN)) { +return lhs; +} +switch (lhs.type) { +case OBJECT_INIT: +case ARRAY_INIT: +lhs.destructuredNames = checkDestructuring(t, x, lhs); +case IDENTIFIER: case DOT: case INDEX: case CALL: +break; +default: +throw t.newSyntaxError("Bad left-hand side of assignment"); +break; +} +n.assignOp = t.token.assignOp; +n.push(lhs); +n.push(AssignExpression(t, x)); +return n; +} +function ConditionalExpression(t, x) { +var n, n2; +n = OrExpression(t, x); +if (t.match(HOOK)) { +n2 = n; +n = new Node(t, { type: HOOK }); +n.push(n2); +n.push(AssignExpression(t, x.update({ inForLoopInit: false }))); +if (!t.match(COLON)) +throw t.newSyntaxError("missing : after ?"); +n.push(AssignExpression(t, x)); +} +return n; +} +function OrExpression(t, x) { +var n, n2; +n = AndExpression(t, x); +while (t.match(OR)) { +n2 = new Node(t); +n2.push(n); +n2.push(AndExpression(t, x)); +n = n2; +} +return n; +} +function AndExpression(t, x) { +var n, n2; +n = BitwiseOrExpression(t, x); +while (t.match(AND)) { +n2 = new Node(t); +n2.push(n); +n2.push(BitwiseOrExpression(t, x)); +n = n2; +} +return n; +} +function BitwiseOrExpression(t, x) { +var n, n2; +n = BitwiseXorExpression(t, x); +while (t.match(BITWISE_OR)) { +n2 = new Node(t); +n2.push(n); +n2.push(BitwiseXorExpression(t, x)); +n = n2; +} +return n; +} +function BitwiseXorExpression(t, x) { +var n, n2; +n = BitwiseAndExpression(t, x); +while (t.match(BITWISE_XOR)) { +n2 = new Node(t); +n2.push(n); +n2.push(BitwiseAndExpression(t, x)); +n = n2; +} +return n; +} +function BitwiseAndExpression(t, x) { +var n, n2; +n = EqualityExpression(t, x); +while (t.match(BITWISE_AND)) { +n2 = new Node(t); +n2.push(n); +n2.push(EqualityExpression(t, x)); +n = n2; +} +return n; +} +function EqualityExpression(t, x) { +var n, n2; +n = RelationalExpression(t, x); +while (t.match(EQ) || t.match(NE) || +t.match(STRICT_EQ) || t.match(STRICT_NE)) { +n2 = new Node(t); +n2.push(n); +n2.push(RelationalExpression(t, x)); +n = n2; +} +return n; +} +function RelationalExpression(t, x) { +var n, n2; +var x2 = x.update({ inForLoopInit: false }); +n = ShiftExpression(t, x2); +while ((t.match(LT) || t.match(LE) || t.match(GE) || t.match(GT) || +(!x.inForLoopInit && t.match(IN)) || +t.match(INSTANCEOF))) { +n2 = new Node(t); +n2.push(n); +n2.push(ShiftExpression(t, x2)); +n = n2; +} +return n; +} +function ShiftExpression(t, x) { +var n, n2; +n = AddExpression(t, x); +while (t.match(LSH) || t.match(RSH) || t.match(URSH)) { +n2 = new Node(t); +n2.push(n); +n2.push(AddExpression(t, x)); +n = n2; +} +return n; +} +function AddExpression(t, x) { +var n, n2; +n = MultiplyExpression(t, x); +while (t.match(PLUS) || t.match(MINUS)) { +n2 = new Node(t); +n2.push(n); +n2.push(MultiplyExpression(t, x)); +n = n2; +} +return n; +} +function MultiplyExpression(t, x) { +var n, n2; +n = UnaryExpression(t, x); +while (t.match(MUL) || t.match(DIV) || t.match(MOD)) { +n2 = new Node(t); +n2.push(n); +n2.push(UnaryExpression(t, x)); +n = n2; +} +return n; +} +function UnaryExpression(t, x) { +var n, n2, tt; +switch (tt = t.get(true)) { +case DELETE: case VOID: case TYPEOF: +case NOT: case BITWISE_NOT: case PLUS: case MINUS: +if (tt === PLUS) +n = new Node(t, { type: UNARY_PLUS }); +else if (tt === MINUS) +n = new Node(t, { type: UNARY_MINUS }); +else +n = new Node(t); +n.push(UnaryExpression(t, x)); +break; +case INCREMENT: +case DECREMENT: +n = new Node(t); +n.push(MemberExpression(t, x, true)); +break; +default: +t.unget(); +n = MemberExpression(t, x, true); +if (t.tokens[(t.tokenIndex + t.lookahead - 1) & 3].lineno === +t.lineno) { +if (t.match(INCREMENT) || t.match(DECREMENT)) { +n2 = new Node(t, { postfix: true }); +n2.push(n); +n = n2; +} +} +break; +} +return n; +} +function MemberExpression(t, x, allowCallSyntax) { +var n, n2, name, tt; +if (t.match(NEW)) { +n = new Node(t); +n.push(MemberExpression(t, x, false)); +if (t.match(LEFT_PAREN)) { +n.type = NEW_WITH_ARGS; +n.push(ArgumentList(t, x)); +} +} else { +n = PrimaryExpression(t, x); +} +while ((tt = t.get()) !== END) { +switch (tt) { +case DOT: +n2 = new Node(t); +n2.push(n); +t.mustMatch(IDENTIFIER); +n2.push(new Node(t)); +break; +case LEFT_BRACKET: +n2 = new Node(t, { type: INDEX }); +n2.push(n); +n2.push(Expression(t, x)); +t.mustMatch(RIGHT_BRACKET); +break; +case LEFT_PAREN: +if (allowCallSyntax) { +n2 = new Node(t, { type: CALL }); +n2.push(n); +n2.push(ArgumentList(t, x)); +break; +} +default: +t.unget(); +return n; +} +n = n2; +} +return n; +} +function ArgumentList(t, x) { +var n, n2; +n = new Node(t, { type: LIST }); +if (t.match(RIGHT_PAREN, true)) +return n; +do { +n2 = AssignExpression(t, x); +if (n2.type === YIELD && !n2.parenthesized && t.peek() === COMMA) +throw t.newSyntaxError("Yield expression must be parenthesized"); +if (t.match(FOR)) { +n2 = GeneratorExpression(t, x, n2); +if (n.children.length > 1 || t.peek(true) === COMMA) +throw t.newSyntaxError("Generator expression must be parenthesized"); +} +n.push(n2); +} while (t.match(COMMA)); +t.mustMatch(RIGHT_PAREN); +return n; +} +function PrimaryExpression(t, x) { +var n, n2, tt = t.get(true); +switch (tt) { +case FUNCTION: +n = FunctionDefinition(t, x, false, EXPRESSED_FORM); +break; +case LEFT_BRACKET: +n = new Node(t, { type: ARRAY_INIT }); +while ((tt = t.peek(true)) !== RIGHT_BRACKET) { +if (tt === COMMA) { +t.get(); +n.push(null); +continue; +} +n.push(AssignExpression(t, x)); +if (tt !== COMMA && !t.match(COMMA)) +break; +} +if (n.children.length === 1 && t.match(FOR)) { +n2 = new Node(t, { type: ARRAY_COMP, +expression: n.children[0], +tail: ComprehensionTail(t, x) }); +n = n2; +} +t.mustMatch(RIGHT_BRACKET); +break; +case LEFT_CURLY: +var id, fd; +n = new Node(t, { type: OBJECT_INIT }); +object_init: +if (!t.match(RIGHT_CURLY)) { +do { +tt = t.get(); +if ((t.token.value === "get" || t.token.value === "set") && +t.peek() === IDENTIFIER) { +if (x.ecma3OnlyMode) +throw t.newSyntaxError("Illegal property accessor"); +n.push(FunctionDefinition(t, x, true, EXPRESSED_FORM)); +} else { +switch (tt) { +case IDENTIFIER: case NUMBER: case STRING: +id = new Node(t, { type: IDENTIFIER }); +break; +case RIGHT_CURLY: +if (x.ecma3OnlyMode) +throw t.newSyntaxError("Illegal trailing ,"); +break object_init; +default: +if (t.token.value in definitions.keywords) { +id = new Node(t, { type: IDENTIFIER }); +break; +} +throw t.newSyntaxError("Invalid property name"); +} +if (t.match(COLON)) { +n2 = new Node(t, { type: PROPERTY_INIT }); +n2.push(id); +n2.push(AssignExpression(t, x)); +n.push(n2); +} else { +if (t.peek() !== COMMA && t.peek() !== RIGHT_CURLY) +throw t.newSyntaxError("missing : after property"); +n.push(id); +} +} +} while (t.match(COMMA)); +t.mustMatch(RIGHT_CURLY); +} +break; +case LEFT_PAREN: +n = ParenExpression(t, x); +t.mustMatch(RIGHT_PAREN); +n.parenthesized = true; +break; +case LET: +n = LetBlock(t, x, false); +break; +case NULL: case THIS: case TRUE: case FALSE: +case IDENTIFIER: case NUMBER: case STRING: case REGEXP: +n = new Node(t); +break; +default: +throw t.newSyntaxError("missing operand"); +break; +} +return n; +} +function parse(s, f, l) { +var t = new lexer.Tokenizer(s, f, l); +var n = Script(t, false); +if (!t.done) +throw t.newSyntaxError("Syntax error"); +return n; +} +function parseStdin(s, ln) { +for (;;) { +try { +var t = new lexer.Tokenizer(s, "stdin", ln.value); +var n = Script(t, false); +ln.value = t.lineno; +return n; +} catch (e) { +if (!t.unexpectedEOF) +throw e; +var more = readline(); +if (!more) +throw e; +s += "\n" + more; +} +} +} +return { +parse: parse, +parseStdin: parseStdin, +Node: Node, +DECLARED_FORM: DECLARED_FORM, +EXPRESSED_FORM: EXPRESSED_FORM, +STATEMENT_FORM: STATEMENT_FORM, +Tokenizer: lexer.Tokenizer, +FunctionDefinition: FunctionDefinition +}; +}()); +var exports = { +definitions: Narcissus.definitions, +lexer: Narcissus.lexer, +parser: Narcissus.parser +}; +if (typeof module != 'undefined') { +module.exports = exports; +}; +(function() { +var Node, Typenames, Types, exports, narcissus, parser, tokens, _, +__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, +__slice = Array.prototype.slice; +narcissus = this.Narcissus || require('./narcissus_packed'); +_ = this._ || require('underscore'); +tokens = narcissus.definitions.tokens; +parser = narcissus.parser; +Node = parser.Node; +Node.prototype.left = function() { +return this.children[0]; +}; +Node.prototype.right = function() { +return this.children[1]; +}; +Node.prototype.last = function() { +return this.children[this.children.length - 1]; +}; +Node.prototype.walk = function(options, fn, parent, list) { +if (parent == null) parent = null; +if (list == null) list = null; +if (parent) fn(parent, this, list); +if (options.last) if (this.last() != null) this.last().walk(options, fn, this); +if (this.thenPart != null) this.thenPart.walk(options, fn, this, 'thenPart'); +if (this.elsePart != null) this.elsePart.walk(options, fn, this, 'elsePart'); +if (this.cases) { +return _.each(this.cases, function(item) { +return item.statements.walk(options, fn, item, 'cases'); +}); +} +}; +Node.prototype.clone = function(hash) { +var i; +for (i in this) { +if (i === 'tokenizer' || i === 'length' || i === 'filename') continue; +if (hash[i] == null) hash[i] = this[i]; +} +return new Node(this.tokenizer, hash); +}; +Node.prototype.toHash = function(done) { +var hash, i, toHash; +if (done == null) done = []; +hash = {}; +toHash = function(what) { +if (!what) return null; +if (what.toHash) { +if (__indexOf.call(done, what) >= 0) { +return "--recursive " + what.id + "--"; +} +what.id = done.push(what); +return what.toHash(done); +} else { +return what; +} +}; +hash.type = this.typeName(); +hash.src = this.src(); +for (i in this) { +if (i === 'filename' || i === 'length' || i === 'type' || i === 'start' || i === 'end' || i === 'tokenizer') { +continue; +} +if (typeof this[i] === 'function') continue; +if (!this[i]) continue; +if (this[i].constructor === Array) { +hash[i] = _.map(this[i], function(item) { +return toHash(item); +}); +} else { +hash[i] = toHash(this[i]); +} +} +return hash; +}; +Node.prototype.inspect = function() { +return JSON.stringify(this.toHash(), null, ' '); +}; +Node.prototype.src = function() { +return this.tokenizer.source.substr(this.start, this.end - this.start); +}; +Node.prototype.typeName = function() { +return Types[this.type]; +}; +Node.prototype.isA = function() { +var what, _ref; +what = 1 <= arguments.length ? __slice.call(arguments, 0) : []; +return _ref = Types[this.type], __indexOf.call(what, _ref) >= 0; +}; +Types = (function() { +var dict, i, last; +dict = {}; +last = 0; +for (i in tokens) { +if (typeof tokens[i] === 'number') { +dict[tokens[i]] = i.toLowerCase(); +last = tokens[i]; +} +} +dict[++last] = 'call_statement'; +dict[++last] = 'existence_check'; +return dict; +})(); +Typenames = (function() { +var dict, i; +dict = {}; +for (i in Types) { +dict[Types[i]] = i; +} +return dict; +})(); +this.NodeExt = exports = { +Types: Types, +Typenames: Typenames, +Node: Node +}; +if (typeof module !== "undefined" && module !== null) module.exports = exports; +}).call(this); +(function() { +var Code, CoffeeScript, blockTrim, coffeescript_reserved, exports, indentLines, isSingleLine, ltrim, p, paren, rtrim, strEscape, strRepeat, trim, truthy, unreserve, unshift, word, +__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; +CoffeeScript = this.CoffeeScript || require('coffee-script'); +Code = (function() { +function Code() { +this.code = ''; +} +Code.prototype.add = function(str) { +this.code += str.toString(); +return this; +}; +Code.prototype.scope = function(str, level) { +var indent; +if (level == null) level = 1; +indent = strRepeat(" ", level); +this.code = rtrim(this.code) + "\n"; +this.code += indent + rtrim(str).replace(/\n/g, "\n" + indent) + "\n"; +return this; +}; +Code.prototype.toString = function() { +return this.code; +}; +return Code; +})(); +paren = function(string) { +var str; +str = string.toString(); +if (str.substr(0, 1) === '(' && str.substr(-1, 1) === ')') { +return str; +} else { +return "(" + str + ")"; +} +}; +strRepeat = function(str, times) { +var i; +return ((function() { +var _results; +_results = []; +for (i = 0; 0 <= times ? i < times : i > times; 0 <= times ? i++ : i--) { +_results.push(str); +} +return _results; +})()).join(''); +}; +ltrim = function(str) { +return ("" + str).replace(/^\s*/g, ''); +}; +rtrim = function(str) { +return ("" + str).replace(/\s*$/g, ''); +}; +blockTrim = function(str) { +return ("" + str).replace(/^\s*\n|\s*$/g, ''); +}; +trim = function(str) { +return ("" + str).replace(/^\s*|\s*$/g, ''); +}; +isSingleLine = function(str) { +return trim(str).indexOf("\n") === -1; +}; +unshift = function(str) { +var m1, m2; +str = "" + str; +while (true) { +m1 = str.match(/^/gm); +m2 = str.match(/^ /gm); +if (!m1 || !m2 || m1.length !== m2.length) return str; +str = str.replace(/^ /gm, ''); +} +}; +truthy = function(n) { +return n.isA('true') || (n.isA('number') && parseFloat(n.src()) !== 0.0); +}; +strEscape = function(str) { +return JSON.stringify("" + str); +}; +p = function(str) { +if (str.constructor === String) { +console.log(JSON.stringify(str)); +} else { +console.log(str); +} +return ''; +}; +coffeescript_reserved = (function() { +var _i, _len, _ref, _results; +_ref = CoffeeScript.RESERVED; +_results = []; +for (_i = 0, _len = _ref.length; _i < _len; _i++) { +word = _ref[_i]; +if (word !== 'undefined') _results.push(word); +} +return _results; +})(); +unreserve = function(str) { +var _ref; +if (_ref = "" + str, __indexOf.call(coffeescript_reserved, _ref) >= 0) { +return "" + str + "_"; +} else { +return "" + str; +} +}; +indentLines = function(indent, lines) { +return indent + lines.replace(/\n/g, "\n" + indent); +}; +this.Js2coffeeHelpers = exports = { +Code: Code, +p: p, +strEscape: strEscape, +unreserve: unreserve, +unshift: unshift, +isSingleLine: isSingleLine, +trim: trim, +blockTrim: blockTrim, +ltrim: ltrim, +rtrim: rtrim, +strRepeat: strRepeat, +paren: paren, +truthy: truthy, +indentLines: indentLines +}; +if (typeof module !== "undefined" && module !== null) module.exports = exports; +}).call(this); +(function() { +var Builder, Code, Node, Transformer, Typenames, Types, UnsupportedError, blockTrim, buildCoffee, exports, indentLines, isSingleLine, ltrim, p, paren, parser, rtrim, strEscape, strRepeat, trim, truthy, unreserve, unshift, _, _ref, _ref2, +__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, +__slice = Array.prototype.slice, +__hasProp = Object.prototype.hasOwnProperty; +parser = (this.Narcissus || require('./narcissus_packed')).parser; +_ = this._ || require('underscore'); +_ref = this.NodeExt || require('./node_ext'), Types = _ref.Types, Typenames = _ref.Typenames, Node = _ref.Node; +_ref2 = this.Js2coffeeHelpers || require('./helpers'), Code = _ref2.Code, p = _ref2.p, strEscape = _ref2.strEscape, unreserve = _ref2.unreserve, unshift = _ref2.unshift, isSingleLine = _ref2.isSingleLine, trim = _ref2.trim, blockTrim = _ref2.blockTrim, ltrim = _ref2.ltrim, rtrim = _ref2.rtrim, strRepeat = _ref2.strRepeat, paren = _ref2.paren, truthy = _ref2.truthy, indentLines = _ref2.indentLines; +buildCoffee = function(str, opts) { +var builder, comments, indent, keepLineNumbers, l, line, minline, output, precomments, res, scriptNode, srclines, text, _i, _len, _ref3; +if (opts == null) opts = {}; +str = str.replace(/\r/g, ''); +str += "\n"; +builder = new Builder(opts); +scriptNode = parser.parse(str); +output = trim(builder.build(scriptNode)); +if (opts.no_comments) { +return ((function() { +var _i, _len, _ref3, _results; +_ref3 = output.split('\n'); +_results = []; +for (_i = 0, _len = _ref3.length; _i < _len; _i++) { +line = _ref3[_i]; +_results.push(rtrim(line)); +} +return _results; +})()).join('\n'); +} else { +keepLineNumbers = opts.show_src_lineno; +res = []; +_ref3 = output.split("\n"); +for (_i = 0, _len = _ref3.length; _i < _len; _i++) { +l = _ref3[_i]; +srclines = []; +text = l.replace(/\uFEFE([0-9]+).*?\uFEFE/g, function(m, g) { +srclines.push(parseInt(g)); +return ""; +}); +srclines = _.sortBy(_.uniq(srclines), function(i) { +return i; +}); +text = rtrim(text); +indent = text.match(/^\s*/); +if (srclines.length > 0) { +minline = _.last(srclines); +precomments = builder.commentsNotDoneTo(minline); +if (precomments) res.push(indentLines(indent, precomments)); +} +if (text) { +if (keepLineNumbers) text = text + "#" + srclines.join(",") + "# "; +res.push(rtrim(text + " " + ltrim(builder.lineComments(srclines)))); +} else { +res.push(""); +} +} +comments = builder.commentsNotDoneTo(1e10); +if (comments) res.push(comments); +return res.join("\n"); +} +}; +Builder = (function() { +function Builder(options) { +this.options = options != null ? options : {}; +this.transformer = new Transformer; +} +Builder.prototype.l = function(n) { +if (this.options.no_comments) return ''; +if (n && n.lineno) { +return "\uFEFE" + n.lineno + "\uFEFE"; +} else { +return ""; +} +}; +Builder.prototype.makeComment = function(comment) { +var c, line; +if (comment.type === "BLOCK_COMMENT") { +c = comment.value.split("\n"); +if (c.length > 0 && c[0].length > 0 && c[0][0] === "*") { +c = (function() { +var _i, _len, _results; +_results = []; +for (_i = 0, _len = c.length; _i < _len; _i++) { +line = c[_i]; +_results.push(line.replace(/^[\s\*]*/, '')); +} +return _results; +})(); +c = (function() { +var _i, _len, _results; +_results = []; +for (_i = 0, _len = c.length; _i < _len; _i++) { +line = c[_i]; +_results.push(line.replace(/[\s]*$/, '')); +} +return _results; +})(); +while (c.length > 0 && c[0].length === 0) { +c.shift(); +} +while (c.length > 0 && c[c.length - 1].length === 0) { +c.pop(); +} +c.unshift('###'); +c.push('###'); +} else { +c = (function() { +var _i, _len, _results; +_results = []; +for (_i = 0, _len = c.length; _i < _len; _i++) { +line = c[_i]; +_results.push("#" + line); +} +return _results; +})(); +} +} else { +c = ['#' + comment.value]; +} +if (comment.nlcount > 0) c.unshift(''); +return c.join('\n'); +}; +Builder.prototype.commentsNotDoneTo = function(lineno) { +var c, res; +res = []; +while (true) { +if (this.comments.length === 0) break; +c = this.comments[0]; +if (c.lineno < lineno) { +res.push(this.makeComment(c)); +this.comments.shift(); +continue; +} +break; +} +return res.join("\n"); +}; +Builder.prototype.lineComments = function(linenos) { +var c, selection; +selection = (function() { +var _i, _len, _ref3, _ref4, _results; +_ref3 = this.comments; +_results = []; +for (_i = 0, _len = _ref3.length; _i < _len; _i++) { +c = _ref3[_i]; +if (_ref4 = c.lineno, __indexOf.call(linenos, _ref4) >= 0) { +_results.push(c); +} +} +return _results; +}).call(this); +this.comments = _.difference(this.comments, selection); +return ((function() { +var _i, _len, _results; +_results = []; +for (_i = 0, _len = selection.length; _i < _len; _i++) { +c = selection[_i]; +_results.push(this.makeComment(c)); +} +return _results; +}).call(this)).join("\n"); +}; +Builder.prototype.build = function() { +var args, fn, name, node, out; +args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; +node = args[0]; +if (!(this.comments != null)) { +this.comments = _.sortBy(node.tokenizer.comments, function(n) { +return n.start; +}); +} +this.transform(node); +name = 'other'; +if (node !== void 0 && node.typeName) name = node.typeName(); +fn = this[name] || this.other; +out = fn.apply(this, args); +if (node.parenthesized) { +return paren(out); +} else { +return out; +} +}; +Builder.prototype.transform = function() { +var args; +args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; +return this.transformer.transform.apply(this.transformer, args); +}; +Builder.prototype.body = function(node, opts) { +var str; +if (opts == null) opts = {}; +str = this.build(node, opts); +str = blockTrim(str); +str = unshift(str); +if (str.length > 0) { +return str; +} else { +return ""; +} +}; +Builder.prototype['script'] = function(n, opts) { +var c, +_this = this; +if (opts == null) opts = {}; +c = new Code; +_.each(n.functions, function(item) { +return c.add(_this.build(item)); +}); +_.each(n.nonfunctions, function(item) { +return c.add(_this.build(item)); +}); +return c.toString(); +}; +Builder.prototype['property_identifier'] = function(n) { +var str; +str = n.value.toString(); +if (str.match(/^([_\$a-z][_\$a-z0-9]*)$/i) || str.match(/^[0-9]+$/i)) { +return this.l(n) + str; +} else { +return this.l(n) + strEscape(str); +} +}; +Builder.prototype['identifier'] = function(n) { +if (n.value === 'undefined') { +return this.l(n) + '`undefined`'; +} else if (n.property_accessor) { +return this.l(n) + n.value.toString(); +} else { +return this.l(n) + unreserve(n.value.toString()); +} +}; +Builder.prototype['number'] = function(n) { +return this.l(n) + ("" + (n.src())); +}; +Builder.prototype['id'] = function(n) { +if (n.property_accessor) { +return this.l(n) + n; +} else { +return this.l(n) + unreserve(n); +} +}; +Builder.prototype['id_param'] = function(n) { +var _ref3; +if ((_ref3 = n.toString()) === 'undefined') { +return this.l(n) + ("" + n + "_"); +} else { +return this.l(n) + this.id(n); +} +}; +Builder.prototype['return'] = function(n) { +if (!(n.value != null)) { +return this.l(n) + "return\n"; +} else { +return this.l(n) + ("return " + (this.build(n.value)) + "\n"); +} +}; +Builder.prototype[';'] = function(n) { +var src; +if (n.expression == null) { +return ""; +} else if (n.expression.typeName() === 'object_init') { +src = this.object_init(n.expression); +if (n.parenthesized) { +return src; +} else { +return "" + (unshift(blockTrim(src))) + "\n"; +} +} else { +return this.build(n.expression) + "\n"; +} +}; +Builder.prototype['new'] = function(n) { +return this.l(n) + ("new " + (this.build(n.left()))); +}; +Builder.prototype['new_with_args'] = function(n) { +return this.l(n) + ("new " + (this.build(n.left())) + "(" + (this.build(n.right())) + ")"); +}; +Builder.prototype['unary_plus'] = function(n) { +return "+" + (this.build(n.left())); +}; +Builder.prototype['unary_minus'] = function(n) { +return "-" + (this.build(n.left())); +}; +Builder.prototype['this'] = function(n) { +return this.l(n) + 'this'; +}; +Builder.prototype['null'] = function(n) { +return this.l(n) + 'null'; +}; +Builder.prototype['true'] = function(n) { +return this.l(n) + 'true'; +}; +Builder.prototype['false'] = function(n) { +return this.l(n) + 'false'; +}; +Builder.prototype['void'] = function(n) { +return this.l(n) + 'undefined'; +}; +Builder.prototype['debugger'] = function(n) { +return this.l(n) + "debugger\n"; +}; +Builder.prototype['break'] = function(n) { +return this.l(n) + "break\n"; +}; +Builder.prototype['continue'] = function(n) { +return this.l(n) + "continue\n"; +}; +Builder.prototype['~'] = function(n) { +return "~" + (this.build(n.left())); +}; +Builder.prototype['typeof'] = function(n) { +return this.l(n) + ("typeof " + (this.build(n.left()))); +}; +Builder.prototype['index'] = function(n) { +var right; +right = this.build(n.right()); +if (_.any(n.children, function(child) { +return child.typeName() === 'object_init' && child.children.length > 1; +})) { +right = "{" + right + "}"; +} +return this.l(n) + ("" + (this.build(n.left())) + "[" + right + "]"); +}; +Builder.prototype['throw'] = function(n) { +return this.l(n) + ("throw " + (this.build(n.exception))); +}; +Builder.prototype['!'] = function(n) { +var negations, target; +target = n.left(); +negations = 1; +while ((target.isA('!')) && (target = target.left())) { +++negations; +} +if ((negations & 1) && target.isA('==', '!=', '===', '!==', 'in', 'instanceof')) { +target.negated = !target.negated; +return this.build(target); +} +return this.l(n) + ("" + (negations & 1 ? 'not ' : '!!') + (this.build(target))); +}; +Builder.prototype["in"] = function(n) { +return this.binary_operator(n, 'of'); +}; +Builder.prototype['+'] = function(n) { +return this.binary_operator(n, '+'); +}; +Builder.prototype['-'] = function(n) { +return this.binary_operator(n, '-'); +}; +Builder.prototype['*'] = function(n) { +return this.binary_operator(n, '*'); +}; +Builder.prototype['/'] = function(n) { +return this.binary_operator(n, '/'); +}; +Builder.prototype['%'] = function(n) { +return this.binary_operator(n, '%'); +}; +Builder.prototype['>'] = function(n) { +return this.binary_operator(n, '>'); +}; +Builder.prototype['<'] = function(n) { +return this.binary_operator(n, '<'); +}; +Builder.prototype['&'] = function(n) { +return this.binary_operator(n, '&'); +}; +Builder.prototype['|'] = function(n) { +return this.binary_operator(n, '|'); +}; +Builder.prototype['^'] = function(n) { +return this.binary_operator(n, '^'); +}; +Builder.prototype['&&'] = function(n) { +return this.binary_operator(n, 'and'); +}; +Builder.prototype['||'] = function(n) { +return this.binary_operator(n, 'or'); +}; +Builder.prototype['<<'] = function(n) { +return this.binary_operator(n, '<<'); +}; +Builder.prototype['<='] = function(n) { +return this.binary_operator(n, '<='); +}; +Builder.prototype['>>'] = function(n) { +return this.binary_operator(n, '>>'); +}; +Builder.prototype['>='] = function(n) { +return this.binary_operator(n, '>='); +}; +Builder.prototype['==='] = function(n) { +return this.binary_operator(n, 'is'); +}; +Builder.prototype['!=='] = function(n) { +return this.binary_operator(n, 'isnt'); +}; +Builder.prototype['>>>'] = function(n) { +return this.binary_operator(n, '>>>'); +}; +Builder.prototype["instanceof"] = function(n) { +return this.binary_operator(n, 'instanceof'); +}; +Builder.prototype['=='] = function(n) { +return this.binary_operator(n, 'is'); +}; +Builder.prototype['!='] = function(n) { +return this.binary_operator(n, 'isnt'); +}; +Builder.prototype['binary_operator'] = (function() { +var INVERSIONS, k, v; +INVERSIONS = { +is: 'isnt', +"in": 'not in', +of: 'not of', +"instanceof": 'not instanceof' +}; +for (k in INVERSIONS) { +if (!__hasProp.call(INVERSIONS, k)) continue; +v = INVERSIONS[k]; +INVERSIONS[v] = k; +} +return function(n, sign) { +if (n.negated) sign = INVERSIONS[sign]; +return this.l(n) + ("" + (this.build(n.left())) + " " + sign + " " + (this.build(n.right()))); +}; +})(); +Builder.prototype['--'] = function(n) { +return this.increment_decrement(n, '--'); +}; +Builder.prototype['++'] = function(n) { +return this.increment_decrement(n, '++'); +}; +Builder.prototype['increment_decrement'] = function(n, sign) { +if (n.postfix) { +return this.l(n) + ("" + (this.build(n.left())) + sign); +} else { +return this.l(n) + ("" + sign + (this.build(n.left()))); +} +}; +Builder.prototype['='] = function(n) { +var sign; +sign = n.assignOp != null ? Types[n.assignOp] + '=' : '='; +return this.l(n) + ("" + (this.build(n.left())) + " " + sign + " " + (this.build(n.right()))); +}; +Builder.prototype[','] = function(n) { +var list, +_this = this; +list = _.map(n.children, function(item) { +return _this.l(item) + _this.build(item) + "\n"; +}); +return list.join(''); +}; +Builder.prototype['regexp'] = function(n) { +var begins_with, flag, m, value; +m = n.value.toString().match(/^\/(.*)\/([a-z]?)/); +value = m[1]; +flag = m[2]; +begins_with = value[0]; +if (begins_with === ' ' || begins_with === '=') { +if (flag.length > 0) { +return this.l(n) + ("RegExp(" + (strEscape(value)) + ", \"" + flag + "\")"); +} else { +return this.l(n) + ("RegExp(" + (strEscape(value)) + ")"); +} +} else { +return this.l(n) + ("/" + value + "/" + flag); +} +}; +Builder.prototype['string'] = function(n) { +return this.l(n) + strEscape(n.value); +}; +Builder.prototype['call'] = function(n) { +if (n.right().children.length === 0) { +return ("" + (this.build(n.left())) + "()") + this.l(n); +} else { +return ("" + (this.build(n.left())) + "(" + (this.build(n.right())) + ")") + this.l(n); +} +}; +Builder.prototype['call_statement'] = function(n) { +var left; +left = this.build(n.left()); +if (n.left().isA('function')) left = paren(left); +if (n.right().children.length === 0) { +return ("" + left + "()") + this.l(n); +} else { +return ("" + left + " " + (this.build(n.right()))) + this.l(n); +} +}; +Builder.prototype['list'] = function(n) { +var list, +_this = this; +list = _.map(n.children, function(item) { +if (n.children.length > 1) item.is_list_element = true; +return _this.build(item); +}); +return this.l(n) + list.join(", "); +}; +Builder.prototype['delete'] = function(n) { +var ids, +_this = this; +ids = _.map(n.children, function(el) { +return _this.build(el); +}); +ids = ids.join(', '); +return this.l(n) + ("delete " + ids + "\n"); +}; +Builder.prototype['.'] = function(n) { +var left, right, right_obj; +left = this.build(n.left()); +right_obj = n.right(); +right_obj.property_accessor = true; +right = this.build(right_obj); +if (n.isThis && n.isPrototype) { +return this.l(n) + "@::"; +} else if (n.isThis) { +return this.l(n) + ("@" + right); +} else if (n.isPrototype) { +return this.l(n) + ("" + left + "::"); +} else if (n.left().isPrototype) { +return this.l(n) + ("" + left + right); +} else { +return this.l(n) + ("" + left + "." + right); +} +}; +Builder.prototype['try'] = function(n) { +var c, +_this = this; +c = new Code; +c.add('try'); +c.scope(this.body(n.tryBlock)); +_.each(n.catchClauses, function(clause) { +return c.add(_this.build(clause)); +}); +if (n.finallyBlock != null) { +c.add("finally"); +c.scope(this.body(n.finallyBlock)); +} +return this.l(n) + c; +}; +Builder.prototype['catch'] = function(n) { +var body_, c; +body_ = this.body(n.block); +if (trim(body_).length === 0) return ''; +c = new Code; +if (n.varName != null) { +c.add("catch " + n.varName); +} else { +c.add('catch'); +} +c.scope(this.body(n.block)); +return this.l(n) + c; +}; +Builder.prototype['?'] = function(n) { +return this.l(n) + ("(if " + (this.build(n.left())) + " then " + (this.build(n.children[1])) + " else " + (this.build(n.children[2])) + ")"); +}; +Builder.prototype['for'] = function(n) { +var c; +c = new Code; +if (n.setup != null) c.add("" + (this.build(n.setup)) + "\n"); +if (n.condition != null) { +c.add("while " + (this.build(n.condition)) + "\n"); +} else { +c.add("loop"); +} +c.scope(this.body(n.body)); +if (n.update != null) c.scope(this.body(n.update)); +return this.l(n) + c; +}; +Builder.prototype['for_in'] = function(n) { +var c; +c = new Code; +c.add("for " + (this.build(n.iterator)) + " of " + (this.build(n.object))); +c.scope(this.body(n.body)); +return this.l(n) + c; +}; +Builder.prototype['while'] = function(n) { +var body_, c, keyword, statement; +c = new Code; +keyword = n.positive ? "while" : "until"; +body_ = this.body(n.body); +if (truthy(n.condition)) { +statement = "loop"; +} else { +statement = "" + keyword + " " + (this.build(n.condition)); +} +if (isSingleLine(body_) && statement !== "loop") { +c.add("" + (trim(body_)) + " " + statement + "\n"); +} else { +c.add(statement); +c.scope(body_); +} +return this.l(n) + c; +}; +Builder.prototype['do'] = function(n) { +var c; +c = new Code; +c.add("loop"); +c.scope(this.body(n.body)); +if (n.condition != null) { +c.scope("break unless " + (this.build(n.condition))); +} +return this.l(n) + c; +}; +Builder.prototype['if'] = function(n) { +var body_, c, keyword; +c = new Code; +keyword = n.positive ? "if" : "unless"; +body_ = this.body(n.thenPart); +n.condition.parenthesized = false; +if (n.thenPart.isA('block') && n.thenPart.children.length === 0 && !(n.elsePart != null)) { +console.log(n.thenPart); +c.add("" + (this.build(n.condition)) + "\n"); +} else if (isSingleLine(body_) && !(n.elsePart != null)) { +c.add("" + (trim(body_)) + " " + keyword + " " + (this.build(n.condition)) + "\n"); +} else { +c.add("" + keyword + " " + (this.build(n.condition))); +c.scope(this.body(n.thenPart)); +if (n.elsePart != null) { +if (n.elsePart.typeName() === 'if') { +c.add("else " + (this.build(n.elsePart).toString())); +} else { +c.add(this.l(n.elsePart) + "else\n"); +c.scope(this.body(n.elsePart)); +} +} +} +return this.l(n) + c; +}; +Builder.prototype['switch'] = function(n) { +var c, fall_through, +_this = this; +c = new Code; +c.add("switch " + (this.build(n.discriminant)) + "\n"); +fall_through = false; +_.each(n.cases, function(item) { +var first; +if (item.value === 'default') { +c.scope(_this.l(item) + "else"); +} else { +if (fall_through === true) { +c.add(_this.l(item) + (", " + (_this.build(item.caseLabel)) + "\n")); +} else { +c.add(_this.l(item) + (" when " + (_this.build(item.caseLabel)))); +} +} +if (_this.body(item.statements).length === 0) { +fall_through = true; +} else { +fall_through = false; +c.add("\n"); +c.scope(_this.body(item.statements), 2); +} +return first = false; +}); +return this.l(n) + c; +}; +Builder.prototype['existence_check'] = function(n) { +return this.l(n) + ("" + (this.build(n.left())) + "?"); +}; +Builder.prototype['array_init'] = function(n) { +if (n.children.length === 0) { +return this.l(n) + "[]"; +} else { +return this.l(n) + ("[" + (this.list(n)) + "]"); +} +}; +Builder.prototype['property_init'] = function(n) { +var left, right; +left = n.left(); +right = n.right(); +right.is_property_value = true; +return "" + (this.property_identifier(left)) + ": " + (this.build(right)); +}; +Builder.prototype['object_init'] = function(n, options) { +var c, list, +_this = this; +if (options == null) options = {}; +if (n.children.length === 0) { +return this.l(n) + "{}"; +} else if (n.children.length === 1 && !(n.is_property_value || n.is_list_element)) { +return this.build(n.children[0]); +} else { +list = _.map(n.children, function(item) { +return _this.build(item); +}); +c = new Code(this, n); +c.scope(list.join("\n")); +if (options.brackets != null) c = "{" + c + "}"; +return c; +} +}; +Builder.prototype['function'] = function(n) { +var body, c, params, +_this = this; +c = new Code; +params = _.map(n.params, function(str) { +if (str.constructor === String) { +return _this.id_param(str); +} else { +return _this.build(str); +} +}); +if (n.name) c.add("" + n.name + " = "); +if (n.params.length > 0) { +c.add("(" + (params.join(', ')) + ") ->"); +} else { +c.add("->"); +} +body = this.body(n.body); +if (trim(body).length > 0) { +c.scope(body); +} else { +c.add("\n"); +} +return this.l(n) + c; +}; +Builder.prototype['var'] = function(n) { +var list, +_this = this; +list = _.map(n.children, function(item) { +return "" + (unreserve(item.value)) + " = " + (item.initializer != null ? _this.build(item.initializer) : 'undefined'); +}); +return this.l(n) + _.compact(list).join("\n") + "\n"; +}; +Builder.prototype['other'] = function(n) { +return this.unsupported(n, "" + (n.typeName()) + " is not supported yet"); +}; +Builder.prototype['getter'] = function(n) { +return this.unsupported(n, "getter syntax is not supported; use __defineGetter__"); +}; +Builder.prototype['setter'] = function(n) { +return this.unsupported(n, "setter syntax is not supported; use __defineSetter__"); +}; +Builder.prototype['label'] = function(n) { +return this.unsupported(n, "labels are not supported by CoffeeScript"); +}; +Builder.prototype['const'] = function(n) { +return this.unsupported(n, "consts are not supported by CoffeeScript"); +}; +Builder.prototype['block'] = function() { +var args; +args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; +return this.script.apply(this, args); +}; +Builder.prototype['unsupported'] = function(node, message) { +throw new UnsupportedError("Unsupported: " + message, node); +}; +return Builder; +})(); +Transformer = (function() { +function Transformer() {} +Transformer.prototype.transform = function() { +var args, fn, node, type; +args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; +node = args[0]; +if (node.transformed != null) return; +type = node.typeName(); +fn = this[type]; +if (fn) { +fn.apply(this, args); +return node.transformed = true; +} +}; +Transformer.prototype['script'] = function(n) { +var last, +_this = this; +n.functions = []; +n.nonfunctions = []; +_.each(n.children, function(item) { +if (item.isA('function')) { +return n.functions.push(item); +} else { +return n.nonfunctions.push(item); +} +}); +last = null; +return _.each(n.nonfunctions, function(item) { +var expr; +if (item.expression != null) { +expr = item.expression; +if ((last != null ? last.isA('object_init') : void 0) && expr.isA('object_init')) { +item.parenthesized = true; +} else { +item.parenthesized = false; +} +return last = expr; +} +}); +}; +Transformer.prototype['.'] = function(n) { +n.isThis = n.left().isA('this'); +return n.isPrototype = n.right().isA('identifier') && n.right().value === 'prototype'; +}; +Transformer.prototype[';'] = function(n) { +if (n.expression != null) { +n.expression.parenthesized = false; +if (n.expression.isA('call')) { +n.expression.type = Typenames['call_statement']; +return this.call_statement(n); +} +} +}; +Transformer.prototype['function'] = function(n) { +return n.body.walk({ +last: true +}, function(parent, node, list) { +var lastNode; +if (node.isA('return') && node.value) { +lastNode = list ? parent[list] : parent.children[parent.children.length - 1]; +if (lastNode) { +lastNode.type = Typenames[';']; +return lastNode.expression = lastNode.value; +} +} +}); +}; +Transformer.prototype['switch'] = function(n) { +var _this = this; +return _.each(n.cases, function(item) { +var block, ch, _ref3; +block = item.statements; +ch = block.children; +if ((_ref3 = block.last()) != null ? _ref3.isA('break') : void 0) { +return delete ch[ch.length - 1]; +} +}); +}; +Transformer.prototype['call_statement'] = function(n) { +if (n.children[1]) { +return _.each(n.children[1].children, function(child, i) { +if (child.isA('function') && i !== n.children[1].children.length - 1) { +return child.parenthesized = true; +} +}); +} +}; +Transformer.prototype['return'] = function(n) { +if (n.value && n.value.isA('object_init') && n.value.children.length > 1) { +return n.value.parenthesized = true; +} +}; +Transformer.prototype['block'] = function(n) { +return this.script(n); +}; +Transformer.prototype['if'] = function(n) { +var _ref3; +if (n.thenPart.children.length === 0 && ((_ref3 = n.elsePart) != null ? _ref3.children.length : void 0) > 0) { +n.positive = false; +n.thenPart = n.elsePart; +delete n.elsePart; +} +return this.inversible(n); +}; +Transformer.prototype['while'] = function(n) { +if (n.body.children.length === 0) { +n.body.children.push(n.clone({ +type: Typenames['continue'], +value: 'continue', +children: [] +})); +} +return this.inversible(n); +}; +Transformer.prototype['inversible'] = function(n) { +var positive; +this.transform(n.condition); +positive = n.positive != null ? n.positive : true; +if (n.condition.isA('!=')) { +n.condition.type = Typenames['==']; +return n.positive = !positive; +} else if (n.condition.isA('!')) { +n.condition = n.condition.left(); +return n.positive = !positive; +} else { +return n.positive = positive; +} +}; +Transformer.prototype['=='] = function(n) { +if (n.right().isA('null', 'void')) { +n.type = Typenames['!']; +return n.children = [ +n.clone({ +type: Typenames['existence_check'], +children: [n.left()] +}) +]; +} +}; +Transformer.prototype['!='] = function(n) { +if (n.right().isA('null', 'void')) { +n.type = Typenames['existence_check']; +return n.children = [n.left()]; +} +}; +return Transformer; +})(); +UnsupportedError = (function() { +function UnsupportedError(str, src) { +this.message = str; +this.cursor = src.start; +this.line = src.lineno; +this.source = src.tokenizer.source; +} +UnsupportedError.prototype.toString = function() { +return this.message; +}; +return UnsupportedError; +})(); +this.Js2coffee = exports = { +VERSION: '0.2.0', +build: buildCoffee, +UnsupportedError: UnsupportedError +}; +if (typeof module !== "undefined" && module !== null) module.exports = exports; +}).call(this); \ No newline at end of file diff --git a/bower_components/messenger/docs/welcome/lib/executr/lib/underscore.min.js b/bower_components/messenger/docs/welcome/lib/executr/lib/underscore.min.js new file mode 100644 index 0000000..459f691 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/lib/underscore.min.js @@ -0,0 +1,32 @@ +// Underscore.js 1.3.3 +// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. +// Underscore is freely distributable under the MIT license. +// Portions of Underscore are inspired or borrowed from Prototype, +// Oliver Steele's Functional, and John Resig's Micro-Templating. +// For all details and documentation: +// http://documentcloud.github.com/underscore +(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== +c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break; +g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a, +c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a==null&&(a=[]);if(A&& +a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a, +c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b, +a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= +function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]}; +j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a= +i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&& +c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty= +function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"}; +b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a, +b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId= +function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape|| +u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c}; +b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d, +this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); \ No newline at end of file diff --git a/bower_components/messenger/docs/welcome/lib/executr/src/coffee/executr.coffee b/bower_components/messenger/docs/welcome/lib/executr/src/coffee/executr.coffee new file mode 100644 index 0000000..dbdbfc5 --- /dev/null +++ b/bower_components/messenger/docs/welcome/lib/executr/src/coffee/executr.coffee @@ -0,0 +1,207 @@ +runners = + 'javascript': (opts, code) -> + eval code + +converters = + 'coffeescript:javascript': (opts, code) -> + csOptions = $.extend {}, opts.coffeeOptions, + bare: true + + CoffeeScript.compile code, csOptions + + + 'javascript:coffeescript': (opts, code) -> + if Js2coffee + out = Js2coffee.build code + else + #fallback if you dont include Js2Coffee + console.error "Can't convert javascript to coffeescript" + return code + +normalizeType = (codeType) -> + switch codeType.toLowerCase() + when 'js', 'javascript', 'text/javascript', 'application/javascript' + return 'javascript' + when 'cs', 'coffee', 'coffeescript', 'text/coffeescript', 'application/coffeescript' + return 'coffeescript' + else + console.error "Code type #{ codeType } not understood." + +class Editor + constructor: (args) -> + @el = args.el + @opts = args.opts + @codeCache = {} + + @$el = $ @el + + do @buildEditor + do @addRunButton + do @addListeners + + getValue: -> + @editor.getValue() + + addListeners: -> + @$el.on 'executrSwitchType', (e, type) => + @switchType type + + addRunButton: -> + @$runButton = $(' + + + + + + + + diff --git a/bower_components/raven-js/example/scratch.js b/bower_components/raven-js/example/scratch.js new file mode 100644 index 0000000..cf1f909 --- /dev/null +++ b/bower_components/raven-js/example/scratch.js @@ -0,0 +1,38 @@ +function foo() { + console.log("lol, i don't do anything") +} + +function foo2() { + foo() + console.log('i called foo') +} + +function broken() { + try { + /*fkjdsahfdhskfhdsahfudshafuoidashfudsa*/ fdasfds[0]; // i throw an error h sadhf hadsfdsakf kl;dsjaklf jdklsajfk ljds;klafldsl fkhdas;hf hdsaf hdsalfhjldksahfljkdsahfjkl dhsajkfl hdklsahflkjdsahkfj hdsjakhf dkashfl diusafh kdsjahfkldsahf jkdashfj khdasjkfhdjksahflkjdhsakfhjdksahfjkdhsakf hdajskhf kjdash kjfads fjkadsh jkfdsa jkfdas jkfdjkas hfjkdsajlk fdsajk fjkdsa fjdsa fdkjlsa fjkdaslk hfjlkdsah fhdsahfui + }catch(e) { + Raven.captureException(e); + } +} + +function ready() { + document.getElementById('test').onclick = broken; +} + +function foo3() { + document.getElementById('crap').value = 'barfdasjkfhoadshflkaosfjadiosfhdaskjfasfadsfads'; +} + +function somethingelse() { + document.getElementById('somethingelse').value = 'this is some realy really long message just so our minification is largeeeeeeeeee!'; +} + +function derp() { + fdas[0]; +} + +function testOptions() { + Raven.context({tags: {foo: 'bar'}}, function() { + throw new Error('foo'); + }); +} diff --git a/bower_components/raven-js/package.json b/bower_components/raven-js/package.json new file mode 100644 index 0000000..1621ef3 --- /dev/null +++ b/bower_components/raven-js/package.json @@ -0,0 +1,29 @@ +{ + "name": "raven", + "version": "1.1.11", + "scripts": { + "test": "./node_modules/.bin/grunt test" + }, + "repository": { + "type": "git", + "url": "git://github.com/getsentry/raven-js.git" + }, + "devDependencies": { + "chai": "~1.8.1", + "grunt": "~0.4.1", + "grunt-cli": "~0.1.9", + "grunt-contrib-jshint": "~0.6.3", + "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-clean": "~0.4.0", + "grunt-mocha": "~0.4.1", + "grunt-release": "~0.6.0", + "grunt-s3": "~0.2.0-alpha.3", + "grunt-gitinfo": "~0.1.1", + "grunt-contrib-connect": "~0.5.0", + "grunt-contrib-copy": "~0.4.1", + "sinon": "~1.7.3", + "lodash": "~2.4.0" + }, + "private": true +} diff --git a/bower_components/raven-js/plugins/console.js b/bower_components/raven-js/plugins/console.js new file mode 100644 index 0000000..4623a5f --- /dev/null +++ b/bower_components/raven-js/plugins/console.js @@ -0,0 +1,36 @@ +/** + * console plugin + * + * Monkey patches console.* calls into Sentry messages with + * their appropriate log levels. (Experimental) + */ +;(function(window, Raven, console) { +'use strict'; + +var originalConsole = console, + logLevels = ['debug', 'info', 'warn', 'error'], + level; + +var logForGivenLevel = function(level) { + var originalConsoleLevel = console[level]; + return function () { + var args = [].slice.call(arguments); + Raven.captureMessage('' + args, {level: level, logger: 'console'}); + + // this fails for some browsers. :( + if (originalConsoleLevel) { + originalConsoleLevel.apply(originalConsole, args); + } + }; +}; + + +level = logLevels.pop(); +while(level) { + console[level] = logForGivenLevel(level); + level = logLevels.pop(); +} +// export +window.console = console; + +}(this, Raven, console || {})); diff --git a/bower_components/raven-js/plugins/jquery.js b/bower_components/raven-js/plugins/jquery.js new file mode 100644 index 0000000..2718507 --- /dev/null +++ b/bower_components/raven-js/plugins/jquery.js @@ -0,0 +1,75 @@ +/** + * jQuery plugin + * + * Patches event handler callbacks and ajax callbacks. + */ +;(function(window, Raven, $) { +'use strict'; + +// quit if jQuery isn't on the page +if (!$) { + return; +} + +var _oldEventAdd = $.event.add; +$.event.add = function ravenEventAdd(elem, types, handler, data, selector) { + var _handler; + + if (handler && handler.handler) { + _handler = handler.handler; + handler.handler = Raven.wrap(handler.handler); + } else { + _handler = handler; + handler = Raven.wrap(handler); + } + + // If the handler we are attaching doesn’t have the same guid as + // the original, it will never be removed when someone tries to + // unbind the original function later. Technically as a result of + // this our guids are no longer globally unique, but whatever, that + // never hurt anybody RIGHT?! + if (_handler.guid) { + handler.guid = _handler.guid; + } else { + handler.guid = _handler.guid = $.guid++; + } + + return _oldEventAdd.call(this, elem, types, handler, data, selector); +}; + +var _oldReady = $.fn.ready; +$.fn.ready = function ravenjQueryReadyWrapper(fn) { + return _oldReady.call(this, Raven.wrap(fn)); +}; + +var _oldAjax = $.ajax; +$.ajax = function ravenAjaxWrapper(url, options) { + var keys = ['complete', 'error', 'success'], key; + + // Taken from https://github.com/jquery/jquery/blob/eee2eaf1d7a189d99106423a4206c224ebd5b848/src/ajax.js#L311-L318 + // If url is an object, simulate pre-1.5 signature + if (typeof url === 'object') { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + /*jshint -W084*/ + while(key = keys.pop()) { + if ($.isFunction(options[key])) { + options[key] = Raven.wrap(options[key]); + } + } + /*jshint +W084*/ + + try { + return _oldAjax.call(this, url, options); + } catch (e) { + Raven.captureException(e); + throw e; + } +}; + +}(this, Raven, window.jQuery)); diff --git a/bower_components/raven-js/plugins/native.js b/bower_components/raven-js/plugins/native.js new file mode 100644 index 0000000..c4cb2d3 --- /dev/null +++ b/bower_components/raven-js/plugins/native.js @@ -0,0 +1,33 @@ +/** + * native plugin + * + * Extends support for global error handling for asynchronous browser + * functions. Adopted from Closure Library's errorhandler.js + */ +;(function extendToAsynchronousCallbacks(window, Raven) { +"use strict"; + +var _helper = function _helper(fnName) { + var originalFn = window[fnName]; + window[fnName] = function ravenAsyncExtension() { + // Make a copy of the arguments + var args = [].slice.call(arguments); + var originalCallback = args[0]; + if (typeof (originalCallback) === 'function') { + args[0] = Raven.wrap(originalCallback); + } + // IE < 9 doesn't support .call/.apply on setInterval/etTimeout, but it + // also only supports 2 argument and doesn't care what this" is, so we + // can just call the original function directly. + if (originalFn.apply) { + return originalFn.apply(this, args); + } else { + return originalFn(args[0], args[1]); + } + }; +}; + +_helper('setTimeout'); +_helper('setInterval'); + +}(this, Raven)); diff --git a/bower_components/raven-js/plugins/require.js b/bower_components/raven-js/plugins/require.js new file mode 100644 index 0000000..197314e --- /dev/null +++ b/bower_components/raven-js/plugins/require.js @@ -0,0 +1,13 @@ +/** + * require.js plugin + * + * Automatically wrap define/require callbacks. (Experimental) + */ +;(function(window, Raven) { + "use strict"; + + if (typeof define === 'function' && define.amd) { + window.define = Raven.wrap(define); + window.require = Raven.wrap(require); + } +}(this, Raven)); diff --git a/bower_components/raven-js/src/raven.js b/bower_components/raven-js/src/raven.js new file mode 100644 index 0000000..1883093 --- /dev/null +++ b/bower_components/raven-js/src/raven.js @@ -0,0 +1,699 @@ +'use strict'; + +// First, check for JSON support +// If there is no JSON, we no-op the core features of Raven +// since JSON is required to encode the payload +var _Raven = window.Raven, + hasJSON = !!(window.JSON && window.JSON.stringify), + lastCapturedException, + lastEventId, + globalServer, + globalUser, + globalKey, + globalProject, + globalOptions = { + logger: 'javascript', + ignoreErrors: [], + ignoreUrls: [], + whitelistUrls: [], + includePaths: [], + collectWindowErrors: true, + tags: {}, + extra: {} + }; + +/* + * The core Raven singleton + * + * @this {Raven} + */ +var Raven = { + VERSION: '<%= pkg.version %>', + + // Expose TraceKit to the Raven namespace + TraceKit: TraceKit, + + /* + * Allow Raven to be configured as soon as it is loaded + * It uses a global RavenConfig = {dsn: '...', config: {}} + * + * @return undefined + */ + afterLoad: function() { + var globalConfig = window.RavenConfig; + if (globalConfig) { + this.config(globalConfig.dsn, globalConfig.config).install(); + } + }, + + /* + * Allow multiple versions of Raven to be installed. + * Strip Raven from the global context and returns the instance. + * + * @return {Raven} + */ + noConflict: function() { + window.Raven = _Raven; + return Raven; + }, + + /* + * Configure Raven with a DSN and extra options + * + * @param {string} dsn The public Sentry DSN + * @param {object} options Optional set of of global options [optional] + * @return {Raven} + */ + config: function(dsn, options) { + if (!dsn) return Raven; + + var uri = parseDSN(dsn), + lastSlash = uri.path.lastIndexOf('/'), + path = uri.path.substr(1, lastSlash); + + // merge in options + if (options) { + each(options, function(key, value){ + globalOptions[key] = value; + }); + } + + // "Script error." is hard coded into browsers for errors that it can't read. + // this is the result of a script being pulled in from an external domain and CORS. + globalOptions.ignoreErrors.push('Script error.'); + globalOptions.ignoreErrors.push('Script error'); + + // join regexp rules into one big rule + globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors); + globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false; + globalOptions.whitelistUrls = globalOptions.whitelistUrls.length ? joinRegExp(globalOptions.whitelistUrls) : false; + globalOptions.includePaths = joinRegExp(globalOptions.includePaths); + + globalKey = uri.user; + globalProject = uri.path.substr(lastSlash + 1); + + // assemble the endpoint from the uri pieces + globalServer = '//' + uri.host + + (uri.port ? ':' + uri.port : '') + + '/' + path + 'api/' + globalProject + '/store/'; + + if (uri.protocol) { + globalServer = uri.protocol + ':' + globalServer; + } + + if (globalOptions.fetchContext) { + TraceKit.remoteFetching = true; + } + + if (globalOptions.linesOfContext) { + TraceKit.linesOfContext = globalOptions.linesOfContext; + } + + TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors; + + // return for chaining + return Raven; + }, + + /* + * Installs a global window.onerror error handler + * to capture and report uncaught exceptions. + * At this point, install() is required to be called due + * to the way TraceKit is set up. + * + * @return {Raven} + */ + install: function() { + if (isSetup()) { + TraceKit.report.subscribe(handleStackInfo); + } + + return Raven; + }, + + /* + * Wrap code within a context so Raven can capture errors + * reliably across domains that is executed immediately. + * + * @param {object} options A specific set of options for this context [optional] + * @param {function} func The callback to be immediately executed within the context + * @param {array} args An array of arguments to be called with the callback [optional] + */ + context: function(options, func, args) { + if (isFunction(options)) { + args = func || []; + func = options; + options = undefined; + } + + return Raven.wrap(options, func).apply(this, args); + }, + + /* + * Wrap code within a context and returns back a new function to be executed + * + * @param {object} options A specific set of options for this context [optional] + * @param {function} func The function to be wrapped in a new context + * @return {function} The newly wrapped functions with a context + */ + wrap: function(options, func) { + // 1 argument has been passed, and it's not a function + // so just return it + if (isUndefined(func) && !isFunction(options)) { + return options; + } + + // options is optional + if (isFunction(options)) { + func = options; + options = undefined; + } + + // At this point, we've passed along 2 arguments, and the second one + // is not a function either, so we'll just return the second argument. + if (!isFunction(func)) { + return func; + } + + // We don't wanna wrap it twice! + if (func.__raven__) { + return func; + } + + function wrapped() { + var args = [], i = arguments.length, + deep = !options || options && options.deep !== false; + // Recursively wrap all of a function's arguments that are + // functions themselves. + + while(i--) args[i] = deep ? Raven.wrap(options, arguments[i]) : arguments[i]; + + try { + /*jshint -W040*/ + return func.apply(this, args); + } catch(e) { + Raven.captureException(e, options); + throw e; + } + } + + // copy over properties of the old function + for (var property in func) { + if (func.hasOwnProperty(property)) { + wrapped[property] = func[property]; + } + } + + // Signal that this function has been wrapped already + // for both debugging and to prevent it to being wrapped twice + wrapped.__raven__ = true; + + return wrapped; + }, + + /* + * Uninstalls the global error handler. + * + * @return {Raven} + */ + uninstall: function() { + TraceKit.report.uninstall(); + + return Raven; + }, + + /* + * Manually capture an exception and send it over to Sentry + * + * @param {error} ex An exception to be logged + * @param {object} options A specific set of options for this error [optional] + * @return {Raven} + */ + captureException: function(ex, options) { + // If a string is passed through, recall as a message + if (isString(ex)) return Raven.captureMessage(ex, options); + + // Store the raw exception object for potential debugging and introspection + lastCapturedException = ex; + + // TraceKit.report will re-raise any exception passed to it, + // which means you have to wrap it in try/catch. Instead, we + // can wrap it here and only re-raise if TraceKit.report + // raises an exception different from the one we asked to + // report on. + try { + TraceKit.report(ex, options); + } catch(ex1) { + if(ex !== ex1) { + throw ex1; + } + } + + return Raven; + }, + + /* + * Manually send a message to Sentry + * + * @param {string} msg A plain message to be captured in Sentry + * @param {object} options A specific set of options for this message [optional] + * @return {Raven} + */ + captureMessage: function(msg, options) { + // Fire away! + send( + objectMerge({ + message: msg + }, options) + ); + + return Raven; + }, + + /* + * Set/clear a user to be sent along with the payload. + * + * @param {object} user An object representing user data [optional] + * @return {Raven} + */ + setUser: function(user) { + globalUser = user; + + return Raven; + }, + + /* + * Get the latest raw exception that was captured by Raven. + * + * @return {error} + */ + lastException: function() { + return lastCapturedException; + }, + + /* + * Get the last event id + * + * @return {string} + */ + lastEventId: function() { + return lastEventId; + } +}; + +function triggerEvent(eventType, options) { + var event, key; + + options = options || {}; + + eventType = 'raven' + eventType.substr(0,1).toUpperCase() + eventType.substr(1); + + if (document.createEvent) { + event = document.createEvent('HTMLEvents'); + event.initEvent(eventType, true, true); + } else { + event = document.createEventObject(); + event.eventType = eventType; + } + + for (key in options) if (options.hasOwnProperty(key)) { + event[key] = options[key]; + } + + if (document.createEvent) { + // IE9 if standards + document.dispatchEvent(event); + } else { + // IE8 regardless of Quirks or Standards + // IE9 if quirks + try { + document.fireEvent('on' + event.eventType.toLowerCase(), event); + } catch(e) {} + } +} + +var dsnKeys = 'source protocol user pass host port path'.split(' '), + dsnPattern = /^(?:(\w+):)?\/\/(\w+)(:\w+)?@([\w\.-]+)(?::(\d+))?(\/.*)/; + +function RavenConfigError(message) { + this.name = 'RavenConfigError'; + this.message = message; +} +RavenConfigError.prototype = new Error(); +RavenConfigError.prototype.constructor = RavenConfigError; + +/**** Private functions ****/ +function parseDSN(str) { + var m = dsnPattern.exec(str), + dsn = {}, + i = 7; + + try { + while (i--) dsn[dsnKeys[i]] = m[i] || ''; + } catch(e) { + throw new RavenConfigError('Invalid DSN: ' + str); + } + + if (dsn.pass) + throw new RavenConfigError('Do not specify your private key in the DSN!'); + + return dsn; +} + +function isUndefined(what) { + return typeof what === 'undefined'; +} + +function isFunction(what) { + return typeof what === 'function'; +} + +function isString(what) { + return typeof what === 'string'; +} + +function isEmptyObject(what) { + for (var k in what) return false; + return true; +} + +/** + * hasKey, a better form of hasOwnProperty + * Example: hasKey(MainHostObject, property) === true/false + * + * @param {Object} host object to check property + * @param {string} key to check + */ +function hasKey(object, key) { + return Object.prototype.hasOwnProperty.call(object, key); +} + +function each(obj, callback) { + var i, j; + + if (isUndefined(obj.length)) { + for (i in obj) { + if (obj.hasOwnProperty(i)) { + callback.call(null, i, obj[i]); + } + } + } else { + j = obj.length; + if (j) { + for (i = 0; i < j; i++) { + callback.call(null, i, obj[i]); + } + } + } +} + +var cachedAuth; + +function getAuthQueryString() { + if (cachedAuth) return cachedAuth; + + var qs = [ + 'sentry_version=4', + 'sentry_client=raven-js/' + Raven.VERSION + ]; + if (globalKey) { + qs.push('sentry_key=' + globalKey); + } + + cachedAuth = '?' + qs.join('&'); + return cachedAuth; +} + +function handleStackInfo(stackInfo, options) { + var frames = []; + + if (stackInfo.stack && stackInfo.stack.length) { + each(stackInfo.stack, function(i, stack) { + var frame = normalizeFrame(stack); + if (frame) { + frames.push(frame); + } + }); + } + + triggerEvent('handle', { + stackInfo: stackInfo, + options: options + }); + + processException( + stackInfo.name, + stackInfo.message, + stackInfo.url, + stackInfo.lineno, + frames, + options + ); +} + +function normalizeFrame(frame) { + if (!frame.url) return; + + // normalize the frames data + var normalized = { + filename: frame.url, + lineno: frame.line, + colno: frame.column, + 'function': frame.func || '?' + }, context = extractContextFromFrame(frame), i; + + if (context) { + var keys = ['pre_context', 'context_line', 'post_context']; + i = 3; + while (i--) normalized[keys[i]] = context[i]; + } + + normalized.in_app = !( // determine if an exception came from outside of our app + // first we check the global includePaths list. + !globalOptions.includePaths.test(normalized.filename) || + // Now we check for fun, if the function name is Raven or TraceKit + /(Raven|TraceKit)\./.test(normalized['function']) || + // finally, we do a last ditch effort and check for raven.min.js + /raven\.(min\.)js$/.test(normalized.filename) + ); + + return normalized; +} + +function extractContextFromFrame(frame) { + // immediately check if we should even attempt to parse a context + if (!frame.context || !globalOptions.fetchContext) return; + + var context = frame.context, + pivot = ~~(context.length / 2), + i = context.length, isMinified = false; + + while (i--) { + // We're making a guess to see if the source is minified or not. + // To do that, we make the assumption if *any* of the lines passed + // in are greater than 300 characters long, we bail. + // Sentry will see that there isn't a context + if (context[i].length > 300) { + isMinified = true; + break; + } + } + + if (isMinified) { + // The source is minified and we don't know which column. Fuck it. + if (isUndefined(frame.column)) return; + + // If the source is minified and has a frame column + // we take a chunk of the offending line to hopefully shed some light + return [ + [], // no pre_context + context[pivot].substr(frame.column, 50), // grab 50 characters, starting at the offending column + [] // no post_context + ]; + } + + return [ + context.slice(0, pivot), // pre_context + context[pivot], // context_line + context.slice(pivot + 1) // post_context + ]; +} + +function processException(type, message, fileurl, lineno, frames, options) { + var stacktrace, label, i; + + // Sometimes an exception is getting logged in Sentry as + // + // This can only mean that the message was falsey since this value + // is hardcoded into Sentry itself. + // At this point, if the message is falsey, we bail since it's useless + if (!message) return; + + if (globalOptions.ignoreErrors.test(message)) return; + + if (frames && frames.length) { + fileurl = frames[0].filename || fileurl; + // Sentry expects frames oldest to newest + // and JS sends them as newest to oldest + frames.reverse(); + stacktrace = {frames: frames}; + } else if (fileurl) { + stacktrace = { + frames: [{ + filename: fileurl, + lineno: lineno + }] + }; + } + + if (globalOptions.ignoreUrls && globalOptions.ignoreUrls.test(fileurl)) return; + if (globalOptions.whitelistUrls && !globalOptions.whitelistUrls.test(fileurl)) return; + + label = lineno ? message + ' at ' + lineno : message; + + // Fire away! + send( + objectMerge({ + // sentry.interfaces.Exception + exception: { + type: type, + value: message + }, + // sentry.interfaces.Stacktrace + stacktrace: stacktrace, + culprit: fileurl, + message: label + }, options) + ); +} + +function objectMerge(obj1, obj2) { + if (!obj2) { + return obj1; + } + each(obj2, function(key, value){ + obj1[key] = value; + }); + return obj1; +} + +function getHttpData() { + var http = { + url: document.location.href, + headers: { + 'User-Agent': navigator.userAgent + } + }; + + if (document.referrer) { + http.headers.Referer = document.referrer; + } + + return http; +} + +function send(data) { + if (!isSetup()) return; + + data = objectMerge({ + project: globalProject, + logger: globalOptions.logger, + site: globalOptions.site, + platform: 'javascript', + // sentry.interfaces.Http + request: getHttpData() + }, data); + + // Merge in the tags and extra separately since objectMerge doesn't handle a deep merge + data.tags = objectMerge(globalOptions.tags, data.tags); + data.extra = objectMerge(globalOptions.extra, data.extra); + + // If there are no tags/extra, strip the key from the payload alltogther. + if (isEmptyObject(data.tags)) delete data.tags; + if (isEmptyObject(data.extra)) delete data.extra; + + if (globalUser) { + // sentry.interfaces.User + data.user = globalUser; + } + + if (isFunction(globalOptions.dataCallback)) { + data = globalOptions.dataCallback(data); + } + + // Check if the request should be filtered or not + if (isFunction(globalOptions.shouldSendCallback) && !globalOptions.shouldSendCallback(data)) { + return; + } + + // Send along an event_id if not explicitly passed. + // This event_id can be used to reference the error within Sentry itself. + // Set lastEventId after we know the error should actually be sent + lastEventId = data.event_id || (data.event_id = generateUUID4()); + + makeRequest(data); +} + + +function makeRequest(data) { + var img = new Image(), + src = globalServer + getAuthQueryString() + '&sentry_data=' + encodeURIComponent(JSON.stringify(data)); + + img.onload = function success() { + triggerEvent('success', { + data: data, + src: src + }); + }; + img.onerror = img.onabort = function failure() { + triggerEvent('failure', { + data: data, + src: src + }); + }; + img.src = src; +} + +function isSetup() { + if (!hasJSON) return false; // needs JSON support + if (!globalServer) { + if (window.console && console.error) { + console.error("Error: Raven has not been configured."); + } + return false; + } + return true; +} + +function joinRegExp(patterns) { + // Combine an array of regular expressions and strings into one large regexp + // Be mad. + var sources = [], + i = 0, len = patterns.length, + pattern; + + for (; i < len; i++) { + pattern = patterns[i]; + if (isString(pattern)) { + // If it's a string, we need to escape it + // Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1")); + } else if (pattern && pattern.source) { + // If it's a regexp already, we want to extract the source + sources.push(pattern.source); + } + // Intentionally skip other cases + } + return new RegExp(sources.join('|'), 'i'); +} + +// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 +function generateUUID4() { + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, + v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); +} + +Raven.afterLoad(); diff --git a/bower_components/raven-js/template/_copyright.js b/bower_components/raven-js/template/_copyright.js new file mode 100644 index 0000000..f1ee870 --- /dev/null +++ b/bower_components/raven-js/template/_copyright.js @@ -0,0 +1,11 @@ +/*! Raven.js <%= pkg.release %> (<%= gitinfo.local.branch.current.shortSHA %>) | github.com/getsentry/raven-js */ + +/* + * Includes TraceKit + * https://github.com/getsentry/TraceKit + * + * Copyright <%= grunt.template.today('yyyy') %> Matt Robenolt and other contributors + * Released under the BSD license + * https://github.com/getsentry/raven-js/blob/master/LICENSE + * + */ diff --git a/bower_components/raven-js/template/_footer.js b/bower_components/raven-js/template/_footer.js new file mode 100644 index 0000000..0a9efcc --- /dev/null +++ b/bower_components/raven-js/template/_footer.js @@ -0,0 +1,9 @@ +// Expose Raven to the world +window.Raven = Raven; + +// AMD +if (typeof define === 'function' && define.amd) { + define('raven', [], function() { return Raven; }); +} + +})(window); diff --git a/bower_components/raven-js/template/_header.js b/bower_components/raven-js/template/_header.js new file mode 100644 index 0000000..27595a6 --- /dev/null +++ b/bower_components/raven-js/template/_header.js @@ -0,0 +1,2 @@ +;(function(window, undefined){ +'use strict'; diff --git a/bower_components/raven-js/test/index.html b/bower_components/raven-js/test/index.html new file mode 100644 index 0000000..b5188ed --- /dev/null +++ b/bower_components/raven-js/test/index.html @@ -0,0 +1,62 @@ + + + + Raven.js Test Suite + + + + +
          + + + + + + + + + + + + + + + + + + + diff --git a/bower_components/raven-js/test/raven.test.js b/bower_components/raven-js/test/raven.test.js new file mode 100644 index 0000000..c9e16b5 --- /dev/null +++ b/bower_components/raven-js/test/raven.test.js @@ -0,0 +1,1365 @@ +function flushRavenState() { + cachedAuth = undefined; + hasJSON = !isUndefined(window.JSON); + lastCapturedException = undefined; + lastEventId = undefined; + globalServer = undefined; + globalUser = undefined; + globalProject = undefined; + globalOptions = { + logger: 'javascript', + ignoreErrors: [], + ignoreUrls: [], + whitelistUrls: [], + includePaths: [], + collectWindowErrors: true, + tags: {}, + extra: {} + }; + Raven.uninstall(); +} + +var imageCache = []; +window.Image = function Image() { + imageCache.push(this); +}; + +// window.console must be stubbed in for browsers that don't have it +if (typeof window.console === 'undefined') { + console = {error: function(){}}; +} + +var SENTRY_DSN = 'http://abc@example.com:80/2'; + +function setupRaven() { + Raven.config(SENTRY_DSN); +} + +// patched to return a predictable result +function generateUUID4() { + return 'abc123'; +} + +describe('TraceKit', function(){ + describe('error notifications', function(){ + var testMessage = "__mocha_ignore__"; + var subscriptionHandler; + // TraceKit waits 2000ms for window.onerror to fire, so give the tests + // some extra time. + this.timeout(3000); + + before(function() { + // Prevent the onerror call that's part of our tests from getting to + // mocha's handler, which would treat it as a test failure. + // + // We set this up here and don't ever restore the old handler, because + // we can't do that without clobbering TraceKit's handler, which can only + // be installed once. + var oldOnError = window.onerror; + window.onerror = function(message) { + if (message == testMessage) { + return true; + } + return oldOnError.apply(this, arguments); + }; + }); + + afterEach(function() { + if (subscriptionHandler) { + TraceKit.report.unsubscribe(subscriptionHandler); + subscriptionHandler = null; + } + }); + + function testErrorNotification(collectWindowErrors, callOnError, numReports, done) { + var extraVal = "foo"; + var numDone = 0; + // TraceKit's collectWindowErrors flag shouldn't affect direct calls + // to TraceKit.report, so we parameterize it for the tests. + TraceKit.collectWindowErrors = collectWindowErrors; + + subscriptionHandler = function(stackInfo, extra) { + assert.equal(extra, extraVal); + numDone++; + if (numDone == numReports) { + done(); + } + } + TraceKit.report.subscribe(subscriptionHandler); + + // TraceKit.report always throws an exception in order to trigger + // window.onerror so it can gather more stack data. Mocha treats + // uncaught exceptions as errors, so we catch it via assert.throws + // here (and manually call window.onerror later if appropriate). + // + // We test multiple reports because TraceKit has special logic for when + // report() is called a second time before either a timeout elapses or + // window.onerror is called (which is why we always call window.onerror + // only once below, after all calls to report()). + for (var i=0; i < numReports; i++) { + var e = new Error('testing'); + assert.throws(function() { + TraceKit.report(e, extraVal); + }, e); + } + // The call to report should work whether or not window.onerror is + // triggered, so we parameterize it for the tests. We only call it + // once, regardless of numReports, because the case we want to test for + // multiple reports is when window.onerror is *not* called between them. + if (callOnError) { + window.onerror(testMessage); + } + } + + Mocha.utils.forEach([false, true], function(collectWindowErrors) { + Mocha.utils.forEach([false, true], function(callOnError) { + Mocha.utils.forEach([1, 2], function(numReports) { + it('it should receive arguments from report() when' + + ' collectWindowErrors is ' + collectWindowErrors + + ' and callOnError is ' + callOnError + + ' and numReports is ' + numReports, function(done) { + testErrorNotification(collectWindowErrors, callOnError, numReports, done); + }); + }); + }); + }); + }); +}); + +describe('globals', function() { + beforeEach(function() { + setupRaven(); + globalOptions.fetchContext = true; + }); + + afterEach(function() { + flushRavenState(); + }); + + describe('getHttpData', function() { + var data = getHttpData(); + + it('should have a url', function() { + assert.equal(data.url, window.location.href); + }); + + it('should have the user-agent header', function() { + assert.equal(data.headers['User-Agent'], navigator.userAgent); + }); + + it('should have referer header when available', function() { + // lol this test is awful + if (window.document.referrer) { + assert.equal(data.headers.Referer, window.document.referrer); + } else { + assert.isUndefined(data.headers.Referer); + } + }); + + }); + + describe('isUndefined', function() { + it('should do as advertised', function() { + assert.isTrue(isUndefined()); + assert.isFalse(isUndefined({})); + assert.isFalse(isUndefined('')); + assert.isTrue(isUndefined(undefined)); + }); + }); + + describe('isFunction', function() { + it('should do as advertised', function() { + assert.isTrue(isFunction(function(){})); + assert.isFalse(isFunction({})); + assert.isFalse(isFunction('')); + assert.isFalse(isFunction(undefined)); + }); + }); + + describe('isString', function() { + it('should do as advertised', function() { + assert.isTrue(isString('')); + assert.isFalse(isString({})); + assert.isFalse(isString(undefined)); + assert.isFalse(isString(function(){})) + }); + }); + + describe('isEmptyObject', function() { + it('should work as advertised', function() { + assert.isTrue(isEmptyObject({})); + assert.isFalse(isEmptyObject({foo: 1})); + }); + }); + + describe('objectMerge', function() { + it('should work as advertised', function() { + assert.deepEqual(objectMerge({}, {}), {}); + assert.deepEqual(objectMerge({a:1}, {b:2}), {a:1, b:2}); + assert.deepEqual(objectMerge({a:1}), {a:1}); + }); + }); + + describe('isSetup', function() { + it('should return false with no JSON support', function() { + globalServer = 'http://localhost/'; + hasJSON = false; + assert.isFalse(isSetup()); + }); + + it('should return false when Raven is not configured and write to console.error', function() { + hasJSON = true; // be explicit + globalServer = undefined; + this.sinon.stub(console, 'error'); + assert.isFalse(isSetup()); + assert.isTrue(console.error.calledOnce); + }); + + it('should return true when everything is all gravy', function() { + hasJSON = true; + assert.isTrue(isSetup()); + }); + }); + + describe('getAuthQueryString', function() { + it('should return a properly formatted string and cache it', function() { + var expected = '?sentry_version=4&sentry_client=raven-js/<%= pkg.version %>&sentry_key=abc'; + assert.strictEqual(getAuthQueryString(), expected); + assert.strictEqual(cachedAuth, expected); + }); + + it('should return cached value when it exists', function() { + cachedAuth = 'lol'; + assert.strictEqual(getAuthQueryString(), 'lol'); + }); + }); + + describe('parseDSN', function() { + it('should do what it advertises', function() { + var pieces = parseDSN('http://abc@example.com:80/2'); + assert.strictEqual(pieces.protocol, 'http'); + assert.strictEqual(pieces.user, 'abc'); + assert.strictEqual(pieces.port, '80'); + assert.strictEqual(pieces.path, '/2'); + assert.strictEqual(pieces.host, 'example.com'); + }); + + it('should parse protocol relative', function() { + var pieces = parseDSN('//user@mattrobenolt.com/'); + assert.strictEqual(pieces.protocol, ''); + assert.strictEqual(pieces.user, 'user'); + assert.strictEqual(pieces.port, ''); + assert.strictEqual(pieces.path, '/'); + assert.strictEqual(pieces.host, 'mattrobenolt.com'); + }); + + it('should parse domain with hyphen', function() { + var pieces = parseDSN('http://user@matt-robenolt.com/1'); + assert.strictEqual(pieces.protocol, 'http'); + assert.strictEqual(pieces.user, 'user'); + assert.strictEqual(pieces.port, ''); + assert.strictEqual(pieces.path, '/1'); + assert.strictEqual(pieces.host, 'matt-robenolt.com'); + }); + + it('should raise a RavenConfigError when setting a password', function() { + try { + parseDSN('http://user:pass@example.com/2'); + } catch(e) { + return assert.equal(e.name, 'RavenConfigError'); + } + // shouldn't hit this + assert.isTrue(false); + }); + + it('should raise a RavenConfigError with an invalid DSN', function() { + try { + parseDSN('lol'); + } catch(e) { + return assert.equal(e.name, 'RavenConfigError'); + } + // shouldn't hit this + assert.isTrue(false); + }); + }); + + describe('normalizeFrame', function() { + it('should handle a normal frame', function() { + var context = [ + ['line1'], // pre + 'line2', // culprit + ['line3'] // post + ]; + this.sinon.stub(window, 'extractContextFromFrame').returns(context); + var frame = { + url: 'http://example.com/path/file.js', + line: 10, + column: 11, + func: 'lol' + // context: [] context is stubbed + }; + + globalOptions.fetchContext = true; + + assert.deepEqual(normalizeFrame(frame), { + filename: 'http://example.com/path/file.js', + lineno: 10, + colno: 11, + 'function': 'lol', + pre_context: ['line1'], + context_line: 'line2', + post_context: ['line3'], + in_app: true + }); + }); + + it('should handle a frame without context', function() { + this.sinon.stub(window, 'extractContextFromFrame').returns(undefined); + var frame = { + url: 'http://example.com/path/file.js', + line: 10, + column: 11, + func: 'lol' + // context: [] context is stubbed + }; + + globalOptions.fetchContext = true; + + assert.deepEqual(normalizeFrame(frame), { + filename: 'http://example.com/path/file.js', + lineno: 10, + colno: 11, + 'function': 'lol', + in_app: true + }); + }); + + it('should not mark `in_app` if rules match', function() { + this.sinon.stub(window, 'extractContextFromFrame').returns(undefined); + var frame = { + url: 'http://example.com/path/file.js', + line: 10, + column: 11, + func: 'lol' + // context: [] context is stubbed + }; + + globalOptions.fetchContext = true; + globalOptions.includePaths = /^http:\/\/example\.com/; + + assert.deepEqual(normalizeFrame(frame), { + filename: 'http://example.com/path/file.js', + lineno: 10, + colno: 11, + 'function': 'lol', + in_app: true + }); + }); + + it('should mark `in_app` if rules do not match', function() { + this.sinon.stub(window, 'extractContextFromFrame').returns(undefined); + var frame = { + url: 'http://lol.com/path/file.js', + line: 10, + column: 11, + func: 'lol' + // context: [] context is stubbed + }; + + globalOptions.fetchContext = true; + globalOptions.includePaths = /^http:\/\/example\.com/; + + assert.deepEqual(normalizeFrame(frame), { + filename: 'http://lol.com/path/file.js', + lineno: 10, + colno: 11, + 'function': 'lol', + in_app: false + }); + }); + }); + + describe('extractContextFromFrame', function() { + it('should handle a normal frame', function() { + var frame = { + column: 2, + context: [ + 'line1', + 'line2', + 'line3', + 'line4', + 'line5', + 'culprit', + 'line7', + 'line8', + 'line9', + 'line10', + 'line11' + ] + }; + var context = extractContextFromFrame(frame); + assert.deepEqual(context, [ + ['line1', 'line2', 'line3', 'line4', 'line5'], + 'culprit', + ['line7', 'line8', 'line9', 'line10', 'line11'] + ]); + }); + + it('should return nothing if there is no context', function() { + var frame = { + column: 2 + }; + assert.isUndefined(extractContextFromFrame(frame)); + }); + + it('should reject a context if a line is too long without a column', function() { + var frame = { + context: [ + new Array(1000).join('f') // generate a line that is 1000 chars long + ] + }; + assert.isUndefined(extractContextFromFrame(frame)); + }); + + it('should reject a minified context with fetchContext disabled', function() { + var frame = { + column: 2, + context: [ + 'line1', + 'line2', + 'line3', + 'line4', + 'line5', + 'culprit', + 'line7', + 'line8', + 'line9', + 'line10', + 'line11' + ] + }; + globalOptions.fetchContext = false; + assert.isUndefined(extractContextFromFrame(frame)); + }); + + it('should truncate the minified line if there is a column number without sourcemaps enabled', function() { + // Note to future self: + // Array(51).join('f').length === 50 + var frame = { + column: 2, + context: [ + 'aa' + (new Array(51).join('f')) + (new Array(500).join('z')) + ] + }; + assert.deepEqual(extractContextFromFrame(frame), [[], new Array(51).join('f'), []]); + }); + }); + + describe('processException', function() { + it('should respect `ignoreErrors`', function() { + this.sinon.stub(window, 'send'); + + globalOptions.ignoreErrors = joinRegExp(['e1', 'e2']); + processException('Error', 'e1', 'http://example.com', []); + assert.isFalse(window.send.called); + processException('Error', 'e2', 'http://example.com', []); + assert.isFalse(window.send.called); + processException('Error', 'error', 'http://example.com', []); + assert.isTrue(window.send.calledOnce); + }); + + it('should respect `ignoreUrls`', function() { + this.sinon.stub(window, 'send'); + + globalOptions.ignoreUrls = joinRegExp([/.+?host1.+/, /.+?host2.+/]); + processException('Error', 'error', 'http://host1/', []); + assert.isFalse(window.send.called); + processException('Error', 'error', 'http://host2/', []); + assert.isFalse(window.send.called); + processException('Error', 'error', 'http://host3/', []); + assert.isTrue(window.send.calledOnce); + }); + + it('should respect `whitelistUrls`', function() { + this.sinon.stub(window, 'send'); + + globalOptions.whitelistUrls = joinRegExp([/.+?host1.+/, /.+?host2.+/]); + processException('Error', 'error', 'http://host1/', []); + assert.equal(window.send.callCount, 1); + processException('Error', 'error', 'http://host2/', []); + assert.equal(window.send.callCount, 2); + processException('Error', 'error', 'http://host3/', []); + assert.equal(window.send.callCount, 2); + }); + + it('should send a proper payload with frames', function() { + this.sinon.stub(window, 'send'); + + var frames = [ + { + filename: 'http://example.com/file1.js' + }, + { + filename: 'http://example.com/file2.js' + } + ], framesFlipped = frames.slice(0); + + framesFlipped.reverse(); + + processException('Error', 'lol', 'http://example.com/override.js', 10, frames.slice(0), {}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: framesFlipped + }, + culprit: 'http://example.com/file1.js', + message: 'lol at 10' + }]); + + processException('Error', 'lol', '', 10, frames.slice(0), {}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: framesFlipped + }, + culprit: 'http://example.com/file1.js', + message: 'lol at 10' + }]); + + processException('Error', 'lol', '', 10, frames.slice(0), {extra: 'awesome'}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: framesFlipped + }, + culprit: 'http://example.com/file1.js', + message: 'lol at 10', + extra: 'awesome' + }]); + }); + + it('should send a proper payload without frames', function() { + this.sinon.stub(window, 'send'); + + processException('Error', 'lol', 'http://example.com/override.js', 10, [], {}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: [{ + filename: 'http://example.com/override.js', + lineno: 10 + }] + }, + culprit: 'http://example.com/override.js', + message: 'lol at 10' + }]); + + processException('Error', 'lol', 'http://example.com/override.js', 10, [], {}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: [{ + filename: 'http://example.com/override.js', + lineno: 10 + }] + }, + culprit: 'http://example.com/override.js', + message: 'lol at 10' + }]); + + processException('Error', 'lol', 'http://example.com/override.js', 10, [], {extra: 'awesome'}); + assert.deepEqual(window.send.lastCall.args, [{ + exception: { + type: 'Error', + value: 'lol' + }, + stacktrace: { + frames: [{ + filename: 'http://example.com/override.js', + lineno: 10 + }] + }, + culprit: 'http://example.com/override.js', + message: 'lol at 10', + extra: 'awesome' + }]); + }); + + it('should ignored falsey messages', function() { + this.sinon.stub(window, 'send'); + + processException('Error', '', 'http://example.com', []); + assert.isFalse(window.send.called); + }); + }); + + describe('send', function() { + it('should check `isSetup`', function() { + this.sinon.stub(window, 'isSetup').returns(false); + this.sinon.stub(window, 'makeRequest'); + + send(); + assert.isTrue(window.isSetup.calledOnce); + assert.isFalse(window.makeRequest.calledOnce); + }); + + it('should build a good data payload', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + this.sinon.stub(window, 'getHttpData').returns({ + url: 'http://localhost/?a=b', + headers: {'User-Agent': 'lolbrowser'} + }); + + globalProject = '2'; + globalOptions = { + logger: 'javascript', + site: 'THE BEST' + }; + + send({foo: 'bar'}); + assert.deepEqual(window.makeRequest.lastCall.args[0], { + project: '2', + logger: 'javascript', + site: 'THE BEST', + platform: 'javascript', + request: { + url: 'http://localhost/?a=b', + headers: { + 'User-Agent': 'lolbrowser' + } + }, + event_id: 'abc123', + foo: 'bar' + }); + }); + + it('should build a good data payload with a User', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + this.sinon.stub(window, 'getHttpData').returns({ + url: 'http://localhost/?a=b', + headers: {'User-Agent': 'lolbrowser'} + }); + + globalProject = '2'; + globalOptions = { + logger: 'javascript', + site: 'THE BEST' + }; + + globalUser = {name: 'Matt'}; + + send({foo: 'bar'}); + assert.deepEqual(window.makeRequest.lastCall.args, [{ + project: '2', + logger: 'javascript', + site: 'THE BEST', + platform: 'javascript', + request: { + url: 'http://localhost/?a=b', + headers: { + 'User-Agent': 'lolbrowser' + } + }, + event_id: 'abc123', + user: { + name: 'Matt' + }, + foo: 'bar' + }]); + }); + + it('should merge in global tags', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + this.sinon.stub(window, 'getHttpData').returns({ + url: 'http://localhost/?a=b', + headers: {'User-Agent': 'lolbrowser'} + }); + + globalProject = '2'; + globalOptions = { + logger: 'javascript', + site: 'THE BEST', + tags: {tag1: 'value1'} + }; + + + send({tags: {tag2: 'value2'}}); + assert.deepEqual(window.makeRequest.lastCall.args, [{ + project: '2', + logger: 'javascript', + site: 'THE BEST', + platform: 'javascript', + request: { + url: 'http://localhost/?a=b', + headers: { + 'User-Agent': 'lolbrowser' + } + }, + event_id: 'abc123', + tags: {tag1: 'value1', tag2: 'value2'} + }]); + }); + + it('should merge in global extra', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + this.sinon.stub(window, 'getHttpData').returns({ + url: 'http://localhost/?a=b', + headers: {'User-Agent': 'lolbrowser'} + }); + + globalProject = '2'; + globalOptions = { + logger: 'javascript', + site: 'THE BEST', + extra: {key1: 'value1'} + }; + + + send({extra: {key2: 'value2'}}); + assert.deepEqual(window.makeRequest.lastCall.args, [{ + project: '2', + logger: 'javascript', + site: 'THE BEST', + platform: 'javascript', + request: { + url: 'http://localhost/?a=b', + headers: { + 'User-Agent': 'lolbrowser' + } + }, + event_id: 'abc123', + extra: {key1: 'value1', key2: 'value2'} + }]); + }); + + it('should let dataCallback override everything', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + + globalOptions = { + projectId: 2, + logger: 'javascript', + site: 'THE BEST', + dataCallback: function() { + return {lol: 'ibrokeit'}; + } + }; + + globalUser = {name: 'Matt'}; + + send({foo: 'bar'}); + assert.deepEqual(window.makeRequest.lastCall.args, [{ + lol: 'ibrokeit', + event_id: 'abc123', + }]); + }); + + it('should strip empty tags/extra', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(window, 'makeRequest'); + this.sinon.stub(window, 'getHttpData').returns({ + url: 'http://localhost/?a=b', + headers: {'User-Agent': 'lolbrowser'} + }); + + globalOptions = { + projectId: 2, + logger: 'javascript', + site: 'THE BEST', + tags: {}, + extra: {} + }; + + send({foo: 'bar', tags: {}, extra: {}}); + assert.deepEqual(window.makeRequest.lastCall.args[0], { + project: '2', + logger: 'javascript', + site: 'THE BEST', + platform: 'javascript', + request: { + url: 'http://localhost/?a=b', + headers: { + 'User-Agent': 'lolbrowser' + } + }, + event_id: 'abc123', + foo: 'bar' + }); + }); + }); + + describe('makeRequest', function() { + it('should load an Image', function() { + imageCache = []; + this.sinon.stub(window, 'getAuthQueryString').returns('?lol'); + globalServer = 'http://localhost/'; + + makeRequest({foo: 'bar'}); + assert.equal(imageCache.length, 1); + assert.equal(imageCache[0].src, 'http://localhost/?lol&sentry_data=%7B%22foo%22%3A%22bar%22%7D'); + }); + }); + + describe('handleStackInfo', function() { + it('should work as advertised', function() { + var frame = {url: 'http://example.com'}; + this.sinon.stub(window, 'normalizeFrame').returns(frame); + this.sinon.stub(window, 'processException'); + + var stackInfo = { + name: 'Matt', + message: 'hey', + url: 'http://example.com', + lineno: 10, + stack: [ + frame, frame + ] + }; + + handleStackInfo(stackInfo, {foo: 'bar'}); + assert.deepEqual(window.processException.lastCall.args, [ + 'Matt', 'hey', 'http://example.com', 10, [frame, frame], {foo: 'bar'} + ]); + }); + + it('should work as advertised #integration', function() { + this.sinon.stub(window, 'makeRequest'); + var stackInfo = { + name: 'Error', + message: 'crap', + url: 'http://example.com', + lineno: 10, + stack: [ + { + url: 'http://example.com/file1.js', + line: 10, + column: 11, + func: 'broken', + context: [ + 'line1', + 'line2', + 'line3' + ] + }, + { + url: 'http://example.com/file2.js', + line: 12, + column: 13, + func: 'lol', + context: [ + 'line4', + 'line5', + 'line6' + ] + } + ] + }; + + handleStackInfo(stackInfo, {foo: 'bar'}); + assert.isTrue(window.makeRequest.calledOnce); + /* This is commented out because chai is broken. + + assert.deepEqual(window.makeRequest.lastCall.args, [{ + project: '2', + logger: 'javascript', + platform: 'javascript', + request: { + url: window.location.protocol + '//' + window.location.host + window.location.pathname, + querystring: window.location.search.slice(1) + }, + exception: { + type: 'Error', + value: 'crap' + }, + stacktrace: { + frames: [{ + filename: 'http://example.com/file1.js', + filename: 'file1.js', + lineno: 10, + colno: 11, + 'function': 'broken', + post_context: ['line3'], + context_line: 'line2', + pre_context: ['line1'] + }, { + filename: 'http://example.com/file2.js', + filename: 'file2.js', + lineno: 12, + colno: 13, + 'function': 'lol', + post_context: ['line6'], + context_line: 'line5', + pre_context: ['line4'] + }] + }, + culprit: 'http://example.com', + message: 'crap at 10', + foo: 'bar' + }]); + */ + }); + + it('should ignore frames that dont have a url', function() { + this.sinon.stub(window, 'normalizeFrame').returns(undefined); + this.sinon.stub(window, 'processException'); + + var stackInfo = { + name: 'Matt', + message: 'hey', + url: 'http://example.com', + lineno: 10, + stack: new Array(2) + }; + + handleStackInfo(stackInfo, {foo: 'bar'}); + assert.deepEqual(window.processException.lastCall.args, [ + 'Matt', 'hey', 'http://example.com', 10, [], {foo: 'bar'} + ]); + }); + + it('should not shit when there is no stack object from TK', function() { + this.sinon.stub(window, 'normalizeFrame').returns(undefined); + this.sinon.stub(window, 'processException'); + + var stackInfo = { + name: 'Matt', + message: 'hey', + url: 'http://example.com', + lineno: 10 + // stack: new Array(2) + }; + + handleStackInfo(stackInfo); + assert.isFalse(window.normalizeFrame.called); + assert.deepEqual(window.processException.lastCall.args, [ + 'Matt', 'hey', 'http://example.com', 10, [], undefined + ]); + }); + }); + + describe('joinRegExp', function() { + it('should work as advertised', function() { + assert.equal(joinRegExp([ + 'a', 'b', 'a.b', /d/, /[0-9]/ + ]).source, 'a|b|a\\.b|d|[0-9]'); + }); + + it('should not process empty or undefined variables', function() { + assert.equal(joinRegExp([ + 'a', 'b', null, undefined + ]).source, 'a|b'); + }); + + it('should skip entries that are not strings or regular expressions in the passed array of patterns', function() { + assert.equal(joinRegExp([ + 'a', 'b', null, 'a.b', undefined, true, /d/, 123, {}, /[0-9]/, [] + ]).source, 'a|b|a\\.b|d|[0-9]'); + }); + }); +}); + +describe('Raven (public API)', function() { + afterEach(function() { + flushRavenState(); + }); + + describe('.VERSION', function() { + it('should have a version', function() { + assert.isString(Raven.VERSION); + }); + }); + + describe('callback function', function() { + it('should callback a function if it is global', function() { + window.RavenConfig = { + dsn: "http://random@some.other.server:80/2", + config: {some: 'config'} + }; + + this.sinon.stub(window, 'isSetup').returns(false); + this.sinon.stub(TraceKit.report, 'subscribe'); + + Raven.afterLoad(); + + assert.equal(globalKey, 'random'); + assert.equal(globalServer, 'http://some.other.server:80/api/2/store/'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default'); + assert.equal(globalOptions.some, 'config'); + assert.equal(globalProject, '2'); + + assert.isTrue(window.isSetup.calledOnce); + assert.isFalse(TraceKit.report.subscribe.calledOnce); + + delete window.RavenConfig; + }); + }); + + describe('.config', function() { + it('should work with a DSN', function() { + assert.equal(Raven, Raven.config(SENTRY_DSN, {foo: 'bar'}), 'it should return Raven'); + assert.equal(globalKey, 'abc'); + assert.equal(globalServer, 'http://example.com:80/api/2/store/'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default'); + assert.equal(globalOptions.foo, 'bar'); + assert.equal(globalProject, '2'); + assert.isTrue(isSetup()); + }); + + it('should work with a protocol relative DSN', function() { + Raven.config('//abc@example.com/2'); + assert.equal(globalKey, 'abc'); + assert.equal(globalServer, '//example.com/api/2/store/'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default'); + assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default'); + assert.equal(globalProject, '2'); + assert.isTrue(isSetup()); + }); + + it('should work should work at a non root path', function() { + Raven.config('//abc@example.com/sentry/2'); + assert.equal(globalKey, 'abc'); + assert.equal(globalServer, '//example.com/sentry/api/2/store/'); + assert.equal(globalProject, '2'); + assert.isTrue(isSetup()); + }); + + it('should noop a falsey dsn', function() { + Raven.config(''); + assert.isFalse(isSetup()); + }); + + it('should return Raven for a falsey dsn', function() { + assert.equal(Raven.config(''), Raven); + }); + + describe('whitelistUrls', function() { + it('should be false if none are passed', function() { + Raven.config('//abc@example.com/2'); + assert.equal(globalOptions.whitelistUrls, false); + }); + + it('should join into a single RegExp', function() { + Raven.config('//abc@example.com/2', { + whitelistUrls: [ + /my.app/i, + /other.app/i + ] + }); + + assert.match(globalOptions.whitelistUrls, /my.app|other.app/i); + }); + + it('should handle strings as well', function() { + Raven.config('//abc@example.com/2', { + whitelistUrls: [ + /my.app/i, + "stringy.app" + ] + }); + + assert.match(globalOptions.whitelistUrls, /my.app|stringy.app/i); + }); + }); + + describe('collectWindowErrors', function() { + it('should be true by default', function() { + Raven.config(SENTRY_DSN); + assert.isTrue(TraceKit.collectWindowErrors); + }); + + it('should be true if set to true', function() { + Raven.config(SENTRY_DSN, { + collectWindowErrors: true + }); + + assert.isTrue(TraceKit.collectWindowErrors); + }); + + it('should be false if set to false', function() { + Raven.config(SENTRY_DSN, { + collectWindowErrors: false + }); + + assert.isFalse(TraceKit.collectWindowErrors); + }); + }); + }); + + describe('.install', function() { + it('should check `isSetup`', function() { + this.sinon.stub(window, 'isSetup').returns(false); + this.sinon.stub(TraceKit.report, 'subscribe'); + Raven.install(); + assert.isTrue(window.isSetup.calledOnce); + assert.isFalse(TraceKit.report.subscribe.calledOnce); + }); + + it('should register itself with TraceKit', function() { + this.sinon.stub(window, 'isSetup').returns(true); + this.sinon.stub(TraceKit.report, 'subscribe'); + assert.equal(Raven, Raven.install()); + assert.isTrue(TraceKit.report.subscribe.calledOnce); + assert.equal(TraceKit.report.subscribe.lastCall.args[0], handleStackInfo); + }); + }); + + describe('.wrap', function() { + it('should return a wrapped callback', function() { + var spy = this.sinon.spy(); + var wrapped = Raven.wrap(spy); + assert.isFunction(wrapped); + assert.isTrue(wrapped.__raven__); + wrapped(); + assert.isTrue(spy.calledOnce); + }); + + it('should copy property when wrapping function', function() { + var func = function() {}; + func.test = true; + var wrapped = Raven.wrap(func); + assert.isTrue(wrapped.test); + }); + + it('should not copy prototype property when wrapping function', function() { + var func = function() {}; + func.prototype.test = true; + var wrapped = Raven.wrap(func); + assert.isUndefined(new wrapped().test); + }); + + it('should return the result of a wrapped function', function() { + var func = function() { return 'foo'; }; + var wrapped = Raven.wrap(func); + assert.equal(wrapped(), 'foo'); + }); + + it('should not wrap a non-function', function() { + assert.equal(Raven.wrap('lol'), 'lol'); + assert.equal(Raven.wrap({}, 'lol'), 'lol'); + assert.equal(Raven.wrap(undefined, 'lol'), 'lol'); + var a = [1, 2]; + assert.equal(Raven.wrap(a), a); + }); + + it('should wrap function arguments', function() { + var spy = this.sinon.spy(); + var wrapped = Raven.wrap(function(f) { + assert.isTrue(f.__raven__); + f(); + }); + wrapped(spy); + assert.isTrue(spy.calledOnce); + }); + + it('should not wrap function arguments', function() { + var spy = this.sinon.spy(); + var wrapped = Raven.wrap({ deep: false }, function(f) { + assert.isUndefined(f.__raven__); + f(); + }); + wrapped(spy); + assert.isTrue(spy.calledOnce); + }); + + it('should maintain the correct scope', function() { + var foo = {}; + var bar = function() { + assert.equal(this, foo); + }; + bar.apply(foo, []); + Raven.wrap(bar).apply(foo, []); + }); + + it('should re-raise a thrown exception', function() { + var error = new Error('lol'); + try { + Raven.wrap(function() { throw error; })(); + } catch(e) { + return assert.equal(e, error); + } + // Shouldn't hit this + assert.isTrue(false); + }); + + }); + + describe('.context', function() { + it('should execute the callback with options', function() { + var spy = this.sinon.spy(); + this.sinon.stub(Raven, 'captureException'); + Raven.context({'foo': 'bar'}, spy); + assert.isTrue(spy.calledOnce); + assert.isFalse(Raven.captureException.called); + }); + + it('should execute the callback with arguments', function() { + var spy = this.sinon.spy(); + var args = [1, 2]; + Raven.context(spy, args); + assert.deepEqual(spy.lastCall.args, args); + }); + + it('should execute the callback without options', function() { + var spy = this.sinon.spy(); + this.sinon.stub(Raven, 'captureException'); + Raven.context(spy); + assert.isTrue(spy.calledOnce); + assert.isFalse(Raven.captureException.called); + }); + + it('should capture the exception with options', function() { + var error = new Error('crap'); + var broken = function() { throw error; }; + this.sinon.stub(Raven, 'captureException'); + try { + Raven.context({'foo': 'bar'}, broken); + } catch(e) { + assert.equal(e, error); + } + assert.isTrue(Raven.captureException.called); + assert.deepEqual(Raven.captureException.lastCall.args, [error, {'foo': 'bar'}]); + }); + + it('should capture the exception without options', function() { + var error = new Error('crap'); + var broken = function() { throw error; }; + this.sinon.stub(Raven, 'captureException'); + try { + Raven.context(broken); + } catch(e) { + assert.equal(e, error); + } + assert.isTrue(Raven.captureException.called); + assert.deepEqual(Raven.captureException.lastCall.args, [error, undefined]); + }); + + it('should execute the callback without arguments', function() { + // This is only reproducable in a browser that complains about passing + // undefined to Function.apply + var spy = this.sinon.spy(); + Raven.context(spy); + assert.deepEqual(spy.lastCall.args, []); + }); + + it('should return the result of the wrapped function', function() { + var val = {}; + var func = function() { return val; }; + assert.equal(Raven.context(func), val); + }); + }); + + describe('.uninstall', function() { + it('should uninstall from TraceKit', function() { + this.sinon.stub(TraceKit.report, 'uninstall'); + Raven.uninstall(); + assert.isTrue(TraceKit.report.uninstall.calledOnce); + }); + }); + + describe('.setUser', function() { + it('should set the globalUser object', function() { + Raven.setUser({name: 'Matt'}); + assert.deepEqual(globalUser, {name: 'Matt'}); + }); + + it('should clear the globalUser with no arguments', function() { + globalUser = {name: 'Matt'}; + Raven.setUser(); + assert.isUndefined(globalUser); + }); + }); + + describe('.captureMessage', function() { + it('should work as advertised', function() { + this.sinon.stub(window, 'send'); + Raven.captureMessage('lol', {foo: 'bar'}); + assert.deepEqual(window.send.lastCall.args, [{ + message: 'lol', + foo: 'bar' + }]); + }); + + it('should work as advertised #integration', function() { + imageCache = []; + setupRaven(); + Raven.captureMessage('lol', {foo: 'bar'}); + assert.equal(imageCache.length, 1); + // It'd be hard to assert the actual payload being sent + // since it includes the generated url, which is going to + // vary between users running the tests + // Unit tests should cover that the payload was constructed properly + }); + + it('should tag lastEventId #integration', function() { + setupRaven(); + Raven.captureMessage('lol'); + assert.equal(Raven.lastEventId(), 'abc123'); + }); + }); + + describe('.captureException', function() { + it('should call TraceKit.report', function() { + var error = new Error('crap'); + this.sinon.stub(TraceKit, 'report'); + Raven.captureException(error, {foo: 'bar'}); + assert.isTrue(TraceKit.report.calledOnce); + assert.deepEqual(TraceKit.report.lastCall.args, [error, {foo: 'bar'}]); + }); + + it('should store the last exception', function() { + var error = new Error('crap'); + this.sinon.stub(TraceKit, 'report'); + Raven.captureException(error); + assert.equal(Raven.lastException(), error); + }); + + it('shouldn\'t reraise the if the error is the same error', function() { + var error = new Error('crap'); + this.sinon.stub(TraceKit, 'report').throws(error); + // this would raise if the errors didn't match + Raven.captureException(error, {foo: 'bar'}); + assert.isTrue(TraceKit.report.calledOnce); + }); + + it('should reraise a different error', function() { + var error = new Error('crap1'); + this.sinon.stub(TraceKit, 'report').throws(error); + try { + Raven.captureException(new Error('crap2')); + } catch(e) { + return assert.equal(e, error); + } + // shouldn't hit this + assert.isTrue(false); + }); + + it('should capture as a normal message if a string is passed', function() { + this.sinon.stub(Raven, 'captureMessage'); + this.sinon.stub(TraceKit, 'report'); + Raven.captureException('derp'); + assert.equal(Raven.captureMessage.lastCall.args[0], 'derp'); + assert.isFalse(TraceKit.report.called); + }); + }); +}); diff --git a/bower_components/raven-js/vendor/TraceKit/tracekit.js b/bower_components/raven-js/vendor/TraceKit/tracekit.js new file mode 100644 index 0000000..568bef6 --- /dev/null +++ b/bower_components/raven-js/vendor/TraceKit/tracekit.js @@ -0,0 +1,1072 @@ +/* + TraceKit - Cross brower stack traces - github.com/occ/TraceKit + MIT license +*/ + +var TraceKit = { + remoteFetching: false, + collectWindowErrors: true, + // 3 lines before, the offending line, 3 lines after + linesOfContext: 7 +}; + +// global reference to slice +var _slice = [].slice; +var UNKNOWN_FUNCTION = '?'; + + +/** + * TraceKit.wrap: Wrap any function in a TraceKit reporter + * Example: func = TraceKit.wrap(func); + * + * @param {Function} func Function to be wrapped + * @return {Function} The wrapped func + */ +TraceKit.wrap = function traceKitWrapper(func) { + function wrapped() { + try { + return func.apply(this, arguments); + } catch (e) { + TraceKit.report(e); + throw e; + } + } + return wrapped; +}; + +/** + * TraceKit.report: cross-browser processing of unhandled exceptions + * + * Syntax: + * TraceKit.report.subscribe(function(stackInfo) { ... }) + * TraceKit.report.unsubscribe(function(stackInfo) { ... }) + * TraceKit.report(exception) + * try { ...code... } catch(ex) { TraceKit.report(ex); } + * + * Supports: + * - Firefox: full stack trace with line numbers, plus column number + * on top frame; column number is not guaranteed + * - Opera: full stack trace with line and column numbers + * - Chrome: full stack trace with line and column numbers + * - Safari: line and column number for the top frame only; some frames + * may be missing, and column number is not guaranteed + * - IE: line and column number for the top frame only; some frames + * may be missing, and column number is not guaranteed + * + * In theory, TraceKit should work on all of the following versions: + * - IE5.5+ (only 8.0 tested) + * - Firefox 0.9+ (only 3.5+ tested) + * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require + * Exceptions Have Stacktrace to be enabled in opera:config) + * - Safari 3+ (only 4+ tested) + * - Chrome 1+ (only 5+ tested) + * - Konqueror 3.5+ (untested) + * + * Requires TraceKit.computeStackTrace. + * + * Tries to catch all unhandled exceptions and report them to the + * subscribed handlers. Please note that TraceKit.report will rethrow the + * exception. This is REQUIRED in order to get a useful stack trace in IE. + * If the exception does not reach the top of the browser, you will only + * get a stack trace from the point where TraceKit.report was called. + * + * Handlers receive a stackInfo object as described in the + * TraceKit.computeStackTrace docs. + */ +TraceKit.report = (function reportModuleWrapper() { + var handlers = [], + lastArgs = null, + lastException = null, + lastExceptionStack = null; + + /** + * Add a crash handler. + * @param {Function} handler + */ + function subscribe(handler) { + installGlobalHandler(); + handlers.push(handler); + } + + /** + * Remove a crash handler. + * @param {Function} handler + */ + function unsubscribe(handler) { + for (var i = handlers.length - 1; i >= 0; --i) { + if (handlers[i] === handler) { + handlers.splice(i, 1); + } + } + } + + /** + * Remove all crash handlers. + */ + function unsubscribeAll() { + uninstallGlobalHandler(); + handlers = []; + } + + /** + * Dispatch stack information to all handlers. + * @param {Object.} stack + */ + function notifyHandlers(stack, isWindowError) { + var exception = null; + if (isWindowError && !TraceKit.collectWindowErrors) { + return; + } + for (var i in handlers) { + if (hasKey(handlers, i)) { + try { + handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2))); + } catch (inner) { + exception = inner; + } + } + } + + if (exception) { + throw exception; + } + } + + var _oldOnerrorHandler, _onErrorHandlerInstalled; + + /** + * Ensures all global unhandled exceptions are recorded. + * Supported by Gecko and IE. + * @param {string} message Error message. + * @param {string} url URL of script that generated the exception. + * @param {(number|string)} lineNo The line number at which the error + * occurred. + * @param {?(number|string)} colNo The column number at which the error + * occurred. + * @param {?Error} ex The actual Error object. + */ + function traceKitWindowOnError(message, url, lineNo, colNo, ex) { + var stack = null; + + if (lastExceptionStack) { + TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message); + processLastException(); + } else if (ex) { + // New chrome and blink send along a real error object + // Let's just report that like a normal error. + // See: https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror + stack = TraceKit.computeStackTrace(ex); + notifyHandlers(stack, true); + } else { + var location = { + 'url': url, + 'line': lineNo, + 'column': colNo + }; + location.func = TraceKit.computeStackTrace.guessFunctionName(location.url, location.line); + location.context = TraceKit.computeStackTrace.gatherContext(location.url, location.line); + stack = { + 'message': message, + 'url': document.location.href, + 'stack': [location] + }; + notifyHandlers(stack, true); + } + + if (_oldOnerrorHandler) { + return _oldOnerrorHandler.apply(this, arguments); + } + + return false; + } + + function installGlobalHandler () + { + if (_onErrorHandlerInstalled) { + return; + } + _oldOnerrorHandler = window.onerror; + window.onerror = traceKitWindowOnError; + _onErrorHandlerInstalled = true; + } + + function uninstallGlobalHandler () + { + if (!_onErrorHandlerInstalled) { + return; + } + window.onerror = _oldOnerrorHandler; + _onErrorHandlerInstalled = false; + _oldOnerrorHandler = undefined; + } + + function processLastException() { + var _lastExceptionStack = lastExceptionStack, + _lastArgs = lastArgs; + lastArgs = null; + lastExceptionStack = null; + lastException = null; + notifyHandlers.apply(null, [_lastExceptionStack, false].concat(_lastArgs)); + } + + /** + * Reports an unhandled Error to TraceKit. + * @param {Error} ex + * @param {?boolean} rethrow If false, do not re-throw the exception. + * Only used for window.onerror to not cause an infinite loop of + * rethrowing. + */ + function report(ex, rethrow) { + var args = _slice.call(arguments, 1); + if (lastExceptionStack) { + if (lastException === ex) { + return; // already caught by an inner catch block, ignore + } else { + processLastException(); + } + } + + var stack = TraceKit.computeStackTrace(ex); + lastExceptionStack = stack; + lastException = ex; + lastArgs = args; + + // If the stack trace is incomplete, wait for 2 seconds for + // slow slow IE to see if onerror occurs or not before reporting + // this exception; otherwise, we will end up with an incomplete + // stack trace + window.setTimeout(function () { + if (lastException === ex) { + processLastException(); + } + }, (stack.incomplete ? 2000 : 0)); + + if (rethrow !== false) { + throw ex; // re-throw to propagate to the top level (and cause window.onerror) + } + } + + report.subscribe = subscribe; + report.unsubscribe = unsubscribe; + report.uninstall = unsubscribeAll; + return report; +}()); + +/** + * TraceKit.computeStackTrace: cross-browser stack traces in JavaScript + * + * Syntax: + * s = TraceKit.computeStackTrace.ofCaller([depth]) + * s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below) + * Returns: + * s.name - exception name + * s.message - exception message + * s.stack[i].url - JavaScript or HTML file URL + * s.stack[i].func - function name, or empty for anonymous functions (if guessing did not work) + * s.stack[i].args - arguments passed to the function, if known + * s.stack[i].line - line number, if known + * s.stack[i].column - column number, if known + * s.stack[i].context - an array of source code lines; the middle element corresponds to the correct line# + * + * Supports: + * - Firefox: full stack trace with line numbers and unreliable column + * number on top frame + * - Opera 10: full stack trace with line and column numbers + * - Opera 9-: full stack trace with line numbers + * - Chrome: full stack trace with line and column numbers + * - Safari: line and column number for the topmost stacktrace element + * only + * - IE: no line numbers whatsoever + * + * Tries to guess names of anonymous functions by looking for assignments + * in the source code. In IE and Safari, we have to guess source file names + * by searching for function bodies inside all page scripts. This will not + * work for scripts that are loaded cross-domain. + * Here be dragons: some function names may be guessed incorrectly, and + * duplicate functions may be mismatched. + * + * TraceKit.computeStackTrace should only be used for tracing purposes. + * Logging of unhandled exceptions should be done with TraceKit.report, + * which builds on top of TraceKit.computeStackTrace and provides better + * IE support by utilizing the window.onerror event to retrieve information + * about the top of the stack. + * + * Note: In IE and Safari, no stack trace is recorded on the Error object, + * so computeStackTrace instead walks its *own* chain of callers. + * This means that: + * * in Safari, some methods may be missing from the stack trace; + * * in IE, the topmost function in the stack trace will always be the + * caller of computeStackTrace. + * + * This is okay for tracing (because you are likely to be calling + * computeStackTrace from the function you want to be the topmost element + * of the stack trace anyway), but not okay for logging unhandled + * exceptions (because your catch block will likely be far away from the + * inner function that actually caused the exception). + * + * Tracing example: + * function trace(message) { + * var stackInfo = TraceKit.computeStackTrace.ofCaller(); + * var data = message + "\n"; + * for(var i in stackInfo.stack) { + * var item = stackInfo.stack[i]; + * data += (item.func || '[anonymous]') + "() in " + item.url + ":" + (item.line || '0') + "\n"; + * } + * if (window.console) + * console.info(data); + * else + * alert(data); + * } + */ +TraceKit.computeStackTrace = (function computeStackTraceWrapper() { + var debug = false, + sourceCache = {}; + + /** + * Attempts to retrieve source code via XMLHttpRequest, which is used + * to look up anonymous function names. + * @param {string} url URL of source code. + * @return {string} Source contents. + */ + function loadSource(url) { + if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on. + return ''; + } + try { + var getXHR = function() { + try { + return new window.XMLHttpRequest(); + } catch (e) { + // explicitly bubble up the exception if not found + return new window.ActiveXObject('Microsoft.XMLHTTP'); + } + }; + + var request = getXHR(); + request.open('GET', url, false); + request.send(''); + return request.responseText; + } catch (e) { + return ''; + } + } + + /** + * Retrieves source code from the source code cache. + * @param {string} url URL of source code. + * @return {Array.} Source contents. + */ + function getSource(url) { + if (!isString(url)) return []; + if (!hasKey(sourceCache, url)) { + // URL needs to be able to fetched within the acceptable domain. Otherwise, + // cross-domain errors will be triggered. + var source = ''; + if (url.indexOf(document.domain) !== -1) { + source = loadSource(url); + } + sourceCache[url] = source ? source.split('\n') : []; + } + + return sourceCache[url]; + } + + /** + * Tries to use an externally loaded copy of source code to determine + * the name of a function by looking at the name of the variable it was + * assigned to, if any. + * @param {string} url URL of source code. + * @param {(string|number)} lineNo Line number in source code. + * @return {string} The function name, if discoverable. + */ + function guessFunctionName(url, lineNo) { + var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/, + reGuessFunction = /['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/, + line = '', + maxLines = 10, + source = getSource(url), + m; + + if (!source.length) { + return UNKNOWN_FUNCTION; + } + + // Walk backwards from the first line in the function until we find the line which + // matches the pattern above, which is the function definition + for (var i = 0; i < maxLines; ++i) { + line = source[lineNo - i] + line; + + if (!isUndefined(line)) { + if ((m = reGuessFunction.exec(line))) { + return m[1]; + } else if ((m = reFunctionArgNames.exec(line))) { + return m[1]; + } + } + } + + return UNKNOWN_FUNCTION; + } + + /** + * Retrieves the surrounding lines from where an exception occurred. + * @param {string} url URL of source code. + * @param {(string|number)} line Line number in source code to centre + * around for context. + * @return {?Array.} Lines of source code. + */ + function gatherContext(url, line) { + var source = getSource(url); + + if (!source.length) { + return null; + } + + var context = [], + // linesBefore & linesAfter are inclusive with the offending line. + // if linesOfContext is even, there will be one extra line + // *before* the offending line. + linesBefore = Math.floor(TraceKit.linesOfContext / 2), + // Add one extra line if linesOfContext is odd + linesAfter = linesBefore + (TraceKit.linesOfContext % 2), + start = Math.max(0, line - linesBefore - 1), + end = Math.min(source.length, line + linesAfter - 1); + + line -= 1; // convert to 0-based index + + for (var i = start; i < end; ++i) { + if (!isUndefined(source[i])) { + context.push(source[i]); + } + } + + return context.length > 0 ? context : null; + } + + /** + * Escapes special characters, except for whitespace, in a string to be + * used inside a regular expression as a string literal. + * @param {string} text The string. + * @return {string} The escaped string literal. + */ + function escapeRegExp(text) { + return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&'); + } + + /** + * Escapes special characters in a string to be used inside a regular + * expression as a string literal. Also ensures that HTML entities will + * be matched the same as their literal friends. + * @param {string} body The string. + * @return {string} The escaped string. + */ + function escapeCodeAsRegExpForMatchingInsideHTML(body) { + return escapeRegExp(body).replace('<', '(?:<|<)').replace('>', '(?:>|>)').replace('&', '(?:&|&)').replace('"', '(?:"|")').replace(/\s+/g, '\\s+'); + } + + /** + * Determines where a code fragment occurs in the source code. + * @param {RegExp} re The function definition. + * @param {Array.} urls A list of URLs to search. + * @return {?Object.} An object containing + * the url, line, and column number of the defined function. + */ + function findSourceInUrls(re, urls) { + var source, m; + for (var i = 0, j = urls.length; i < j; ++i) { + // console.log('searching', urls[i]); + if ((source = getSource(urls[i])).length) { + source = source.join('\n'); + if ((m = re.exec(source))) { + // console.log('Found function in ' + urls[i]); + + return { + 'url': urls[i], + 'line': source.substring(0, m.index).split('\n').length, + 'column': m.index - source.lastIndexOf('\n', m.index) - 1 + }; + } + } + } + + // console.log('no match'); + + return null; + } + + /** + * Determines at which column a code fragment occurs on a line of the + * source code. + * @param {string} fragment The code fragment. + * @param {string} url The URL to search. + * @param {(string|number)} line The line number to examine. + * @return {?number} The column number. + */ + function findSourceInLine(fragment, url, line) { + var source = getSource(url), + re = new RegExp('\\b' + escapeRegExp(fragment) + '\\b'), + m; + + line -= 1; + + if (source && source.length > line && (m = re.exec(source[line]))) { + return m.index; + } + + return null; + } + + /** + * Determines where a function was defined within the source code. + * @param {(Function|string)} func A function reference or serialized + * function definition. + * @return {?Object.} An object containing + * the url, line, and column number of the defined function. + */ + function findSourceByFunctionBody(func) { + var urls = [window.location.href], + scripts = document.getElementsByTagName('script'), + body, + code = '' + func, + codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, + eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, + re, + parts, + result; + + for (var i = 0; i < scripts.length; ++i) { + var script = scripts[i]; + if (script.src) { + urls.push(script.src); + } + } + + if (!(parts = codeRE.exec(code))) { + re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+')); + } + + // not sure if this is really necessary, but I don’t have a test + // corpus large enough to confirm that and it was in the original. + else { + var name = parts[1] ? '\\s+' + parts[1] : '', + args = parts[2].split(',').join('\\s*,\\s*'); + + body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); + re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}'); + } + + // look for a normal function definition + if ((result = findSourceInUrls(re, urls))) { + return result; + } + + // look for an old-school event handler function + if ((parts = eventRE.exec(code))) { + var event = parts[1]; + body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]); + + // look for a function defined in HTML as an onXXX handler + re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i'); + + if ((result = findSourceInUrls(re, urls[0]))) { + return result; + } + + // look for ??? + re = new RegExp(body); + + if ((result = findSourceInUrls(re, urls))) { + return result; + } + } + + return null; + } + + // Contents of Exception in various browsers. + // + // SAFARI: + // ex.message = Can't find variable: qq + // ex.line = 59 + // ex.sourceId = 580238192 + // ex.sourceURL = http://... + // ex.expressionBeginOffset = 96 + // ex.expressionCaretOffset = 98 + // ex.expressionEndOffset = 98 + // ex.name = ReferenceError + // + // FIREFOX: + // ex.message = qq is not defined + // ex.fileName = http://... + // ex.lineNumber = 59 + // ex.columnNumber = 69 + // ex.stack = ...stack trace... (see the example below) + // ex.name = ReferenceError + // + // CHROME: + // ex.message = qq is not defined + // ex.name = ReferenceError + // ex.type = not_defined + // ex.arguments = ['aa'] + // ex.stack = ...stack trace... + // + // INTERNET EXPLORER: + // ex.message = ... + // ex.name = ReferenceError + // + // OPERA: + // ex.message = ...message... (see the example below) + // ex.name = ReferenceError + // ex.opera#sourceloc = 11 (pretty much useless, duplicates the info in ex.message) + // ex.stacktrace = n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace' + + /** + * Computes stack trace information from the stack property. + * Chrome and Gecko use this property. + * @param {Error} ex + * @return {?Object.} Stack trace information. + */ + function computeStackTraceFromStackProp(ex) { + if (!ex.stack) { + return null; + } + + var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?):.*?):(\d+)(?::(\d+))?\)?\s*$/i, + gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|https?).*?):(\d+)(?::(\d+))?\s*$/i, + lines = ex.stack.split('\n'), + stack = [], + parts, + element, + reference = /^(.*) is undefined$/.exec(ex.message); + + for (var i = 0, j = lines.length; i < j; ++i) { + if ((parts = gecko.exec(lines[i]))) { + element = { + 'url': parts[3], + 'func': parts[1] || UNKNOWN_FUNCTION, + 'args': parts[2] ? parts[2].split(',') : '', + 'line': +parts[4], + 'column': parts[5] ? +parts[5] : null + }; + } else if ((parts = chrome.exec(lines[i]))) { + element = { + 'url': parts[2], + 'func': parts[1] || UNKNOWN_FUNCTION, + 'line': +parts[3], + 'column': parts[4] ? +parts[4] : null + }; + } else { + continue; + } + + if (!element.func && element.line) { + element.func = guessFunctionName(element.url, element.line); + } + + if (element.line) { + element.context = gatherContext(element.url, element.line); + } + + stack.push(element); + } + + if (!stack.length) { + return null; + } + + if (stack[0].line && !stack[0].column && reference) { + stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line); + } else if (!stack[0].column && !isUndefined(ex.columnNumber)) { + // FireFox uses this awesome columnNumber property for its top frame + // Also note, Firefox's column number is 0-based and everything else expects 1-based, + // so adding 1 + stack[0].column = ex.columnNumber + 1; + } + + return { + 'name': ex.name, + 'message': ex.message, + 'url': document.location.href, + 'stack': stack + }; + } + + /** + * Computes stack trace information from the stacktrace property. + * Opera 10 uses this property. + * @param {Error} ex + * @return {?Object.} Stack trace information. + */ + function computeStackTraceFromStacktraceProp(ex) { + // Access and store the stacktrace property before doing ANYTHING + // else to it because Opera is not very good at providing it + // reliably in other circumstances. + var stacktrace = ex.stacktrace; + + var testRE = / line (\d+), column (\d+) in (?:]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i, + lines = stacktrace.split('\n'), + stack = [], + parts; + + for (var i = 0, j = lines.length; i < j; i += 2) { + if ((parts = testRE.exec(lines[i]))) { + var element = { + 'line': +parts[1], + 'column': +parts[2], + 'func': parts[3] || parts[4], + 'args': parts[5] ? parts[5].split(',') : [], + 'url': parts[6] + }; + + if (!element.func && element.line) { + element.func = guessFunctionName(element.url, element.line); + } + if (element.line) { + try { + element.context = gatherContext(element.url, element.line); + } catch (exc) {} + } + + if (!element.context) { + element.context = [lines[i + 1]]; + } + + stack.push(element); + } + } + + if (!stack.length) { + return null; + } + + return { + 'name': ex.name, + 'message': ex.message, + 'url': document.location.href, + 'stack': stack + }; + } + + /** + * NOT TESTED. + * Computes stack trace information from an error message that includes + * the stack trace. + * Opera 9 and earlier use this method if the option to show stack + * traces is turned on in opera:config. + * @param {Error} ex + * @return {?Object.} Stack information. + */ + function computeStackTraceFromOperaMultiLineMessage(ex) { + // Opera includes a stack trace into the exception message. An example is: + // + // Statement on line 3: Undefined variable: undefinedFunc + // Backtrace: + // Line 3 of linked script file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.js: In function zzz + // undefinedFunc(a); + // Line 7 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function yyy + // zzz(x, y, z); + // Line 3 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function xxx + // yyy(a, a, a); + // Line 1 of function script + // try { xxx('hi'); return false; } catch(ex) { TraceKit.report(ex); } + // ... + + var lines = ex.message.split('\n'); + if (lines.length < 4) { + return null; + } + + var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i, + lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i, + lineRE3 = /^\s*Line (\d+) of function script\s*$/i, + stack = [], + scripts = document.getElementsByTagName('script'), + inlineScriptBlocks = [], + parts, + i, + len, + source; + + for (i in scripts) { + if (hasKey(scripts, i) && !scripts[i].src) { + inlineScriptBlocks.push(scripts[i]); + } + } + + for (i = 2, len = lines.length; i < len; i += 2) { + var item = null; + if ((parts = lineRE1.exec(lines[i]))) { + item = { + 'url': parts[2], + 'func': parts[3], + 'line': +parts[1] + }; + } else if ((parts = lineRE2.exec(lines[i]))) { + item = { + 'url': parts[3], + 'func': parts[4] + }; + var relativeLine = (+parts[1]); // relative to the start of the + + + + + + + diff --git a/bower_components/sizzle/test/data/testinit.js b/bower_components/sizzle/test/data/testinit.js new file mode 100644 index 0000000..1c49c7a --- /dev/null +++ b/bower_components/sizzle/test/data/testinit.js @@ -0,0 +1,136 @@ +var fireNative, + jQuery = this.jQuery || "jQuery", // For testing .noConflict() + $ = this.$ || "$", + originaljQuery = jQuery, + original$ = $; + +(function() { + // Config parameter to force basic code paths + QUnit.config.urlConfig.push({ + id: "basic", + label: "Bypass optimizations", + tooltip: "Force use of the most basic code by disabling native querySelectorAll; contains; compareDocumentPosition" + }); + if ( QUnit.urlParams.basic ) { + document.querySelectorAll = null; + document.documentElement.contains = null; + document.documentElement.compareDocumentPosition = null; + // Return array of length two to pass assertion + // But support should be false as its not native + document.getElementsByClassName = function() { return [ 0, 1 ]; }; + } +})(); + +/** + * Returns an array of elements with the given IDs + * @example q("main", "foo", "bar") + * @result [
          , , ] + */ +function q() { + var r = [], + i = 0; + + for ( ; i < arguments.length; i++ ) { + r.push( document.getElementById( arguments[i] ) ); + } + return r; +} + +/** + * Asserts that a select matches the given IDs + * @param {String} a - Assertion name + * @param {String} b - Sizzle selector + * @param {String} c - Array of ids to construct what is expected + * @example t("Check for something", "//[a]", ["foo", "baar"]); + * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar' + */ +function t( a, b, c ) { + var f = Sizzle(b), + s = "", + i = 0; + + for ( ; i < f.length; i++ ) { + s += ( s && "," ) + '"' + f[ i ].id + '"'; + } + + deepEqual(f, q.apply( q, c ), a + " (" + b + ")"); +} + +/** + * Add random number to url to stop caching + * + * @example url("data/test.html") + * @result "data/test.html?10538358428943" + * + * @example url("data/test.php?foo=bar") + * @result "data/test.php?foo=bar&10538358345554" + */ +function url( value ) { + return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000); +} + +var createWithFriesXML = function() { + var string = ' \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + 1 \ + \ + \ + \ + \ + foo \ + \ + \ + \ + \ + \ + \ + '; + + return jQuery.parseXML( string ); +}; + +fireNative = document.createEvent ? + function( node, type ) { + var event = document.createEvent("HTMLEvents"); + event.initEvent( type, true, true ); + node.dispatchEvent( event ); + } : + function( node, type ) { + var event = document.createEventObject(); + node.fireEvent( "on" + type, event ); + }; + +function testIframeWithCallback( title, fileName, func ) { + test( title, function() { + var iframe; + + stop(); + window.iframeCallback = function() { + var self = this, + args = arguments; + setTimeout(function() { + window.iframeCallback = undefined; + iframe.remove(); + func.apply( self, args ); + func = function() {}; + start(); + }, 0 ); + }; + iframe = jQuery( "
          " ).css({ position: "absolute", width: "500px", left: "-600px" }) + .append( jQuery( " +
          + + +
          +
          + +
          + + + + +
          + +
          + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          +
          +
          + +
          +
          hi there
          +
          +
          +
          +
          +
          +
          +
          + +
          +
          +
          + + +
          + + +
          + + +
          C
          +
          +
          + +
          +
            +
          1. Rice
          2. +
          3. Beans
          4. +
          5. Blinis
          6. +
          7. Tofu
          8. +
          + +
          I'm hungry. I should...
          + ...Eat lots of food... | + ...Eat a little food... | + ...Eat no food... + ...Eat a burger... + ...Eat some funyuns... + ...Eat some funyuns... +
          + +
          + + +
          + +
          + 1 + 2 + + + + + + + + +
          ​ +
          + +
          + + diff --git a/bower_components/sizzle/test/jquery.js b/bower_components/sizzle/test/jquery.js new file mode 100644 index 0000000..86a3305 --- /dev/null +++ b/bower_components/sizzle/test/jquery.js @@ -0,0 +1,9597 @@ +/*! + * jQuery JavaScript Library v1.9.1 + * http://jquery.com/ + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * + * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2013-2-4 + */ +(function( window, undefined ) { + +// Can't do this because several apps including ASP.NET trace +// the stack via arguments.caller.callee and Firefox dies if +// you try to trace through "use strict" call chains. (#13335) +// Support: Firefox 18+ +//"use strict"; +var + // The deferred used on DOM ready + readyList, + + // A central reference to the root jQuery(document) + rootjQuery, + + // Support: IE<9 + // For `typeof node.method` instead of `node.method !== undefined` + core_strundefined = typeof undefined, + + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + location = window.location, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // [[Class]] -> type pairs + class2type = {}, + + // List of deleted data cache ids, so we can reuse them + core_deletedIds = [], + + core_version = "1.9.1", + + // Save a reference to some core methods + core_concat = core_deletedIds.concat, + core_push = core_deletedIds.push, + core_slice = core_deletedIds.slice, + core_indexOf = core_deletedIds.indexOf, + core_toString = class2type.toString, + core_hasOwn = class2type.hasOwnProperty, + core_trim = core_version.trim, + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Used for matching numbers + core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, + + // Used for splitting on whitespace + core_rnotwhite = /\S+/g, + + // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) + rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, + rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, + + // Matches dashed string for camelizing + rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return letter.toUpperCase(); + }, + + // The ready event handler + completed = function( event ) { + + // readyState === "complete" is good enough for us to call the dom ready in oldIE + if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { + detach(); + jQuery.ready(); + } + }, + // Clean-up method for dom ready events + detach = function() { + if ( document.addEventListener ) { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + + } else { + document.detachEvent( "onreadystatechange", completed ); + window.detachEvent( "onload", completed ); + } + }; + +jQuery.fn = jQuery.prototype = { + // The current version of jQuery being used + jquery: core_version, + + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return core_slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + ret.context = this.context; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; + }, + + slice: function() { + return this.pushStack( core_slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: core_push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var src, copyIsArray, copy, name, options, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + isWindow: function( obj ) { + return obj != null && obj == obj.window; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + if ( obj == null ) { + return String( obj ); + } + return typeof obj === "object" || typeof obj === "function" ? + class2type[ core_toString.call(obj) ] || "object" : + typeof obj; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !core_hasOwn.call(obj, "constructor") && + !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || core_hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + // data: string of html + // context (optional): If specified, the fragment will be created in this context, defaults to document + // keepScripts (optional): If true, will include scripts passed in the html string + parseHTML: function( data, context, keepScripts ) { + if ( !data || typeof data !== "string" ) { + return null; + } + if ( typeof context === "boolean" ) { + keepScripts = context; + context = false; + } + context = context || document; + + var parsed = rsingleTag.exec( data ), + scripts = !keepScripts && []; + + // Single tag + if ( parsed ) { + return [ context.createElement( parsed[1] ) ]; + } + + parsed = jQuery.buildFragment( [ data ], context, scripts ); + if ( scripts ) { + jQuery( scripts ).remove(); + } + return jQuery.merge( [], parsed.childNodes ); + }, + + parseJSON: function( data ) { + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + if ( data === null ) { + return data; + } + + if ( typeof data === "string" ) { + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + if ( data ) { + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + } + } + } + + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + if ( !data || typeof data !== "string" ) { + return null; + } + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && jQuery.trim( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var value, + i = 0, + length = obj.length, + isArray = isArraylike( obj ); + + if ( args ) { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.apply( obj[ i ], args ); + + if ( value === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } else { + for ( i in obj ) { + value = callback.call( obj[ i ], i, obj[ i ] ); + + if ( value === false ) { + break; + } + } + } + } + + return obj; + }, + + // Use native String.trim function wherever possible + trim: core_trim && !core_trim.call("\uFEFF\xA0") ? + function( text ) { + return text == null ? + "" : + core_trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + ( text + "" ).replace( rtrim, "" ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArraylike( Object(arr) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + core_push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + var len; + + if ( arr ) { + if ( core_indexOf ) { + return core_indexOf.call( arr, elem, i ); + } + + len = arr.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in arr && arr[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var l = second.length, + i = first.length, + j = 0; + + if ( typeof l === "number" ) { + for ( ; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var retVal, + ret = [], + i = 0, + length = elems.length; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, + i = 0, + length = elems.length, + isArray = isArraylike( elems ), + ret = []; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return core_concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + var args, proxy, tmp; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = core_slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; + }, + + // Multifunctional method to get and set values of a collection + // The value/s can optionally be executed if it's a function + access: function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + length = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < length; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; + }, + + now: function() { + return ( new Date() ).getTime(); + } +}); + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + // Standards-based browsers support DOMContentLoaded + } else if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + + // If IE event model is used + } else { + // Ensure firing before onload, maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", completed ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", completed ); + + // If IE and not a frame + // continually check to see if the document is ready + var top = false; + + try { + top = window.frameElement == null && document.documentElement; + } catch(e) {} + + if ( top && top.doScroll ) { + (function doScrollCheck() { + if ( !jQuery.isReady ) { + + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch(e) { + return setTimeout( doScrollCheck, 50 ); + } + + // detach all dom ready events + detach(); + + // and execute any waiting functions + jQuery.ready(); + } + })(); + } + } + } + return readyList.promise( obj ); +}; + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +function isArraylike( obj ) { + var length = obj.length, + type = jQuery.type( obj ); + + if ( jQuery.isWindow( obj ) ) { + return false; + } + + if ( obj.nodeType === 1 && length ) { + return true; + } + + return type === "array" || type !== "function" && + ( length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj ); +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Flag to know if list is currently firing + firing, + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // First callback to fire (used internally by add and fireWith) + firingStart, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( list && ( !fired || stack ) ) { + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var action = tuple[ 0 ], + fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = core_slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; + if( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); +jQuery.support = (function() { + + var support, all, a, + input, select, fragment, + opt, eventName, isSupported, i, + div = document.createElement("div"); + + // Setup + div.setAttribute( "className", "t" ); + div.innerHTML = "
          a"; + + // Support tests won't run in some limited or non-browser environments + all = div.getElementsByTagName("*"); + a = div.getElementsByTagName("a")[ 0 ]; + if ( !all || !a || !all.length ) { + return {}; + } + + // First batch of tests + select = document.createElement("select"); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName("input")[ 0 ]; + + a.style.cssText = "top:1px;float:left;opacity:.5"; + support = { + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: div.firstChild.nodeType === 3, + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: a.getAttribute("href") === "/a", + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.5/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) + checkOn: !!input.value, + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Tests for enctype support on a form (#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode + boxModel: document.compatMode === "CSS1Compat", + + // Will be defined later + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true, + boxSizingReliable: true, + pixelPosition: false + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Support: IE<9 + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + // Check if we can trust getAttribute("value") + input = document.createElement("input"); + input.setAttribute( "value", "" ); + support.input = input.getAttribute( "value" ) === ""; + + // Check if an input maintains its value after becoming a radio + input.value = "t"; + input.setAttribute( "type", "radio" ); + support.radioValue = input.value === "t"; + + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "checked", "t" ); + input.setAttribute( "name", "t" ); + + fragment = document.createDocumentFragment(); + fragment.appendChild( input ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE<9 + // Opera does not clone events (and typeof div.attachEvent === undefined). + // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() + if ( div.attachEvent ) { + div.attachEvent( "onclick", function() { + support.noCloneEvent = false; + }); + + div.cloneNode( true ).click(); + } + + // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event) + // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php + for ( i in { submit: true, change: true, focusin: true }) { + div.setAttribute( eventName = "on" + i, "t" ); + + support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false; + } + + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, marginDiv, tds, + divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + container = document.createElement("div"); + container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; + + body.appendChild( container ).appendChild( div ); + + // Support: IE8 + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + div.innerHTML = "
          t
          "; + tds = div.getElementsByTagName("td"); + tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Support: IE8 + // Check if empty table cells still have offsetWidth/Height + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Check box-sizing and margin behavior + div.innerHTML = ""; + div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; + support.boxSizing = ( div.offsetWidth === 4 ); + support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); + + // Use window.getComputedStyle because jsdom on node.js will break without it. + if ( window.getComputedStyle ) { + support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; + support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. (#3333) + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + marginDiv = div.appendChild( document.createElement("div") ); + marginDiv.style.cssText = div.style.cssText = divReset; + marginDiv.style.marginRight = marginDiv.style.width = "0"; + div.style.width = "1px"; + + support.reliableMarginRight = + !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); + } + + if ( typeof div.style.zoom !== core_strundefined ) { + // Support: IE<8 + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + div.innerHTML = ""; + div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); + + // Support: IE6 + // Check if elements with layout shrink-wrap their children + div.style.display = "block"; + div.innerHTML = "
          "; + div.firstChild.style.width = "5px"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); + + if ( support.inlineBlockNeedsLayout ) { + // Prevent IE 6 from affecting layout for positioned elements #11048 + // Prevent IE from shrinking the body in IE 7 mode #12869 + // Support: IE<8 + body.style.zoom = 1; + } + } + + body.removeChild( container ); + + // Null elements to avoid leaks in IE + container = div = tds = marginDiv = null; + }); + + // Null elements to avoid leaks in IE + all = select = fragment = opt = a = input = null; + + return support; +})(); + +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, + rmultiDash = /([A-Z])/g; + +function internalData( elem, name, data, pvt /* Internal Use Only */ ){ + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; +} + +function internalRemoveData( elem, name, pvt ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var i, l, thisCache, + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split(" "); + } + } + } else { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = name.concat( jQuery.map( name, jQuery.camelCase ) ); + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject( cache[ id ] ) ) { + return; + } + } + + // Destroy the cache + if ( isNode ) { + jQuery.cleanData( [ elem ], true ); + + // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) + } else if ( jQuery.support.deleteExpando || cache != cache.window ) { + delete cache[ id ]; + + // When all else fails, null + } else { + cache[ id ] = null; + } +} + +jQuery.extend({ + cache: {}, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data ) { + return internalData( elem, name, data ); + }, + + removeData: function( elem, name ) { + return internalRemoveData( elem, name ); + }, + + // For internal use only. + _data: function( elem, name, data ) { + return internalData( elem, name, data, true ); + }, + + _removeData: function( elem, name ) { + return internalRemoveData( elem, name, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + // Do not set data on non-element because it will not be cleared (#8335). + if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) { + return false; + } + + var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; + + // nodes accept data unless otherwise specified; rejection can be conditional + return !noData || noData !== true && elem.getAttribute("classid") === noData; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var attrs, name, + elem = this[0], + i = 0, + data = null; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = jQuery.data( elem ); + + if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { + attrs = elem.attributes; + for ( ; i < attrs.length; i++ ) { + name = attrs[i].name; + + if ( !name.indexOf( "data-" ) ) { + name = jQuery.camelCase( name.slice(5) ); + + dataAttr( elem, name, data[ name ] ); + } + } + jQuery._data( elem, "parsedAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + return jQuery.access( this, function( value ) { + + if ( value === undefined ) { + // Try to fetch any internally stored data first + return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; + } + + this.each(function() { + jQuery.data( this, key, value ); + }); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + var name; + for ( name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray(data) ) { + queue = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + hooks.cur = fn; + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return jQuery._data( elem, key ) || jQuery._data( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + jQuery._removeData( elem, type + "queue" ); + jQuery._removeData( elem, key ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while( i-- ) { + tmp = jQuery._data( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var nodeHook, boolHook, + rclass = /[\t\r\n]/g, + rreturn = /\r/g, + rfocusable = /^(?:input|select|textarea|button|object)$/i, + rclickable = /^(?:a|area)$/i, + rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i, + ruseDefault = /^(?:checked|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + getSetInput = jQuery.support.input; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = typeof value === "string" && value; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call( this, j, this.className ) ); + }); + } + + if ( proceed ) { + // The disjunction here is for better compressibility (see removeClass) + classes = ( value || "" ).match( core_rnotwhite ) || []; + + for ( ; i < len; i++ ) { + elem = this[ i ]; + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + " " + ); + + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + if ( cur.indexOf( " " + clazz + " " ) < 0 ) { + cur += clazz + " "; + } + } + elem.className = jQuery.trim( cur ); + + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classes, elem, cur, clazz, j, + i = 0, + len = this.length, + proceed = arguments.length === 0 || typeof value === "string" && value; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call( this, j, this.className ) ); + }); + } + if ( proceed ) { + classes = ( value || "" ).match( core_rnotwhite ) || []; + + for ( ; i < len; i++ ) { + elem = this[ i ]; + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( elem.className ? + ( " " + elem.className + " " ).replace( rclass, " " ) : + "" + ); + + if ( cur ) { + j = 0; + while ( (clazz = classes[j++]) ) { + // Remove *all* instances + while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { + cur = cur.replace( " " + clazz + " ", " " ); + } + } + elem.className = value ? jQuery.trim( cur ) : ""; + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.match( core_rnotwhite ) || []; + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space separated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + // Toggle whole class name + } else if ( type === core_strundefined || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // If the element has a class name or if we're passed "false", + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var ret, hooks, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var val, + self = jQuery(this); + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, option, + options = elem.options, + index = elem.selectedIndex, + one = elem.type === "select-one" || index < 0, + values = one ? null : [], + max = one ? index + 1 : options.length, + i = index < 0 ? + max : + one ? index : 0; + + // Loop through all the selected options + for ( ; i < max; i++ ) { + option = options[ i ]; + + // oldIE doesn't update selected after form reset (#2551) + if ( ( option.selected || i === index ) && + // Don't return options that are disabled or in a disabled optgroup + ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && + ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attr: function( elem, name, value ) { + var hooks, notxml, ret, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === core_strundefined ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + + } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, value + "" ); + return value; + } + + } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + // In IE9+, Flash objects don't have .getAttribute (#12945) + // Support: IE9+ + if ( typeof elem.getAttribute !== core_strundefined ) { + ret = elem.getAttribute( name ); + } + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var name, propName, + i = 0, + attrNames = value && value.match( core_rnotwhite ); + + if ( attrNames && elem.nodeType === 1 ) { + while ( (name = attrNames[i++]) ) { + propName = jQuery.propFix[ name ] || name; + + // Boolean attributes get special treatment (#10870) + if ( rboolean.test( name ) ) { + // Set corresponding property to false for boolean attributes + // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8 + if ( !getSetAttribute && ruseDefault.test( name ) ) { + elem[ jQuery.camelCase( "default-" + name ) ] = + elem[ propName ] = false; + } else { + elem[ propName ] = false; + } + + // See #9699 for explanation of this approach (setting first, then removal) + } else { + jQuery.attr( elem, name, "" ); + } + + elem.removeAttribute( getSetAttribute ? name : propName ); + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to default in case type is set after value during creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + var + // Use .prop to determine if this attribute is understood as boolean + prop = jQuery.prop( elem, name ), + + // Fetch it accordingly + attr = typeof prop === "boolean" && elem.getAttribute( name ), + detail = typeof prop === "boolean" ? + + getSetInput && getSetAttribute ? + attr != null : + // oldIE fabricates an empty string for missing boolean attributes + // and conflates checked/selected into attroperties + ruseDefault.test( name ) ? + elem[ jQuery.camelCase( "default-" + name ) ] : + !!attr : + + // fetch an attribute node for properties not recognized as boolean + elem.getAttributeNode( name ); + + return detail && detail.value !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { + // IE<8 needs the *property* name + elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); + + // Use defaultChecked and defaultSelected for oldIE + } else { + elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; + } + + return name; + } +}; + +// fix oldIE value attroperty +if ( !getSetInput || !getSetAttribute ) { + jQuery.attrHooks.value = { + get: function( elem, name ) { + var ret = elem.getAttributeNode( name ); + return jQuery.nodeName( elem, "input" ) ? + + // Ignore the value *property* by using defaultValue + elem.defaultValue : + + ret && ret.specified ? ret.value : undefined; + }, + set: function( elem, value, name ) { + if ( jQuery.nodeName( elem, "input" ) ) { + // Does not return so that setAttribute is also used + elem.defaultValue = value; + } else { + // Use nodeHook if defined (#1954); otherwise setAttribute is fine + return nodeHook && nodeHook.set( elem, value, name ); + } + } + }; +} + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret = elem.getAttributeNode( name ); + return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ? + ret.value : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + elem.setAttributeNode( + (ret = elem.ownerDocument.createAttribute( name )) + ); + } + + ret.value = value += ""; + + // Break association with cloned elements by also using setAttribute (#9646) + return name === "value" || value === elem.getAttribute( name ) ? + value : + undefined; + } + }; + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + nodeHook.set( elem, value === "" ? false : value, name ); + } + }; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); +} + + +// Some attributes require a special call on IE +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret == null ? undefined : ret; + } + }); + }); + + // href/src property should get the full normalized URL (#10299/#12915) + jQuery.each([ "href", "src" ], function( i, name ) { + jQuery.propHooks[ name ] = { + get: function( elem ) { + return elem.getAttribute( name, 4 ); + } + }; + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Note: IE uppercases css property names, but if we were to .toLowerCase() + // .cssText, that would destroy case senstitivity in URL's, like in "background" + return elem.style.cssText || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = value + "" ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); +var rformElems = /^(?:input|select|textarea)$/i, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + var tmp, events, t, handleObjIn, + special, eventHandle, handleObj, + handlers, type, namespaces, origType, + elemData = jQuery._data( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = ( types || "" ).match( core_rnotwhite ) || [""]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + var j, handleObj, tmp, + origCount, t, events, + special, handlers, type, + namespaces, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( core_rnotwhite ) || [""]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery._removeData( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + var handle, ontype, cur, + bubbleType, special, tmp, i, + eventPath = [ elem || document ], + type = core_hasOwn.call( event, "type" ) ? event.type : event, + namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + event.isTrigger = true; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + try { + elem[ type ](); + } catch ( e ) { + // IE<9 dies on focus/blur to hidden element (#1486,#12518) + // only reproducible on winXP IE8 native, not IE9 in IE8 mode + } + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, ret, handleObj, matched, j, + handlerQueue = [], + args = core_slice.call( arguments ), + handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var sel, handleObj, matches, i, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur != this; cur = cur.parentNode || this ) { + + // Don't check non-elements (#13208) + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: IE<9 + // Fix target property (#1925) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Support: Chrome 23+, Safari? + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Support: IE<9 + // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) + event.metaKey = !!event.metaKey; + + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var body, eventDoc, doc, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { + this.click(); + return false; + } + } + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== document.activeElement && this.focus ) { + try { + this.focus(); + return false; + } catch ( e ) { + // Support: IE<9 + // If we error on focus to hidden element (#1486, #12518), + // let .trigger() run the handlers + } + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === document.activeElement && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + + beforeunload: { + postDispatch: function( event ) { + + // Even when returnValue equals to undefined Firefox will still show alert + if ( event.result !== undefined ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + var name = "on" + type; + + if ( elem.detachEvent ) { + + // #8545, #7054, preventing memory leaks for custom events in IE6-8 + // detachEvent needed property on element, by name of that event, to properly expose it to GC + if ( typeof elem[ name ] === core_strundefined ) { + elem[ name ] = null; + } + + elem.detachEvent( name, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + if ( !e ) { + return; + } + + // If preventDefault exists, run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // Support: IE + // Otherwise set the returnValue property of the original event to false + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + if ( !e ) { + return; + } + // If stopPropagation exists, run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + + // Support: IE + // Set the cancelBubble property of the original event to true + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !jQuery._data( form, "submitBubbles" ) ) { + jQuery.event.add( form, "submit._submit", function( event ) { + event._submit_bubble = true; + }); + jQuery._data( form, "submitBubbles", true ); + } + }); + // return undefined since we don't need an event listener + }, + + postDispatch: function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( event._submit_bubble ) { + delete event._submit_bubble; + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + } + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + } + // Allow triggered, simulated change events (#11500) + jQuery.event.simulate( "change", this, event, true ); + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + jQuery._data( elem, "changeBubbles", true ); + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return !rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var type, origFn; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); +/*! + * Sizzle CSS Selector Engine + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license + * http://sizzlejs.com/ + */ +(function( window, undefined ) { + +var i, + cachedruns, + Expr, + getText, + isXML, + compile, + hasDuplicate, + outermostContext, + + // Local document vars + setDocument, + document, + docElem, + documentIsXML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + sortOrder, + + // Instance-specific data + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + support = {}, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + + // General-purpose constants + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, + + // Array methods + arr = [], + pop = arr.pop, + push = arr.push, + slice = arr.slice, + // Use a stripped-down indexOf if we can't use a native one + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, + + + // Regular expressions + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + operators = "([*^$|!~]?=)", + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", + + // Prefer arguments quoted, + // then not containing pseudos/brackets, + // then attribute selectors/non-parenthetical expressions, + // then anything else + // These preferences are here to reduce the number of selectors + // needing tokenize in the PSEUDO preFilter + pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rsibling = /[\x20\t\r\n\f]*[+~]/, + + rnative = /^[^{]+\{\s*\[native code/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rescape = /'|\\/g, + rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, + + // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g, + funescape = function( _, escaped ) { + var high = "0x" + escaped - 0x10000; + // NaN means non-codepoint + return high !== high ? + escaped : + // BMP codepoint + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; + +// Use a stripped-down slice if we can't use a native one +try { + slice.call( preferredDoc.documentElement.childNodes, 0 )[0].nodeType; +} catch ( e ) { + slice = function( i ) { + var elem, + results = []; + while ( (elem = this[i++]) ) { + results.push( elem ); + } + return results; + }; +} + +/** + * For feature detection + * @param {Function} fn The function to test for native support + */ +function isNative( fn ) { + return rnative.test( fn + "" ); +} + +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var cache, + keys = []; + + return (cache = function( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key += " " ) > Expr.cacheLength ) { + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return (cache[ key ] = value); + }); +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); + + try { + return fn( div ); + } catch (e) { + return false; + } finally { + // release memory in IE + div = null; + } +} + +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + // QSA vars + i, groups, old, nid, newContext, newSelector; + + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } + + context = context || document; + results = results || []; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } + + if ( !documentIsXML && !seed ) { + + // Shortcuts + if ( (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) { + push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); + return results; + } + } + + // QSA path + if ( support.qsa && !rbuggyQSA.test(selector) ) { + old = true; + nid = expando; + newContext = context; + newSelector = nodeType === 9 && selector; + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); + } + newContext = rsibling.test( selector ) && context.parentNode || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, slice.call( newContext.querySelectorAll( + newSelector + ), 0 ) ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Detect xml + * @param {Element|Object} elem An element or a document + */ +isXML = Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var doc = node ? node.ownerDocument || node : preferredDoc; + + // If no document and documentElement is available, return + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Set our document + document = doc; + docElem = doc.documentElement; + + // Support tests + documentIsXML = isXML( doc ); + + // Check if getElementsByTagName("*") returns only elements + support.tagNameNoComments = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); + + // Check if attributes should be retrieved by attribute nodes + support.attributes = assert(function( div ) { + div.innerHTML = ""; + var type = typeof div.lastChild.getAttribute("multiple"); + // IE8 returns a string for some attributes even when not present + return type !== "boolean" && type !== "string"; + }); + + // Check if getElementsByClassName can be trusted + support.getByClassName = assert(function( div ) { + // Opera can't find a second classname (in 9.6) + div.innerHTML = ""; + if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { + return false; + } + + // Safari 3.2 caches class attributes and doesn't catch changes + div.lastChild.className = "e"; + return div.getElementsByClassName("e").length === 2; + }); + + // Check if getElementById returns elements by name + // Check if getElementsByName privileges form controls or returns elements by ID + support.getByName = assert(function( div ) { + // Inject content + div.id = expando + 0; + div.innerHTML = "
          "; + docElem.insertBefore( div, docElem.firstChild ); + + // Test + var pass = doc.getElementsByName && + // buggy browsers will return fewer than the correct 2 + doc.getElementsByName( expando ).length === 2 + + // buggy browsers will return more than the correct 0 + doc.getElementsByName( expando + 0 ).length; + support.getIdNotName = !doc.getElementById( expando ); + + // Cleanup + docElem.removeChild( div ); + + return pass; + }); + + // IE6/7 return modified attributes + Expr.attrHandle = assert(function( div ) { + div.innerHTML = ""; + return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && + div.firstChild.getAttribute("href") === "#"; + }) ? + {} : + { + "href": function( elem ) { + return elem.getAttribute( "href", 2 ); + }, + "type": function( elem ) { + return elem.getAttribute("type"); + } + }; + + // ID find and filter + if ( support.getIdNotName ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && !documentIsXML ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && !documentIsXML ) { + var m = context.getElementById( id ); + + return m ? + m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? + [m] : + undefined : + []; + } + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } + + // Tag + Expr.find["TAG"] = support.tagNameNoComments ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Name + Expr.find["NAME"] = support.getByName && function( tag, context ) { + if ( typeof context.getElementsByName !== strundefined ) { + return context.getElementsByName( name ); + } + }; + + // Class + Expr.find["CLASS"] = support.getByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) { + return context.getElementsByClassName( className ); + } + }; + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21), + // no need to also add to buggyMatches since matches checks buggyQSA + // A support test would require too much code (would include document ready) + rbuggyQSA = [ ":focus" ]; + + if ( (support.qsa = isNative(doc.querySelectorAll)) ) { + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explictly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = ""; + + // IE8 - Some boolean attributes are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + + // Opera 10-12/IE8 - ^= $= *= and empty values + // Should not select anything + div.innerHTML = ""; + if ( div.querySelectorAll("[i^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector || + docElem.mozMatchesSelector || + docElem.webkitMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = new RegExp( rbuggyMatches.join("|") ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + // Document order sorting + sortOrder = docElem.compareDocumentPosition ? + function( a, b ) { + var compare; + + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) { + if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) { + if ( a === doc || contains( preferredDoc, a ) ) { + return -1; + } + if ( b === doc || contains( preferredDoc, b ) ) { + return 1; + } + return 0; + } + return compare & 4 ? -1 : 1; + } + + return a.compareDocumentPosition ? -1 : 1; + } : + function( a, b ) { + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Parentless nodes are either documents or disconnected + } else if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + // Always assume the presence of duplicates if sort doesn't + // pass them to our comparison function (as in Google Chrome). + hasDuplicate = false; + [0, 0].sort( sortOrder ); + support.detectDuplicates = hasDuplicate; + + return document; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + // rbuggyQSA always contains :focus, so no need for an existence check + if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) { + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, document, null, [elem] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + var val; + + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + if ( !documentIsXML ) { + name = name.toLowerCase(); + } + if ( (val = Expr.attrHandle[ name ]) ) { + return val( elem ); + } + if ( documentIsXML || support.attributes ) { + return elem.getAttribute( name ); + } + return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ? + name : + val && val.specified ? val.value : null; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +// Document sorting and removing duplicates +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + i = 1, + j = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( ; (elem = results[i]); i++ ) { + if ( elem === results[ i - 1 ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + return results; +}; + +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE ); + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +// Returns a function to use in pseudos for input types +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +// Returns a function to use in pseudos for buttons +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +// Returns a function to use in pseudos for positionals +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + for ( ; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (see #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[4] ) { + match[2] = match[4]; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeName ) { + if ( nodeName === "*" ) { + return function() { return true; }; + } + + nodeName = nodeName.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifider + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsXML ? + elem.getAttribute("xml:lang") || elem.getAttribute("lang") : + elem.lang) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), + // not comment, processing instructions, or others + // Thanks to Diego Perini for the nodeName shortcut + // Greater than "@" means alpha characters (specifically not starting with "#" or "?") + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( tokens = [] ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push( { + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + } ); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push( { + value: matched, + type: type, + matches: match + } ); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var data, cache, outerCache, + dirkey = dirruns + " " + doneName; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { + if ( (data = cache[1]) === true || data === cachedruns ) { + return data === true; + } + } else { + cache = outerCache[ dir ] = [ dirkey ]; + cache[1] = matcher( elem, context, xml ) || cachedruns; + if ( cache[1] === true ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + // A counter to specify which element is currently being matched + var matcherCachedRuns = 0, + bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, expandContext ) { + var elem, j, matcher, + setMatched = [], + matchedCount = 0, + i = "0", + unmatched = seed && [], + outermost = expandContext != null, + contextBackup = outermostContext, + // We must always have either seed elements or context + elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); + + if ( outermost ) { + outermostContext = context !== document && context; + cachedruns = matcherCachedRuns; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + for ( ; (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + cachedruns = ++matcherCachedRuns; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + } + return cached; +}; + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + match = tokenize( selector ); + + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + context.nodeType === 9 && !documentIsXML && + Expr.relative[ tokens[1].type ] ) { + + context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0]; + if ( !context ) { + return results; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && context.parentNode || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, slice.call( seed, 0 ) ); + return results; + } + + break; + } + } + } + } + } + + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + documentIsXML, + results, + rsibling.test( selector ) + ); + return results; +} + +// Deprecated +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Easy API for creating new setFilters +function setFilters() {} +Expr.filters = setFilters.prototype = Expr.pseudos; +Expr.setFilters = new setFilters(); + +// Initialize with the default document +setDocument(); + +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})( window ); +var runtil = /Until$/, + rparentsprev = /^(?:parents|prev(?:Until|All))/, + isSimple = /^.[^:#\[\.,]*$/, + rneedsContext = jQuery.expr.match.needsContext, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var i, ret, self, + len = this.length; + + if ( typeof selector !== "string" ) { + self = this; + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + ret = []; + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, this[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = ( this.selector ? this.selector + " " : "" ) + selector; + return ret; + }, + + has: function( target ) { + var i, + targets = jQuery( target, this ), + len = targets.length; + + return this.filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false) ); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true) ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + rneedsContext.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + ret = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + cur = this[i]; + + while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + } + cur = cur.parentNode; + } + } + + return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( jQuery.unique(all) ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +jQuery.fn.andSelf = jQuery.fn.addBack; + +function sibling( cur, dir ) { + do { + cur = cur[ dir ]; + } while ( cur && cur.nodeType !== 1 ); + + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( this.length > 1 && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, + rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rtbody = /\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + option: [ 1, "" ], + legend: [ 1, "
          ", "
          " ], + area: [ 1, "", "" ], + param: [ 1, "", "" ], + thead: [ 1, "", "
          " ], + tr: [ 2, "", "
          " ], + col: [ 2, "", "
          " ], + td: [ 3, "", "
          " ], + + // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, + // unless wrapped in a div with non-breaking characters in front of it. + _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
          ", "
          " ] + }, + safeFragment = createSafeFragment( document ), + fragmentDiv = safeFragment.appendChild( document.createElement("div") ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +jQuery.fn.extend({ + text: function( value ) { + return jQuery.access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); + }, null, value, arguments.length ); + }, + + wrapAll: function( html ) { + if ( jQuery.isFunction( html ) ) { + return this.each(function(i) { + jQuery(this).wrapAll( html.call(this, i) ); + }); + } + + if ( this[0] ) { + // The elements to wrap the target around + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); + + if ( this[0].parentNode ) { + wrap.insertBefore( this[0] ); + } + + wrap.map(function() { + var elem = this; + + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { + elem = elem.firstChild; + } + + return elem; + }).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( jQuery.isFunction( html ) ) { + return this.each(function(i) { + jQuery(this).wrapInner( html.call(this, i) ); + }); + } + + return this.each(function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + }); + }, + + wrap: function( html ) { + var isFunction = jQuery.isFunction( html ); + + return this.each(function(i) { + jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); + }); + }, + + unwrap: function() { + return this.parent().each(function() { + if ( !jQuery.nodeName( this, "body" ) ) { + jQuery( this ).replaceWith( this.childNodes ); + } + }).end(); + }, + + append: function() { + return this.domManip(arguments, true, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip(arguments, true, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.insertBefore( elem, this.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, false, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, false, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + // keepData is for internal use only--do not document + remove: function( selector, keepData ) { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + } + + // Remove any remaining nodes + while ( elem.firstChild ) { + elem.removeChild( elem.firstChild ); + } + + // If this is a select, ensure that it displays empty (#12336) + // Support: IE<9 + if ( elem.options && jQuery.nodeName( elem, "select" ) ) { + elem.options.length = 0; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function () { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return jQuery.access( this, function( value ) { + var elem = this[0] || {}, + i = 0, + l = this.length; + + if ( value === undefined ) { + return elem.nodeType === 1 ? + elem.innerHTML.replace( rinlinejQuery, "" ) : + undefined; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && + ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && + !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for (; i < l; i++ ) { + // Remove element nodes and prevent memory leaks + elem = this[i] || {}; + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch(e) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function( value ) { + var isFunc = jQuery.isFunction( value ); + + // Make sure that the elements are removed from the DOM before they are inserted + // this can help fix replacing a parent with child elements + if ( !isFunc && typeof value !== "string" ) { + value = jQuery( value ).not( this ).detach(); + } + + return this.domManip( [ value ], true, function( elem ) { + var next = this.nextSibling, + parent = this.parentNode; + + if ( parent ) { + jQuery( this ).remove(); + parent.insertBefore( elem, next ); + } + }); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, table, callback ) { + + // Flatten any nested arrays + args = core_concat.apply( [], args ); + + var first, node, hasScripts, + scripts, doc, fragment, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[0], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[0] = value.call( this, index, table ? self.html() : undefined ); + } + self.domManip( args, table, callback ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + table = table && jQuery.nodeName( first, "tr" ); + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( + table && jQuery.nodeName( this[i], "table" ) ? + findOrAppend( this[i], "tbody" ) : + this[i], + node, + i + ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Hope ajax is available... + jQuery.ajax({ + url: node.src, + type: "GET", + dataType: "script", + async: false, + global: false, + "throws": true + }); + } else { + jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); + } + } + } + } + + // Fix #11809: Avoid leaking memory + fragment = first = null; + } + } + + return this; + } +}); + +function findOrAppend( elem, tag ) { + return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + var attr = elem.getAttributeNode("type"); + elem.type = ( attr && attr.specified ) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + if ( match ) { + elem.type = match[1]; + } else { + elem.removeAttribute("type"); + } + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var elem, + i = 0; + for ( ; (elem = elems[i]) != null; i++ ) { + jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); + } +} + +function cloneCopyEvent( src, dest ) { + + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { + return; + } + + var type, i, l, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; + + if ( events ) { + delete curData.handle; + curData.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); + } +} + +function fixCloneNodeIssues( src, dest ) { + var nodeName, e, data; + + // We do not need to do anything for non-Elements + if ( dest.nodeType !== 1 ) { + return; + } + + nodeName = dest.nodeName.toLowerCase(); + + // IE6-8 copies events bound via attachEvent when using cloneNode. + if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) { + data = jQuery._data( dest ); + + for ( e in data.events ) { + jQuery.removeEvent( dest, e, data.handle ); + } + + // Event data gets referenced instead of copied if the expando gets copied too + dest.removeAttribute( jQuery.expando ); + } + + // IE blanks contents when cloning scripts, and tries to evaluate newly-set text + if ( nodeName === "script" && dest.text !== src.text ) { + disableScript( dest ).text = src.text; + restoreScript( dest ); + + // IE6-10 improperly clones children of object elements using classid. + // IE10 throws NoModificationAllowedError if parent is null, #12132. + } else if ( nodeName === "object" ) { + if ( dest.parentNode ) { + dest.outerHTML = src.outerHTML; + } + + // This path appears unavoidable for IE9. When cloning an object + // element in IE9, the outerHTML strategy above is not sufficient. + // If the src has innerHTML and the destination does not, + // copy the src.innerHTML into the dest.innerHTML. #10324 + if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { + dest.innerHTML = src.innerHTML; + } + + } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) { + // IE6-8 fails to persist the checked state of a cloned checkbox + // or radio button. Worse, IE6-7 fail to give the cloned element + // a checked appearance if the defaultChecked value isn't also set + + dest.defaultChecked = dest.checked = src.checked; + + // IE6-7 get confused and end up setting the value of a cloned + // checkbox/radio button to an empty string instead of "on" + if ( dest.value !== src.value ) { + dest.value = src.value; + } + + // IE6-8 fails to return the selected option to the default selected + // state when cloning options + } else if ( nodeName === "option" ) { + dest.defaultSelected = dest.selected = src.defaultSelected; + + // IE6-8 fails to set the defaultValue to the correct value when + // cloning other types of input fields + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + i = 0, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone(true); + jQuery( insert[i] )[ original ]( elems ); + + // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() + core_push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + +function getAll( context, tag ) { + var elems, elem, + i = 0, + found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) : + typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) : + undefined; + + if ( !found ) { + for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { + if ( !tag || jQuery.nodeName( elem, tag ) ) { + found.push( elem ); + } else { + jQuery.merge( found, getAll( elem, tag ) ); + } + } + } + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], found ) : + found; +} + +// Used in buildFragment, fixes the defaultChecked property +function fixDefaultChecked( elem ) { + if ( manipulation_rcheckableType.test( elem.type ) ) { + elem.defaultChecked = elem.checked; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var destElements, node, clone, i, srcElements, + inPage = jQuery.contains( elem.ownerDocument, elem ); + + if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { + clone = elem.cloneNode( true ); + + // IE<=8 does not properly clone detached, unknown element nodes + } else { + fragmentDiv.innerHTML = elem.outerHTML; + fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); + } + + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + // Fix all IE cloning issues + for ( i = 0; (node = srcElements[i]) != null; ++i ) { + // Ensure that the destination node is not null; Fixes #9587 + if ( destElements[i] ) { + fixCloneNodeIssues( node, destElements[i] ); + } + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0; (node = srcElements[i]) != null; i++ ) { + cloneCopyEvent( node, destElements[i] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + destElements = srcElements = node = null; + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var j, elem, contains, + tmp, tag, tbody, wrap, + l = elems.length, + + // Ensure a safe fragment + safe = createSafeFragment( context ), + + nodes = [], + i = 0; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || safe.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + + tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; + + // Descend through wrappers to the right content + j = wrap[0]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Manually add leading whitespace removed by IE + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { + nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); + } + + // Remove IE's autoinserted from table fragments + if ( !jQuery.support.tbody ) { + + // String was a , *may* have spurious + elem = tag === "table" && !rtbody.test( elem ) ? + tmp.firstChild : + + // String was a bare or + wrap[1] === "
          " && !rtbody.test( elem ) ? + tmp : + 0; + + j = elem && elem.childNodes.length; + while ( j-- ) { + if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { + elem.removeChild( tbody ); + } + } + } + + jQuery.merge( nodes, tmp.childNodes ); + + // Fix #12392 for WebKit and IE > 9 + tmp.textContent = ""; + + // Fix #12392 for oldIE + while ( tmp.firstChild ) { + tmp.removeChild( tmp.firstChild ); + } + + // Remember the top-level container for proper cleanup + tmp = safe.lastChild; + } + } + } + + // Fix #11356: Clear elements from fragment + if ( tmp ) { + safe.removeChild( tmp ); + } + + // Reset defaultChecked for any radios and checkboxes + // about to be appended to the DOM in IE 6/7 (#8060) + if ( !jQuery.support.appendChecked ) { + jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); + } + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( safe.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + tmp = null; + + return safe; + }, + + cleanData: function( elems, /* internal */ acceptData ) { + var elem, type, id, data, + i = 0, + internalKey = jQuery.expando, + cache = jQuery.cache, + deleteExpando = jQuery.support.deleteExpando, + special = jQuery.event.special; + + for ( ; (elem = elems[i]) != null; i++ ) { + + if ( acceptData || jQuery.acceptData( elem ) ) { + + id = elem[ internalKey ]; + data = id && cache[ id ]; + + if ( data ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Remove cache only if it was not already removed by jQuery.event.remove + if ( cache[ id ] ) { + + delete cache[ id ]; + + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( deleteExpando ) { + delete elem[ internalKey ]; + + } else if ( typeof elem.removeAttribute !== core_strundefined ) { + elem.removeAttribute( internalKey ); + + } else { + elem[ internalKey ] = null; + } + + core_deletedIds.push( id ); + } + } + } + } + } +}); +var iframe, getStyles, curCSS, + ralpha = /alpha\([^)]*\)/i, + ropacity = /opacity\s*=\s*([^)]*)/, + rposition = /^(top|right|bottom|left)$/, + // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" + // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rmargin = /^margin/, + rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), + rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), + rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), + elemdisplay = { BODY: "block" }, + + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: 0, + fontWeight: 400 + }, + + cssExpand = [ "Top", "Right", "Bottom", "Left" ], + cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; + +// return a css property mapped to a potentially vendor prefixed property +function vendorPropName( style, name ) { + + // shortcut for names that are not vendor prefixed + if ( name in style ) { + return name; + } + + // check for vendor prefixed names + var capName = name.charAt(0).toUpperCase() + name.slice(1), + origName = name, + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in style ) { + return name; + } + } + + return origName; +} + +function isHidden( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); +} + +function showHide( elements, show ) { + var display, elem, hidden, + values = [], + index = 0, + length = elements.length; + + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + values[ index ] = jQuery._data( elem, "olddisplay" ); + display = elem.style.display; + if ( show ) { + // Reset the inline display of this element to learn if it is + // being hidden by cascaded rules or not + if ( !values[ index ] && display === "none" ) { + elem.style.display = ""; + } + + // Set elements which have been overridden with display: none + // in a stylesheet to whatever the default browser style is + // for such an element + if ( elem.style.display === "" && isHidden( elem ) ) { + values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); + } + } else { + + if ( !values[ index ] ) { + hidden = isHidden( elem ); + + if ( display && display !== "none" || !hidden ) { + jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); + } + } + } + } + + // Set the display of most of the elements in a second loop + // to avoid the constant reflow + for ( index = 0; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + if ( !show || elem.style.display === "none" || elem.style.display === "" ) { + elem.style.display = show ? values[ index ] || "" : "none"; + } + } + + return elements; +} + +jQuery.fn.extend({ + css: function( name, value ) { + return jQuery.access( this, function( elem, name, value ) { + var len, styles, + map = {}, + i = 0; + + if ( jQuery.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + }, + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + var bool = typeof state === "boolean"; + + return this.each(function() { + if ( bool ? state : isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + }); + } +}); + +jQuery.extend({ + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + } + } + } + }, + + // Exclude the following css properties to add px + cssNumber: { + "columnCount": true, + "fillOpacity": true, + "fontWeight": true, + "lineHeight": true, + "opacity": true, + "orphans": true, + "widows": true, + "zIndex": true, + "zoom": true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: { + // normalize float css property + "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" + }, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = jQuery.camelCase( name ), + style = elem.style; + + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // convert relative number strings (+= or -=) to relative numbers. #7345 + if ( type === "string" && (ret = rrelNum.exec( value )) ) { + value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); + // Fixes bug #9237 + type = "number"; + } + + // Make sure that NaN and null values aren't set. See: #7116 + if ( value == null || type === "number" && isNaN( value ) ) { + return; + } + + // If a number was passed in, add 'px' to the (except for certain CSS properties) + if ( type === "number" && !jQuery.cssNumber[ origName ] ) { + value += "px"; + } + + // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, + // but it would mean to define eight (for every problematic property) identical functions + if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { + style[ name ] = "inherit"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { + + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided + // Fixes bug #5509 + try { + style[ name ] = value; + } catch(e) {} + } + + } else { + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, extra, styles ) { + var num, val, hooks, + origName = jQuery.camelCase( name ); + + // Make sure that we're working with the right name + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + //convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Return, converting to number if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; + } + return val; + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback, args ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.apply( elem, args || [] ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; + } +}); + +// NOTE: we've included the "window" in window.getComputedStyle +// because jsdom on node.js will break without it. +if ( window.getComputedStyle ) { + getStyles = function( elem ) { + return window.getComputedStyle( elem, null ); + }; + + curCSS = function( elem, name, _computed ) { + var width, minWidth, maxWidth, + computed = _computed || getStyles( elem ), + + // getPropertyValue is only needed for .css('filter') in IE9, see #12537 + ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, + style = elem.style; + + if ( computed ) { + + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right + // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels + // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret; + }; +} else if ( document.documentElement.currentStyle ) { + getStyles = function( elem ) { + return elem.currentStyle; + }; + + curCSS = function( elem, name, _computed ) { + var left, rs, rsLeft, + computed = _computed || getStyles( elem ), + ret = computed ? computed[ name ] : undefined, + style = elem.style; + + // Avoid setting ret to empty string here + // so we don't default to auto + if ( ret == null && style && style[ name ] ) { + ret = style[ name ]; + } + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + // but not position css attributes, as those are proportional to the parent element instead + // and we can't measure the parent instead because it might trigger a "stacking dolls" problem + if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { + + // Remember the original values + left = style.left; + rs = elem.runtimeStyle; + rsLeft = rs && rs.left; + + // Put in the new values to get a computed value out + if ( rsLeft ) { + rs.left = elem.currentStyle.left; + } + style.left = name === "fontSize" ? "1em" : ret; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + if ( rsLeft ) { + rs.left = rsLeft; + } + } + + return ret === "" ? "auto" : ret; + }; +} + +function setPositiveNumber( elem, value, subtract ) { + var matches = rnumsplit.exec( value ); + return matches ? + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : + value; +} + +function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { + var i = extra === ( isBorderBox ? "border" : "content" ) ? + // If we already have the right measurement, avoid augmentation + 4 : + // Otherwise initialize for horizontal or vertical properties + name === "width" ? 1 : 0, + + val = 0; + + for ( ; i < 4; i += 2 ) { + // both box models exclude margin, so add it if we want it + if ( extra === "margin" ) { + val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); + } + + if ( isBorderBox ) { + // border-box includes padding, so remove it if we want content + if ( extra === "content" ) { + val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // at this point, extra isn't border nor margin, so remove border + if ( extra !== "margin" ) { + val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } else { + // at this point, extra isn't content, so add padding + val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // at this point, extra isn't content nor padding, so add border + if ( extra !== "padding" ) { + val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + return val; +} + +function getWidthOrHeight( elem, name, extra ) { + + // Start with offset property, which is equivalent to the border-box value + var valueIsBorderBox = true, + val = name === "width" ? elem.offsetWidth : elem.offsetHeight, + styles = getStyles( elem ), + isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // some non-html elements return undefined for offsetWidth, so check for null/undefined + // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 + // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 + if ( val <= 0 || val == null ) { + // Fall back to computed then uncomputed css if necessary + val = curCSS( elem, name, styles ); + if ( val < 0 || val == null ) { + val = elem.style[ name ]; + } + + // Computed unit is not pixels. Stop here and return. + if ( rnumnonpx.test(val) ) { + return val; + } + + // we need the check for style in case a browser which returns unreliable values + // for getComputedStyle silently falls back to the reliable elem.style + valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); + + // Normalize "", auto, and prepare for extra + val = parseFloat( val ) || 0; + } + + // use the active box-sizing model to add/subtract irrelevant styles + return ( val + + augmentWidthOrHeight( + elem, + name, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles + ) + ) + "px"; +} + +// Try to determine the default display value of an element +function css_defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + // Use the already-created iframe if possible + iframe = ( iframe || + jQuery(" \ + \ + Powered by JSLitmus \ + '; + + /** + * The public API for creating and running tests + */ + window.JSLitmus = { + /** The list of all tests that have been registered with JSLitmus.test */ + _tests: [], + /** The queue of tests that need to be run */ + _queue: [], + + /** + * The parsed query parameters the current page URL. This is provided as a + * convenience for test functions - it's not used by JSLitmus proper + */ + params: {}, + + /** + * Initialize + */ + _init: function() { + // Parse query params into JSLitmus.params[] hash + var match = (location + '').match(/([^?#]*)(#.*)?$/); + if (match) { + var pairs = match[1].split('&'); + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i].split('='); + if (pair.length > 1) { + var key = pair.shift(); + var value = pair.length > 1 ? pair.join('=') : pair[0]; + this.params[key] = value; + } + } + } + + // Write out the stylesheet. We have to do this here because IE + // doesn't honor sheets written after the document has loaded. + document.write(STYLESHEET); + + // Setup the rest of the UI once the document is loaded + if (window.addEventListener) { + window.addEventListener('load', this._setup, false); + } else if (document.addEventListener) { + document.addEventListener('load', this._setup, false); + } else if (window.attachEvent) { + window.attachEvent('onload', this._setup); + } + + return this; + }, + + /** + * Set up the UI + */ + _setup: function() { + var el = jsl.$('jslitmus_container'); + if (!el) document.body.appendChild(el = document.createElement('div')); + + el.innerHTML = MARKUP; + + // Render the UI for all our tests + for (var i=0; i < JSLitmus._tests.length; i++) + JSLitmus.renderTest(JSLitmus._tests[i]); + }, + + /** + * (Re)render all the test results + */ + renderAll: function() { + for (var i = 0; i < JSLitmus._tests.length; i++) + JSLitmus.renderTest(JSLitmus._tests[i]); + JSLitmus.renderChart(); + }, + + /** + * (Re)render the chart graphics + */ + renderChart: function() { + var url = JSLitmus.chartUrl(); + jsl.$('chart_link').href = url; + jsl.$('chart_image').src = url; + jsl.$('chart').style.display = ''; + + // Update the tiny URL + jsl.$('tiny_url').src = 'http://tinyurl.com/api-create.php?url='+escape(url); + }, + + /** + * (Re)render the results for a specific test + */ + renderTest: function(test) { + // Make a new row if needed + if (!test._row) { + var trow = jsl.$('test_row_template'); + if (!trow) return; + + test._row = trow.cloneNode(true); + test._row.style.display = ''; + test._row.id = ''; + test._row.onclick = function() {JSLitmus._queueTest(test);}; + test._row.title = 'Run ' + test.name + ' test'; + trow.parentNode.appendChild(test._row); + test._row.cells[0].innerHTML = test.name; + } + + var cell = test._row.cells[1]; + var cns = [test.loopArg ? 'test_looping' : 'test_nonlooping']; + + if (test.error) { + cns.push('test_error'); + cell.innerHTML = + '
          ' + test.error + '
          ' + + '
          • ' + + jsl.join(test.error, ': ', '
          • ') + + '
          '; + } else { + if (test.running) { + cns.push('test_running'); + cell.innerHTML = 'running'; + } else if (jsl.indexOf(JSLitmus._queue, test) >= 0) { + cns.push('test_pending'); + cell.innerHTML = 'pending'; + } else if (test.count) { + cns.push('test_done'); + var hz = test.getHz(jsl.$('test_normalize').checked); + cell.innerHTML = hz != Infinity ? hz : '∞'; + } else { + cell.innerHTML = 'ready'; + } + } + cell.className = cns.join(' '); + }, + + /** + * Create a new test + */ + test: function(name, f) { + // Create the Test object + var test = new Test(name, f); + JSLitmus._tests.push(test); + + // Re-render if the test state changes + test.onChange = JSLitmus.renderTest; + + // Run the next test if this one finished + test.onStop = function(test) { + if (JSLitmus.onTestFinish) JSLitmus.onTestFinish(test); + JSLitmus.currentTest = null; + JSLitmus._nextTest(); + }; + + // Render the new test + this.renderTest(test); + }, + + /** + * Add all tests to the run queue + */ + runAll: function(e) { + e = e || window.event; + var reverse = e && e.shiftKey, len = JSLitmus._tests.length; + for (var i = 0; i < len; i++) { + JSLitmus._queueTest(JSLitmus._tests[!reverse ? i : (len - i - 1)]); + } + }, + + /** + * Remove all tests from the run queue. The current test has to finish on + * it's own though + */ + stop: function() { + while (JSLitmus._queue.length) { + var test = JSLitmus._queue.shift(); + JSLitmus.renderTest(test); + } + }, + + /** + * Run the next test in the run queue + */ + _nextTest: function() { + if (!JSLitmus.currentTest) { + var test = JSLitmus._queue.shift(); + if (test) { + jsl.$('stop_button').disabled = false; + JSLitmus.currentTest = test; + test.run(); + JSLitmus.renderTest(test); + if (JSLitmus.onTestStart) JSLitmus.onTestStart(test); + } else { + jsl.$('stop_button').disabled = true; + JSLitmus.renderChart(); + } + } + }, + + /** + * Add a test to the run queue + */ + _queueTest: function(test) { + if (jsl.indexOf(JSLitmus._queue, test) >= 0) return; + JSLitmus._queue.push(test); + JSLitmus.renderTest(test); + JSLitmus._nextTest(); + }, + + /** + * Generate a Google Chart URL that shows the data for all tests + */ + chartUrl: function() { + var n = JSLitmus._tests.length, markers = [], data = []; + var d, min = 0, max = -1e10; + var normalize = jsl.$('test_normalize').checked; + + // Gather test data + for (var i=0; i < JSLitmus._tests.length; i++) { + var test = JSLitmus._tests[i]; + if (test.count) { + var hz = test.getHz(normalize); + var v = hz != Infinity ? hz : 0; + data.push(v); + markers.push('t' + jsl.escape(test.name + '(' + jsl.toLabel(hz)+ ')') + ',000000,0,' + + markers.length + ',10'); + max = Math.max(v, max); + } + } + if (markers.length <= 0) return null; + + // Build chart title + var title = document.getElementsByTagName('title'); + title = (title && title.length) ? title[0].innerHTML : null; + var chart_title = []; + if (title) chart_title.push(title); + chart_title.push('Ops/sec (' + platform + ')'); + + // Build labels + var labels = [jsl.toLabel(min), jsl.toLabel(max)]; + + var w = 250, bw = 15; + var bs = 5; + var h = markers.length*(bw + bs) + 30 + chart_title.length*20; + + var params = { + chtt: escape(chart_title.join('|')), + chts: '000000,10', + cht: 'bhg', // chart type + chd: 't:' + data.join(','), // data set + chds: min + ',' + max, // max/min of data + chxt: 'x', // label axes + chxl: '0:|' + labels.join('|'), // labels + chsp: '0,1', + chm: markers.join('|'), // test names + chbh: [bw, 0, bs].join(','), // bar widths + // chf: 'bg,lg,0,eeeeee,0,eeeeee,.5,ffffff,1', // gradient + chs: w + 'x' + h + }; + return 'http://chart.apis.google.com/chart?' + jsl.join(params, '=', '&'); + } + }; + + JSLitmus._init(); +})(); \ No newline at end of file diff --git a/bower_components/underscore/test/vendor/qunit.css b/bower_components/underscore/test/vendor/qunit.css new file mode 100644 index 0000000..7ba3f9a --- /dev/null +++ b/bower_components/underscore/test/vendor/qunit.css @@ -0,0 +1,244 @@ +/** + * QUnit v1.12.0 - A JavaScript Unit Testing Framework + * + * http://qunitjs.com + * + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699a4; + background-color: #0d3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: normal; + + border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + -webkit-border-top-right-radius: 5px; + -webkit-border-top-left-radius: 5px; +} + +#qunit-header a { + text-decoration: none; + color: #c2ccd1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #fff; +} + +#qunit-testrunner-toolbar label { + display: inline-block; + padding: 0 .5em 0 .1em; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0.5em 0 0.5em 2em; + color: #5E740B; + background-color: #eee; + overflow: hidden; +} + +#qunit-userAgent { + padding: 0.5em 0 0.5em 2.5em; + background-color: #2b81af; + color: #fff; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + +#qunit-modulefilter-container { + float: right; +} + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 0.5em 0.4em 2.5em; + border-bottom: 1px solid #fff; + list-style-position: inside; +} + +#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { + display: none; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li a { + padding: 0.5em; + color: #c2ccd1; + text-decoration: none; +} +#qunit-tests li a:hover, +#qunit-tests li a:focus { + color: #000; +} + +#qunit-tests li .runtime { + float: right; + font-size: smaller; +} + +.qunit-assert-list { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #fff; + + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +.qunit-collapsed { + display: none; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: .2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 .5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #e0f2be; + color: #374e0c; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #ffcaca; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: black; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + padding: 5px; + background-color: #fff; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #3c510c; + background-color: #fff; + border-left: 10px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #fff; + border-left: 10px solid #EE5757; + white-space: pre; +} + +#qunit-tests > li:last-child { + border-radius: 0 0 5px 5px; + -moz-border-radius: 0 0 5px 5px; + -webkit-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; +} + +#qunit-tests .fail { color: #000000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: green; } + +#qunit-banner.qunit-fail { background-color: #EE5757; } + + +/** Result */ + +#qunit-testresult { + padding: 0.5em 0.5em 0.5em 2.5em; + + color: #2b81af; + background-color: #D2E0E6; + + border-bottom: 1px solid white; +} +#qunit-testresult .module-name { + font-weight: bold; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; + width: 1000px; + height: 1000px; +} diff --git a/bower_components/underscore/test/vendor/qunit.js b/bower_components/underscore/test/vendor/qunit.js new file mode 100644 index 0000000..84c7390 --- /dev/null +++ b/bower_components/underscore/test/vendor/qunit.js @@ -0,0 +1,2212 @@ +/** + * QUnit v1.12.0 - A JavaScript Unit Testing Framework + * + * http://qunitjs.com + * + * Copyright 2013 jQuery Foundation and other contributors + * Released under the MIT license. + * https://jquery.org/license/ + */ + +(function( window ) { + +var QUnit, + assert, + config, + onErrorFnPrev, + testId = 0, + fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""), + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + // Keep a local reference to Date (GH-283) + Date = window.Date, + setTimeout = window.setTimeout, + defined = { + setTimeout: typeof window.setTimeout !== "undefined", + sessionStorage: (function() { + var x = "qunit-test-string"; + try { + sessionStorage.setItem( x, x ); + sessionStorage.removeItem( x ); + return true; + } catch( e ) { + return false; + } + }()) + }, + /** + * Provides a normalized error string, correcting an issue + * with IE 7 (and prior) where Error.prototype.toString is + * not properly implemented + * + * Based on http://es5.github.com/#x15.11.4.4 + * + * @param {String|Error} error + * @return {String} error message + */ + errorString = function( error ) { + var name, message, + errorString = error.toString(); + if ( errorString.substring( 0, 7 ) === "[object" ) { + name = error.name ? error.name.toString() : "Error"; + message = error.message ? error.message.toString() : ""; + if ( name && message ) { + return name + ": " + message; + } else if ( name ) { + return name; + } else if ( message ) { + return message; + } else { + return "Error"; + } + } else { + return errorString; + } + }, + /** + * Makes a clone of an object using only Array or Object as base, + * and copies over the own enumerable properties. + * + * @param {Object} obj + * @return {Object} New object with only the own properties (recursively). + */ + objectValues = function( obj ) { + // Grunt 0.3.x uses an older version of jshint that still has jshint/jshint#392. + /*jshint newcap: false */ + var key, val, + vals = QUnit.is( "array", obj ) ? [] : {}; + for ( key in obj ) { + if ( hasOwn.call( obj, key ) ) { + val = obj[key]; + vals[key] = val === Object(val) ? objectValues(val) : val; + } + } + return vals; + }; + +function Test( settings ) { + extend( this, settings ); + this.assertions = []; + this.testNumber = ++Test.count; +} + +Test.count = 0; + +Test.prototype = { + init: function() { + var a, b, li, + tests = id( "qunit-tests" ); + + if ( tests ) { + b = document.createElement( "strong" ); + b.innerHTML = this.nameHtml; + + // `a` initialized at top of scope + a = document.createElement( "a" ); + a.innerHTML = "Rerun"; + a.href = QUnit.url({ testNumber: this.testNumber }); + + li = document.createElement( "li" ); + li.appendChild( b ); + li.appendChild( a ); + li.className = "running"; + li.id = this.id = "qunit-test-output" + testId++; + + tests.appendChild( li ); + } + }, + setup: function() { + if ( + // Emit moduleStart when we're switching from one module to another + this.module !== config.previousModule || + // They could be equal (both undefined) but if the previousModule property doesn't + // yet exist it means this is the first test in a suite that isn't wrapped in a + // module, in which case we'll just emit a moduleStart event for 'undefined'. + // Without this, reporters can get testStart before moduleStart which is a problem. + !hasOwn.call( config, "previousModule" ) + ) { + if ( hasOwn.call( config, "previousModule" ) ) { + runLoggingCallbacks( "moduleDone", QUnit, { + name: config.previousModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + config.previousModule = this.module; + config.moduleStats = { all: 0, bad: 0 }; + runLoggingCallbacks( "moduleStart", QUnit, { + name: this.module + }); + } + + config.current = this; + + this.testEnvironment = extend({ + setup: function() {}, + teardown: function() {} + }, this.moduleTestEnvironment ); + + this.started = +new Date(); + runLoggingCallbacks( "testStart", QUnit, { + name: this.testName, + module: this.module + }); + + /*jshint camelcase:false */ + + + /** + * Expose the current test environment. + * + * @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead. + */ + QUnit.current_testEnvironment = this.testEnvironment; + + /*jshint camelcase:true */ + + if ( !config.pollution ) { + saveGlobal(); + } + if ( config.notrycatch ) { + this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); + return; + } + try { + this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); + } catch( e ) { + QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); + } + }, + run: function() { + config.current = this; + + var running = id( "qunit-testresult" ); + + if ( running ) { + running.innerHTML = "Running:
          " + this.nameHtml; + } + + if ( this.async ) { + QUnit.stop(); + } + + this.callbackStarted = +new Date(); + + if ( config.notrycatch ) { + this.callback.call( this.testEnvironment, QUnit.assert ); + this.callbackRuntime = +new Date() - this.callbackStarted; + return; + } + + try { + this.callback.call( this.testEnvironment, QUnit.assert ); + this.callbackRuntime = +new Date() - this.callbackStarted; + } catch( e ) { + this.callbackRuntime = +new Date() - this.callbackStarted; + + QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); + // else next test will carry the responsibility + saveGlobal(); + + // Restart the tests if they're blocking + if ( config.blocking ) { + QUnit.start(); + } + } + }, + teardown: function() { + config.current = this; + if ( config.notrycatch ) { + if ( typeof this.callbackRuntime === "undefined" ) { + this.callbackRuntime = +new Date() - this.callbackStarted; + } + this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); + return; + } else { + try { + this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); + } catch( e ) { + QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); + } + } + checkPollution(); + }, + finish: function() { + config.current = this; + if ( config.requireExpects && this.expected === null ) { + QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); + } else if ( this.expected !== null && this.expected !== this.assertions.length ) { + QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); + } else if ( this.expected === null && !this.assertions.length ) { + QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); + } + + var i, assertion, a, b, time, li, ol, + test = this, + good = 0, + bad = 0, + tests = id( "qunit-tests" ); + + this.runtime = +new Date() - this.started; + config.stats.all += this.assertions.length; + config.moduleStats.all += this.assertions.length; + + if ( tests ) { + ol = document.createElement( "ol" ); + ol.className = "qunit-assert-list"; + + for ( i = 0; i < this.assertions.length; i++ ) { + assertion = this.assertions[i]; + + li = document.createElement( "li" ); + li.className = assertion.result ? "pass" : "fail"; + li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" ); + ol.appendChild( li ); + + if ( assertion.result ) { + good++; + } else { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + + // store result when possible + if ( QUnit.config.reorder && defined.sessionStorage ) { + if ( bad ) { + sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad ); + } else { + sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName ); + } + } + + if ( bad === 0 ) { + addClass( ol, "qunit-collapsed" ); + } + + // `b` initialized at top of scope + b = document.createElement( "strong" ); + b.innerHTML = this.nameHtml + " (" + bad + ", " + good + ", " + this.assertions.length + ")"; + + addEvent(b, "click", function() { + var next = b.parentNode.lastChild, + collapsed = hasClass( next, "qunit-collapsed" ); + ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" ); + }); + + addEvent(b, "dblclick", function( e ) { + var target = e && e.target ? e.target : window.event.srcElement; + if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { + target = target.parentNode; + } + if ( window.location && target.nodeName.toLowerCase() === "strong" ) { + window.location = QUnit.url({ testNumber: test.testNumber }); + } + }); + + // `time` initialized at top of scope + time = document.createElement( "span" ); + time.className = "runtime"; + time.innerHTML = this.runtime + " ms"; + + // `li` initialized at top of scope + li = id( this.id ); + li.className = bad ? "fail" : "pass"; + li.removeChild( li.firstChild ); + a = li.firstChild; + li.appendChild( b ); + li.appendChild( a ); + li.appendChild( time ); + li.appendChild( ol ); + + } else { + for ( i = 0; i < this.assertions.length; i++ ) { + if ( !this.assertions[i].result ) { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + } + + runLoggingCallbacks( "testDone", QUnit, { + name: this.testName, + module: this.module, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length, + duration: this.runtime + }); + + QUnit.reset(); + + config.current = undefined; + }, + + queue: function() { + var bad, + test = this; + + synchronize(function() { + test.init(); + }); + function run() { + // each of these can by async + synchronize(function() { + test.setup(); + }); + synchronize(function() { + test.run(); + }); + synchronize(function() { + test.teardown(); + }); + synchronize(function() { + test.finish(); + }); + } + + // `bad` initialized at top of scope + // defer when previous test run passed, if storage is available + bad = QUnit.config.reorder && defined.sessionStorage && + +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); + + if ( bad ) { + run(); + } else { + synchronize( run, true ); + } + } +}; + +// Root QUnit object. +// `QUnit` initialized at top of scope +QUnit = { + + // call on start of module test to prepend name to all tests + module: function( name, testEnvironment ) { + config.currentModule = name; + config.currentModuleTestEnvironment = testEnvironment; + config.modules[name] = true; + }, + + asyncTest: function( testName, expected, callback ) { + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + QUnit.test( testName, expected, callback, true ); + }, + + test: function( testName, expected, callback, async ) { + var test, + nameHtml = "" + escapeText( testName ) + ""; + + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + if ( config.currentModule ) { + nameHtml = "" + escapeText( config.currentModule ) + ": " + nameHtml; + } + + test = new Test({ + nameHtml: nameHtml, + testName: testName, + expected: expected, + async: async, + callback: callback, + module: config.currentModule, + moduleTestEnvironment: config.currentModuleTestEnvironment, + stack: sourceFromStacktrace( 2 ) + }); + + if ( !validTest( test ) ) { + return; + } + + test.queue(); + }, + + // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through. + expect: function( asserts ) { + if (arguments.length === 1) { + config.current.expected = asserts; + } else { + return config.current.expected; + } + }, + + start: function( count ) { + // QUnit hasn't been initialized yet. + // Note: RequireJS (et al) may delay onLoad + if ( config.semaphore === undefined ) { + QUnit.begin(function() { + // This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first + setTimeout(function() { + QUnit.start( count ); + }); + }); + return; + } + + config.semaphore -= count || 1; + // don't start until equal number of stop-calls + if ( config.semaphore > 0 ) { + return; + } + // ignore if start is called more often then stop + if ( config.semaphore < 0 ) { + config.semaphore = 0; + QUnit.pushFailure( "Called start() while already started (QUnit.config.semaphore was 0 already)", null, sourceFromStacktrace(2) ); + return; + } + // A slight delay, to avoid any current callbacks + if ( defined.setTimeout ) { + setTimeout(function() { + if ( config.semaphore > 0 ) { + return; + } + if ( config.timeout ) { + clearTimeout( config.timeout ); + } + + config.blocking = false; + process( true ); + }, 13); + } else { + config.blocking = false; + process( true ); + } + }, + + stop: function( count ) { + config.semaphore += count || 1; + config.blocking = true; + + if ( config.testTimeout && defined.setTimeout ) { + clearTimeout( config.timeout ); + config.timeout = setTimeout(function() { + QUnit.ok( false, "Test timed out" ); + config.semaphore = 1; + QUnit.start(); + }, config.testTimeout ); + } + } +}; + +// `assert` initialized at top of scope +// Assert helpers +// All of these must either call QUnit.push() or manually do: +// - runLoggingCallbacks( "log", .. ); +// - config.current.assertions.push({ .. }); +// We attach it to the QUnit object *after* we expose the public API, +// otherwise `assert` will become a global variable in browsers (#341). +assert = { + /** + * Asserts rough true-ish result. + * @name ok + * @function + * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); + */ + ok: function( result, msg ) { + if ( !config.current ) { + throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); + } + result = !!result; + msg = msg || (result ? "okay" : "failed" ); + + var source, + details = { + module: config.current.module, + name: config.current.testName, + result: result, + message: msg + }; + + msg = "" + escapeText( msg ) + ""; + + if ( !result ) { + source = sourceFromStacktrace( 2 ); + if ( source ) { + details.source = source; + msg += "
          Source:
          " + escapeText( source ) + "
          "; + } + } + runLoggingCallbacks( "log", QUnit, details ); + config.current.assertions.push({ + result: result, + message: msg + }); + }, + + /** + * Assert that the first two arguments are equal, with an optional message. + * Prints out both actual and expected values. + * @name equal + * @function + * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); + */ + equal: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + QUnit.push( expected == actual, actual, expected, message ); + }, + + /** + * @name notEqual + * @function + */ + notEqual: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + QUnit.push( expected != actual, actual, expected, message ); + }, + + /** + * @name propEqual + * @function + */ + propEqual: function( actual, expected, message ) { + actual = objectValues(actual); + expected = objectValues(expected); + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name notPropEqual + * @function + */ + notPropEqual: function( actual, expected, message ) { + actual = objectValues(actual); + expected = objectValues(expected); + QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name deepEqual + * @function + */ + deepEqual: function( actual, expected, message ) { + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name notDeepEqual + * @function + */ + notDeepEqual: function( actual, expected, message ) { + QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name strictEqual + * @function + */ + strictEqual: function( actual, expected, message ) { + QUnit.push( expected === actual, actual, expected, message ); + }, + + /** + * @name notStrictEqual + * @function + */ + notStrictEqual: function( actual, expected, message ) { + QUnit.push( expected !== actual, actual, expected, message ); + }, + + "throws": function( block, expected, message ) { + var actual, + expectedOutput = expected, + ok = false; + + // 'expected' is optional + if ( typeof expected === "string" ) { + message = expected; + expected = null; + } + + config.current.ignoreGlobalErrors = true; + try { + block.call( config.current.testEnvironment ); + } catch (e) { + actual = e; + } + config.current.ignoreGlobalErrors = false; + + if ( actual ) { + // we don't want to validate thrown error + if ( !expected ) { + ok = true; + expectedOutput = null; + // expected is a regexp + } else if ( QUnit.objectType( expected ) === "regexp" ) { + ok = expected.test( errorString( actual ) ); + // expected is a constructor + } else if ( actual instanceof expected ) { + ok = true; + // expected is a validation function which returns true is validation passed + } else if ( expected.call( {}, actual ) === true ) { + expectedOutput = null; + ok = true; + } + + QUnit.push( ok, actual, expectedOutput, message ); + } else { + QUnit.pushFailure( message, null, "No exception was thrown." ); + } + } +}; + +/** + * @deprecated since 1.8.0 + * Kept assertion helpers in root for backwards compatibility. + */ +extend( QUnit, assert ); + +/** + * @deprecated since 1.9.0 + * Kept root "raises()" for backwards compatibility. + * (Note that we don't introduce assert.raises). + */ +QUnit.raises = assert[ "throws" ]; + +/** + * @deprecated since 1.0.0, replaced with error pushes since 1.3.0 + * Kept to avoid TypeErrors for undefined methods. + */ +QUnit.equals = function() { + QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); +}; +QUnit.same = function() { + QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" ); +}; + +// We want access to the constructor's prototype +(function() { + function F() {} + F.prototype = QUnit; + QUnit = new F(); + // Make F QUnit's constructor so that we can add to the prototype later + QUnit.constructor = F; +}()); + +/** + * Config object: Maintain internal state + * Later exposed as QUnit.config + * `config` initialized at top of scope + */ +config = { + // The queue of tests to run + queue: [], + + // block until document ready + blocking: true, + + // when enabled, show only failing tests + // gets persisted through sessionStorage and can be changed in UI via checkbox + hidepassed: false, + + // by default, run previously failed tests first + // very useful in combination with "Hide passed tests" checked + reorder: true, + + // by default, modify document.title when suite is done + altertitle: true, + + // when enabled, all tests must call expect() + requireExpects: false, + + // add checkboxes that are persisted in the query-string + // when enabled, the id is set to `true` as a `QUnit.config` property + urlConfig: [ + { + id: "noglobals", + label: "Check for Globals", + tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings." + }, + { + id: "notrycatch", + label: "No try-catch", + tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings." + } + ], + + // Set of all modules. + modules: {}, + + // logging callback queues + begin: [], + done: [], + log: [], + testStart: [], + testDone: [], + moduleStart: [], + moduleDone: [] +}; + +// Export global variables, unless an 'exports' object exists, +// in that case we assume we're in CommonJS (dealt with on the bottom of the script) +if ( typeof exports === "undefined" ) { + extend( window, QUnit.constructor.prototype ); + + // Expose QUnit object + window.QUnit = QUnit; +} + +// Initialize more QUnit.config and QUnit.urlParams +(function() { + var i, + location = window.location || { search: "", protocol: "file:" }, + params = location.search.slice( 1 ).split( "&" ), + length = params.length, + urlParams = {}, + current; + + if ( params[ 0 ] ) { + for ( i = 0; i < length; i++ ) { + current = params[ i ].split( "=" ); + current[ 0 ] = decodeURIComponent( current[ 0 ] ); + // allow just a key to turn on a flag, e.g., test.html?noglobals + current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; + urlParams[ current[ 0 ] ] = current[ 1 ]; + } + } + + QUnit.urlParams = urlParams; + + // String search anywhere in moduleName+testName + config.filter = urlParams.filter; + + // Exact match of the module name + config.module = urlParams.module; + + config.testNumber = parseInt( urlParams.testNumber, 10 ) || null; + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = location.protocol === "file:"; +}()); + +// Extend QUnit object, +// these after set here because they should not be exposed as global functions +extend( QUnit, { + assert: assert, + + config: config, + + // Initialize the configuration options + init: function() { + extend( config, { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: +new Date(), + updateRate: 1000, + blocking: false, + autostart: true, + autorun: false, + filter: "", + queue: [], + semaphore: 1 + }); + + var tests, banner, result, + qunit = id( "qunit" ); + + if ( qunit ) { + qunit.innerHTML = + "

          " + escapeText( document.title ) + "

          " + + "

          " + + "
          " + + "

          " + + "
            "; + } + + tests = id( "qunit-tests" ); + banner = id( "qunit-banner" ); + result = id( "qunit-testresult" ); + + if ( tests ) { + tests.innerHTML = ""; + } + + if ( banner ) { + banner.className = ""; + } + + if ( result ) { + result.parentNode.removeChild( result ); + } + + if ( tests ) { + result = document.createElement( "p" ); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests ); + result.innerHTML = "Running...
             "; + } + }, + + // Resets the test setup. Useful for tests that modify the DOM. + /* + DEPRECATED: Use multiple tests instead of resetting inside a test. + Use testStart or testDone for custom cleanup. + This method will throw an error in 2.0, and will be removed in 2.1 + */ + reset: function() { + var fixture = id( "qunit-fixture" ); + if ( fixture ) { + fixture.innerHTML = config.fixture; + } + }, + + // Trigger an event on an element. + // @example triggerEvent( document.body, "click" ); + triggerEvent: function( elem, type, event ) { + if ( document.createEvent ) { + event = document.createEvent( "MouseEvents" ); + event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, + 0, 0, 0, 0, 0, false, false, false, false, 0, null); + + elem.dispatchEvent( event ); + } else if ( elem.fireEvent ) { + elem.fireEvent( "on" + type ); + } + }, + + // Safe object type checking + is: function( type, obj ) { + return QUnit.objectType( obj ) === type; + }, + + objectType: function( obj ) { + if ( typeof obj === "undefined" ) { + return "undefined"; + // consider: typeof null === object + } + if ( obj === null ) { + return "null"; + } + + var match = toString.call( obj ).match(/^\[object\s(.*)\]$/), + type = match && match[1] || ""; + + switch ( type ) { + case "Number": + if ( isNaN(obj) ) { + return "nan"; + } + return "number"; + case "String": + case "Boolean": + case "Array": + case "Date": + case "RegExp": + case "Function": + return type.toLowerCase(); + } + if ( typeof obj === "object" ) { + return "object"; + } + return undefined; + }, + + push: function( result, actual, expected, message ) { + if ( !config.current ) { + throw new Error( "assertion outside test context, was " + sourceFromStacktrace() ); + } + + var output, source, + details = { + module: config.current.module, + name: config.current.testName, + result: result, + message: message, + actual: actual, + expected: expected + }; + + message = escapeText( message ) || ( result ? "okay" : "failed" ); + message = "" + message + ""; + output = message; + + if ( !result ) { + expected = escapeText( QUnit.jsDump.parse(expected) ); + actual = escapeText( QUnit.jsDump.parse(actual) ); + output += ""; + + if ( actual !== expected ) { + output += ""; + output += ""; + } + + source = sourceFromStacktrace(); + + if ( source ) { + details.source = source; + output += ""; + } + + output += "
            Expected:
            " + expected + "
            Result:
            " + actual + "
            Diff:
            " + QUnit.diff( expected, actual ) + "
            Source:
            " + escapeText( source ) + "
            "; + } + + runLoggingCallbacks( "log", QUnit, details ); + + config.current.assertions.push({ + result: !!result, + message: output + }); + }, + + pushFailure: function( message, source, actual ) { + if ( !config.current ) { + throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) ); + } + + var output, + details = { + module: config.current.module, + name: config.current.testName, + result: false, + message: message + }; + + message = escapeText( message ) || "error"; + message = "" + message + ""; + output = message; + + output += ""; + + if ( actual ) { + output += ""; + } + + if ( source ) { + details.source = source; + output += ""; + } + + output += "
            Result:
            " + escapeText( actual ) + "
            Source:
            " + escapeText( source ) + "
            "; + + runLoggingCallbacks( "log", QUnit, details ); + + config.current.assertions.push({ + result: false, + message: output + }); + }, + + url: function( params ) { + params = extend( extend( {}, QUnit.urlParams ), params ); + var key, + querystring = "?"; + + for ( key in params ) { + if ( hasOwn.call( params, key ) ) { + querystring += encodeURIComponent( key ) + "=" + + encodeURIComponent( params[ key ] ) + "&"; + } + } + return window.location.protocol + "//" + window.location.host + + window.location.pathname + querystring.slice( 0, -1 ); + }, + + extend: extend, + id: id, + addEvent: addEvent, + addClass: addClass, + hasClass: hasClass, + removeClass: removeClass + // load, equiv, jsDump, diff: Attached later +}); + +/** + * @deprecated: Created for backwards compatibility with test runner that set the hook function + * into QUnit.{hook}, instead of invoking it and passing the hook function. + * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here. + * Doing this allows us to tell if the following methods have been overwritten on the actual + * QUnit object. + */ +extend( QUnit.constructor.prototype, { + + // Logging callbacks; all receive a single argument with the listed properties + // run test/logs.html for any related changes + begin: registerLoggingCallback( "begin" ), + + // done: { failed, passed, total, runtime } + done: registerLoggingCallback( "done" ), + + // log: { result, actual, expected, message } + log: registerLoggingCallback( "log" ), + + // testStart: { name } + testStart: registerLoggingCallback( "testStart" ), + + // testDone: { name, failed, passed, total, duration } + testDone: registerLoggingCallback( "testDone" ), + + // moduleStart: { name } + moduleStart: registerLoggingCallback( "moduleStart" ), + + // moduleDone: { name, failed, passed, total } + moduleDone: registerLoggingCallback( "moduleDone" ) +}); + +if ( typeof document === "undefined" || document.readyState === "complete" ) { + config.autorun = true; +} + +QUnit.load = function() { + runLoggingCallbacks( "begin", QUnit, {} ); + + // Initialize the config, saving the execution queue + var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, + urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter, + numModules = 0, + moduleNames = [], + moduleFilterHtml = "", + urlConfigHtml = "", + oldconfig = extend( {}, config ); + + QUnit.init(); + extend(config, oldconfig); + + config.blocking = false; + + len = config.urlConfig.length; + + for ( i = 0; i < len; i++ ) { + val = config.urlConfig[i]; + if ( typeof val === "string" ) { + val = { + id: val, + label: val, + tooltip: "[no tooltip available]" + }; + } + config[ val.id ] = QUnit.urlParams[ val.id ]; + urlConfigHtml += ""; + } + for ( i in config.modules ) { + if ( config.modules.hasOwnProperty( i ) ) { + moduleNames.push(i); + } + } + numModules = moduleNames.length; + moduleNames.sort( function( a, b ) { + return a.localeCompare( b ); + }); + moduleFilterHtml += ""; + + // `userAgent` initialized at top of scope + userAgent = id( "qunit-userAgent" ); + if ( userAgent ) { + userAgent.innerHTML = navigator.userAgent; + } + + // `banner` initialized at top of scope + banner = id( "qunit-header" ); + if ( banner ) { + banner.innerHTML = "" + banner.innerHTML + " "; + } + + // `toolbar` initialized at top of scope + toolbar = id( "qunit-testrunner-toolbar" ); + if ( toolbar ) { + // `filter` initialized at top of scope + filter = document.createElement( "input" ); + filter.type = "checkbox"; + filter.id = "qunit-filter-pass"; + + addEvent( filter, "click", function() { + var tmp, + ol = document.getElementById( "qunit-tests" ); + + if ( filter.checked ) { + ol.className = ol.className + " hidepass"; + } else { + tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " "; + ol.className = tmp.replace( / hidepass /, " " ); + } + if ( defined.sessionStorage ) { + if (filter.checked) { + sessionStorage.setItem( "qunit-filter-passed-tests", "true" ); + } else { + sessionStorage.removeItem( "qunit-filter-passed-tests" ); + } + } + }); + + if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) { + filter.checked = true; + // `ol` initialized at top of scope + ol = document.getElementById( "qunit-tests" ); + ol.className = ol.className + " hidepass"; + } + toolbar.appendChild( filter ); + + // `label` initialized at top of scope + label = document.createElement( "label" ); + label.setAttribute( "for", "qunit-filter-pass" ); + label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." ); + label.innerHTML = "Hide passed tests"; + toolbar.appendChild( label ); + + urlConfigCheckboxesContainer = document.createElement("span"); + urlConfigCheckboxesContainer.innerHTML = urlConfigHtml; + urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input"); + // For oldIE support: + // * Add handlers to the individual elements instead of the container + // * Use "click" instead of "change" + // * Fallback from event.target to event.srcElement + addEvents( urlConfigCheckboxes, "click", function( event ) { + var params = {}, + target = event.target || event.srcElement; + params[ target.name ] = target.checked ? true : undefined; + window.location = QUnit.url( params ); + }); + toolbar.appendChild( urlConfigCheckboxesContainer ); + + if (numModules > 1) { + moduleFilter = document.createElement( "span" ); + moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); + moduleFilter.innerHTML = moduleFilterHtml; + addEvent( moduleFilter.lastChild, "change", function() { + var selectBox = moduleFilter.getElementsByTagName("select")[0], + selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value); + + window.location = QUnit.url({ + module: ( selectedModule === "" ) ? undefined : selectedModule, + // Remove any existing filters + filter: undefined, + testNumber: undefined + }); + }); + toolbar.appendChild(moduleFilter); + } + } + + // `main` initialized at top of scope + main = id( "qunit-fixture" ); + if ( main ) { + config.fixture = main.innerHTML; + } + + if ( config.autostart ) { + QUnit.start(); + } +}; + +addEvent( window, "load", QUnit.load ); + +// `onErrorFnPrev` initialized at top of scope +// Preserve other handlers +onErrorFnPrev = window.onerror; + +// Cover uncaught exceptions +// Returning true will suppress the default browser handler, +// returning false will let it run. +window.onerror = function ( error, filePath, linerNr ) { + var ret = false; + if ( onErrorFnPrev ) { + ret = onErrorFnPrev( error, filePath, linerNr ); + } + + // Treat return value as window.onerror itself does, + // Only do our handling if not suppressed. + if ( ret !== true ) { + if ( QUnit.config.current ) { + if ( QUnit.config.current.ignoreGlobalErrors ) { + return true; + } + QUnit.pushFailure( error, filePath + ":" + linerNr ); + } else { + QUnit.test( "global failure", extend( function() { + QUnit.pushFailure( error, filePath + ":" + linerNr ); + }, { validTest: validTest } ) ); + } + return false; + } + + return ret; +}; + +function done() { + config.autorun = true; + + // Log the last module results + if ( config.currentModule ) { + runLoggingCallbacks( "moduleDone", QUnit, { + name: config.currentModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + delete config.previousModule; + + var i, key, + banner = id( "qunit-banner" ), + tests = id( "qunit-tests" ), + runtime = +new Date() - config.started, + passed = config.stats.all - config.stats.bad, + html = [ + "Tests completed in ", + runtime, + " milliseconds.
            ", + "", + passed, + " assertions of ", + config.stats.all, + " passed, ", + config.stats.bad, + " failed." + ].join( "" ); + + if ( banner ) { + banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" ); + } + + if ( tests ) { + id( "qunit-testresult" ).innerHTML = html; + } + + if ( config.altertitle && typeof document !== "undefined" && document.title ) { + // show ✖ for good, ✔ for bad suite result in title + // use escape sequences in case file gets loaded with non-utf-8-charset + document.title = [ + ( config.stats.bad ? "\u2716" : "\u2714" ), + document.title.replace( /^[\u2714\u2716] /i, "" ) + ].join( " " ); + } + + // clear own sessionStorage items if all tests passed + if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) { + // `key` & `i` initialized at top of scope + for ( i = 0; i < sessionStorage.length; i++ ) { + key = sessionStorage.key( i++ ); + if ( key.indexOf( "qunit-test-" ) === 0 ) { + sessionStorage.removeItem( key ); + } + } + } + + // scroll back to top to show results + if ( window.scrollTo ) { + window.scrollTo(0, 0); + } + + runLoggingCallbacks( "done", QUnit, { + failed: config.stats.bad, + passed: passed, + total: config.stats.all, + runtime: runtime + }); +} + +/** @return Boolean: true if this test should be ran */ +function validTest( test ) { + var include, + filter = config.filter && config.filter.toLowerCase(), + module = config.module && config.module.toLowerCase(), + fullName = (test.module + ": " + test.testName).toLowerCase(); + + // Internally-generated tests are always valid + if ( test.callback && test.callback.validTest === validTest ) { + delete test.callback.validTest; + return true; + } + + if ( config.testNumber ) { + return test.testNumber === config.testNumber; + } + + if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) { + return false; + } + + if ( !filter ) { + return true; + } + + include = filter.charAt( 0 ) !== "!"; + if ( !include ) { + filter = filter.slice( 1 ); + } + + // If the filter matches, we need to honour include + if ( fullName.indexOf( filter ) !== -1 ) { + return include; + } + + // Otherwise, do the opposite + return !include; +} + +// so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions) +// Later Safari and IE10 are supposed to support error.stack as well +// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack +function extractStacktrace( e, offset ) { + offset = offset === undefined ? 3 : offset; + + var stack, include, i; + + if ( e.stacktrace ) { + // Opera + return e.stacktrace.split( "\n" )[ offset + 3 ]; + } else if ( e.stack ) { + // Firefox, Chrome + stack = e.stack.split( "\n" ); + if (/^error$/i.test( stack[0] ) ) { + stack.shift(); + } + if ( fileName ) { + include = []; + for ( i = offset; i < stack.length; i++ ) { + if ( stack[ i ].indexOf( fileName ) !== -1 ) { + break; + } + include.push( stack[ i ] ); + } + if ( include.length ) { + return include.join( "\n" ); + } + } + return stack[ offset ]; + } else if ( e.sourceURL ) { + // Safari, PhantomJS + // hopefully one day Safari provides actual stacktraces + // exclude useless self-reference for generated Error objects + if ( /qunit.js$/.test( e.sourceURL ) ) { + return; + } + // for actual exceptions, this is useful + return e.sourceURL + ":" + e.line; + } +} +function sourceFromStacktrace( offset ) { + try { + throw new Error(); + } catch ( e ) { + return extractStacktrace( e, offset ); + } +} + +/** + * Escape text for attribute or text content. + */ +function escapeText( s ) { + if ( !s ) { + return ""; + } + s = s + ""; + // Both single quotes and double quotes (for attributes) + return s.replace( /['"<>&]/g, function( s ) { + switch( s ) { + case "'": + return "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + } + }); +} + +function synchronize( callback, last ) { + config.queue.push( callback ); + + if ( config.autorun && !config.blocking ) { + process( last ); + } +} + +function process( last ) { + function next() { + process( last ); + } + var start = new Date().getTime(); + config.depth = config.depth ? config.depth + 1 : 1; + + while ( config.queue.length && !config.blocking ) { + if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { + config.queue.shift()(); + } else { + setTimeout( next, 13 ); + break; + } + } + config.depth--; + if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { + done(); + } +} + +function saveGlobal() { + config.pollution = []; + + if ( config.noglobals ) { + for ( var key in window ) { + if ( hasOwn.call( window, key ) ) { + // in Opera sometimes DOM element ids show up here, ignore them + if ( /^qunit-test-output/.test( key ) ) { + continue; + } + config.pollution.push( key ); + } + } + } +} + +function checkPollution() { + var newGlobals, + deletedGlobals, + old = config.pollution; + + saveGlobal(); + + newGlobals = diff( config.pollution, old ); + if ( newGlobals.length > 0 ) { + QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") ); + } + + deletedGlobals = diff( old, config.pollution ); + if ( deletedGlobals.length > 0 ) { + QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") ); + } +} + +// returns a new Array with the elements that are in a but not in b +function diff( a, b ) { + var i, j, + result = a.slice(); + + for ( i = 0; i < result.length; i++ ) { + for ( j = 0; j < b.length; j++ ) { + if ( result[i] === b[j] ) { + result.splice( i, 1 ); + i--; + break; + } + } + } + return result; +} + +function extend( a, b ) { + for ( var prop in b ) { + if ( hasOwn.call( b, prop ) ) { + // Avoid "Member not found" error in IE8 caused by messing with window.constructor + if ( !( prop === "constructor" && a === window ) ) { + if ( b[ prop ] === undefined ) { + delete a[ prop ]; + } else { + a[ prop ] = b[ prop ]; + } + } + } + } + + return a; +} + +/** + * @param {HTMLElement} elem + * @param {string} type + * @param {Function} fn + */ +function addEvent( elem, type, fn ) { + // Standards-based browsers + if ( elem.addEventListener ) { + elem.addEventListener( type, fn, false ); + // IE + } else { + elem.attachEvent( "on" + type, fn ); + } +} + +/** + * @param {Array|NodeList} elems + * @param {string} type + * @param {Function} fn + */ +function addEvents( elems, type, fn ) { + var i = elems.length; + while ( i-- ) { + addEvent( elems[i], type, fn ); + } +} + +function hasClass( elem, name ) { + return (" " + elem.className + " ").indexOf(" " + name + " ") > -1; +} + +function addClass( elem, name ) { + if ( !hasClass( elem, name ) ) { + elem.className += (elem.className ? " " : "") + name; + } +} + +function removeClass( elem, name ) { + var set = " " + elem.className + " "; + // Class name may appear multiple times + while ( set.indexOf(" " + name + " ") > -1 ) { + set = set.replace(" " + name + " " , " "); + } + // If possible, trim it for prettiness, but not necessarily + elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, ""); +} + +function id( name ) { + return !!( typeof document !== "undefined" && document && document.getElementById ) && + document.getElementById( name ); +} + +function registerLoggingCallback( key ) { + return function( callback ) { + config[key].push( callback ); + }; +} + +// Supports deprecated method of completely overwriting logging callbacks +function runLoggingCallbacks( key, scope, args ) { + var i, callbacks; + if ( QUnit.hasOwnProperty( key ) ) { + QUnit[ key ].call(scope, args ); + } else { + callbacks = config[ key ]; + for ( i = 0; i < callbacks.length; i++ ) { + callbacks[ i ].call( scope, args ); + } + } +} + +// Test for equality any JavaScript type. +// Author: Philippe Rathé +QUnit.equiv = (function() { + + // Call the o related callback with the given arguments. + function bindCallbacks( o, callbacks, args ) { + var prop = QUnit.objectType( o ); + if ( prop ) { + if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) { + return callbacks[ prop ].apply( callbacks, args ); + } else { + return callbacks[ prop ]; // or undefined + } + } + } + + // the real equiv function + var innerEquiv, + // stack to decide between skip/abort functions + callers = [], + // stack to avoiding loops from circular referencing + parents = [], + parentsB = [], + + getProto = Object.getPrototypeOf || function ( obj ) { + /*jshint camelcase:false */ + return obj.__proto__; + }, + callbacks = (function () { + + // for string, boolean, number and null + function useStrictEquality( b, a ) { + /*jshint eqeqeq:false */ + if ( b instanceof a.constructor || a instanceof b.constructor ) { + // to catch short annotation VS 'new' annotation of a + // declaration + // e.g. var i = 1; + // var j = new Number(1); + return a == b; + } else { + return a === b; + } + } + + return { + "string": useStrictEquality, + "boolean": useStrictEquality, + "number": useStrictEquality, + "null": useStrictEquality, + "undefined": useStrictEquality, + + "nan": function( b ) { + return isNaN( b ); + }, + + "date": function( b, a ) { + return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf(); + }, + + "regexp": function( b, a ) { + return QUnit.objectType( b ) === "regexp" && + // the regex itself + a.source === b.source && + // and its modifiers + a.global === b.global && + // (gmi) ... + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky; + }, + + // - skip when the property is a method of an instance (OOP) + // - abort otherwise, + // initial === would have catch identical references anyway + "function": function() { + var caller = callers[callers.length - 1]; + return caller !== Object && typeof caller !== "undefined"; + }, + + "array": function( b, a ) { + var i, j, len, loop, aCircular, bCircular; + + // b could be an object literal here + if ( QUnit.objectType( b ) !== "array" ) { + return false; + } + + len = a.length; + if ( len !== b.length ) { + // safe and faster + return false; + } + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + for ( i = 0; i < len; i++ ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[j] === a[i]; + bCircular = parentsB[j] === b[i]; + if ( aCircular || bCircular ) { + if ( a[i] === b[i] || aCircular && bCircular ) { + loop = true; + } else { + parents.pop(); + parentsB.pop(); + return false; + } + } + } + if ( !loop && !innerEquiv(a[i], b[i]) ) { + parents.pop(); + parentsB.pop(); + return false; + } + } + parents.pop(); + parentsB.pop(); + return true; + }, + + "object": function( b, a ) { + /*jshint forin:false */ + var i, j, loop, aCircular, bCircular, + // Default to true + eq = true, + aProperties = [], + bProperties = []; + + // comparing constructors is more strict than using + // instanceof + if ( a.constructor !== b.constructor ) { + // Allow objects with no prototype to be equivalent to + // objects with Object as their constructor. + if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) || + ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) { + return false; + } + } + + // stack constructor before traversing properties + callers.push( a.constructor ); + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + + // be strict: don't ensure hasOwnProperty and go deep + for ( i in a ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[j] === a[i]; + bCircular = parentsB[j] === b[i]; + if ( aCircular || bCircular ) { + if ( a[i] === b[i] || aCircular && bCircular ) { + loop = true; + } else { + eq = false; + break; + } + } + } + aProperties.push(i); + if ( !loop && !innerEquiv(a[i], b[i]) ) { + eq = false; + break; + } + } + + parents.pop(); + parentsB.pop(); + callers.pop(); // unstack, we are done + + for ( i in b ) { + bProperties.push( i ); // collect b's properties + } + + // Ensures identical properties name + return eq && innerEquiv( aProperties.sort(), bProperties.sort() ); + } + }; + }()); + + innerEquiv = function() { // can take multiple arguments + var args = [].slice.apply( arguments ); + if ( args.length < 2 ) { + return true; // end transition + } + + return (function( a, b ) { + if ( a === b ) { + return true; // catch the most you can + } else if ( a === null || b === null || typeof a === "undefined" || + typeof b === "undefined" || + QUnit.objectType(a) !== QUnit.objectType(b) ) { + return false; // don't lose time with error prone cases + } else { + return bindCallbacks(a, callbacks, [ b, a ]); + } + + // apply transition with (1..n) arguments + }( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) ); + }; + + return innerEquiv; +}()); + +/** + * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | + * http://flesler.blogspot.com Licensed under BSD + * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008 + * + * @projectDescription Advanced and extensible data dumping for Javascript. + * @version 1.0.0 + * @author Ariel Flesler + * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} + */ +QUnit.jsDump = (function() { + function quote( str ) { + return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\""; + } + function literal( o ) { + return o + ""; + } + function join( pre, arr, post ) { + var s = jsDump.separator(), + base = jsDump.indent(), + inner = jsDump.indent(1); + if ( arr.join ) { + arr = arr.join( "," + s + inner ); + } + if ( !arr ) { + return pre + post; + } + return [ pre, inner + arr, base + post ].join(s); + } + function array( arr, stack ) { + var i = arr.length, ret = new Array(i); + this.up(); + while ( i-- ) { + ret[i] = this.parse( arr[i] , undefined , stack); + } + this.down(); + return join( "[", ret, "]" ); + } + + var reName = /^function (\w+)/, + jsDump = { + // type is used mostly internally, you can fix a (custom)type in advance + parse: function( obj, type, stack ) { + stack = stack || [ ]; + var inStack, res, + parser = this.parsers[ type || this.typeOf(obj) ]; + + type = typeof parser; + inStack = inArray( obj, stack ); + + if ( inStack !== -1 ) { + return "recursion(" + (inStack - stack.length) + ")"; + } + if ( type === "function" ) { + stack.push( obj ); + res = parser.call( this, obj, stack ); + stack.pop(); + return res; + } + return ( type === "string" ) ? parser : this.parsers.error; + }, + typeOf: function( obj ) { + var type; + if ( obj === null ) { + type = "null"; + } else if ( typeof obj === "undefined" ) { + type = "undefined"; + } else if ( QUnit.is( "regexp", obj) ) { + type = "regexp"; + } else if ( QUnit.is( "date", obj) ) { + type = "date"; + } else if ( QUnit.is( "function", obj) ) { + type = "function"; + } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) { + type = "window"; + } else if ( obj.nodeType === 9 ) { + type = "document"; + } else if ( obj.nodeType ) { + type = "node"; + } else if ( + // native arrays + toString.call( obj ) === "[object Array]" || + // NodeList objects + ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) ) + ) { + type = "array"; + } else if ( obj.constructor === Error.prototype.constructor ) { + type = "error"; + } else { + type = typeof obj; + } + return type; + }, + separator: function() { + return this.multiline ? this.HTML ? "
            " : "\n" : this.HTML ? " " : " "; + }, + // extra can be a number, shortcut for increasing-calling-decreasing + indent: function( extra ) { + if ( !this.multiline ) { + return ""; + } + var chr = this.indentChar; + if ( this.HTML ) { + chr = chr.replace( /\t/g, " " ).replace( / /g, " " ); + } + return new Array( this.depth + ( extra || 0 ) ).join(chr); + }, + up: function( a ) { + this.depth += a || 1; + }, + down: function( a ) { + this.depth -= a || 1; + }, + setParser: function( name, parser ) { + this.parsers[name] = parser; + }, + // The next 3 are exposed so you can use them + quote: quote, + literal: literal, + join: join, + // + depth: 1, + // This is the list of parsers, to modify them, use jsDump.setParser + parsers: { + window: "[Window]", + document: "[Document]", + error: function(error) { + return "Error(\"" + error.message + "\")"; + }, + unknown: "[Unknown]", + "null": "null", + "undefined": "undefined", + "function": function( fn ) { + var ret = "function", + // functions never have name in IE + name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1]; + + if ( name ) { + ret += " " + name; + } + ret += "( "; + + ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" ); + return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" ); + }, + array: array, + nodelist: array, + "arguments": array, + object: function( map, stack ) { + /*jshint forin:false */ + var ret = [ ], keys, key, val, i; + QUnit.jsDump.up(); + keys = []; + for ( key in map ) { + keys.push( key ); + } + keys.sort(); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + val = map[ key ]; + ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) ); + } + QUnit.jsDump.down(); + return join( "{", ret, "}" ); + }, + node: function( node ) { + var len, i, val, + open = QUnit.jsDump.HTML ? "<" : "<", + close = QUnit.jsDump.HTML ? ">" : ">", + tag = node.nodeName.toLowerCase(), + ret = open + tag, + attrs = node.attributes; + + if ( attrs ) { + for ( i = 0, len = attrs.length; i < len; i++ ) { + val = attrs[i].nodeValue; + // IE6 includes all attributes in .attributes, even ones not explicitly set. + // Those have values like undefined, null, 0, false, "" or "inherit". + if ( val && val !== "inherit" ) { + ret += " " + attrs[i].nodeName + "=" + QUnit.jsDump.parse( val, "attribute" ); + } + } + } + ret += close; + + // Show content of TextNode or CDATASection + if ( node.nodeType === 3 || node.nodeType === 4 ) { + ret += node.nodeValue; + } + + return ret + open + "/" + tag + close; + }, + // function calls it internally, it's the arguments part of the function + functionArgs: function( fn ) { + var args, + l = fn.length; + + if ( !l ) { + return ""; + } + + args = new Array(l); + while ( l-- ) { + // 97 is 'a' + args[l] = String.fromCharCode(97+l); + } + return " " + args.join( ", " ) + " "; + }, + // object calls it internally, the key part of an item in a map + key: quote, + // function calls it internally, it's the content of the function + functionCode: "[code]", + // node calls it internally, it's an html attribute value + attribute: quote, + string: quote, + date: quote, + regexp: literal, + number: literal, + "boolean": literal + }, + // if true, entities are escaped ( <, >, \t, space and \n ) + HTML: false, + // indentation unit + indentChar: " ", + // if true, items in a collection, are separated by a \n, else just a space. + multiline: true + }; + + return jsDump; +}()); + +// from jquery.js +function inArray( elem, array ) { + if ( array.indexOf ) { + return array.indexOf( elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; +} + +/* + * Javascript Diff Algorithm + * By John Resig (http://ejohn.org/) + * Modified by Chu Alan "sprite" + * + * Released under the MIT license. + * + * More Info: + * http://ejohn.org/projects/javascript-diff-algorithm/ + * + * Usage: QUnit.diff(expected, actual) + * + * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick brown fox jumped jumps over" + */ +QUnit.diff = (function() { + /*jshint eqeqeq:false, eqnull:true */ + function diff( o, n ) { + var i, + ns = {}, + os = {}; + + for ( i = 0; i < n.length; i++ ) { + if ( !hasOwn.call( ns, n[i] ) ) { + ns[ n[i] ] = { + rows: [], + o: null + }; + } + ns[ n[i] ].rows.push( i ); + } + + for ( i = 0; i < o.length; i++ ) { + if ( !hasOwn.call( os, o[i] ) ) { + os[ o[i] ] = { + rows: [], + n: null + }; + } + os[ o[i] ].rows.push( i ); + } + + for ( i in ns ) { + if ( hasOwn.call( ns, i ) ) { + if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) { + n[ ns[i].rows[0] ] = { + text: n[ ns[i].rows[0] ], + row: os[i].rows[0] + }; + o[ os[i].rows[0] ] = { + text: o[ os[i].rows[0] ], + row: ns[i].rows[0] + }; + } + } + } + + for ( i = 0; i < n.length - 1; i++ ) { + if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null && + n[ i + 1 ] == o[ n[i].row + 1 ] ) { + + n[ i + 1 ] = { + text: n[ i + 1 ], + row: n[i].row + 1 + }; + o[ n[i].row + 1 ] = { + text: o[ n[i].row + 1 ], + row: i + 1 + }; + } + } + + for ( i = n.length - 1; i > 0; i-- ) { + if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null && + n[ i - 1 ] == o[ n[i].row - 1 ]) { + + n[ i - 1 ] = { + text: n[ i - 1 ], + row: n[i].row - 1 + }; + o[ n[i].row - 1 ] = { + text: o[ n[i].row - 1 ], + row: i - 1 + }; + } + } + + return { + o: o, + n: n + }; + } + + return function( o, n ) { + o = o.replace( /\s+$/, "" ); + n = n.replace( /\s+$/, "" ); + + var i, pre, + str = "", + out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ), + oSpace = o.match(/\s+/g), + nSpace = n.match(/\s+/g); + + if ( oSpace == null ) { + oSpace = [ " " ]; + } + else { + oSpace.push( " " ); + } + + if ( nSpace == null ) { + nSpace = [ " " ]; + } + else { + nSpace.push( " " ); + } + + if ( out.n.length === 0 ) { + for ( i = 0; i < out.o.length; i++ ) { + str += "" + out.o[i] + oSpace[i] + ""; + } + } + else { + if ( out.n[0].text == null ) { + for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) { + str += "" + out.o[n] + oSpace[n] + ""; + } + } + + for ( i = 0; i < out.n.length; i++ ) { + if (out.n[i].text == null) { + str += "" + out.n[i] + nSpace[i] + ""; + } + else { + // `pre` initialized at top of scope + pre = ""; + + for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) { + pre += "" + out.o[n] + oSpace[n] + ""; + } + str += " " + out.n[i].text + nSpace[i] + pre; + } + } + } + + return str; + }; +}()); + +// for CommonJS environments, export everything +if ( typeof exports !== "undefined" ) { + extend( exports, QUnit.constructor.prototype ); +} + +// get at whatever the global object is, like window in browsers +}( (function() {return this;}.call()) )); diff --git a/bower_components/underscore/test/vendor/runner.js b/bower_components/underscore/test/vendor/runner.js new file mode 100644 index 0000000..4b1d38b --- /dev/null +++ b/bower_components/underscore/test/vendor/runner.js @@ -0,0 +1,127 @@ +/* + * QtWebKit-powered headless test runner using PhantomJS + * + * PhantomJS binaries: http://phantomjs.org/download.html + * Requires PhantomJS 1.6+ (1.7+ recommended) + * + * Run with: + * phantomjs runner.js [url-of-your-qunit-testsuite] + * + * e.g. + * phantomjs runner.js http://localhost/qunit/test/index.html + */ + +/*jshint latedef:false */ +/*global phantom:false, require:false, console:false, window:false, QUnit:false */ + +(function() { + 'use strict'; + + var args = require('system').args; + + // arg[0]: scriptName, args[1...]: arguments + if (args.length !== 2) { + console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite]'); + phantom.exit(1); + } + + var url = args[1], + page = require('webpage').create(); + + // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`) + page.onConsoleMessage = function(msg) { + console.log(msg); + }; + + page.onInitialized = function() { + page.evaluate(addLogging); + }; + + page.onCallback = function(message) { + var result, + failed; + + if (message) { + if (message.name === 'QUnit.done') { + result = message.data; + failed = !result || result.failed; + + phantom.exit(failed ? 1 : 0); + } + } + }; + + page.open(url, function(status) { + if (status !== 'success') { + console.error('Unable to access network: ' + status); + phantom.exit(1); + } else { + // Cannot do this verification with the 'DOMContentLoaded' handler because it + // will be too late to attach it if a page does not have any script tags. + var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); }); + if (qunitMissing) { + console.error('The `QUnit` object is not present on this page.'); + phantom.exit(1); + } + + // Do nothing... the callback mechanism will handle everything! + } + }); + + function addLogging() { + window.document.addEventListener('DOMContentLoaded', function() { + var current_test_assertions = []; + + QUnit.log(function(details) { + var response; + + // Ignore passing assertions + if (details.result) { + return; + } + + response = details.message || ''; + + if (typeof details.expected !== 'undefined') { + if (response) { + response += ', '; + } + + response += 'expected: ' + details.expected + ', but was: ' + details.actual; + if (details.source) { + response += "\n" + details.source; + } + } + + current_test_assertions.push('Failed assertion: ' + response); + }); + + QUnit.testDone(function(result) { + var i, + len, + name = result.module + ': ' + result.name; + + if (result.failed) { + console.log('Test failed: ' + name); + + for (i = 0, len = current_test_assertions.length; i < len; i++) { + console.log(' ' + current_test_assertions[i]); + } + } + + current_test_assertions.length = 0; + }); + + QUnit.done(function(result) { + console.log('Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.'); + + if (typeof window.callPhantom === 'function') { + window.callPhantom({ + 'name': 'QUnit.done', + 'data': result + }); + } + }); + }, false); + } +})(); diff --git a/bower_components/underscore/underscore-min.js b/bower_components/underscore/underscore-min.js new file mode 100644 index 0000000..d22f881 --- /dev/null +++ b/bower_components/underscore/underscore-min.js @@ -0,0 +1,6 @@ +// Underscore.js 1.5.2 +// http://underscorejs.org +// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?(this._wrapped=n,void 0):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.5.2";var A=j.each=j.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;ae||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={},i=null==r?j.identity:k(r);return A(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};j.groupBy=F(function(n,t,r){(j.has(n,t)?n[t]:n[t]=[]).push(r)}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=null==r?j.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=w||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); +//# sourceMappingURL=underscore-min.map \ No newline at end of file diff --git a/bower_components/underscore/underscore-min.map b/bower_components/underscore/underscore-min.map new file mode 100644 index 0000000..4fbe0ba --- /dev/null +++ b/bower_components/underscore/underscore-min.map @@ -0,0 +1 @@ +{"version":3,"file":"underscore-min.js","sources":["underscore.js"],"names":["root","this","previousUnderscore","_","breaker","ArrayProto","Array","prototype","ObjProto","Object","FuncProto","Function","push","slice","concat","toString","hasOwnProperty","nativeForEach","forEach","nativeMap","map","nativeReduce","reduce","nativeReduceRight","reduceRight","nativeFilter","filter","nativeEvery","every","nativeSome","some","nativeIndexOf","indexOf","nativeLastIndexOf","lastIndexOf","nativeIsArray","isArray","nativeKeys","keys","nativeBind","bind","obj","_wrapped","exports","module","VERSION","each","iterator","context","length","i","call","collect","results","value","index","list","reduceError","foldl","inject","memo","initial","arguments","TypeError","foldr","find","detect","result","any","select","reject","all","identity","contains","include","target","invoke","method","args","isFunc","isFunction","apply","pluck","key","where","attrs","first","isEmpty","findWhere","max","Math","Infinity","computed","min","shuffle","rand","shuffled","random","sample","n","guard","lookupIterator","sortBy","criteria","sort","left","right","a","b","group","behavior","groupBy","has","indexBy","countBy","sortedIndex","array","low","high","mid","toArray","values","size","head","take","last","rest","tail","drop","compact","flatten","input","shallow","output","isArguments","without","difference","uniq","unique","isSorted","seen","union","intersection","item","other","zip","object","from","hasIndex","range","start","stop","step","ceil","idx","ctor","func","bound","self","partial","bindAll","funcs","Error","f","memoize","hasher","delay","wait","setTimeout","defer","throttle","options","timeout","previous","later","leading","Date","now","remaining","clearTimeout","trailing","debounce","immediate","timestamp","callNow","once","ran","wrap","wrapper","compose","after","times","pairs","invert","functions","methods","names","extend","source","prop","pick","copy","omit","defaults","clone","isObject","tap","interceptor","eq","aStack","bStack","className","String","global","multiline","ignoreCase","aCtor","constructor","bCtor","pop","isEqual","isString","isElement","nodeType","name","isFinite","isNaN","parseFloat","isNumber","isBoolean","isNull","isUndefined","noConflict","accum","floor","entityMap","escape","&","<",">","\"","'","unescape","entityRegexes","RegExp","join","string","replace","match","property","mixin","idCounter","uniqueId","prefix","id","templateSettings","evaluate","interpolate","noMatch","escapes","\\","\r","\n","\t","
","
","escaper","template","text","data","settings","render","matcher","offset","variable","e","chain","_chain"],"mappings":";;;;CAKA,WAME,GAAIA,GAAOC,KAGPC,EAAqBF,EAAKG,EAG1BC,KAGAC,EAAaC,MAAMC,UAAWC,EAAWC,OAAOF,UAAWG,EAAYC,SAASJ,UAIlFK,EAAmBP,EAAWO,KAC9BC,EAAmBR,EAAWQ,MAC9BC,EAAmBT,EAAWS,OAC9BC,EAAmBP,EAASO,SAC5BC,EAAmBR,EAASQ,eAK5BC,EAAqBZ,EAAWa,QAChCC,EAAqBd,EAAWe,IAChCC,EAAqBhB,EAAWiB,OAChCC,EAAqBlB,EAAWmB,YAChCC,EAAqBpB,EAAWqB,OAChCC,EAAqBtB,EAAWuB,MAChCC,EAAqBxB,EAAWyB,KAChCC,EAAqB1B,EAAW2B,QAChCC,EAAqB5B,EAAW6B,YAChCC,EAAqB7B,MAAM8B,QAC3BC,EAAqB5B,OAAO6B,KAC5BC,EAAqB7B,EAAU8B,KAG7BrC,EAAI,SAASsC,GACf,MAAIA,aAAetC,GAAUsC,EACvBxC,eAAgBE,IACtBF,KAAKyC,SAAWD,EAAhBxC,QADiC,GAAIE,GAAEsC,GAQlB,oBAAZE,UACa,mBAAXC,SAA0BA,OAAOD,UAC1CA,QAAUC,OAAOD,QAAUxC,GAE7BwC,QAAQxC,EAAIA,GAEZH,EAAKG,EAAIA,EAIXA,EAAE0C,QAAU,OAQZ,IAAIC,GAAO3C,EAAE2C,KAAO3C,EAAEe,QAAU,SAASuB,EAAKM,EAAUC,GACtD,GAAW,MAAPP,EACJ,GAAIxB,GAAiBwB,EAAIvB,UAAYD,EACnCwB,EAAIvB,QAAQ6B,EAAUC,OACjB,IAAIP,EAAIQ,UAAYR,EAAIQ,QAC7B,IAAK,GAAIC,GAAI,EAAGD,EAASR,EAAIQ,OAAYA,EAAJC,EAAYA,IAC/C,GAAIH,EAASI,KAAKH,EAASP,EAAIS,GAAIA,EAAGT,KAASrC,EAAS,WAI1D,KAAK,GADDkC,GAAOnC,EAAEmC,KAAKG,GACTS,EAAI,EAAGD,EAASX,EAAKW,OAAYA,EAAJC,EAAYA,IAChD,GAAIH,EAASI,KAAKH,EAASP,EAAIH,EAAKY,IAAKZ,EAAKY,GAAIT,KAASrC,EAAS,OAO1ED,GAAEiB,IAAMjB,EAAEiD,QAAU,SAASX,EAAKM,EAAUC,GAC1C,GAAIK,KACJ,OAAW,OAAPZ,EAAoBY,EACpBlC,GAAasB,EAAIrB,MAAQD,EAAkBsB,EAAIrB,IAAI2B,EAAUC,IACjEF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/BH,EAAQzC,KAAKmC,EAASI,KAAKH,EAASM,EAAOC,EAAOC,MAE7CH,GAGT,IAAII,GAAc,6CAIlBtD,GAAEmB,OAASnB,EAAEuD,MAAQvD,EAAEwD,OAAS,SAASlB,EAAKM,EAAUa,EAAMZ,GAC5D,GAAIa,GAAUC,UAAUb,OAAS,CAEjC,IADW,MAAPR,IAAaA,MACbpB,GAAgBoB,EAAInB,SAAWD,EAEjC,MADI2B,KAASD,EAAW5C,EAAEqC,KAAKO,EAAUC,IAClCa,EAAUpB,EAAInB,OAAOyB,EAAUa,GAAQnB,EAAInB,OAAOyB,EAU3D,IARAD,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC1BK,EAIHD,EAAOb,EAASI,KAAKH,EAASY,EAAMN,EAAOC,EAAOC,IAHlDI,EAAON,EACPO,GAAU,MAKTA,EAAS,KAAM,IAAIE,WAAUN,EAClC,OAAOG,IAKTzD,EAAEqB,YAAcrB,EAAE6D,MAAQ,SAASvB,EAAKM,EAAUa,EAAMZ,GACtD,GAAIa,GAAUC,UAAUb,OAAS,CAEjC,IADW,MAAPR,IAAaA,MACblB,GAAqBkB,EAAIjB,cAAgBD,EAE3C,MADIyB,KAASD,EAAW5C,EAAEqC,KAAKO,EAAUC,IAClCa,EAAUpB,EAAIjB,YAAYuB,EAAUa,GAAQnB,EAAIjB,YAAYuB,EAErE,IAAIE,GAASR,EAAIQ,MACjB,IAAIA,KAAYA,EAAQ,CACtB,GAAIX,GAAOnC,EAAEmC,KAAKG,EAClBQ,GAASX,EAAKW,OAWhB,GATAH,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/BD,EAAQjB,EAAOA,IAAOW,KAAYA,EAC7BY,EAIHD,EAAOb,EAASI,KAAKH,EAASY,EAAMnB,EAAIc,GAAQA,EAAOC,IAHvDI,EAAOnB,EAAIc,GACXM,GAAU,MAKTA,EAAS,KAAM,IAAIE,WAAUN,EAClC,OAAOG,IAITzD,EAAE8D,KAAO9D,EAAE+D,OAAS,SAASzB,EAAKM,EAAUC,GAC1C,GAAImB,EAOJ,OANAC,GAAI3B,EAAK,SAASa,EAAOC,EAAOC,GAC9B,MAAIT,GAASI,KAAKH,EAASM,EAAOC,EAAOC,IACvCW,EAASb,GACF,GAFT,SAKKa,GAMThE,EAAEuB,OAASvB,EAAEkE,OAAS,SAAS5B,EAAKM,EAAUC,GAC5C,GAAIK,KACJ,OAAW,OAAPZ,EAAoBY,EACpB5B,GAAgBgB,EAAIf,SAAWD,EAAqBgB,EAAIf,OAAOqB,EAAUC,IAC7EF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC3BT,EAASI,KAAKH,EAASM,EAAOC,EAAOC,IAAOH,EAAQzC,KAAK0C,KAExDD,IAITlD,EAAEmE,OAAS,SAAS7B,EAAKM,EAAUC,GACjC,MAAO7C,GAAEuB,OAAOe,EAAK,SAASa,EAAOC,EAAOC,GAC1C,OAAQT,EAASI,KAAKH,EAASM,EAAOC,EAAOC,IAC5CR,IAML7C,EAAEyB,MAAQzB,EAAEoE,IAAM,SAAS9B,EAAKM,EAAUC,GACxCD,IAAaA,EAAW5C,EAAEqE,SAC1B,IAAIL,IAAS,CACb,OAAW,OAAP1B,EAAoB0B,EACpBxC,GAAec,EAAIb,QAAUD,EAAoBc,EAAIb,MAAMmB,EAAUC,IACzEF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,OAAMW,EAASA,GAAUpB,EAASI,KAAKH,EAASM,EAAOC,EAAOC,IAA9D,OAA6EpD,MAEtE+D,GAMX,IAAIC,GAAMjE,EAAE2B,KAAO3B,EAAEiE,IAAM,SAAS3B,EAAKM,EAAUC,GACjDD,IAAaA,EAAW5C,EAAEqE,SAC1B,IAAIL,IAAS,CACb,OAAW,OAAP1B,EAAoB0B,EACpBtC,GAAcY,EAAIX,OAASD,EAAmBY,EAAIX,KAAKiB,EAAUC,IACrEF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,MAAIW,KAAWA,EAASpB,EAASI,KAAKH,EAASM,EAAOC,EAAOC,IAAepD,EAA5E,WAEO+D,GAKXhE,GAAEsE,SAAWtE,EAAEuE,QAAU,SAASjC,EAAKkC,GACrC,MAAW,OAAPlC,GAAoB,EACpBV,GAAiBU,EAAIT,UAAYD,EAAsBU,EAAIT,QAAQ2C,KAAY,EAC5EP,EAAI3B,EAAK,SAASa,GACvB,MAAOA,KAAUqB,KAKrBxE,EAAEyE,OAAS,SAASnC,EAAKoC,GACvB,GAAIC,GAAOjE,EAAMsC,KAAKW,UAAW,GAC7BiB,EAAS5E,EAAE6E,WAAWH,EAC1B,OAAO1E,GAAEiB,IAAIqB,EAAK,SAASa,GACzB,OAAQyB,EAASF,EAASvB,EAAMuB,IAASI,MAAM3B,EAAOwB,MAK1D3E,EAAE+E,MAAQ,SAASzC,EAAK0C,GACtB,MAAOhF,GAAEiB,IAAIqB,EAAK,SAASa,GAAQ,MAAOA,GAAM6B,MAKlDhF,EAAEiF,MAAQ,SAAS3C,EAAK4C,EAAOC,GAC7B,MAAInF,GAAEoF,QAAQF,GAAeC,MAAa,MACnCnF,EAAEmF,EAAQ,OAAS,UAAU7C,EAAK,SAASa,GAChD,IAAK,GAAI6B,KAAOE,GACd,GAAIA,EAAMF,KAAS7B,EAAM6B,GAAM,OAAO,CAExC,QAAO,KAMXhF,EAAEqF,UAAY,SAAS/C,EAAK4C,GAC1B,MAAOlF,GAAEiF,MAAM3C,EAAK4C,GAAO,IAM7BlF,EAAEsF,IAAM,SAAShD,EAAKM,EAAUC,GAC9B,IAAKD,GAAY5C,EAAEiC,QAAQK,IAAQA,EAAI,MAAQA,EAAI,IAAMA,EAAIQ,OAAS,MACpE,MAAOyC,MAAKD,IAAIR,MAAMS,KAAMjD,EAE9B,KAAKM,GAAY5C,EAAEoF,QAAQ9C,GAAM,OAAQkD,GACzC,IAAIxB,IAAUyB,UAAYD,IAAUrC,OAAQqC,IAK5C,OAJA7C,GAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,GAAIoC,GAAW7C,EAAWA,EAASI,KAAKH,EAASM,EAAOC,EAAOC,GAAQF,CACvEsC,GAAWzB,EAAOyB,WAAazB,GAAUb,MAAQA,EAAOsC,SAAWA,MAE9DzB,EAAOb,OAIhBnD,EAAE0F,IAAM,SAASpD,EAAKM,EAAUC,GAC9B,IAAKD,GAAY5C,EAAEiC,QAAQK,IAAQA,EAAI,MAAQA,EAAI,IAAMA,EAAIQ,OAAS,MACpE,MAAOyC,MAAKG,IAAIZ,MAAMS,KAAMjD,EAE9B,KAAKM,GAAY5C,EAAEoF,QAAQ9C,GAAM,MAAOkD,IACxC,IAAIxB,IAAUyB,SAAWD,IAAUrC,MAAOqC,IAK1C,OAJA7C,GAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,GAAIoC,GAAW7C,EAAWA,EAASI,KAAKH,EAASM,EAAOC,EAAOC,GAAQF,CACvEsC,GAAWzB,EAAOyB,WAAazB,GAAUb,MAAQA,EAAOsC,SAAWA,MAE9DzB,EAAOb,OAKhBnD,EAAE2F,QAAU,SAASrD,GACnB,GAAIsD,GACAxC,EAAQ,EACRyC,IAMJ,OALAlD,GAAKL,EAAK,SAASa,GACjByC,EAAO5F,EAAE8F,OAAO1C,KAChByC,EAASzC,EAAQ,GAAKyC,EAASD,GAC/BC,EAASD,GAAQzC,IAEZ0C,GAMT7F,EAAE+F,OAAS,SAASzD,EAAK0D,EAAGC,GAC1B,MAAItC,WAAUb,OAAS,GAAKmD,EACnB3D,EAAItC,EAAE8F,OAAOxD,EAAIQ,OAAS,IAE5B9C,EAAE2F,QAAQrD,GAAK5B,MAAM,EAAG6E,KAAKD,IAAI,EAAGU,IAI7C,IAAIE,GAAiB,SAAS/C,GAC5B,MAAOnD,GAAE6E,WAAW1B,GAASA,EAAQ,SAASb,GAAM,MAAOA,GAAIa,IAIjEnD,GAAEmG,OAAS,SAAS7D,EAAKa,EAAON,GAC9B,GAAID,GAAWsD,EAAe/C,EAC9B,OAAOnD,GAAE+E,MAAM/E,EAAEiB,IAAIqB,EAAK,SAASa,EAAOC,EAAOC,GAC/C,OACEF,MAAOA,EACPC,MAAOA,EACPgD,SAAUxD,EAASI,KAAKH,EAASM,EAAOC,EAAOC,MAEhDgD,KAAK,SAASC,EAAMC,GACrB,GAAIC,GAAIF,EAAKF,SACTK,EAAIF,EAAMH,QACd,IAAII,IAAMC,EAAG,CACX,GAAID,EAAIC,GAAKD,QAAW,GAAG,MAAO,EAClC,IAAQC,EAAJD,GAASC,QAAW,GAAG,OAAQ,EAErC,MAAOH,GAAKlD,MAAQmD,EAAMnD,QACxB,SAIN,IAAIsD,GAAQ,SAASC,GACnB,MAAO,UAASrE,EAAKa,EAAON,GAC1B,GAAImB,MACApB,EAAoB,MAATO,EAAgBnD,EAAEqE,SAAW6B,EAAe/C,EAK3D,OAJAR,GAAKL,EAAK,SAASa,EAAOC,GACxB,GAAI4B,GAAMpC,EAASI,KAAKH,EAASM,EAAOC,EAAOd,EAC/CqE,GAAS3C,EAAQgB,EAAK7B,KAEjBa,GAMXhE,GAAE4G,QAAUF,EAAM,SAAS1C,EAAQgB,EAAK7B,IACrCnD,EAAE6G,IAAI7C,EAAQgB,GAAOhB,EAAOgB,GAAQhB,EAAOgB,OAAYvE,KAAK0C,KAK/DnD,EAAE8G,QAAUJ,EAAM,SAAS1C,EAAQgB,EAAK7B,GACtCa,EAAOgB,GAAO7B,IAMhBnD,EAAE+G,QAAUL,EAAM,SAAS1C,EAAQgB,GACjChF,EAAE6G,IAAI7C,EAAQgB,GAAOhB,EAAOgB,KAAShB,EAAOgB,GAAO,IAKrDhF,EAAEgH,YAAc,SAASC,EAAO3E,EAAKM,EAAUC,GAC7CD,EAAuB,MAAZA,EAAmB5C,EAAEqE,SAAW6B,EAAetD,EAG1D,KAFA,GAAIO,GAAQP,EAASI,KAAKH,EAASP,GAC/B4E,EAAM,EAAGC,EAAOF,EAAMnE,OACbqE,EAAND,GAAY,CACjB,GAAIE,GAAOF,EAAMC,IAAU,CAC3BvE,GAASI,KAAKH,EAASoE,EAAMG,IAAQjE,EAAQ+D,EAAME,EAAM,EAAID,EAAOC,EAEtE,MAAOF,IAITlH,EAAEqH,QAAU,SAAS/E,GACnB,MAAKA,GACDtC,EAAEiC,QAAQK,GAAa5B,EAAMsC,KAAKV,GAClCA,EAAIQ,UAAYR,EAAIQ,OAAe9C,EAAEiB,IAAIqB,EAAKtC,EAAEqE,UAC7CrE,EAAEsH,OAAOhF,OAIlBtC,EAAEuH,KAAO,SAASjF,GAChB,MAAW,OAAPA,EAAoB,EAChBA,EAAIQ,UAAYR,EAAIQ,OAAUR,EAAIQ,OAAS9C,EAAEmC,KAAKG,GAAKQ,QASjE9C,EAAEmF,MAAQnF,EAAEwH,KAAOxH,EAAEyH,KAAO,SAASR,EAAOjB,EAAGC,GAC7C,MAAa,OAATgB,MAA2B,GAClB,MAALjB,GAAcC,EAAQgB,EAAM,GAAKvG,EAAMsC,KAAKiE,EAAO,EAAGjB,IAOhEhG,EAAE0D,QAAU,SAASuD,EAAOjB,EAAGC,GAC7B,MAAOvF,GAAMsC,KAAKiE,EAAO,EAAGA,EAAMnE,QAAgB,MAALkD,GAAcC,EAAQ,EAAID,KAKzEhG,EAAE0H,KAAO,SAAST,EAAOjB,EAAGC,GAC1B,MAAa,OAATgB,MAA2B,GACrB,MAALjB,GAAcC,EACVgB,EAAMA,EAAMnE,OAAS,GAErBpC,EAAMsC,KAAKiE,EAAO1B,KAAKD,IAAI2B,EAAMnE,OAASkD,EAAG,KAQxDhG,EAAE2H,KAAO3H,EAAE4H,KAAO5H,EAAE6H,KAAO,SAASZ,EAAOjB,EAAGC,GAC5C,MAAOvF,GAAMsC,KAAKiE,EAAa,MAALjB,GAAcC,EAAQ,EAAID,IAItDhG,EAAE8H,QAAU,SAASb,GACnB,MAAOjH,GAAEuB,OAAO0F,EAAOjH,EAAEqE,UAI3B,IAAI0D,GAAU,SAASC,EAAOC,EAASC,GACrC,MAAID,IAAWjI,EAAEyB,MAAMuG,EAAOhI,EAAEiC,SACvBtB,EAAOmE,MAAMoD,EAAQF,IAE9BrF,EAAKqF,EAAO,SAAS7E,GACfnD,EAAEiC,QAAQkB,IAAUnD,EAAEmI,YAAYhF,GACpC8E,EAAUxH,EAAKqE,MAAMoD,EAAQ/E,GAAS4E,EAAQ5E,EAAO8E,EAASC,GAE9DA,EAAOzH,KAAK0C,KAGT+E,GAITlI,GAAE+H,QAAU,SAASd,EAAOgB,GAC1B,MAAOF,GAAQd,EAAOgB,OAIxBjI,EAAEoI,QAAU,SAASnB,GACnB,MAAOjH,GAAEqI,WAAWpB,EAAOvG,EAAMsC,KAAKW,UAAW,KAMnD3D,EAAEsI,KAAOtI,EAAEuI,OAAS,SAAStB,EAAOuB,EAAU5F,EAAUC,GAClD7C,EAAE6E,WAAW2D,KACf3F,EAAUD,EACVA,EAAW4F,EACXA,GAAW,EAEb,IAAI9E,GAAUd,EAAW5C,EAAEiB,IAAIgG,EAAOrE,EAAUC,GAAWoE,EACvD/D,KACAuF,IAOJ,OANA9F,GAAKe,EAAS,SAASP,EAAOC,IACxBoF,EAAapF,GAASqF,EAAKA,EAAK3F,OAAS,KAAOK,EAAUnD,EAAEsE,SAASmE,EAAMtF,MAC7EsF,EAAKhI,KAAK0C,GACVD,EAAQzC,KAAKwG,EAAM7D,OAGhBF,GAKTlD,EAAE0I,MAAQ,WACR,MAAO1I,GAAEsI,KAAKtI,EAAE+H,QAAQpE,WAAW,KAKrC3D,EAAE2I,aAAe,SAAS1B,GACxB,GAAIU,GAAOjH,EAAMsC,KAAKW,UAAW,EACjC,OAAO3D,GAAEuB,OAAOvB,EAAEsI,KAAKrB,GAAQ,SAAS2B,GACtC,MAAO5I,GAAEyB,MAAMkG,EAAM,SAASkB,GAC5B,MAAO7I,GAAE6B,QAAQgH,EAAOD,IAAS,OAOvC5I,EAAEqI,WAAa,SAASpB,GACtB,GAAIU,GAAOhH,EAAOmE,MAAM5E,EAAYQ,EAAMsC,KAAKW,UAAW,GAC1D,OAAO3D,GAAEuB,OAAO0F,EAAO,SAAS9D,GAAQ,OAAQnD,EAAEsE,SAASqD,EAAMxE,MAKnEnD,EAAE8I,IAAM,WAGN,IAAK,GAFDhG,GAAS9C,EAAEsF,IAAItF,EAAE+E,MAAMpB,UAAW,UAAUhD,OAAO,IACnDuC,EAAU,GAAI/C,OAAM2C,GACfC,EAAI,EAAOD,EAAJC,EAAYA,IAC1BG,EAAQH,GAAK/C,EAAE+E,MAAMpB,UAAW,GAAKZ,EAEvC,OAAOG,IAMTlD,EAAE+I,OAAS,SAAS1F,EAAMiE,GACxB,GAAY,MAARjE,EAAc,QAElB,KAAK,GADDW,MACKjB,EAAI,EAAGD,EAASO,EAAKP,OAAYA,EAAJC,EAAYA,IAC5CuE,EACFtD,EAAOX,EAAKN,IAAMuE,EAAOvE,GAEzBiB,EAAOX,EAAKN,GAAG,IAAMM,EAAKN,GAAG,EAGjC,OAAOiB,IASThE,EAAE6B,QAAU,SAASoF,EAAO2B,EAAMJ,GAChC,GAAa,MAATvB,EAAe,OAAQ,CAC3B,IAAIlE,GAAI,EAAGD,EAASmE,EAAMnE,MAC1B,IAAI0F,EAAU,CACZ,GAAuB,gBAAZA,GAIT,MADAzF,GAAI/C,EAAEgH,YAAYC,EAAO2B,GAClB3B,EAAMlE,KAAO6F,EAAO7F,GAAK,CAHhCA,GAAgB,EAAXyF,EAAejD,KAAKD,IAAI,EAAGxC,EAAS0F,GAAYA,EAMzD,GAAI5G,GAAiBqF,EAAMpF,UAAYD,EAAe,MAAOqF,GAAMpF,QAAQ+G,EAAMJ,EACjF,MAAW1F,EAAJC,EAAYA,IAAK,GAAIkE,EAAMlE,KAAO6F,EAAM,MAAO7F,EACtD,QAAQ,GAIV/C,EAAE+B,YAAc,SAASkF,EAAO2B,EAAMI,GACpC,GAAa,MAAT/B,EAAe,OAAQ,CAC3B,IAAIgC,GAAmB,MAARD,CACf,IAAIlH,GAAqBmF,EAAMlF,cAAgBD,EAC7C,MAAOmH,GAAWhC,EAAMlF,YAAY6G,EAAMI,GAAQ/B,EAAMlF,YAAY6G,EAGtE,KADA,GAAI7F,GAAKkG,EAAWD,EAAO/B,EAAMnE,OAC1BC,KAAK,GAAIkE,EAAMlE,KAAO6F,EAAM,MAAO7F,EAC1C,QAAQ,GAMV/C,EAAEkJ,MAAQ,SAASC,EAAOC,EAAMC,GAC1B1F,UAAUb,QAAU,IACtBsG,EAAOD,GAAS,EAChBA,EAAQ,GAEVE,EAAO1F,UAAU,IAAM,CAMvB,KAJA,GAAIb,GAASyC,KAAKD,IAAIC,KAAK+D,MAAMF,EAAOD,GAASE,GAAO,GACpDE,EAAM,EACNL,EAAQ,GAAI/I,OAAM2C,GAEVA,EAANyG,GACJL,EAAMK,KAASJ,EACfA,GAASE,CAGX,OAAOH,GAOT,IAAIM,GAAO,YAKXxJ,GAAEqC,KAAO,SAASoH,EAAM5G,GACtB,GAAI8B,GAAM+E,CACV,IAAItH,GAAcqH,EAAKpH,OAASD,EAAY,MAAOA,GAAW0C,MAAM2E,EAAM/I,EAAMsC,KAAKW,UAAW,GAChG,KAAK3D,EAAE6E,WAAW4E,GAAO,KAAM,IAAI7F,UAEnC,OADAe,GAAOjE,EAAMsC,KAAKW,UAAW,GACtB+F,EAAQ,WACb,KAAM5J,eAAgB4J,IAAQ,MAAOD,GAAK3E,MAAMjC,EAAS8B,EAAKhE,OAAOD,EAAMsC,KAAKW,YAChF6F,GAAKpJ,UAAYqJ,EAAKrJ,SACtB,IAAIuJ,GAAO,GAAIH,EACfA,GAAKpJ,UAAY,IACjB,IAAI4D,GAASyF,EAAK3E,MAAM6E,EAAMhF,EAAKhE,OAAOD,EAAMsC,KAAKW,YACrD,OAAIrD,QAAO0D,KAAYA,EAAeA,EAC/B2F,IAMX3J,EAAE4J,QAAU,SAASH,GACnB,GAAI9E,GAAOjE,EAAMsC,KAAKW,UAAW,EACjC,OAAO,YACL,MAAO8F,GAAK3E,MAAMhF,KAAM6E,EAAKhE,OAAOD,EAAMsC,KAAKW,eAMnD3D,EAAE6J,QAAU,SAASvH,GACnB,GAAIwH,GAAQpJ,EAAMsC,KAAKW,UAAW,EAClC,IAAqB,IAAjBmG,EAAMhH,OAAc,KAAM,IAAIiH,OAAM,wCAExC,OADApH,GAAKmH,EAAO,SAASE,GAAK1H,EAAI0H,GAAKhK,EAAEqC,KAAKC,EAAI0H,GAAI1H,KAC3CA,GAITtC,EAAEiK,QAAU,SAASR,EAAMS,GACzB,GAAIzG,KAEJ,OADAyG,KAAWA,EAASlK,EAAEqE,UACf,WACL,GAAIW,GAAMkF,EAAOpF,MAAMhF,KAAM6D,UAC7B,OAAO3D,GAAE6G,IAAIpD,EAAMuB,GAAOvB,EAAKuB,GAAQvB,EAAKuB,GAAOyE,EAAK3E,MAAMhF,KAAM6D,aAMxE3D,EAAEmK,MAAQ,SAASV,EAAMW,GACvB,GAAIzF,GAAOjE,EAAMsC,KAAKW,UAAW,EACjC,OAAO0G,YAAW,WAAY,MAAOZ,GAAK3E,MAAM,KAAMH,IAAUyF,IAKlEpK,EAAEsK,MAAQ,SAASb,GACjB,MAAOzJ,GAAEmK,MAAMrF,MAAM9E,GAAIyJ,EAAM,GAAG9I,OAAOD,EAAMsC,KAAKW,UAAW,MAQjE3D,EAAEuK,SAAW,SAASd,EAAMW,EAAMI,GAChC,GAAI3H,GAAS8B,EAAMX,EACfyG,EAAU,KACVC,EAAW,CACfF,KAAYA,KACZ,IAAIG,GAAQ,WACVD,EAAWF,EAAQI,WAAY,EAAQ,EAAI,GAAIC,MAC/CJ,EAAU,KACVzG,EAASyF,EAAK3E,MAAMjC,EAAS8B,GAE/B,OAAO,YACL,GAAImG,GAAM,GAAID,KACTH,IAAYF,EAAQI,WAAY,IAAOF,EAAWI,EACvD,IAAIC,GAAYX,GAAQU,EAAMJ,EAW9B,OAVA7H,GAAU/C,KACV6E,EAAOhB,UACU,GAAboH,GACFC,aAAaP,GACbA,EAAU,KACVC,EAAWI,EACX9G,EAASyF,EAAK3E,MAAMjC,EAAS8B,IACnB8F,GAAWD,EAAQS,YAAa,IAC1CR,EAAUJ,WAAWM,EAAOI,IAEvB/G,IAQXhE,EAAEkL,SAAW,SAASzB,EAAMW,EAAMe,GAChC,GAAIV,GAAS9F,EAAM9B,EAASuI,EAAWpH,CACvC,OAAO,YACLnB,EAAU/C,KACV6E,EAAOhB,UACPyH,EAAY,GAAIP,KAChB,IAAIF,GAAQ,WACV,GAAIjD,GAAO,GAAKmD,MAAUO,CACfhB,GAAP1C,EACF+C,EAAUJ,WAAWM,EAAOP,EAAO1C,IAEnC+C,EAAU,KACLU,IAAWnH,EAASyF,EAAK3E,MAAMjC,EAAS8B,MAG7C0G,EAAUF,IAAcV,CAK5B,OAJKA,KACHA,EAAUJ,WAAWM,EAAOP,IAE1BiB,IAASrH,EAASyF,EAAK3E,MAAMjC,EAAS8B,IACnCX,IAMXhE,EAAEsL,KAAO,SAAS7B,GAChB,GAAiBhG,GAAb8H,GAAM,CACV,OAAO,YACL,MAAIA,GAAY9H,GAChB8H,GAAM,EACN9H,EAAOgG,EAAK3E,MAAMhF,KAAM6D,WACxB8F,EAAO,KACAhG,KAOXzD,EAAEwL,KAAO,SAAS/B,EAAMgC,GACtB,MAAO,YACL,GAAI9G,IAAQ8E,EAEZ,OADAhJ,GAAKqE,MAAMH,EAAMhB,WACV8H,EAAQ3G,MAAMhF,KAAM6E,KAM/B3E,EAAE0L,QAAU,WACV,GAAI5B,GAAQnG,SACZ,OAAO,YAEL,IAAK,GADDgB,GAAOhB,UACFZ,EAAI+G,EAAMhH,OAAS,EAAGC,GAAK,EAAGA,IACrC4B,GAAQmF,EAAM/G,GAAG+B,MAAMhF,KAAM6E,GAE/B,OAAOA,GAAK,KAKhB3E,EAAE2L,MAAQ,SAASC,EAAOnC,GACxB,MAAO,YACL,QAAMmC,EAAQ,EACLnC,EAAK3E,MAAMhF,KAAM6D,WAD1B,SAWJ3D,EAAEmC,KAAOD,GAAc,SAASI,GAC9B,GAAIA,IAAQhC,OAAOgC,GAAM,KAAM,IAAIsB,WAAU,iBAC7C,IAAIzB,KACJ,KAAK,GAAI6C,KAAO1C,GAAStC,EAAE6G,IAAIvE,EAAK0C,IAAM7C,EAAK1B,KAAKuE,EACpD,OAAO7C,IAITnC,EAAEsH,OAAS,SAAShF,GAIlB,IAAK,GAHDH,GAAOnC,EAAEmC,KAAKG,GACdQ,EAASX,EAAKW,OACdwE,EAAS,GAAInH,OAAM2C,GACdC,EAAI,EAAOD,EAAJC,EAAYA,IAC1BuE,EAAOvE,GAAKT,EAAIH,EAAKY,GAEvB,OAAOuE,IAITtH,EAAE6L,MAAQ,SAASvJ,GAIjB,IAAK,GAHDH,GAAOnC,EAAEmC,KAAKG,GACdQ,EAASX,EAAKW,OACd+I,EAAQ,GAAI1L,OAAM2C,GACbC,EAAI,EAAOD,EAAJC,EAAYA,IAC1B8I,EAAM9I,IAAMZ,EAAKY,GAAIT,EAAIH,EAAKY,IAEhC,OAAO8I,IAIT7L,EAAE8L,OAAS,SAASxJ,GAGlB,IAAK,GAFD0B,MACA7B,EAAOnC,EAAEmC,KAAKG,GACTS,EAAI,EAAGD,EAASX,EAAKW,OAAYA,EAAJC,EAAYA,IAChDiB,EAAO1B,EAAIH,EAAKY,KAAOZ,EAAKY,EAE9B,OAAOiB,IAKThE,EAAE+L,UAAY/L,EAAEgM,QAAU,SAAS1J,GACjC,GAAI2J,KACJ,KAAK,GAAIjH,KAAO1C,GACVtC,EAAE6E,WAAWvC,EAAI0C,KAAOiH,EAAMxL,KAAKuE,EAEzC,OAAOiH,GAAM5F,QAIfrG,EAAEkM,OAAS,SAAS5J,GAQlB,MAPAK,GAAKjC,EAAMsC,KAAKW,UAAW,GAAI,SAASwI,GACtC,GAAIA,EACF,IAAK,GAAIC,KAAQD,GACf7J,EAAI8J,GAAQD,EAAOC,KAIlB9J,GAITtC,EAAEqM,KAAO,SAAS/J,GAChB,GAAIgK,MACAnK,EAAOxB,EAAOmE,MAAM5E,EAAYQ,EAAMsC,KAAKW,UAAW,GAI1D,OAHAhB,GAAKR,EAAM,SAAS6C,GACdA,IAAO1C,KAAKgK,EAAKtH,GAAO1C,EAAI0C,MAE3BsH,GAITtM,EAAEuM,KAAO,SAASjK,GAChB,GAAIgK,MACAnK,EAAOxB,EAAOmE,MAAM5E,EAAYQ,EAAMsC,KAAKW,UAAW,GAC1D,KAAK,GAAIqB,KAAO1C,GACTtC,EAAEsE,SAASnC,EAAM6C,KAAMsH,EAAKtH,GAAO1C,EAAI0C,GAE9C,OAAOsH,IAITtM,EAAEwM,SAAW,SAASlK,GAQpB,MAPAK,GAAKjC,EAAMsC,KAAKW,UAAW,GAAI,SAASwI,GACtC,GAAIA,EACF,IAAK,GAAIC,KAAQD,GACX7J,EAAI8J,SAAe,KAAG9J,EAAI8J,GAAQD,EAAOC,MAI5C9J,GAITtC,EAAEyM,MAAQ,SAASnK,GACjB,MAAKtC,GAAE0M,SAASpK,GACTtC,EAAEiC,QAAQK,GAAOA,EAAI5B,QAAUV,EAAEkM,UAAW5J,GADtBA,GAO/BtC,EAAE2M,IAAM,SAASrK,EAAKsK,GAEpB,MADAA,GAAYtK,GACLA,EAIT,IAAIuK,GAAK,SAASrG,EAAGC,EAAGqG,EAAQC,GAG9B,GAAIvG,IAAMC,EAAG,MAAa,KAAND,GAAW,EAAIA,GAAK,EAAIC,CAE5C,IAAS,MAALD,GAAkB,MAALC,EAAW,MAAOD,KAAMC,CAErCD,aAAaxG,KAAGwG,EAAIA,EAAEjE,UACtBkE,YAAazG,KAAGyG,EAAIA,EAAElE,SAE1B,IAAIyK,GAAYpM,EAASoC,KAAKwD,EAC9B,IAAIwG,GAAapM,EAASoC,KAAKyD,GAAI,OAAO,CAC1C,QAAQuG,GAEN,IAAK,kBAGH,MAAOxG,IAAKyG,OAAOxG,EACrB,KAAK,kBAGH,MAAOD,KAAMA,EAAIC,IAAMA,EAAU,GAALD,EAAS,EAAIA,GAAK,EAAIC,EAAID,IAAMC,CAC9D,KAAK,gBACL,IAAK,mBAIH,OAAQD,IAAMC,CAEhB,KAAK,kBACH,MAAOD,GAAE2F,QAAU1F,EAAE0F,QACd3F,EAAE0G,QAAUzG,EAAEyG,QACd1G,EAAE2G,WAAa1G,EAAE0G,WACjB3G,EAAE4G,YAAc3G,EAAE2G,WAE7B,GAAgB,gBAAL5G,IAA6B,gBAALC,GAAe,OAAO,CAIzD,KADA,GAAI3D,GAASgK,EAAOhK,OACbA,KAGL,GAAIgK,EAAOhK,IAAW0D,EAAG,MAAOuG,GAAOjK,IAAW2D,CAIpD,IAAI4G,GAAQ7G,EAAE8G,YAAaC,EAAQ9G,EAAE6G,WACrC,IAAID,IAAUE,KAAWvN,EAAE6E,WAAWwI,IAAWA,YAAiBA,IACzCrN,EAAE6E,WAAW0I,IAAWA,YAAiBA,IAChE,OAAO,CAGTT,GAAOrM,KAAK+F,GACZuG,EAAOtM,KAAKgG,EACZ,IAAIc,GAAO,EAAGvD,GAAS,CAEvB,IAAiB,kBAAbgJ,GAIF,GAFAzF,EAAOf,EAAE1D,OACTkB,EAASuD,GAAQd,EAAE3D,OAGjB,KAAOyE,MACCvD,EAAS6I,EAAGrG,EAAEe,GAAOd,EAAEc,GAAOuF,EAAQC,WAG3C,CAEL,IAAK,GAAI/H,KAAOwB,GACd,GAAIxG,EAAE6G,IAAIL,EAAGxB,KAEXuC,MAEMvD,EAAShE,EAAE6G,IAAIJ,EAAGzB,IAAQ6H,EAAGrG,EAAExB,GAAMyB,EAAEzB,GAAM8H,EAAQC,KAAU,KAIzE,IAAI/I,EAAQ,CACV,IAAKgB,IAAOyB,GACV,GAAIzG,EAAE6G,IAAIJ,EAAGzB,KAAUuC,IAAS,KAElCvD,IAAUuD,GAMd,MAFAuF,GAAOU,MACPT,EAAOS,MACAxJ,EAIThE,GAAEyN,QAAU,SAASjH,EAAGC,GACtB,MAAOoG,GAAGrG,EAAGC,UAKfzG,EAAEoF,QAAU,SAAS9C,GACnB,GAAW,MAAPA,EAAa,OAAO,CACxB,IAAItC,EAAEiC,QAAQK,IAAQtC,EAAE0N,SAASpL,GAAM,MAAsB,KAAfA,EAAIQ,MAClD,KAAK,GAAIkC,KAAO1C,GAAK,GAAItC,EAAE6G,IAAIvE,EAAK0C,GAAM,OAAO,CACjD,QAAO,GAIThF,EAAE2N,UAAY,SAASrL,GACrB,SAAUA,GAAwB,IAAjBA,EAAIsL,WAKvB5N,EAAEiC,QAAUD,GAAiB,SAASM,GACpC,MAA6B,kBAAtB1B,EAASoC,KAAKV,IAIvBtC,EAAE0M,SAAW,SAASpK,GACpB,MAAOA,KAAQhC,OAAOgC,IAIxBK,GAAM,YAAa,WAAY,SAAU,SAAU,OAAQ,UAAW,SAASkL,GAC7E7N,EAAE,KAAO6N,GAAQ,SAASvL,GACxB,MAAO1B,GAASoC,KAAKV,IAAQ,WAAauL,EAAO,OAMhD7N,EAAEmI,YAAYxE,aACjB3D,EAAEmI,YAAc,SAAS7F,GACvB,SAAUA,IAAOtC,EAAE6G,IAAIvE,EAAK,aAKX,kBAAV,MACTtC,EAAE6E,WAAa,SAASvC,GACtB,MAAsB,kBAARA,KAKlBtC,EAAE8N,SAAW,SAASxL,GACpB,MAAOwL,UAASxL,KAASyL,MAAMC,WAAW1L,KAI5CtC,EAAE+N,MAAQ,SAASzL,GACjB,MAAOtC,GAAEiO,SAAS3L,IAAQA,IAAQA,GAIpCtC,EAAEkO,UAAY,SAAS5L,GACrB,MAAOA,MAAQ,GAAQA,KAAQ,GAA+B,oBAAtB1B,EAASoC,KAAKV,IAIxDtC,EAAEmO,OAAS,SAAS7L,GAClB,MAAe,QAARA,GAITtC,EAAEoO,YAAc,SAAS9L,GACvB,MAAOA,SAAa,IAKtBtC,EAAE6G,IAAM,SAASvE,EAAK0C,GACpB,MAAOnE,GAAemC,KAAKV,EAAK0C,IAQlChF,EAAEqO,WAAa,WAEb,MADAxO,GAAKG,EAAID,EACFD,MAITE,EAAEqE,SAAW,SAASlB,GACpB,MAAOA,IAITnD,EAAE4L,MAAQ,SAAS5F,EAAGpD,EAAUC,GAE9B,IAAK,GADDyL,GAAQnO,MAAMoF,KAAKD,IAAI,EAAGU,IACrBjD,EAAI,EAAOiD,EAAJjD,EAAOA,IAAKuL,EAAMvL,GAAKH,EAASI,KAAKH,EAASE,EAC9D,OAAOuL,IAITtO,EAAE8F,OAAS,SAASJ,EAAKJ,GAKvB,MAJW,OAAPA,IACFA,EAAMI,EACNA,EAAM,GAEDA,EAAMH,KAAKgJ,MAAMhJ,KAAKO,UAAYR,EAAMI,EAAM,IAIvD,IAAI8I,IACFC,QACEC,IAAK,QACLC,IAAK,OACLC,IAAK,OACLC,IAAK,SACLC,IAAK,UAGTN,GAAUO,SAAW/O,EAAE8L,OAAO0C,EAAUC,OAGxC,IAAIO,IACFP,OAAU,GAAIQ,QAAO,IAAMjP,EAAEmC,KAAKqM,EAAUC,QAAQS,KAAK,IAAM,IAAK,KACpEH,SAAU,GAAIE,QAAO,IAAMjP,EAAEmC,KAAKqM,EAAUO,UAAUG,KAAK,KAAO,IAAK,KAIzElP,GAAE2C,MAAM,SAAU,YAAa,SAAS+B,GACtC1E,EAAE0E,GAAU,SAASyK,GACnB,MAAc,OAAVA,EAAuB,IACnB,GAAKA,GAAQC,QAAQJ,EAActK,GAAS,SAAS2K,GAC3D,MAAOb,GAAU9J,GAAQ2K,QAO/BrP,EAAEgE,OAAS,SAAS+E,EAAQuG,GAC1B,GAAc,MAAVvG,EAAgB,WAAY,EAChC,IAAI5F,GAAQ4F,EAAOuG,EACnB,OAAOtP,GAAE6E,WAAW1B,GAASA,EAAMH,KAAK+F,GAAU5F,GAIpDnD,EAAEuP,MAAQ,SAASjN,GACjBK,EAAK3C,EAAE+L,UAAUzJ,GAAM,SAASuL,GAC9B,GAAIpE,GAAOzJ,EAAE6N,GAAQvL,EAAIuL,EACzB7N,GAAEI,UAAUyN,GAAQ,WAClB,GAAIlJ,IAAQ7E,KAAKyC,SAEjB,OADA9B,GAAKqE,MAAMH,EAAMhB,WACVK,EAAOhB,KAAKlD,KAAM2J,EAAK3E,MAAM9E,EAAG2E,OAO7C,IAAI6K,GAAY,CAChBxP,GAAEyP,SAAW,SAASC,GACpB,GAAIC,KAAOH,EAAY,EACvB,OAAOE,GAASA,EAASC,EAAKA,GAKhC3P,EAAE4P,kBACAC,SAAc,kBACdC,YAAc,mBACdrB,OAAc,mBAMhB,IAAIsB,GAAU,OAIVC,GACFlB,IAAU,IACVmB,KAAU,KACVC,KAAU,IACVC,KAAU,IACVC,IAAU,IACVC,SAAU,QACVC,SAAU,SAGRC,EAAU,8BAKdvQ,GAAEwQ,SAAW,SAASC,EAAMC,EAAMC,GAChC,GAAIC,EACJD,GAAW3Q,EAAEwM,YAAamE,EAAU3Q,EAAE4P,iBAGtC,IAAIiB,GAAU,GAAI5B,UACf0B,EAASlC,QAAUsB,GAAS5D,QAC5BwE,EAASb,aAAeC,GAAS5D,QACjCwE,EAASd,UAAYE,GAAS5D,QAC/B+C,KAAK,KAAO,KAAM,KAGhB9L,EAAQ,EACR+I,EAAS,QACbsE,GAAKrB,QAAQyB,EAAS,SAASxB,EAAOZ,EAAQqB,EAAaD,EAAUiB,GAcnE,MAbA3E,IAAUsE,EAAK/P,MAAM0C,EAAO0N,GACzB1B,QAAQmB,EAAS,SAASlB,GAAS,MAAO,KAAOW,EAAQX,KAExDZ,IACFtC,GAAU,cAAgBsC,EAAS,kCAEjCqB,IACF3D,GAAU,cAAgB2D,EAAc,wBAEtCD,IACF1D,GAAU,OAAS0D,EAAW,YAEhCzM,EAAQ0N,EAASzB,EAAMvM,OAChBuM,IAETlD,GAAU,OAGLwE,EAASI,WAAU5E,EAAS,mBAAqBA,EAAS,OAE/DA,EAAS,2CACP,oDACAA,EAAS,eAEX,KACEyE,EAAS,GAAIpQ,UAASmQ,EAASI,UAAY,MAAO,IAAK5E,GACvD,MAAO6E,GAEP,KADAA,GAAE7E,OAASA,EACL6E,EAGR,GAAIN,EAAM,MAAOE,GAAOF,EAAM1Q,EAC9B,IAAIwQ,GAAW,SAASE,GACtB,MAAOE,GAAO5N,KAAKlD,KAAM4Q,EAAM1Q,GAMjC,OAFAwQ,GAASrE,OAAS,aAAewE,EAASI,UAAY,OAAS,OAAS5E,EAAS,IAE1EqE,GAITxQ,EAAEiR,MAAQ,SAAS3O,GACjB,MAAOtC,GAAEsC,GAAK2O,QAUhB,IAAIjN,GAAS,SAAS1B,GACpB,MAAOxC,MAAKoR,OAASlR,EAAEsC,GAAK2O,QAAU3O,EAIxCtC,GAAEuP,MAAMvP,GAGR2C,GAAM,MAAO,OAAQ,UAAW,QAAS,OAAQ,SAAU,WAAY,SAASkL,GAC9E,GAAInJ,GAASxE,EAAW2N,EACxB7N,GAAEI,UAAUyN,GAAQ,WAClB,GAAIvL,GAAMxC,KAAKyC,QAGf,OAFAmC,GAAOI,MAAMxC,EAAKqB,WACL,SAARkK,GAA2B,UAARA,GAAoC,IAAfvL,EAAIQ,cAAqBR,GAAI,GACnE0B,EAAOhB,KAAKlD,KAAMwC,MAK7BK,GAAM,SAAU,OAAQ,SAAU,SAASkL,GACzC,GAAInJ,GAASxE,EAAW2N,EACxB7N,GAAEI,UAAUyN,GAAQ,WAClB,MAAO7J,GAAOhB,KAAKlD,KAAM4E,EAAOI,MAAMhF,KAAKyC,SAAUoB,eAIzD3D,EAAEkM,OAAOlM,EAAEI,WAGT6Q,MAAO,WAEL,MADAnR,MAAKoR,QAAS,EACPpR,MAITqD,MAAO,WACL,MAAOrD,MAAKyC,cAKfS,KAAKlD"} \ No newline at end of file diff --git a/bower_components/underscore/underscore.js b/bower_components/underscore/underscore.js new file mode 100644 index 0000000..b50115d --- /dev/null +++ b/bower_components/underscore/underscore.js @@ -0,0 +1,1276 @@ +// Underscore.js 1.5.2 +// http://underscorejs.org +// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. + +(function() { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `exports` on the server. + var root = this; + + // Save the previous value of the `_` variable. + var previousUnderscore = root._; + + // Establish the object that gets returned to break out of a loop iteration. + var breaker = {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + + // Create quick reference variables for speed access to core prototypes. + var + push = ArrayProto.push, + slice = ArrayProto.slice, + concat = ArrayProto.concat, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // All **ECMAScript 5** native function implementations that we hope to use + // are declared here. + var + nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeReduceRight = ArrayProto.reduceRight, + nativeFilter = ArrayProto.filter, + nativeEvery = ArrayProto.every, + nativeSome = ArrayProto.some, + nativeIndexOf = ArrayProto.indexOf, + nativeLastIndexOf = ArrayProto.lastIndexOf, + nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind; + + // Create a safe reference to the Underscore object for use below. + var _ = function(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + }; + + // Export the Underscore object for **Node.js**, with + // backwards-compatibility for the old `require()` API. If we're in + // the browser, add `_` as a global object via a string identifier, + // for Closure Compiler "advanced" mode. + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = _; + } + exports._ = _; + } else { + root._ = _; + } + + // Current version. + _.VERSION = '1.5.2'; + + // Collection Functions + // -------------------- + + // The cornerstone, an `each` implementation, aka `forEach`. + // Handles objects with the built-in `forEach`, arrays, and raw objects. + // Delegates to **ECMAScript 5**'s native `forEach` if available. + var each = _.each = _.forEach = function(obj, iterator, context) { + if (obj == null) return; + if (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } else if (obj.length === +obj.length) { + for (var i = 0, length = obj.length; i < length; i++) { + if (iterator.call(context, obj[i], i, obj) === breaker) return; + } + } else { + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; + } + } + }; + + // Return the results of applying the iterator to each element. + // Delegates to **ECMAScript 5**'s native `map` if available. + _.map = _.collect = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); + each(obj, function(value, index, list) { + results.push(iterator.call(context, value, index, list)); + }); + return results; + }; + + var reduceError = 'Reduce of empty array with no initial value'; + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. + _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); + } + each(obj, function(value, index, list) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // The right-associative version of reduce, also known as `foldr`. + // Delegates to **ECMAScript 5**'s native `reduceRight` if available. + _.reduceRight = _.foldr = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + } + var length = obj.length; + if (length !== +length) { + var keys = _.keys(obj); + length = keys.length; + } + each(obj, function(value, index, list) { + index = keys ? keys[--length] : --length; + if (!initial) { + memo = obj[index]; + initial = true; + } else { + memo = iterator.call(context, memo, obj[index], index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // Return the first value which passes a truth test. Aliased as `detect`. + _.find = _.detect = function(obj, iterator, context) { + var result; + any(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) { + result = value; + return true; + } + }); + return result; + }; + + // Return all the elements that pass a truth test. + // Delegates to **ECMAScript 5**'s native `filter` if available. + // Aliased as `select`. + _.filter = _.select = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); + each(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) results.push(value); + }); + return results; + }; + + // Return all the elements for which a truth test fails. + _.reject = function(obj, iterator, context) { + return _.filter(obj, function(value, index, list) { + return !iterator.call(context, value, index, list); + }, context); + }; + + // Determine whether all of the elements match a truth test. + // Delegates to **ECMAScript 5**'s native `every` if available. + // Aliased as `all`. + _.every = _.all = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = true; + if (obj == null) return result; + if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); + each(obj, function(value, index, list) { + if (!(result = result && iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if at least one element in the object matches a truth test. + // Delegates to **ECMAScript 5**'s native `some` if available. + // Aliased as `any`. + var any = _.some = _.any = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = false; + if (obj == null) return result; + if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); + each(obj, function(value, index, list) { + if (result || (result = iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if the array or object contains a given value (using `===`). + // Aliased as `include`. + _.contains = _.include = function(obj, target) { + if (obj == null) return false; + if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; + return any(obj, function(value) { + return value === target; + }); + }; + + // Invoke a method (with arguments) on every item in a collection. + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + return (isFunc ? method : value[method]).apply(value, args); + }); + }; + + // Convenience version of a common use case of `map`: fetching a property. + _.pluck = function(obj, key) { + return _.map(obj, function(value){ return value[key]; }); + }; + + // Convenience version of a common use case of `filter`: selecting only objects + // containing specific `key:value` pairs. + _.where = function(obj, attrs, first) { + if (_.isEmpty(attrs)) return first ? void 0 : []; + return _[first ? 'find' : 'filter'](obj, function(value) { + for (var key in attrs) { + if (attrs[key] !== value[key]) return false; + } + return true; + }); + }; + + // Convenience version of a common use case of `find`: getting the first object + // containing specific `key:value` pairs. + _.findWhere = function(obj, attrs) { + return _.where(obj, attrs, true); + }; + + // Return the maximum element or (element-based computation). + // Can't optimize arrays of integers longer than 65,535 elements. + // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) + _.max = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.max.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return -Infinity; + var result = {computed : -Infinity, value: -Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed > result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + + // Return the minimum element (or element-based computation). + _.min = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.min.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return Infinity; + var result = {computed : Infinity, value: Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed < result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + + // Shuffle an array, using the modern version of the + // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + _.shuffle = function(obj) { + var rand; + var index = 0; + var shuffled = []; + each(obj, function(value) { + rand = _.random(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + }; + + // Sample **n** random values from an array. + // If **n** is not specified, returns a single random element from the array. + // The internal `guard` argument allows it to work with `map`. + _.sample = function(obj, n, guard) { + if (arguments.length < 2 || guard) { + return obj[_.random(obj.length - 1)]; + } + return _.shuffle(obj).slice(0, Math.max(0, n)); + }; + + // An internal function to generate lookup iterators. + var lookupIterator = function(value) { + return _.isFunction(value) ? value : function(obj){ return obj[value]; }; + }; + + // Sort the object's values by a criterion produced by an iterator. + _.sortBy = function(obj, value, context) { + var iterator = lookupIterator(value); + return _.pluck(_.map(obj, function(value, index, list) { + return { + value: value, + index: index, + criteria: iterator.call(context, value, index, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + }; + + // An internal function used for aggregate "group by" operations. + var group = function(behavior) { + return function(obj, value, context) { + var result = {}; + var iterator = value == null ? _.identity : lookupIterator(value); + each(obj, function(value, index) { + var key = iterator.call(context, value, index, obj); + behavior(result, key, value); + }); + return result; + }; + }; + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + _.groupBy = group(function(result, key, value) { + (_.has(result, key) ? result[key] : (result[key] = [])).push(value); + }); + + // Indexes the object's values by a criterion, similar to `groupBy`, but for + // when you know that your index values will be unique. + _.indexBy = group(function(result, key, value) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + _.countBy = group(function(result, key) { + _.has(result, key) ? result[key]++ : result[key] = 1; + }); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + _.sortedIndex = function(array, obj, iterator, context) { + iterator = iterator == null ? _.identity : lookupIterator(iterator); + var value = iterator.call(context, obj); + var low = 0, high = array.length; + while (low < high) { + var mid = (low + high) >>> 1; + iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; + } + return low; + }; + + // Safely create a real, live array from anything iterable. + _.toArray = function(obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (obj.length === +obj.length) return _.map(obj, _.identity); + return _.values(obj); + }; + + // Return the number of elements in an object. + _.size = function(obj) { + if (obj == null) return 0; + return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + }; + + // Array Functions + // --------------- + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. Aliased as `head` and `take`. The **guard** check + // allows it to work with `_.map`. + _.first = _.head = _.take = function(array, n, guard) { + if (array == null) return void 0; + return (n == null) || guard ? array[0] : slice.call(array, 0, n); + }; + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. The **guard** check allows it to work with + // `_.map`. + _.initial = function(array, n, guard) { + return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); + }; + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. The **guard** check allows it to work with `_.map`. + _.last = function(array, n, guard) { + if (array == null) return void 0; + if ((n == null) || guard) { + return array[array.length - 1]; + } else { + return slice.call(array, Math.max(array.length - n, 0)); + } + }; + + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. + // Especially useful on the arguments object. Passing an **n** will return + // the rest N values in the array. The **guard** + // check allows it to work with `_.map`. + _.rest = _.tail = _.drop = function(array, n, guard) { + return slice.call(array, (n == null) || guard ? 1 : n); + }; + + // Trim out all falsy values from an array. + _.compact = function(array) { + return _.filter(array, _.identity); + }; + + // Internal implementation of a recursive `flatten` function. + var flatten = function(input, shallow, output) { + if (shallow && _.every(input, _.isArray)) { + return concat.apply(output, input); + } + each(input, function(value) { + if (_.isArray(value) || _.isArguments(value)) { + shallow ? push.apply(output, value) : flatten(value, shallow, output); + } else { + output.push(value); + } + }); + return output; + }; + + // Flatten out an array, either recursively (by default), or just one level. + _.flatten = function(array, shallow) { + return flatten(array, shallow, []); + }; + + // Return a version of the array that does not contain the specified value(s). + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // Aliased as `unique`. + _.uniq = _.unique = function(array, isSorted, iterator, context) { + if (_.isFunction(isSorted)) { + context = iterator; + iterator = isSorted; + isSorted = false; + } + var initial = iterator ? _.map(array, iterator, context) : array; + var results = []; + var seen = []; + each(initial, function(value, index) { + if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { + seen.push(value); + results.push(array[index]); + } + }); + return results; + }; + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + _.union = function() { + return _.uniq(_.flatten(arguments, true)); + }; + + // Produce an array that contains every item shared between all the + // passed-in arrays. + _.intersection = function(array) { + var rest = slice.call(arguments, 1); + return _.filter(_.uniq(array), function(item) { + return _.every(rest, function(other) { + return _.indexOf(other, item) >= 0; + }); + }); + }; + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + _.difference = function(array) { + var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); + return _.filter(array, function(value){ return !_.contains(rest, value); }); + }; + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = function() { + var length = _.max(_.pluck(arguments, "length").concat(0)); + var results = new Array(length); + for (var i = 0; i < length; i++) { + results[i] = _.pluck(arguments, '' + i); + } + return results; + }; + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. + _.object = function(list, values) { + if (list == null) return {}; + var result = {}; + for (var i = 0, length = list.length; i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + + // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), + // we need this function. Return the position of the first occurrence of an + // item in an array, or -1 if the item is not included in the array. + // Delegates to **ECMAScript 5**'s native `indexOf` if available. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + _.indexOf = function(array, item, isSorted) { + if (array == null) return -1; + var i = 0, length = array.length; + if (isSorted) { + if (typeof isSorted == 'number') { + i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); + } else { + i = _.sortedIndex(array, item); + return array[i] === item ? i : -1; + } + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); + for (; i < length; i++) if (array[i] === item) return i; + return -1; + }; + + // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. + _.lastIndexOf = function(array, item, from) { + if (array == null) return -1; + var hasIndex = from != null; + if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { + return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + } + var i = (hasIndex ? from : array.length); + while (i--) if (array[i] === item) return i; + return -1; + }; + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](http://docs.python.org/library/functions.html#range). + _.range = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = arguments[2] || 1; + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var idx = 0; + var range = new Array(length); + + while(idx < length) { + range[idx++] = start; + start += step; + } + + return range; + }; + + // Function (ahem) Functions + // ------------------ + + // Reusable constructor function for prototype setting. + var ctor = function(){}; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if + // available. + _.bind = function(func, context) { + var args, bound; + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + var self = new ctor; + ctor.prototype = null; + var result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; + }; + }; + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. + _.partial = function(func) { + var args = slice.call(arguments, 1); + return function() { + return func.apply(this, args.concat(slice.call(arguments))); + }; + }; + + // Bind all of an object's methods to that object. Useful for ensuring that + // all callbacks defined on an object belong to it. + _.bindAll = function(obj) { + var funcs = slice.call(arguments, 1); + if (funcs.length === 0) throw new Error("bindAll must be passed function names"); + each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); + return obj; + }; + + // Memoize an expensive function by storing its results. + _.memoize = function(func, hasher) { + var memo = {}; + hasher || (hasher = _.identity); + return function() { + var key = hasher.apply(this, arguments); + return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); + }; + }; + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function(){ return func.apply(null, args); }, wait); + }; + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + _.defer = function(func) { + return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); + }; + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + _.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + options || (options = {}); + var later = function() { + previous = options.leading === false ? 0 : new Date; + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date; + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + _.debounce = function(func, wait, immediate) { + var timeout, args, context, timestamp, result; + return function() { + context = this; + args = arguments; + timestamp = new Date(); + var later = function() { + var last = (new Date()) - timestamp; + if (last < wait) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + } + }; + var callNow = immediate && !timeout; + if (!timeout) { + timeout = setTimeout(later, wait); + } + if (callNow) result = func.apply(context, args); + return result; + }; + }; + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + _.once = function(func) { + var ran = false, memo; + return function() { + if (ran) return memo; + ran = true; + memo = func.apply(this, arguments); + func = null; + return memo; + }; + }; + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + _.wrap = function(func, wrapper) { + return function() { + var args = [func]; + push.apply(args, arguments); + return wrapper.apply(this, args); + }; + }; + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + _.compose = function() { + var funcs = arguments; + return function() { + var args = arguments; + for (var i = funcs.length - 1; i >= 0; i--) { + args = [funcs[i].apply(this, args)]; + } + return args[0]; + }; + }; + + // Returns a function that will only be executed after being called N times. + _.after = function(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + + // Object Functions + // ---------------- + + // Retrieve the names of an object's properties. + // Delegates to **ECMAScript 5**'s native `Object.keys` + _.keys = nativeKeys || function(obj) { + if (obj !== Object(obj)) throw new TypeError('Invalid object'); + var keys = []; + for (var key in obj) if (_.has(obj, key)) keys.push(key); + return keys; + }; + + // Retrieve the values of an object's properties. + _.values = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var values = new Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[keys[i]]; + } + return values; + }; + + // Convert an object into a list of `[key, value]` pairs. + _.pairs = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var pairs = new Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [keys[i], obj[keys[i]]]; + } + return pairs; + }; + + // Invert the keys and values of an object. The values must be serializable. + _.invert = function(obj) { + var result = {}; + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + result[obj[keys[i]]] = keys[i]; + } + return result; + }; + + // Return a sorted list of the function names available on the object. + // Aliased as `methods` + _.functions = _.methods = function(obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + + // Extend a given object with all the properties in passed-in object(s). + _.extend = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Return a copy of the object only containing the whitelisted properties. + _.pick = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + each(keys, function(key) { + if (key in obj) copy[key] = obj[key]; + }); + return copy; + }; + + // Return a copy of the object without the blacklisted properties. + _.omit = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + for (var key in obj) { + if (!_.contains(keys, key)) copy[key] = obj[key]; + } + return copy; + }; + + // Fill in a given object with default properties. + _.defaults = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + if (obj[prop] === void 0) obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Create a (shallow-cloned) duplicate of an object. + _.clone = function(obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + + // Invokes interceptor with the obj, and then returns obj. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + _.tap = function(obj, interceptor) { + interceptor(obj); + return obj; + }; + + // Internal recursive comparison function for `isEqual`. + var eq = function(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a == 1 / b; + // A strict comparison is necessary because `null == undefined`. + if (a == null || b == null) return a === b; + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className != toString.call(b)) return false; + switch (className) { + // Strings, numbers, dates, and booleans are compared by value. + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return a == String(b); + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for + // other numeric values. + return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a == +b; + // RegExps are compared by their source patterns and flags. + case '[object RegExp]': + return a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + if (typeof a != 'object' || typeof b != 'object') return false; + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] == a) return bStack[length] == b; + } + // Objects with different constructors are not equivalent, but `Object`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && + _.isFunction(bCtor) && (bCtor instanceof bCtor))) { + return false; + } + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + var size = 0, result = true; + // Recursively compare objects and arrays. + if (className == '[object Array]') { + // Compare array lengths to determine if a deep comparison is necessary. + size = a.length; + result = size == b.length; + if (result) { + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!(result = eq(a[size], b[size], aStack, bStack))) break; + } + } + } else { + // Deep compare objects. + for (var key in a) { + if (_.has(a, key)) { + // Count the expected number of properties. + size++; + // Deep compare each member. + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; + } + } + // Ensure that both objects contain the same number of properties. + if (result) { + for (key in b) { + if (_.has(b, key) && !(size--)) break; + } + result = !size; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return result; + }; + + // Perform a deep comparison to check if two objects are equal. + _.isEqual = function(a, b) { + return eq(a, b, [], []); + }; + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + _.isEmpty = function(obj) { + if (obj == null) return true; + if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; + for (var key in obj) if (_.has(obj, key)) return false; + return true; + }; + + // Is a given value a DOM element? + _.isElement = function(obj) { + return !!(obj && obj.nodeType === 1); + }; + + // Is a given value an array? + // Delegates to ECMA5's native Array.isArray + _.isArray = nativeIsArray || function(obj) { + return toString.call(obj) == '[object Array]'; + }; + + // Is a given variable an object? + _.isObject = function(obj) { + return obj === Object(obj); + }; + + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + _['is' + name] = function(obj) { + return toString.call(obj) == '[object ' + name + ']'; + }; + }); + + // Define a fallback version of the method in browsers (ahem, IE), where + // there isn't any inspectable "Arguments" type. + if (!_.isArguments(arguments)) { + _.isArguments = function(obj) { + return !!(obj && _.has(obj, 'callee')); + }; + } + + // Optimize `isFunction` if appropriate. + if (typeof (/./) !== 'function') { + _.isFunction = function(obj) { + return typeof obj === 'function'; + }; + } + + // Is a given object a finite number? + _.isFinite = function(obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + + // Is the given value `NaN`? (NaN is the only number which does not equal itself). + _.isNaN = function(obj) { + return _.isNumber(obj) && obj != +obj; + }; + + // Is a given value a boolean? + _.isBoolean = function(obj) { + return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; + }; + + // Is a given value equal to null? + _.isNull = function(obj) { + return obj === null; + }; + + // Is a given variable undefined? + _.isUndefined = function(obj) { + return obj === void 0; + }; + + // Shortcut function for checking if an object has a given property directly + // on itself (in other words, not on a prototype). + _.has = function(obj, key) { + return hasOwnProperty.call(obj, key); + }; + + // Utility Functions + // ----------------- + + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its + // previous owner. Returns a reference to the Underscore object. + _.noConflict = function() { + root._ = previousUnderscore; + return this; + }; + + // Keep the identity function around for default iterators. + _.identity = function(value) { + return value; + }; + + // Run a function **n** times. + _.times = function(n, iterator, context) { + var accum = Array(Math.max(0, n)); + for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); + return accum; + }; + + // Return a random integer between min and max (inclusive). + _.random = function(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + + // List of HTML entities for escaping. + var entityMap = { + escape: { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + } + }; + entityMap.unescape = _.invert(entityMap.escape); + + // Regexes containing the keys and values listed immediately above. + var entityRegexes = { + escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), + unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') + }; + + // Functions for escaping and unescaping strings to/from HTML interpolation. + _.each(['escape', 'unescape'], function(method) { + _[method] = function(string) { + if (string == null) return ''; + return ('' + string).replace(entityRegexes[method], function(match) { + return entityMap[method][match]; + }); + }; + }); + + // If the value of the named `property` is a function then invoke it with the + // `object` as context; otherwise, return it. + _.result = function(object, property) { + if (object == null) return void 0; + var value = object[property]; + return _.isFunction(value) ? value.call(object) : value; + }; + + // Add your own custom functions to the Underscore object. + _.mixin = function(obj) { + each(_.functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return result.call(this, func.apply(_, args)); + }; + }); + }; + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + _.uniqueId = function(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + }; + + // By default, Underscore uses ERB-style template delimiters, change the + // following template settings to use alternative delimiters. + _.templateSettings = { + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g + }; + + // When customizing `templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\t': 't', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + _.template = function(text, data, settings) { + var render; + settings = _.defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = new RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset) + .replace(escaper, function(match) { return '\\' + escapes[match]; }); + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } + if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } + if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + "return __p;\n"; + + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + if (data) return render(data, _); + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled function source as a convenience for precompilation. + template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; + + return template; + }; + + // Add a "chain" function, which will delegate to the wrapper. + _.chain = function(obj) { + return _(obj).chain(); + }; + + // OOP + // --------------- + // If Underscore is called as a function, it returns a wrapped object that + // can be used OO-style. This wrapper holds altered versions of all the + // underscore functions. Wrapped objects may be chained. + + // Helper function to continue chaining intermediate results. + var result = function(obj) { + return this._chain ? _(obj).chain() : obj; + }; + + // Add all of the Underscore functions to the wrapper object. + _.mixin(_); + + // Add all mutator Array functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; + return result.call(this, obj); + }; + }); + + // Add all accessor Array functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + return result.call(this, method.apply(this._wrapped, arguments)); + }; + }); + + _.extend(_.prototype, { + + // Start chaining a wrapped Underscore object. + chain: function() { + this._chain = true; + return this; + }, + + // Extracts the result from a wrapped and chained object. + value: function() { + return this._wrapped; + } + + }); + +}).call(this); diff --git a/iframe.html b/iframe.html new file mode 100644 index 0000000..febc147 --- /dev/null +++ b/iframe.html @@ -0,0 +1,129 @@ + + + + + + + + + + + +