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,GAAekC,YAAcA,EAE9C,CAGJ,OAAOgD,CACX,EAGApI,EAASC,YAAYoI,gBAAkB,SAASC,EAAaC,GAoBzD,OAnBAzI,EAAE8E,KAAK2D,GAAQ,SAAS1C,EAAO2C,GAC3B,IAAI5E,EAAiB,CAACd,SAAU+C,EAAM/C,UAEnC+C,EAAMqB,YACLtD,EAAesD,UAAYrB,EAAMqB,WAGlCrB,EAAMT,cACLxB,EAAewB,YAAcS,EAAMT,aAGnCkD,EAAYE,GAIZF,EAAYE,GAAO,CAACF,EAAYE,GAAM5E,GAHtC0E,EAAYE,GAAO5E,CAK3B,IAEO0E,CACX,EAGOtI,EAASC,WAEpB,GAzjB4D,8B","sources":["webpack://app/./node_modules/backbone.modelbinder/Backbone.ModelBinder.js"],"sourcesContent":["// Backbone.ModelBinder v1.1.0\r\n// (c) 2015 Bart Wood\r\n// Distributed Under MIT License\r\n\r\n(function (factory) {\r\n if (typeof define === 'function' && define.amd) {\r\n // AMD. Register as an anonymous module.\r\n define(['underscore', 'jquery', 'backbone'], factory);\r\n } else if(typeof module !== 'undefined' && module.exports) {\r\n // CommonJS\r\n module.exports = factory(\r\n require('underscore'),\r\n require('jquery'),\r\n require('backbone')\r\n );\r\n } else {\r\n // Browser globals\r\n factory(_, jQuery, Backbone);\r\n }\r\n}(function(_, $, Backbone){\r\n\r\n if(!Backbone){\r\n throw 'Please include Backbone.js before Backbone.ModelBinder.js';\r\n }\r\n\r\n Backbone.ModelBinder = function(){\r\n _.bindAll.apply(_, [this].concat(_.functions(this)));\r\n };\r\n\r\n // Static setter for class level options\r\n Backbone.ModelBinder.SetOptions = function(options){\r\n Backbone.ModelBinder.options = options;\r\n };\r\n\r\n // Current version of the library.\r\n Backbone.ModelBinder.VERSION = '1.1.0';\r\n Backbone.ModelBinder.Constants = {};\r\n Backbone.ModelBinder.Constants.ModelToView = 'ModelToView';\r\n Backbone.ModelBinder.Constants.ViewToModel = 'ViewToModel';\r\n\r\n _.extend(Backbone.ModelBinder.prototype, {\r\n\r\n bind:function (model, rootEl, attributeBindings, options) {\r\n this.unbind();\r\n\r\n this._model = model;\r\n this._rootEl = rootEl;\r\n this._setOptions(options);\r\n\r\n if (!this._model) this._throwException('model must be specified');\r\n if (!this._rootEl) this._throwException('rootEl must be specified');\r\n\r\n if(attributeBindings){\r\n // Create a deep clone of the attribute bindings\r\n this._attributeBindings = $.extend(true, {}, attributeBindings);\r\n\r\n this._initializeAttributeBindings();\r\n this._initializeElBindings();\r\n }\r\n else {\r\n this._initializeDefaultBindings();\r\n }\r\n\r\n this._bindModelToView();\r\n this._bindViewToModel();\r\n },\r\n\r\n bindCustomTriggers: function (model, rootEl, triggers, attributeBindings, modelSetOptions) {\r\n this._triggers = triggers;\r\n this.bind(model, rootEl, attributeBindings, modelSetOptions);\r\n },\r\n\r\n unbind:function () {\r\n this._unbindModelToView();\r\n this._unbindViewToModel();\r\n\r\n if(this._attributeBindings){\r\n delete this._attributeBindings;\r\n this._attributeBindings = undefined;\r\n }\r\n },\r\n\r\n _setOptions: function(options){\r\n this._options = _.extend({\r\n boundAttribute: 'name'\r\n }, Backbone.ModelBinder.options, options);\r\n\r\n // initialize default options\r\n if(!this._options['modelSetOptions']){\r\n this._options['modelSetOptions'] = {};\r\n }\r\n this._options['modelSetOptions'].changeSource = 'ModelBinder';\r\n\r\n if(!this._options['changeTriggers']){\r\n this._options['changeTriggers'] = {'': 'change', '[contenteditable]': 'blur'};\r\n }\r\n\r\n if(!this._options['initialCopyDirection']){\r\n this._options['initialCopyDirection'] = Backbone.ModelBinder.Constants.ModelToView;\r\n }\r\n },\r\n\r\n // Converts the input bindings, which might just be empty or strings, to binding objects\r\n _initializeAttributeBindings:function () {\r\n var attributeBindingKey, inputBinding, attributeBinding, elementBindingCount, elementBinding;\r\n\r\n for (attributeBindingKey in this._attributeBindings) {\r\n inputBinding = this._attributeBindings[attributeBindingKey];\r\n\r\n if (_.isString(inputBinding)) {\r\n attributeBinding = {elementBindings: [{selector: inputBinding}]};\r\n }\r\n else if (_.isArray(inputBinding)) {\r\n attributeBinding = {elementBindings: inputBinding};\r\n }\r\n else if(_.isObject(inputBinding)){\r\n attributeBinding = {elementBindings: [inputBinding]};\r\n }\r\n else {\r\n this._throwException('Unsupported type passed to Model Binder ' + attributeBinding);\r\n }\r\n\r\n // Add a linkage from the element binding back to the attribute binding\r\n for(elementBindingCount = 0; elementBindingCount < attributeBinding.elementBindings.length; elementBindingCount++){\r\n elementBinding = attributeBinding.elementBindings[elementBindingCount];\r\n elementBinding.attributeBinding = attributeBinding;\r\n }\r\n\r\n attributeBinding.attributeName = attributeBindingKey;\r\n this._attributeBindings[attributeBindingKey] = attributeBinding;\r\n }\r\n },\r\n\r\n // If the bindings are not specified, the default binding is performed on the specified attribute, name by default\r\n _initializeDefaultBindings: function(){\r\n var elCount, elsWithAttribute, matchedEl, name, attributeBinding;\r\n\r\n this._attributeBindings = {};\r\n elsWithAttribute = $('[' + this._options['boundAttribute'] + ']', this._rootEl);\r\n\r\n for(elCount = 0; elCount < elsWithAttribute.length; elCount++){\r\n matchedEl = elsWithAttribute[elCount];\r\n name = $(matchedEl).attr(this._options['boundAttribute']);\r\n\r\n // For elements like radio buttons we only want a single attribute binding with possibly multiple element bindings\r\n if(!this._attributeBindings[name]){\r\n attributeBinding = {attributeName: name};\r\n attributeBinding.elementBindings = [{attributeBinding: attributeBinding, boundEls: [matchedEl]}];\r\n this._attributeBindings[name] = attributeBinding;\r\n }\r\n else{\r\n this._attributeBindings[name].elementBindings.push({attributeBinding: this._attributeBindings[name], boundEls: [matchedEl]});\r\n }\r\n }\r\n },\r\n\r\n _initializeElBindings:function () {\r\n var bindingKey, attributeBinding, bindingCount, elementBinding, foundEls, elCount, el;\r\n for (bindingKey in this._attributeBindings) {\r\n attributeBinding = this._attributeBindings[bindingKey];\r\n\r\n for (bindingCount = 0; bindingCount < attributeBinding.elementBindings.length; bindingCount++) {\r\n elementBinding = attributeBinding.elementBindings[bindingCount];\r\n if (elementBinding.selector === '') {\r\n foundEls = $(this._rootEl);\r\n }\r\n else {\r\n foundEls = $(elementBinding.selector, this._rootEl);\r\n }\r\n\r\n if (foundEls.length === 0) {\r\n this._throwException('Bad binding found. No elements returned for binding selector ' + elementBinding.selector);\r\n }\r\n else {\r\n elementBinding.boundEls = [];\r\n for (elCount = 0; elCount < foundEls.length; elCount++) {\r\n el = foundEls[elCount];\r\n elementBinding.boundEls.push(el);\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n _bindModelToView: function () {\r\n this._model.on('change', this._onModelChange, this);\r\n\r\n if(this._options['initialCopyDirection'] === Backbone.ModelBinder.Constants.ModelToView){\r\n this.copyModelAttributesToView();\r\n }\r\n },\r\n\r\n // attributesToCopy is an optional parameter - if empty, all attributes\r\n // that are bound will be copied. Otherwise, only attributeBindings specified\r\n // in the attributesToCopy are copied.\r\n copyModelAttributesToView: function(attributesToCopy){\r\n var attributeName, attributeBinding;\r\n\r\n for (attributeName in this._attributeBindings) {\r\n if(attributesToCopy === undefined || _.indexOf(attributesToCopy, attributeName) !== -1){\r\n attributeBinding = this._attributeBindings[attributeName];\r\n this._copyModelToView(attributeBinding);\r\n }\r\n }\r\n },\r\n\r\n copyViewValuesToModel: function(){\r\n var bindingKey, attributeBinding, bindingCount, elementBinding, elCount, el;\r\n for (bindingKey in this._attributeBindings) {\r\n attributeBinding = this._attributeBindings[bindingKey];\r\n\r\n for (bindingCount = 0; bindingCount < attributeBinding.elementBindings.length; bindingCount++) {\r\n elementBinding = attributeBinding.elementBindings[bindingCount];\r\n\r\n if(this._isBindingUserEditable(elementBinding)){\r\n if(this._isBindingRadioGroup(elementBinding)){\r\n el = this._getRadioButtonGroupCheckedEl(elementBinding);\r\n if(el){\r\n this._copyViewToModel(elementBinding, el);\r\n }\r\n }\r\n else {\r\n for(elCount = 0; elCount < elementBinding.boundEls.length; elCount++){\r\n el = $(elementBinding.boundEls[elCount]);\r\n if(this._isElUserEditable(el)){\r\n this._copyViewToModel(elementBinding, el);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n _unbindModelToView: function(){\r\n if(this._model){\r\n this._model.off('change', this._onModelChange);\r\n this._model = undefined;\r\n }\r\n },\r\n\r\n _bindViewToModel: function () {\r\n _.each(this._options['changeTriggers'], function (event, selector) {\r\n $(this._rootEl).on(event, selector, this._onElChanged);\r\n }, this);\r\n\r\n if(this._options['initialCopyDirection'] === Backbone.ModelBinder.Constants.ViewToModel){\r\n this.copyViewValuesToModel();\r\n }\r\n },\r\n\r\n _unbindViewToModel: function () {\r\n if(this._options && this._options['changeTriggers']){\r\n _.each(this._options['changeTriggers'], function (event, selector) {\r\n $(this._rootEl).off(event, selector, this._onElChanged);\r\n }, this);\r\n }\r\n },\r\n\r\n _onElChanged:function (event) {\r\n var el, elBindings, elBindingCount, elBinding;\r\n\r\n el = $(event.target)[0];\r\n elBindings = this._getElBindings(el);\r\n\r\n for(elBindingCount = 0; elBindingCount < elBindings.length; elBindingCount++){\r\n elBinding = elBindings[elBindingCount];\r\n if (this._isBindingUserEditable(elBinding)) {\r\n this._copyViewToModel(elBinding, el);\r\n }\r\n }\r\n },\r\n\r\n _isBindingUserEditable: function(elBinding){\r\n return elBinding.elAttribute === undefined ||\r\n elBinding.elAttribute === 'text' ||\r\n elBinding.elAttribute === 'html';\r\n },\r\n\r\n _isElUserEditable: function(el){\r\n var isContentEditable = el.attr('contenteditable');\r\n return isContentEditable || el.is('input') || el.is('select') || el.is('textarea');\r\n },\r\n\r\n _isBindingRadioGroup: function(elBinding){\r\n var elCount, el;\r\n var isAllRadioButtons = elBinding.boundEls.length > 0;\r\n for(elCount = 0; elCount < elBinding.boundEls.length; elCount++){\r\n el = $(elBinding.boundEls[elCount]);\r\n if(el.attr('type') !== 'radio'){\r\n isAllRadioButtons = false;\r\n break;\r\n }\r\n }\r\n\r\n return isAllRadioButtons;\r\n },\r\n\r\n _getRadioButtonGroupCheckedEl: function(elBinding){\r\n var elCount, el;\r\n for(elCount = 0; elCount < elBinding.boundEls.length; elCount++){\r\n el = $(elBinding.boundEls[elCount]);\r\n if(el.attr('type') === 'radio' && el.prop('checked')){\r\n return el;\r\n }\r\n }\r\n\r\n return undefined;\r\n },\r\n\r\n _getElBindings:function (findEl) {\r\n var attributeName, attributeBinding, elementBindingCount, elementBinding, boundElCount, boundEl;\r\n var elBindings = [];\r\n\r\n for (attributeName in this._attributeBindings) {\r\n attributeBinding = this._attributeBindings[attributeName];\r\n\r\n for (elementBindingCount = 0; elementBindingCount < attributeBinding.elementBindings.length; elementBindingCount++) {\r\n elementBinding = attributeBinding.elementBindings[elementBindingCount];\r\n\r\n for (boundElCount = 0; boundElCount < elementBinding.boundEls.length; boundElCount++) {\r\n boundEl = elementBinding.boundEls[boundElCount];\r\n\r\n if (boundEl === findEl) {\r\n elBindings.push(elementBinding);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return elBindings;\r\n },\r\n\r\n _onModelChange:function () {\r\n var changedAttribute, attributeBinding;\r\n\r\n for (changedAttribute in this._model.changedAttributes()) {\r\n attributeBinding = this._attributeBindings[changedAttribute];\r\n\r\n if (attributeBinding) {\r\n this._copyModelToView(attributeBinding);\r\n }\r\n }\r\n },\r\n\r\n _copyModelToView:function (attributeBinding) {\r\n var elementBindingCount, elementBinding, boundElCount, boundEl, value, convertedValue;\r\n\r\n value = this._model.get(attributeBinding.attributeName);\r\n\r\n for (elementBindingCount = 0; elementBindingCount < attributeBinding.elementBindings.length; elementBindingCount++) {\r\n elementBinding = attributeBinding.elementBindings[elementBindingCount];\r\n\r\n for (boundElCount = 0; boundElCount < elementBinding.boundEls.length; boundElCount++) {\r\n boundEl = elementBinding.boundEls[boundElCount];\r\n\r\n if(!boundEl._isSetting){\r\n convertedValue = this._getConvertedValue(Backbone.ModelBinder.Constants.ModelToView, elementBinding, value);\r\n this._setEl($(boundEl), elementBinding, convertedValue);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _setEl: function (el, elementBinding, convertedValue) {\r\n if (elementBinding.elAttribute) {\r\n this._setElAttribute(el, elementBinding, convertedValue);\r\n }\r\n else {\r\n this._setElValue(el, convertedValue);\r\n }\r\n },\r\n\r\n _setElAttribute:function (el, elementBinding, convertedValue) {\r\n switch (elementBinding.elAttribute) {\r\n case 'html':\r\n el.html(convertedValue);\r\n break;\r\n case 'text':\r\n el.text(convertedValue);\r\n break;\r\n case 'enabled':\r\n el.prop('disabled', !convertedValue);\r\n break;\r\n case 'displayed':\r\n el[convertedValue ? 'show' : 'hide']();\r\n break;\r\n case 'hidden':\r\n el[convertedValue ? 'hide' : 'show']();\r\n break;\r\n case 'css':\r\n el.css(elementBinding.cssAttribute, convertedValue);\r\n break;\r\n case 'class':\r\n var previousValue = this._model.previous(elementBinding.attributeBinding.attributeName);\r\n var currentValue = this._model.get(elementBinding.attributeBinding.attributeName);\r\n // is current value is now defined then remove the class the may have been set for the undefined value\r\n if(!_.isUndefined(previousValue) || !_.isUndefined(currentValue)){\r\n previousValue = this._getConvertedValue(Backbone.ModelBinder.Constants.ModelToView, elementBinding, previousValue);\r\n el.removeClass(previousValue);\r\n }\r\n\r\n if(convertedValue){\r\n el.addClass(convertedValue);\r\n }\r\n break;\r\n default:\r\n el.attr(elementBinding.elAttribute, convertedValue);\r\n }\r\n },\r\n\r\n _setElValue:function (el, convertedValue) {\r\n if(el.attr('type')){\r\n switch (el.attr('type')) {\r\n case 'radio':\r\n el.prop('checked', el.val() === convertedValue);\r\n break;\r\n case 'checkbox':\r\n el.prop('checked', !!convertedValue);\r\n break;\r\n case 'file':\r\n break;\r\n default:\r\n el.val(convertedValue);\r\n }\r\n }\r\n else if(el.is('input') || el.is('select') || el.is('textarea')){\r\n el.val(convertedValue || (convertedValue === 0 ? '0' : ''));\r\n }\r\n else {\r\n el.text(convertedValue || (convertedValue === 0 ? '0' : ''));\r\n }\r\n },\r\n\r\n _copyViewToModel: function (elementBinding, el) {\r\n var result, value, convertedValue;\r\n\r\n if (!el._isSetting) {\r\n\r\n el._isSetting = true;\r\n result = this._setModel(elementBinding, $(el));\r\n el._isSetting = false;\r\n\r\n if(result && elementBinding.converter){\r\n value = this._model.get(elementBinding.attributeBinding.attributeName);\r\n convertedValue = this._getConvertedValue(Backbone.ModelBinder.Constants.ModelToView, elementBinding, value);\r\n this._setEl($(el), elementBinding, convertedValue);\r\n }\r\n }\r\n },\r\n\r\n _getElValue: function(elementBinding, el){\r\n switch (el.attr('type')) {\r\n case 'checkbox':\r\n return el.prop('checked') ? true : false;\r\n default:\r\n if(el.attr('contenteditable') !== undefined){\r\n return el.html();\r\n }\r\n else {\r\n return el.val();\r\n }\r\n }\r\n },\r\n\r\n _setModel: function (elementBinding, el) {\r\n var data = {};\r\n var elVal = this._getElValue(elementBinding, el);\r\n elVal = this._getConvertedValue(Backbone.ModelBinder.Constants.ViewToModel, elementBinding, elVal);\r\n data[elementBinding.attributeBinding.attributeName] = elVal;\r\n return this._model.set(data, this._options['modelSetOptions']);\r\n },\r\n\r\n _getConvertedValue: function (direction, elementBinding, value) {\r\n\r\n if (elementBinding.converter) {\r\n value = elementBinding.converter(direction, value, elementBinding.attributeBinding.attributeName, this._model, elementBinding.boundEls);\r\n }\r\n else if(this._options['converter']){\r\n value = this._options['converter'](direction, value, elementBinding.attributeBinding.attributeName, this._model, elementBinding.boundEls);\r\n }\r\n\r\n return value;\r\n },\r\n\r\n _throwException: function(message){\r\n if(this._options.suppressThrows){\r\n if(typeof(console) !== 'undefined' && console.error){\r\n console.error(message);\r\n }\r\n }\r\n else {\r\n throw message;\r\n }\r\n }\r\n });\r\n\r\n Backbone.ModelBinder.CollectionConverter = function(collection){\r\n this._collection = collection;\r\n\r\n if(!this._collection){\r\n throw 'Collection must be defined';\r\n }\r\n _.bindAll(this, 'convert');\r\n };\r\n\r\n _.extend(Backbone.ModelBinder.CollectionConverter.prototype, {\r\n convert: function(direction, value){\r\n if (direction === Backbone.ModelBinder.Constants.ModelToView) {\r\n return value ? value.id : undefined;\r\n }\r\n else {\r\n return this._collection.get(value);\r\n }\r\n }\r\n });\r\n\r\n // A static helper function to create a default set of bindings that you can customize before calling the bind() function\r\n // rootEl - where to find all of the bound elements\r\n // attributeType - probably 'name' or 'id' in most cases\r\n // converter(optional) - the default converter you want applied to all your bindings\r\n // elAttribute(optional) - the default elAttribute you want applied to all your bindings\r\n Backbone.ModelBinder.createDefaultBindings = function(rootEl, attributeType, converter, elAttribute){\r\n var foundEls, elCount, foundEl, attributeName;\r\n var bindings = {};\r\n\r\n foundEls = $('[' + attributeType + ']', rootEl);\r\n\r\n for(elCount = 0; elCount < foundEls.length; elCount++){\r\n foundEl = foundEls[elCount];\r\n attributeName = $(foundEl).attr(attributeType);\r\n\r\n if(!bindings[attributeName]){\r\n var attributeBinding = {selector: '[' + attributeType + '=\"' + attributeName + '\"]'};\r\n bindings[attributeName] = attributeBinding;\r\n\r\n if(converter){\r\n bindings[attributeName].converter = converter;\r\n }\r\n\r\n if(elAttribute){\r\n bindings[attributeName].elAttribute = elAttribute;\r\n }\r\n }\r\n }\r\n\r\n return bindings;\r\n };\r\n\r\n // Helps you to combine 2 sets of bindings\r\n Backbone.ModelBinder.combineBindings = function(destination, source){\r\n _.each(source, function(value, key){\r\n var elementBinding = {selector: value.selector};\r\n\r\n if(value.converter){\r\n elementBinding.converter = value.converter;\r\n }\r\n\r\n if(value.elAttribute){\r\n elementBinding.elAttribute = value.elAttribute;\r\n }\r\n\r\n if(!destination[key]){\r\n destination[key] = elementBinding;\r\n }\r\n else {\r\n destination[key] = [destination[key], elementBinding];\r\n }\r\n });\r\n\r\n return destination;\r\n };\r\n\r\n\r\n return Backbone.ModelBinder;\r\n\r\n}));\r\n"],"names":["_","$","Backbone","ModelBinder","bindAll","apply","this","concat","functions","SetOptions","options","VERSION","Constants","ModelToView","ViewToModel","extend","prototype","bind","model","rootEl","attributeBindings","unbind","_model","_rootEl","_setOptions","_throwException","_attributeBindings","_initializeAttributeBindings","_initializeElBindings","_initializeDefaultBindings","_bindModelToView","_bindViewToModel","bindCustomTriggers","triggers","modelSetOptions","_triggers","_unbindModelToView","_unbindViewToModel","undefined","_options","boundAttribute","changeSource","attributeBindingKey","inputBinding","attributeBinding","elementBindingCount","isString","elementBindings","selector","isArray","isObject","length","attributeName","elCount","elsWithAttribute","matchedEl","name","attr","push","boundEls","bindingKey","bindingCount","elementBinding","foundEls","el","on","_onModelChange","copyModelAttributesToView","attributesToCopy","indexOf","_copyModelToView","copyViewValuesToModel","_isBindingUserEditable","_isBindingRadioGroup","_getRadioButtonGroupCheckedEl","_copyViewToModel","_isElUserEditable","off","each","event","_onElChanged","elBindings","elBindingCount","elBinding","target","_getElBindings","elAttribute","is","isAllRadioButtons","prop","findEl","boundElCount","changedAttribute","changedAttributes","boundEl","value","convertedValue","get","_isSetting","_getConvertedValue","_setEl","_setElAttribute","_setElValue","html","text","css","cssAttribute","previousValue","previous","currentValue","isUndefined","removeClass","addClass","val","result","_setModel","converter","_getElValue","data","elVal","set","direction","message","suppressThrows","console","error","CollectionConverter","collection","_collection","convert","id","createDefaultBindings","attributeType","foundEl","bindings","combineBindings","destination","source","key"],"sourceRoot":""}