From 6730fdda84ca389c0e13000d348425dc3f81d02b Mon Sep 17 00:00:00 2001 From: David McClure Date: Thu, 12 Sep 2013 16:22:51 -0700 Subject: [PATCH] Synchronizes front-end style defaults with styles.ini configuration file. --- helpers/Globals.php | 7 ++- models/NeatlineRecord.php | 52 +++++++++++++++---- styles.ini | 11 ++++ .../editor/exhibit/records/records.view.js | 2 +- .../javascripts/app/editor/map/map.view.js | 4 +- .../app/editor/record/record.public.js | 4 +- views/shared/javascripts/app/map/map.view.js | 8 +-- .../app/shared/record/record.collection.js | 4 +- .../app/shared/record/record.model.js | 27 ++++++---- .../javascripts/payloads/neatline-editor.js | 4 +- .../javascripts/payloads/neatline-public.js | 2 +- 11 files changed, 87 insertions(+), 38 deletions(-) create mode 100644 styles.ini diff --git a/helpers/Globals.php b/helpers/Globals.php index d0cfd9dfb..24f86d36b 100644 --- a/helpers/Globals.php +++ b/helpers/Globals.php @@ -18,6 +18,10 @@ */ function nl_globals($exhibit) { + + // Read style defaults from `styles.ini`. + $styles = new Zend_Config_Ini(NL_DIR.'/styles.ini'); + return array('neatline' => array( // Exhibit. @@ -32,7 +36,8 @@ function nl_globals($exhibit) // Constants. // ---------------------------------------------------------------- - 'per_page' => (int) get_plugin_ini('Neatline', 'per_page'), + 'per_page' => (int) get_plugin_ini('Neatline', 'per_page'), + 'styles' => $styles->toArray(), // Layers. // ---------------------------------------------------------------- diff --git a/models/NeatlineRecord.php b/models/NeatlineRecord.php index ea38047b9..19a45ddb7 100644 --- a/models/NeatlineRecord.php +++ b/models/NeatlineRecord.php @@ -27,17 +27,17 @@ class NeatlineRecord extends Neatline_Row_Expandable public $coverage; public $tags; public $widgets; - public $presenter = 'StaticBubble'; - public $fill_color = '#00aeff'; - public $fill_color_select = '#00aeff'; - public $stroke_color = '#000000'; - public $stroke_color_select = '#000000'; - public $fill_opacity = 0.3; - public $fill_opacity_select = 0.4; - public $stroke_opacity = 0.9; - public $stroke_opacity_select = 1.0; - public $stroke_width = 2; - public $point_radius = 10; + public $presenter; + public $fill_color; + public $fill_color_select; + public $stroke_color; + public $stroke_color_select; + public $fill_opacity; + public $fill_opacity_select; + public $stroke_opacity; + public $stroke_opacity_select; + public $stroke_width; + public $point_radius; public $zindex; public $weight; public $start_date; @@ -53,6 +53,24 @@ class NeatlineRecord extends Neatline_Row_Expandable public $map_focus; + /** + * Required style attributes set in `styles.ini`. + */ + protected static $preset = array( + 'presenter', + 'fill_color', + 'fill_color_select', + 'stroke_color', + 'stroke_color_select', + 'fill_opacity', + 'fill_opacity_select', + 'stroke_opacity', + 'stroke_opacity_select', + 'stroke_width', + 'point_radius' + ); + + /** * Set exhibit and item references. * @@ -61,9 +79,21 @@ class NeatlineRecord extends Neatline_Row_Expandable */ public function __construct($exhibit=null, $item=null) { + parent::__construct(); + + // Set exhibit and item foreign keys. if (!is_null($exhibit)) $this->exhibit_id = $exhibit->id; if (!is_null($item)) $this->item_id = $item->id; + + // Read style defaults from `styles.ini`. + $styles = new Zend_Config_Ini(NL_DIR.'/styles.ini'); + + // Set default styles. + foreach (self::$preset as $prop) { + if (is_null($this->$prop)) $this->$prop = $styles->$prop; + } + } diff --git a/styles.ini b/styles.ini new file mode 100644 index 000000000..90ff9d6d2 --- /dev/null +++ b/styles.ini @@ -0,0 +1,11 @@ +presenter="StaticBubble" +fill_color="#00aeff" +fill_color_select="#00aeff" +stroke_color="#000000" +stroke_color_select="#000000" +fill_opacity="0.3" +fill_opacity_select="0.4" +stroke_opacity="0.9" +stroke_opacity_select="1.0" +stroke_width="2" +point_radius="10" diff --git a/views/shared/javascripts/app/editor/exhibit/records/records.view.js b/views/shared/javascripts/app/editor/exhibit/records/records.view.js index 9c980bdd1..d120472d6 100644 --- a/views/shared/javascripts/app/editor/exhibit/records/records.view.js +++ b/views/shared/javascripts/app/editor/exhibit/records/records.view.js @@ -63,7 +63,7 @@ Neatline.module('Editor.Exhibit.Records', function( */ getModelByEvent: function(e) { return this.records.get( - parseInt($(e.currentTarget).attr('data-id'), 10) + Number($(e.currentTarget).attr('data-id')) ); }, diff --git a/views/shared/javascripts/app/editor/map/map.view.js b/views/shared/javascripts/app/editor/map/map.view.js index 29e94d4c8..490a15bdf 100644 --- a/views/shared/javascripts/app/editor/map/map.view.js +++ b/views/shared/javascripts/app/editor/map/map.view.js @@ -205,11 +205,11 @@ _.extend(Neatline.Map.View.prototype, { // -------------------------------------------------------------------- // SNAP ANGLE - var snap = parseFloat(settings.poly.snap) || 0; + var snap = Number(settings.poly.snap) || 0; this.controls.regPoly.handler.snapAngle = Math.max(0, snap); // SIDES - var sides = parseInt(settings.poly.sides, 10) || 0; + var sides = Number(settings.poly.sides) || 0; this.controls.regPoly.handler.sides = Math.max(3, sides); // IRREGULAR diff --git a/views/shared/javascripts/app/editor/record/record.public.js b/views/shared/javascripts/app/editor/record/record.public.js index eefc25d21..98c5ce97c 100644 --- a/views/shared/javascripts/app/editor/record/record.public.js +++ b/views/shared/javascripts/app/editor/record/record.public.js @@ -31,10 +31,8 @@ Neatline.module('Editor.Record', function( */ var bindId = function(id, tab) { - id = parseInt(id, 10); - // Get or fetch the model. - Neatline.request('EDITOR:EXHIBIT:RECORDS:getModel', id, + Neatline.request('EDITOR:EXHIBIT:RECORDS:getModel', Number(id), function(record) { Record.__view.bind(record); Record.__view.activateTab(tab); diff --git a/views/shared/javascripts/app/map/map.view.js b/views/shared/javascripts/app/map/map.view.js index 20d100d8a..7c47456b6 100644 --- a/views/shared/javascripts/app/map/map.view.js +++ b/views/shared/javascripts/app/map/map.view.js @@ -432,7 +432,7 @@ Neatline.module('Map', function( _.each(this.layers.vector, _.bind(function(layer, id) { // Delete if model is absent and layer is unfrozen. - if (!_.contains(newIds, parseInt(id, 10)) && !layer.nFrozen) { + if (!_.contains(newIds, Number(id)) && !layer.nFrozen) { this.removeVectorLayer(layer); } @@ -468,7 +468,7 @@ Neatline.module('Map', function( _.each(this.layers.wms, _.bind(function(layer, id) { // Delete if model is absent. - if (!_.contains(newIds, parseInt(id, 10))) { + if (!_.contains(newIds, Number(id))) { this.removeWmsLayer(layer); } @@ -674,8 +674,8 @@ Neatline.module('Map', function( fillOpacitySelect = parseFloat(fillOpacitySelect); strokeOpacity = parseFloat(strokeOpacity); strokeOpacitySelect = parseFloat(strokeOpacitySelect); - strokeWidth = parseInt(strokeWidth); - pointRadius = parseInt(pointRadius); + strokeWidth = Number(strokeWidth); + pointRadius = Number(pointRadius); return new OpenLayers.StyleMap({ diff --git a/views/shared/javascripts/app/shared/record/record.collection.js b/views/shared/javascripts/app/shared/record/record.collection.js index bc5a8c3cb..15be70f81 100644 --- a/views/shared/javascripts/app/shared/record/record.collection.js +++ b/views/shared/javascripts/app/shared/record/record.collection.js @@ -52,8 +52,8 @@ Neatline.module('Shared.Record', function( * @return {Array}: The records collection. */ parse: function(response) { - this.offset = parseInt(response.offset, 10); - this.count = parseInt(response.count, 10); + this.offset = Number(response.offset); + this.count = Number(response.count); return response.records; } diff --git a/views/shared/javascripts/app/shared/record/record.model.js b/views/shared/javascripts/app/shared/record/record.model.js index 6373aab38..802b9f389 100644 --- a/views/shared/javascripts/app/shared/record/record.model.js +++ b/views/shared/javascripts/app/shared/record/record.model.js @@ -28,20 +28,25 @@ Neatline.module('Shared.Record', function( defaults: function() { + + // Alias the style defaults. + var styles = Neatline.g.neatline.styles; + return { exhibit_id: Neatline.g.neatline.exhibit.id, - presenter: 'StaticBubble', - fill_color: '#00aeff', - fill_color_select: '#00aeff', - stroke_color: '#000000', - stroke_color_select: '#000000', - fill_opacity: 0.3, - fill_opacity_select: 0.4, - stroke_opacity: 0.9, - stroke_opacity_select: 1.0, - point_radius: 10, - stroke_width: 2 + presenter: styles.presenter, + fill_color: styles.fill_color, + fill_color_select: styles.fill_color_select, + stroke_color: styles.stroke_color, + stroke_color_select: styles.stroke_color_select, + fill_opacity: Number(styles.fill_opacity), + fill_opacity_select: Number(styles.fill_opacity_select), + stroke_opacity: Number(styles.stroke_opacity), + stroke_opacity_select: Number(styles.stroke_opacity_select), + point_radius: Number(styles.point_radius), + stroke_width: Number(styles.stroke_width) }; + } diff --git a/views/shared/javascripts/payloads/neatline-editor.js b/views/shared/javascripts/payloads/neatline-editor.js index 99ba4c6b6..5076728e7 100644 --- a/views/shared/javascripts/payloads/neatline-editor.js +++ b/views/shared/javascripts/payloads/neatline-editor.js @@ -45,5 +45,5 @@ g.push(new e(k,m.length-o,k+i-1,p))}else for(var q=0;qa&&(this.$changedLines.firstRow=a),this.$changedLines.lastRowthis.layerConfig.lastRow||this.$changedLines.lastRow2)){if(this.resizing>1?this.resizing++:this.resizing=a?1:0,e||(e=d.getInnerHeight(this.container)),e&&(a||g.height!=e)&&(g.height=e,f=this.CHANGE_SIZE,g.scrollerHeight=this.scroller.clientHeight,(a||!g.scrollerHeight)&&(g.scrollerHeight=g.height,this.$horizScroll&&(g.scrollerHeight-=this.scrollBar.getWidth())),this.scrollBar.setHeight(g.scrollerHeight),this.session&&(this.session.setScrollTop(this.getScrollTop()),f|=this.CHANGE_FULL)),c||(c=d.getInnerWidth(this.container)),c&&(a||this.resizing>1||g.width!=c)){f=this.CHANGE_SIZE,g.width=c;var b=this.$showGutter?this.$gutter.offsetWidth:0;this.scroller.style.left=b+"px",g.scrollerWidth=Math.max(0,c-b-this.scrollBar.getWidth()),this.scroller.style.right=this.scrollBar.getWidth()+"px",(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||a)&&(f|=this.CHANGE_FULL)}this.$size.scrollerHeight&&(a?this.$renderChanges(f,!0):this.$loop.schedule(f),a&&(this.$gutterLayer.$padding=null),a&&delete this.resizing)}},this.onGutterResize=function(){var a=this.$size.width,b=this.$showGutter?this.$gutter.offsetWidth:0;this.scroller.style.left=b+"px",this.$size.scrollerWidth=Math.max(0,a-b-this.scrollBar.getWidth()),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$loop.schedule(this.CHANGE_MARKER)},this.adjustWrapLimit=function(){var a=this.$size.scrollerWidth-2*this.$padding,b=Math.floor(a/this.characterWidth);return this.session.adjustWrapLimit(b,this.$showPrintMargin&&this.$printMarginColumn)},this.setAnimatedScroll=function(a){this.setOption("animatedScroll",a)},this.getAnimatedScroll=function(){return this.$animatedScroll},this.setShowInvisibles=function(a){this.setOption("showInvisibles",a)},this.getShowInvisibles=function(){return this.getOption("showInvisibles")},this.getDisplayIndentGuides=function(){return this.getOption("displayIndentGuides")},this.setDisplayIndentGuides=function(a){this.setOption("displayIndentGuides",a)},this.setShowPrintMargin=function(a){this.setOption("showPrintMargin",a)},this.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},this.setPrintMarginColumn=function(a){this.setOption("printMarginColumn",a)},this.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},this.getShowGutter=function(){return this.getOption("showGutter")},this.setShowGutter=function(a){return this.setOption("showGutter",a)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.setFadeFoldWidgets=function(a){this.setOption("fadeFoldWidgets",a)},this.setHighlightGutterLine=function(a){this.setOption("highlightGutterLine",a)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.$updateGutterLineHighlight=function(){var a=this.$cursorLayer.$pixelPos,b=this.layerConfig.lineHeight;if(this.session.getUseWrapMode()){var c=this.session.selection.getCursor();c.column=0,a=this.$cursorLayer.getPixelPosition(c,!0),b*=this.session.getRowLength(c.row)}this.$gutterLineHighlight.style.top=a.top-this.layerConfig.offset+"px",this.$gutterLineHighlight.style.height=b+"px"},this.$updatePrintMargin=function(){if(this.$showPrintMargin||this.$printMarginEl){if(!this.$printMarginEl){var a=d.createElement("div");a.className="ace_layer ace_print-margin-layer",this.$printMarginEl=d.createElement("div"),this.$printMarginEl.className="ace_print-margin",a.appendChild(this.$printMarginEl),this.content.insertBefore(a,this.content.firstChild)}var b=this.$printMarginEl.style;b.left=this.characterWidth*this.$printMarginColumn+this.$padding+"px",b.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&-1==this.session.$wrap&&this.adjustWrapLimit()}},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.content},this.getTextAreaContainer=function(){return this.container},this.$moveTextAreaToCursor=function(){if(this.$keepTextAreaAtCursor){var a=this.layerConfig,b=this.$cursorLayer.$pixelPos.top,c=this.$cursorLayer.$pixelPos.left;b-=a.offset;var d=this.lineHeight;if(!(0>b||b>a.height-d)){var e=this.characterWidth;if(this.$composition){var f=this.textarea.value.replace(/^\x01+/,"");e*=this.session.$getStringScreenWidth(f)[0]+2,d+=2,b-=1}c-=this.scrollLeft,c>this.$size.scrollerWidth-e&&(c=this.$size.scrollerWidth-e),c-=this.scrollBar.width,this.textarea.style.height=d+"px",this.textarea.style.width=e+"px",this.textarea.style.right=Math.max(0,this.$size.scrollerWidth-c-e)+"px",this.textarea.style.bottom=Math.max(0,this.$size.height-b-d)+"px"}}},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(0===this.layerConfig.offset?0:1)},this.getLastFullyVisibleRow=function(){var a=Math.floor((this.layerConfig.height+this.layerConfig.offset)/this.layerConfig.lineHeight);return this.layerConfig.firstRow-1+a},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(a){this.$padding=a,this.$textLayer.setPadding(a),this.$cursorLayer.setPadding(a),this.$markerFront.setPadding(a),this.$markerBack.setPadding(a),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setHScrollBarAlwaysVisible=function(a){this.setOption("hScrollBarAlwaysVisible",a)},this.$updateScrollBar=function(){this.scrollBar.setInnerHeight(this.layerConfig.maxHeight),this.scrollBar.setScrollTop(this.scrollTop)},this.$renderChanges=function(a,b){if(b||a&&this.session&&this.container.offsetWidth){if(this._signal("beforeRender"),(a&this.CHANGE_FULL||a&this.CHANGE_SIZE||a&this.CHANGE_TEXT||a&this.CHANGE_LINES||a&this.CHANGE_SCROLL)&&this.$computeLayerConfig(),a&this.CHANGE_H_SCROLL){this.scroller.scrollLeft=this.scrollLeft;var c=this.scroller.scrollLeft;this.scrollLeft=c,this.session.setScrollLeft(c),this.scroller.className=0==this.scrollLeft?"ace_scroller":"ace_scroller ace_scroll-left"}if(a&this.CHANGE_FULL)return this.$textLayer.checkForSizeChanges(),this.$updateScrollBar(),this.$textLayer.update(this.layerConfig),this.$showGutter&&this.$gutterLayer.update(this.layerConfig),this.$markerBack.update(this.layerConfig),this.$markerFront.update(this.layerConfig),this.$cursorLayer.update(this.layerConfig),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this._signal("afterRender"),void 0;if(a&this.CHANGE_SCROLL)return a&this.CHANGE_TEXT||a&this.CHANGE_LINES?this.$textLayer.update(this.layerConfig):this.$textLayer.scrollLines(this.layerConfig),this.$showGutter&&this.$gutterLayer.update(this.layerConfig),this.$markerBack.update(this.layerConfig),this.$markerFront.update(this.layerConfig),this.$cursorLayer.update(this.layerConfig),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this.$moveTextAreaToCursor(),this.$updateScrollBar(),this._signal("afterRender"),void 0;a&this.CHANGE_TEXT?(this.$textLayer.update(this.layerConfig),this.$showGutter&&this.$gutterLayer.update(this.layerConfig)):a&this.CHANGE_LINES?(this.$updateLines()||a&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(this.layerConfig):(a&this.CHANGE_TEXT||a&this.CHANGE_GUTTER)&&this.$showGutter&&this.$gutterLayer.update(this.layerConfig),a&this.CHANGE_CURSOR&&(this.$cursorLayer.update(this.layerConfig),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight()),a&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(this.layerConfig),a&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(this.layerConfig),a&this.CHANGE_SIZE&&this.$updateScrollBar(),this._signal("afterRender")}},this.$computeLayerConfig=function(){if(!this.$size.scrollerHeight)return this.onResize(!0);var a=this.session,b=this.scrollTop%this.lineHeight,c=this.$size.scrollerHeight+this.lineHeight,d=this.$getLongestLine(),e=this.$hScrollBarAlwaysVisible||this.$size.scrollerWidth-d<0,f=this.$horizScroll!==e;this.$horizScroll=e,f&&(this.scroller.style.overflowX=e?"scroll":"hidden",e||this.session.setScrollLeft(0));var g=this.session.getScreenLength()*this.lineHeight;this.session.setScrollTop(Math.max(0,Math.min(this.scrollTop,g-this.$size.scrollerHeight)));var h,i,j=Math.ceil(c/this.lineHeight)-1,k=Math.max(0,Math.round((this.scrollTop-b)/this.lineHeight)),l=k+j,m=this.lineHeight;k=a.screenToDocumentRow(k,0);var n=a.getFoldLine(k);n&&(k=n.start.row),h=a.documentToScreenRow(k,0),i=a.getRowLength(k)*m,l=Math.min(a.screenToDocumentRow(l,0),a.getLength()-1),c=this.$size.scrollerHeight+a.getRowLength(l)*m+i,b=this.scrollTop-h*m,this.layerConfig={width:d,padding:this.$padding,firstRow:k,firstRowScreen:h,lastRow:l,lineHeight:m,characterWidth:this.characterWidth,minHeight:c,maxHeight:g,offset:b,height:this.$size.scrollerHeight},this.$gutterLayer.element.style.marginTop=-b+"px",this.content.style.marginTop=-b+"px",this.content.style.width=d+2*this.$padding+"px",this.content.style.height=c+"px",f&&this.onResize(!0)},this.$updateLines=function(){var a=this.$changedLines.firstRow,b=this.$changedLines.lastRow;this.$changedLines=null;var c=this.layerConfig;return a>c.lastRow+1||be?(b&&(e-=b*this.$size.scrollerHeight),this.session.setScrollTop(e)):this.scrollTop+this.$size.scrollerHeightd?(dc;++c)e.push(f(c/this.STEPS,a,b-a));return e},this.scrollToLine=function(a,b,c,d){var e=this.$cursorLayer.getPixelPosition({row:a,column:0}),f=e.top;b&&(f-=this.$size.scrollerHeight/2);var g=this.scrollTop;this.session.setScrollTop(f),c!==!1&&this.animateScrolling(g,d)},this.animateScrolling=function(a,b){var c=this.scrollTop;if(this.$animatedScroll){var d=this,e=d.$calcSteps(a,c);this.$scrollAnimation={from:a,to:c},clearInterval(this.$timer),d.session.setScrollTop(e.shift()),this.$timer=setInterval(function(){e.length?(d.session.setScrollTop(e.shift()),d.session.$scrollTop=c):null!=c?(d.session.$scrollTop=-1,d.session.setScrollTop(c),c=null):(d.$timer=clearInterval(d.$timer),d.$scrollAnimation=null,b&&b())},10)}},this.scrollToY=function(a){this.scrollTop!==a&&(this.$loop.schedule(this.CHANGE_SCROLL),this.scrollTop=a)},this.scrollToX=function(a){0>a&&(a=0),this.scrollLeft!==a&&(this.scrollLeft=a),this.$loop.schedule(this.CHANGE_H_SCROLL)},this.scrollBy=function(a,b){b&&this.session.setScrollTop(this.session.getScrollTop()+b),a&&this.session.setScrollLeft(this.session.getScrollLeft()+a)},this.isScrollableBy=function(a,b){return 0>b&&this.session.getScrollTop()>=1?!0:b>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1?!0:void 0},this.pixelToScreenCoordinates=function(a,b){var c=this.scroller.getBoundingClientRect(),d=(a+this.scrollLeft-c.left-this.$padding)/this.characterWidth,e=Math.floor((b+this.scrollTop-c.top)/this.lineHeight),f=Math.round(d);return{row:e,column:f,side:d-f>0?1:-1}},this.screenToTextCoordinates=function(a,b){var c=this.scroller.getBoundingClientRect(),d=Math.round((a+this.scrollLeft-c.left-this.$padding)/this.characterWidth),e=Math.floor((b+this.scrollTop-c.top)/this.lineHeight);return this.session.screenToDocumentPosition(e,Math.max(d,0))},this.textToScreenCoordinates=function(a,b){var c=this.scroller.getBoundingClientRect(),d=this.session.documentToScreenPosition(a,b),e=this.$padding+Math.round(d.column*this.characterWidth),f=d.row*this.lineHeight;return{pageX:c.left+e-this.scrollLeft,pageY:c.top+f-this.scrollTop}},this.visualizeFocus=function(){d.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){d.removeCssClass(this.container,"ace_focus")},this.showComposition=function(){this.$composition||(this.$composition={keepTextAreaAtCursor:this.$keepTextAreaAtCursor,cssText:this.textarea.style.cssText}),this.$keepTextAreaAtCursor=!0,d.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor()},this.setCompositionText=function(){this.$moveTextAreaToCursor()},this.hideComposition=function(){this.$composition&&(d.removeCssClass(this.textarea,"ace_composition"),this.$keepTextAreaAtCursor=this.$composition.keepTextAreaAtCursor,this.textarea.style.cssText=this.$composition.cssText,this.$composition=null)},this.setTheme=function(a){function b(b){if(c.$themeValue==a&&b.cssClass){d.importCssString(b.cssText,b.cssClass,c.container.ownerDocument),c.theme&&d.removeCssClass(c.container,c.theme.cssClass),c.$theme=b.cssClass,c.theme=b,d.addCssClass(c.container,b.cssClass),d.setCssClass(c.container,"ace_dark",b.isDark);var e=b.padding||4;c.$padding&&e!=c.$padding&&c.setPadding(e),c.$size&&(c.$size.width=0,c.onResize()),c._dispatchEvent("themeLoaded",{theme:b})}}var c=this;if(this.$themeValue=a,c._dispatchEvent("themeChange",{theme:a}),a&&"string"!=typeof a)b(a);else{var e=a||"ace/theme/textmate";g.loadModule(["theme",e],b)}},this.getTheme=function(){return this.$themeValue},this.setStyle=function(a,b){d.setCssClass(this.container,a,0!=b)},this.unsetStyle=function(a){d.removeCssClass(this.container,a)},this.destroy=function(){this.$textLayer.destroy(),this.$cursorLayer.destroy()}}.call(p.prototype),g.defineOptions(p.prototype,"renderer",{animatedScroll:{initialValue:!1},showInvisibles:{set:function(a){this.$textLayer.setShowInvisibles(a)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(a){"number"==typeof a&&(this.$printMarginColumn=a),this.$showPrintMargin=!!a,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(a){this.$gutter.style.display=a?"block":"none",this.onGutterResize()},initialValue:!0},fadeFoldWidgets:{set:function(a){d.setCssClass(this.$gutter,"ace_fade-fold-widgets",a)},initialValue:!1},showFoldWidgets:{set:function(a){this.$gutterLayer.setShowFoldWidgets(a)},initialValue:!0},displayIndentGuides:{set:function(a){this.$textLayer.setDisplayIndentGuides(a)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightGutterLine:{set:function(a){return this.$gutterLineHighlight?(this.$gutterLineHighlight.style.display=a?"":"none",this.$cursorLayer.$pixelPos&&this.$updateGutterLineHighlight(),void 0):(this.$gutterLineHighlight=d.createElement("div"),this.$gutterLineHighlight.className="ace_gutter-active-line",this.$gutter.appendChild(this.$gutterLineHighlight),void 0)},initialValue:!1,value:!0},hScrollBarAlwaysVisible:{set:function(a){this.$hScrollBarAlwaysVisible=a,this.$hScrollBarAlwaysVisible&&this.$horizScroll||this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(a){"number"==typeof a&&(a+="px"),this.container.style.fontSize=a,this.updateFontSize()},initialValue:12},fontFamily:{set:function(a){this.container.style.fontFamily=a,this.updateFontSize()}}}),b.VirtualRenderer=p}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"],function(a,b){var c=a("../lib/dom"),d=a("../lib/oop"),e=a("../lib/lang"),f=a("../lib/event_emitter").EventEmitter,g=function(a){this.element=c.createElement("div"),this.element.className="ace_layer ace_gutter-layer",a.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$annotations=[],this.$updateAnnotations=this.$updateAnnotations.bind(this)};!function(){d.implement(this,f),this.setSession=function(a){this.session&&this.session.removeEventListener("change",this.$updateAnnotations),this.session=a,a.on("change",this.$updateAnnotations)},this.addGutterDecoration=function(a,b){window.console&&console.warn&&console.warn("deprecated use session.addGutterDecoration"),this.session.addGutterDecoration(a,b)},this.removeGutterDecoration=function(a,b){window.console&&console.warn&&console.warn("deprecated use session.removeGutterDecoration"),this.session.removeGutterDecoration(a,b)},this.setAnnotations=function(a){this.$annotations=[];for(var b,c,d=0;dh&&(e=g.end.row+1,g=this.session.getNextFoldLine(e,g),h=g?g.start.row:1/0),e>f)break;var n=this.$annotations[e]||b;if(d.push("
",m=e+l),i){var o=i[e];null==o&&(o=i[e]=this.session.getFoldWidget(e)),o&&d.push("")}d.push("
"),e++}this.element=c.setInnerHtml(this.element,d.join("")),this.element.style.height=a.minHeight+"px",this.session.$useWrapMode&&(m=this.session.getLength());var p=(""+m).length*a.characterWidth,q=this.$padding||this.$computePadding();p+=q.left+q.right,p!==this.gutterWidth&&(this.gutterWidth=p,this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._emit("changeGutterWidth",p))},this.$showFoldWidgets=!0,this.setShowFoldWidgets=function(a){a?c.addCssClass(this.element,"ace_folding-enabled"):c.removeCssClass(this.element,"ace_folding-enabled"),this.$showFoldWidgets=a,this.$padding=null},this.getShowFoldWidgets=function(){return this.$showFoldWidgets},this.$computePadding=function(){if(!this.element.firstChild)return{left:0,right:0};var a=c.computedStyle(this.element.firstChild);return this.$padding={},this.$padding.left=parseInt(a.paddingLeft)+1,this.$padding.right=parseInt(a.paddingRight),this.$padding},this.getRegion=function(a){var b=this.$padding||this.$computePadding(),c=this.element.getBoundingClientRect();return a.xc.right-b.right?"foldWidgets":void 0}}.call(g.prototype),b.Gutter=g}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(a,b){var c=a("../range").Range,d=a("../lib/dom"),e=function(a){this.element=d.createElement("div"),this.element.className="ace_layer ace_marker-layer",a.appendChild(this.element)};!function(){this.$padding=0,this.setPadding=function(a){this.$padding=a},this.setSession=function(a){this.session=a},this.setMarkers=function(a){this.markers=a},this.update=function(a){var a=a||this.config;if(a){this.config=a;var b=[];for(var c in this.markers){var e=this.markers[c];if(e.range){var f=e.range.clipRows(a.firstRow,a.lastRow);if(!f.isEmpty())if(f=f.toScreenRange(this.session),e.renderer){var g=this.$getTop(f.start.row,a),h=this.$padding+f.start.column*a.characterWidth;e.renderer(b,f,h,g,a)}else"fullLine"==e.type?this.drawFullLineMarker(b,f,e.clazz,a):"screenLine"==e.type?this.drawScreenLineMarker(b,f,e.clazz,a):f.isMultiLine()?"text"==e.type?this.drawTextMarker(b,f,e.clazz,a):this.drawMultiLineMarker(b,f,e.clazz,a):this.drawSingleLineMarker(b,f,e.clazz+" ace_start",a)}else e.update(b,this,this.session,a)}this.element=d.setInnerHtml(this.element,b.join(""))}},this.$getTop=function(a,b){return(a-b.firstRowScreen)*b.lineHeight},this.drawTextMarker=function(a,b,d,e,f){var g=b.start.row,h=new c(g,b.start.column,g,this.session.getScreenLastRowColumn(g));for(this.drawSingleLineMarker(a,h,d+" ace_start",e,1,f),g=b.end.row,h=new c(g,0,g,b.end.column),this.drawSingleLineMarker(a,h,d,e,0,f),g=b.start.row+1;g"),h=this.$getTop(b.end.row,d);var j=b.end.column*d.characterWidth;a.push("
"),g=(b.end.row-b.start.row-1)*d.lineHeight,0>g||(h=this.$getTop(b.start.row+1,d),a.push("
"))},this.drawSingleLineMarker=function(a,b,c,d,e,f){var g=d.lineHeight,h=(b.end.column+(e||0)-b.start.column)*d.characterWidth,i=this.$getTop(b.start.row,d),j=this.$padding+b.start.column*d.characterWidth;a.push("
")},this.drawFullLineMarker=function(a,b,c,d,e){var f=this.$getTop(b.start.row,d),g=d.lineHeight;b.start.row!=b.end.row&&(g+=this.$getTop(b.end.row,d)-f),a.push("
")},this.drawScreenLineMarker=function(a,b,c,d,e){var f=this.$getTop(b.start.row,d),g=d.lineHeight;a.push("
")}}.call(e.prototype),b.Marker=e}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(a,b){var c=a("../lib/oop"),d=a("../lib/dom"),e=a("../lib/lang"),f=a("../lib/useragent"),g=a("../lib/event_emitter").EventEmitter,h=function(a){this.element=d.createElement("div"),this.element.className="ace_layer ace_text-layer",a.appendChild(this.element),this.$characterSize={width:0,height:0},this.checkForSizeChanges(),this.$pollSizeChanges()};!function(){c.implement(this,g),this.EOF_CHAR="¶",this.EOL_CHAR="¬",this.TAB_CHAR="→",this.SPACE_CHAR="·",this.$padding=0,this.setPadding=function(a){this.$padding=a,this.element.style.padding="0 "+a+"px"},this.getLineHeight=function(){return this.$characterSize.height||1},this.getCharacterWidth=function(){return this.$characterSize.width||1},this.checkForSizeChanges=function(){var a=this.$measureSizes();if(a&&(this.$characterSize.width!==a.width||this.$characterSize.height!==a.height)){this.$measureNode.style.fontWeight="bold";var b=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=a,this.allowBoldFonts=b&&b.width===a.width&&b.height===a.height,this._emit("changeCharacterSize",{data:a})}},this.$pollSizeChanges=function(){var a=this;this.$pollSizeChangesTimer=setInterval(function(){a.checkForSizeChanges()},500)},this.$fontStyles={fontFamily:1,fontSize:1,fontWeight:1,fontStyle:1,lineHeight:1},this.$measureSizes=f.isIE||f.isOldGecko?function(){var a=1e3;if(!this.$measureNode){var b=this.$measureNode=d.createElement("div"),c=b.style;if(c.width=c.height="auto",c.left=c.top=40*-a+"px",c.visibility="hidden",c.position="fixed",c.overflow="visible",c.whiteSpace="nowrap",b.innerHTML=e.stringRepeat("Xy",a),this.element.ownerDocument.body)this.element.ownerDocument.body.appendChild(b);else{for(var f=this.element.parentNode;!d.hasCssClass(f,"ace_editor");)f=f.parentNode;f.appendChild(b)}}if(!this.element.offsetWidth)return null;var c=this.$measureNode.style,g=d.computedStyle(this.element);for(var h in this.$fontStyles)c[h]=g[h];var i={height:this.$measureNode.offsetHeight,width:this.$measureNode.offsetWidth/(2*a)};return 0==i.width||0==i.height?null:i}:function(){if(!this.$measureNode){var a=this.$measureNode=d.createElement("div"),b=a.style;b.width=b.height="auto",b.left=b.top="-100px",b.visibility="hidden",b.position="fixed",b.overflow="visible",b.whiteSpace="nowrap",a.innerHTML="X";for(var c=this.element.parentNode;c&&!d.hasCssClass(c,"ace_editor");)c=c.parentNode;if(!c)return this.$measureNode=null;c.appendChild(a)}var e=this.$measureNode.getBoundingClientRect(),f={height:e.height,width:e.width};return 0==f.width||0==f.height?null:f},this.setSession=function(a){this.session=a,this.$computeTabString()},this.showInvisibles=!1,this.setShowInvisibles=function(a){return this.showInvisibles==a?!1:(this.showInvisibles=a,this.$computeTabString(),!0)},this.displayIndentGuides=!0,this.setDisplayIndentGuides=function(a){return this.displayIndentGuides==a?!1:(this.displayIndentGuides=a,this.$computeTabString(),!0)},this.$tabStrings=[],this.onChangeTabSize=this.$computeTabString=function(){var a=this.session.getTabSize();this.tabSize=a;for(var b=this.$tabStrings=[0],c=1;a+1>c;c++)this.showInvisibles?b.push(""+this.TAB_CHAR+e.stringRepeat(" ",c-1)+""):b.push(e.stringRepeat(" ",c));if(this.displayIndentGuides){this.$indentGuideRe=/\s\S| \t|\t |\s$/;var d="ace_indent-guide";if(this.showInvisibles){d+=" ace_invisible";var f=e.stringRepeat(this.SPACE_CHAR,this.tabSize),g=this.TAB_CHAR+e.stringRepeat(" ",this.tabSize-1)}else var f=e.stringRepeat(" ",this.tabSize),g=f;this.$tabStrings[" "]=""+f+"",this.$tabStrings[" "]=""+g+""}},this.updateLines=function(a,b,c){(this.config.lastRow!=a.lastRow||this.config.firstRow!=a.firstRow)&&this.scrollLines(a),this.config=a;for(var e=Math.max(b,a.firstRow),f=Math.min(c,a.lastRow),g=this.element.childNodes,h=0,i=a.firstRow;e>i;i++){var j=this.session.getFoldLine(i);if(j){if(j.containsRow(e)){e=j.start.row;break}i=j.end.row}h++}for(var i=e,j=this.session.getNextFoldLine(i),k=j?j.start.row:1/0;;){if(i>k&&(i=j.end.row+1,j=this.session.getNextFoldLine(i,j),k=j?j.start.row:1/0),i>f)break;var l=g[h++];if(l){var m=[]; this.$renderLine(m,i,!this.$useLineGroups(),i==k?j:!1),d.setInnerHtml(l,m.join(""))}i++}},this.scrollLines=function(a){var b=this.config;if(this.config=a,!b||b.lastRow0;d--)c.removeChild(c.firstChild);if(b.lastRow>a.lastRow)for(var d=this.session.getFoldedRowCount(a.lastRow+1,b.lastRow);d>0;d--)c.removeChild(c.lastChild);if(a.firstRowb.lastRow){var e=this.$renderLinesFragment(a,b.lastRow+1,a.lastRow);c.appendChild(e)}},this.$renderLinesFragment=function(a,b,c){for(var e=this.element.ownerDocument.createDocumentFragment(),f=b,g=this.session.getNextFoldLine(f),h=g?g.start.row:1/0;;){if(f>h&&(f=g.end.row+1,g=this.session.getNextFoldLine(f,g),h=g?g.start.row:1/0),f>c)break;var i=d.createElement("div"),j=[];if(this.$renderLine(j,f,!1,f==h?g:!1),i.innerHTML=j.join(""),this.$useLineGroups())i.className="ace_line_group",e.appendChild(i);else for(var k=i.childNodes;k.length;)e.appendChild(k[0]);f++}return e},this.update=function(a){this.config=a;for(var b=[],c=a.firstRow,e=a.lastRow,f=c,g=this.session.getNextFoldLine(f),h=g?g.start.row:1/0;;){if(f>h&&(f=g.end.row+1,g=this.session.getNextFoldLine(f,g),h=g?g.start.row:1/0),f>e)break;this.$useLineGroups()&&b.push("
"),this.$renderLine(b,f,!1,f==h?g:!1),this.$useLineGroups()&&b.push("
"),f++}this.element=d.setInnerHtml(this.element,b.join(""))},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(a,b,c,d){var f=this,g=/\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g,h=function(a,c,d,g){if(c)return f.showInvisibles?""+e.stringRepeat(f.SPACE_CHAR,a.length)+"":e.stringRepeat(" ",a.length);if("&"==a)return"&";if("<"==a)return"<";if(" "==a){var h=f.session.getScreenTabSize(b+g);return b+=h-1,f.$tabStrings[h]}if(" "==a){var i=f.showInvisibles?"ace_cjk ace_invisible":"ace_cjk",j=f.showInvisibles?f.SPACE_CHAR:"";return b+=1,""+j+""}return d?""+f.SPACE_CHAR+"":(b+=1,""+a+"")},i=d.replace(g,h);if(this.$textToken[c.type])a.push(i);else{var j="ace_"+c.type.replace(/\./g," ace_"),k="";"fold"==c.type&&(k=" style='width:"+c.value.length*this.config.characterWidth+"px;' "),a.push("",i,"")}return b+d.length},this.renderIndentGuide=function(a,b){var c=b.search(this.$indentGuideRe);return 0>=c?b:" "==b[0]?(c-=c%this.tabSize,a.push(e.stringRepeat(this.$tabStrings[" "],c/this.tabSize)),b.substr(c)):" "==b[0]?(a.push(e.stringRepeat(this.$tabStrings[" "],c)),b.substr(c)):b},this.$renderWrappedLine=function(a,b,c,d){for(var e=0,f=0,g=c[0],h=0,i=0;i=g;)h=this.$renderToken(a,h,j,k.substring(0,g-e)),k=k.substring(g-e),e=g,d||a.push("","
"),f++,h=0,g=c[f]||Number.MAX_VALUE;0!=k.length&&(e+=k.length,h=this.$renderToken(a,h,j,k))}}},this.$renderSimpleLine=function(a,b){var c=0,d=b[0],e=d.value;this.displayIndentGuides&&(e=this.renderIndentGuide(a,e)),e&&(c=this.$renderToken(a,c,d,e));for(var f=1;f"),e.length){var f=this.session.getRowSplitData(b);f&&f.length?this.$renderWrappedLine(a,e,f,c):this.$renderSimpleLine(a,e)}this.showInvisibles&&(d&&(b=d.end.row),a.push("",b==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,"")),c||a.push("
")},this.$getFoldLineTokens=function(a,b){function c(a,b,c){for(var d=0,f=0;f+a[d].value.lengthc-b&&(g=g.substring(0,c-b)),e.push({type:a[d].type,value:g}),f=b+g.length,d+=1}for(;c>f&&dc?e.push({type:a[d].type,value:g.substring(0,c-f)}):e.push(a[d]),f+=g.length,d+=1}}var d=this.session,e=[],f=d.getTokens(a);return b.walk(function(a,b,g,h,i){null!=a?e.push({type:"fold",value:a}):(i&&(f=d.getTokens(b)),f.length&&c(f,h,g))},b.end.row,this.session.getLine(b.end.row).length),e},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$measureNode&&this.$measureNode.parentNode.removeChild(this.$measureNode),delete this.$measureNode}}.call(h.prototype),b.Text=h}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(a,b){var c=a("../lib/dom"),d=function(a){this.element=c.createElement("div"),this.element.className="ace_layer ace_cursor-layer",a.appendChild(this.element),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),c.addCssClass(this.element,"ace_hidden-cursors")};!function(){this.$padding=0,this.setPadding=function(a){this.$padding=a},this.setSession=function(a){this.session=a},this.setBlinking=function(a){a!=this.isBlinking&&(this.isBlinking=a,this.restartTimer())},this.setBlinkInterval=function(a){a!=this.blinkInterval&&(this.blinkInterval=a,this.restartTimer())},this.setSmoothBlinking=function(a){a!=this.smoothBlinking&&(this.smoothBlinking=a,a?c.addCssClass(this.element,"ace_smooth-blinking"):c.removeCssClass(this.element,"ace_smooth-blinking"),this.restartTimer())},this.addCursor=function(){var a=c.createElement("div");return a.className="ace_cursor",this.element.appendChild(a),this.cursors.push(a),a},this.removeCursor=function(){if(this.cursors.length>1){var a=this.cursors.pop();return a.parentNode.removeChild(a),a}},this.hideCursor=function(){this.isVisible=!1,c.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.showCursor=function(){this.isVisible=!0,c.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.restartTimer=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.smoothBlinking&&c.removeCssClass(this.element,"ace_smooth-blinking");for(var a=this.cursors.length;a--;)this.cursors[a].style.opacity="";if(this.isBlinking&&this.blinkInterval&&this.isVisible){this.smoothBlinking&&setTimeout(function(){c.addCssClass(this.element,"ace_smooth-blinking")}.bind(this));var b=function(){this.timeoutId=setTimeout(function(){for(var a=this.cursors.length;a--;)this.cursors[a].style.opacity=0}.bind(this),.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){for(var a=this.cursors.length;a--;)this.cursors[a].style.opacity="";b()}.bind(this),this.blinkInterval),b()}},this.getPixelPosition=function(a,b){if(!this.config||!this.session)return{left:0,top:0};a||(a=this.session.selection.getCursor());var c=this.session.documentToScreenPosition(a),d=this.$padding+c.column*this.config.characterWidth,e=(c.row-(b?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:d,top:e}},this.update=function(a){this.config=a;var b=this.session.$selectionMarkers,c=0,d=0;(void 0===b||0===b.length)&&(b=[{cursor:null}]);for(var c=0,e=b.length;e>c;c++){var f=this.getPixelPosition(b[c].cursor,!0);if(!((f.top>a.height+a.offset||f.top<-a.offset)&&c>1)){var g=(this.cursors[d++]||this.addCursor()).style;g.left=f.left+"px",g.top=f.top+"px",g.width=a.characterWidth+"px",g.height=a.lineHeight+"px"}}for(;this.cursors.length>d;)this.removeCursor();var h=this.session.getOverwrite();this.$setOverwrite(h),this.$pixelPos=f,this.restartTimer()},this.$setOverwrite=function(a){a!=this.overwrite&&(this.overwrite=a,a?c.addCssClass(this.element,"ace_overwrite-cursors"):c.removeCssClass(this.element,"ace_overwrite-cursors"))},this.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)}}.call(d.prototype),b.Cursor=d}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(a,b){var c=a("./lib/oop"),d=a("./lib/dom"),e=a("./lib/event"),f=a("./lib/event_emitter").EventEmitter,g=function(a){this.element=d.createElement("div"),this.element.className="ace_scrollbar",this.inner=d.createElement("div"),this.inner.className="ace_scrollbar-inner",this.element.appendChild(this.inner),a.appendChild(this.element),this.width=d.scrollbarWidth(a.ownerDocument),this.element.style.width=(this.width||15)+5+"px",e.addListener(this.element,"scroll",this.onScroll.bind(this))};!function(){c.implement(this,f),this.onScroll=function(){this.skipEvent||(this.scrollTop=this.element.scrollTop,this._emit("scroll",{data:this.scrollTop})),this.skipEvent=!1},this.getWidth=function(){return this.width},this.setHeight=function(a){this.element.style.height=a+"px"},this.setInnerHeight=function(a){this.inner.style.height=a+"px"},this.setScrollTop=function(a){this.scrollTop!=a&&(this.skipEvent=!0,this.scrollTop=this.element.scrollTop=a)}}.call(g.prototype),b.ScrollBar=g}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(a,b){var c=a("./lib/event"),d=function(a,b){this.onRender=a,this.pending=!1,this.changes=0,this.window=b||window};!function(){this.schedule=function(a){if(this.changes=this.changes|a,!this.pending){this.pending=!0;var b=this;c.nextFrame(function(){b.pending=!1;for(var a;a=b.changes;)b.changes=0,b.onRender(a)},this.window)}}}.call(d.prototype),b.RenderLoop=d}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor"],function(a,b){function c(a,b,c){return o.$options.wrap=!0,o.$options.needle=b,o.$options.backwards=-1==c,o.find(a)}function d(a,b){return a.row==b.row&&a.column==b.column}function e(a){a.$onAddRange=a.$onAddRange.bind(a),a.$onRemoveRange=a.$onRemoveRange.bind(a),a.$onMultiSelect=a.$onMultiSelect.bind(a),a.$onSingleSelect=a.$onSingleSelect.bind(a),b.onSessionChange.call(a,a),a.on("changeSession",b.onSessionChange.bind(a)),a.on("mousedown",j),a.commands.addCommands(m.defaultCommands),f(a)}function f(a){function b(){d&&(e.style.cursor="",d=!1)}var c=a.textInput.getElement(),d=!1,e=a.renderer.content;k.addListener(c,"keydown",function(a){18!=a.keyCode||a.ctrlKey||a.shiftKey||a.metaKey?d&&(e.style.cursor=""):d||(e.style.cursor="crosshair",d=!0)}),k.addListener(c,"keyup",b),k.addListener(c,"blur",b)}var g=a("./range_list").RangeList,h=a("./range").Range,i=a("./selection").Selection,j=a("./mouse/multi_select_handler").onMouseDown,k=a("./lib/event"),l=a("./lib/lang"),m=a("./commands/multi_select_commands");b.commands=m.defaultCommands.concat(m.multiSelectCommands);var n=a("./search").Search,o=new n,p=a("./edit_session").EditSession;!function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}.call(p.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(a,b){if(a){if(!this.inMultiSelectMode&&0==this.rangeCount){var c=this.toOrientedRange();if(this.rangeList.add(c),this.rangeList.add(a),2!=this.rangeList.ranges.length)return this.rangeList.removeAll(),b||this.fromOrientedRange(a);this.rangeList.removeAll(),this.rangeList.add(c),this.$onAddRange(c)}a.cursor||(a.cursor=a.end);var d=this.rangeList.add(a);return this.$onAddRange(a),d.length&&this.$onRemoveRange(d),this.rangeCount>1&&!this.inMultiSelectMode&&(this._emit("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),b||this.fromOrientedRange(a)}},this.toSingleRange=function(a){a=a||this.ranges[0];var b=this.rangeList.removeAll();b.length&&this.$onRemoveRange(b),a&&this.fromOrientedRange(a)},this.substractPoint=function(a){var b=this.rangeList.substractPoint(a);return b?(this.$onRemoveRange(b),b[0]):void 0},this.mergeOverlappingRanges=function(){var a=this.rangeList.merge();a.length?this.$onRemoveRange(a):this.ranges[0]&&this.fromOrientedRange(this.ranges[0])},this.$onAddRange=function(a){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(a),this._emit("addRange",{range:a})},this.$onRemoveRange=function(a){if(this.rangeCount=this.rangeList.ranges.length,1==this.rangeCount&&this.inMultiSelectMode){var b=this.rangeList.ranges.pop();a.push(b),this.rangeCount=0}for(var c=a.length;c--;){var d=this.ranges.indexOf(a[c]);this.ranges.splice(d,1)}this._emit("removeRange",{ranges:a}),0==this.rangeCount&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._emit("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),b=b||this.ranges[0],b&&!b.isEqual(this.getRange())&&this.fromOrientedRange(b)},this.$initRangeList=function(){this.rangeList||(this.rangeList=new g,this.ranges=[],this.rangeCount=0)},this.getAllRanges=function(){return this.rangeList.ranges.concat()},this.splitIntoLines=function(){if(this.rangeCount>1){var a=this.rangeList.ranges,b=a[a.length-1],c=h.fromPoints(a[0].start,b.end);this.toSingleRange(),this.setSelectionRange(c,b.cursor==b.start)}else{var c=this.getRange(),d=this.isBackwards(),e=c.start.row,f=c.end.row;if(e==f){if(d)var g=c.end,i=c.start;else var g=c.start,i=c.end;return this.addRange(h.fromPoints(i,i)),this.addRange(h.fromPoints(g,g)),void 0}var j=[],k=this.getLineRange(e,!0);k.start.column=c.start.column,j.push(k);for(var l=e+1;f>l;l++)j.push(this.getLineRange(l,!0));k=this.getLineRange(f,!0),k.end.column=c.end.column,j.push(k),j.forEach(this.addRange,this)}},this.toggleBlockSelection=function(){if(this.rangeCount>1){var a=this.rangeList.ranges,b=a[a.length-1],c=h.fromPoints(a[0].start,b.end);this.toSingleRange(),this.setSelectionRange(c,b.cursor==b.start)}else{var d=this.session.documentToScreenPosition(this.selectionLead),e=this.session.documentToScreenPosition(this.selectionAnchor),f=this.rectangularRangeBlock(d,e);f.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(a,b,c){var e=[],f=a.columng&&(g=0),0>k&&(k=0),k==l&&(c=!0);for(var m=k;l>=m;m++){var n=h.fromPoints(this.session.screenToDocumentPosition(m,g),this.session.screenToDocumentPosition(m,i));if(n.isEmpty()){if(o&&d(n.end,o))break;var o=n.end}n.cursor=f?n.start:n.end,e.push(n)}if(j&&e.reverse(),!c){for(var p=e.length-1;e[p].isEmpty()&&p>0;)p--;if(p>0)for(var q=0;e[q].isEmpty();)q++;for(var r=p;r>=q;r--)e[r].isEmpty()&&e.splice(r,1)}return e}}.call(i.prototype);var q=a("./editor").Editor;!function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(a){a.cursor||(a.cursor=a.end);var b=this.getSelectionStyle();return a.marker=this.session.addMarker(a,"ace_selection",b),this.session.$selectionMarkers.push(a),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,a},this.removeSelectionMarker=function(a){if(a.marker){this.session.removeMarker(a.marker);var b=this.session.$selectionMarkers.indexOf(a);-1!=b&&this.session.$selectionMarkers.splice(b,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length}},this.removeSelectionMarkers=function(a){for(var b=this.session.$selectionMarkers,c=a.length;c--;){var d=a[c];if(d.marker){this.session.removeMarker(d.marker);var e=b.indexOf(d);-1!=e&&b.splice(e,1)}}this.session.selectionMarkerCount=b.length},this.$onAddRange=function(a){this.addSelectionMarker(a.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(a){this.removeSelectionMarkers(a.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(){this.inMultiSelectMode||(this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(m.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers())},this.$onSingleSelect=function(){this.session.multiSelect.inVirtualMode||(this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(m.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers())},this.$onMultiSelectExec=function(a){var b=a.command,c=a.editor;if(c.multiSelect){if(b.multiSelectAction)"forEach"==b.multiSelectAction?d=c.forEachSelection(b,a.args):"forEachLine"==b.multiSelectAction?d=c.forEachSelection(b,a.args,!0):"single"==b.multiSelectAction?(c.exitMultiSelectMode(),d=b.exec(c,a.args||{})):d=b.multiSelectAction(c,a.args||{});else{var d=b.exec(c,a.args||{});c.multiSelect.addRange(c.multiSelect.toOrientedRange()),c.multiSelect.mergeOverlappingRanges()}return d}},this.forEachSelection=function(a,b,c){if(!this.inVirtualSelectionMode){var d,e=this.session,f=this.selection,g=f.rangeList,h=f._eventRegistry;f._eventRegistry={};var j=new i(e);this.inVirtualSelectionMode=!0;for(var k=g.ranges.length;k--;){if(c)for(;k>0&&g.ranges[k].start.row==g.ranges[k-1].end.row;)k--;j.fromOrientedRange(g.ranges[k]),this.selection=e.selection=j;var l=a.exec(this,b||{});void 0==!d&&(d=l),j.toOrientedRange(g.ranges[k])}j.detach(),this.selection=e.selection=f,this.inVirtualSelectionMode=!1,f._eventRegistry=h,f.mergeOverlappingRanges();var m=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),m&&m.from==m.to&&this.renderer.animateScrolling(m.from),d}},this.exitMultiSelectMode=function(){this.inMultiSelectMode&&!this.inVirtualSelectionMode&&this.multiSelect.toSingleRange()},this.getCopyText=function(){var a="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){for(var b=this.multiSelect.rangeList.ranges,c=[],d=0;dc.length||b.length<2||!b[1])return this.commands.exec("insertstring",this,a);for(var d=c.length;d--;){var e=c[d];e.isEmpty()||this.session.remove(e),this.session.insert(e.start,b[d])}}},this.findAll=function(a,b,c){b=b||{},b.needle=a||b.needle,this.$search.set(b);var d=this.$search.findAll(this.session);if(!d.length)return 0;this.$blockScrolling+=1;var e=this.multiSelect;c||e.toSingleRange(d[0]);for(var f=d.length;f--;)e.addRange(d[f],!0);return this.$blockScrolling-=1,d.length},this.selectMoreLines=function(a,b){var c=this.selection.toOrientedRange(),d=c.cursor==c.end,e=this.session.documentToScreenPosition(c.cursor);this.selection.$desiredColumn&&(e.column=this.selection.$desiredColumn);var f=this.session.screenToDocumentPosition(e.row+a,e.column);if(c.isEmpty())var g=f;else var i=this.session.documentToScreenPosition(d?c.end:c.start),g=this.session.screenToDocumentPosition(i.row+a,i.column);if(d){var j=h.fromPoints(f,g);j.cursor=j.start}else{var j=h.fromPoints(g,f);j.cursor=j.end}if(j.desiredColumn=e.column,this.selection.inMultiSelectMode){if(b)var k=c.cursor}else this.selection.addRange(c);this.selection.addRange(j),k&&this.selection.substractPoint(k)},this.transposeSelections=function(a){for(var b=this.session,c=b.multiSelect,d=c.ranges,e=d.length;e--;){var f=d[e];if(f.isEmpty()){var g=b.getWordRange(f.start.row,f.start.column);f.start.row=g.start.row,f.start.column=g.start.column,f.end.row=g.end.row,f.end.column=g.end.column}}c.mergeOverlappingRanges();for(var h=[],e=d.length;e--;){var f=d[e];h.unshift(b.getTextRange(f))}0>a?h.unshift(h.pop()):h.push(h.shift());for(var e=d.length;e--;){var f=d[e],g=f.clone();b.replace(f,h[e]),f.start.row=g.start.row,f.start.column=g.start.column}},this.selectMore=function(a,b){var d=this.session,e=d.multiSelect,f=e.toOrientedRange();if(f.isEmpty()){var f=d.getWordRange(f.start.row,f.start.column);f.cursor=f.end,this.multiSelect.addRange(f)}var g=d.getTextRange(f),h=c(d,g,a);h&&(h.cursor=-1==a?h.start:h.end,this.multiSelect.addRange(h)),b&&this.multiSelect.substractPoint(f.cursor)},this.alignCursors=function(){var a=this.session,b=a.multiSelect,c=b.ranges;if(c.length){var d=-1,e=c.filter(function(a){return a.cursor.row==d?!0:(d=a.cursor.row,void 0)});b.$onRemoveRange(e);var f=0,g=1/0,i=c.map(function(b){var c=b.cursor,d=a.getLine(c.row),e=d.substr(c.column).search(/\S/g);return-1==e&&(e=0),c.column>f&&(f=c.column),g>e&&(g=e),e});c.forEach(function(b,c){var d=b.cursor,e=f-d.column,j=i[c]-g;e>j?a.insert(d,l.stringRepeat(" ",e-j)):a.remove(new h(d.row,d.column,d.row,d.column-e+j)),b.start.column=b.end.column=f,b.start.row=b.end.row=d.row,b.cursor=b.end}),b.fromOrientedRange(c[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}else{var j=this.selection.getRange(),k=j.start.row,m=j.end.row,n=this.session.doc.removeLines(k,m);n=this.$reAlignText(n),this.session.doc.insertLines(k,n),j.start.column=0,j.end.column=n[n.length-1].length,this.selection.setRange(j)}},this.$reAlignText=function(a){function b(a){return l.stringRepeat(" ",a)}function c(a){return a[2]?b(f)+a[2]+b(g-a[2].length+h)+a[4].replace(/^([=:])\s+/,"$1 "):a[0]}function d(a){return a[2]?b(f+g-a[2].length)+a[2]+b(h," ")+a[4].replace(/^([=:])\s+/,"$1 "):a[0]}function e(a){return a[2]?b(f)+a[2]+b(h)+a[4].replace(/^([=:])\s+/,"$1 "):a[0]}var f,g,h,i=!0,j=!0;return a.map(function(a){var b=a.match(/(\s*)(.*?)(\s*)([=:].*)/);return b?null==f?(f=b[1].length,g=b[2].length,h=b[3].length,b):(f+g+h!=b[1].length+b[2].length+b[3].length&&(j=!1),f!=b[1].length&&(i=!1),f>b[1].length&&(f=b[1].length),gb[3].length&&(h=b[3].length),b):[a]}).map(i?j?d:c:e)}}.call(q.prototype),b.onSessionChange=function(a){var b=a.session;b.multiSelect||(b.$selectionMarkers=[],b.selection.$initRangeList(),b.multiSelect=b.selection),this.multiSelect=b.multiSelect;var c=a.oldSession;c&&(c.multiSelect.removeEventListener("addRange",this.$onAddRange),c.multiSelect.removeEventListener("removeRange",this.$onRemoveRange),c.multiSelect.removeEventListener("multiSelect",this.$onMultiSelect),c.multiSelect.removeEventListener("singleSelect",this.$onSingleSelect)),b.multiSelect.on("addRange",this.$onAddRange),b.multiSelect.on("removeRange",this.$onRemoveRange),b.multiSelect.on("multiSelect",this.$onMultiSelect),b.multiSelect.on("singleSelect",this.$onSingleSelect),this.inMultiSelectMode!=b.selection.inMultiSelectMode&&(b.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())},b.MultiSelect=e}),ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event"],function(a,b){function c(a,b){return a.row==b.row&&a.column==b.column}function d(a){var b=a.domEvent,d=b.altKey,f=b.shiftKey,g=a.getAccelKey(),h=a.getButton();if(a.editor.inMultiSelectMode&&2==h)return a.editor.textInput.onContextMenu(a.domEvent),void 0;if(!g&&!d)return 0==h&&a.editor.inMultiSelectMode&&a.editor.exitMultiSelectMode(),void 0;var i=a.editor,j=i.selection,k=i.inMultiSelectMode,l=a.getDocumentPosition(),m=j.getCursor(),n=a.inSelection()||j.isEmpty()&&c(l,m),o=a.x,p=a.y,q=function(a){o=a.clientX,p=a.clientY},r=function(){var a=i.renderer.pixelToScreenCoordinates(o,p),b=s.screenToDocumentPosition(a.row,a.column);c(u,a)&&c(b,j.selectionLead)||(u=a,i.selection.moveCursorToPosition(b),i.selection.clearSelection(),i.renderer.scrollCursorIntoView(),i.removeSelectionMarkers(v),v=j.rectangularRangeBlock(u,t),v.forEach(i.addSelectionMarker,i),i.updateSelectionMarkers())},s=i.session,t=i.renderer.pixelToScreenCoordinates(o,p),u=t;if(!g||f||d||0!=h){if(d&&0==h){a.stop(),k&&!g?j.toSingleRange():!k&&g&&j.addRange();var v=[];f?(t=s.documentToScreenPosition(j.lead),r()):(j.moveCursorToPosition(l),j.clearSelection());var w=function(){clearInterval(y),i.removeSelectionMarkers(v);for(var a=0;a20&&a.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:a}))}}.call(f.prototype);var g=function(a,b,c){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.callbackId=1,this.callbacks={},this.messageBuffer=[];var f=null,g=Object.create(d),h=this;this.$worker={},this.$worker.terminate=function(){},this.$worker.postMessage=function(a){h.messageBuffer.push(a),f&&setTimeout(i)};var i=function(){var a=h.messageBuffer.shift();a.command?f[a.command].apply(f,a.args):a.event&&g._emit(a.event,a.data)};g.postMessage=function(a){h.onMessage({data:a})},g.callback=function(a,b){this.postMessage({type:"call",id:b,data:a})},g.emit=function(a,b){this.postMessage({type:"event",name:a,data:b})},e.loadModule(["worker",b],function(a){for(f=new a[c](g);h.messageBuffer.length;)i()})};g.prototype=f.prototype,b.UIWorkerClient=g,b.WorkerClient=f}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(a,b){var c=a("./range").Range,d=a("./lib/event_emitter").EventEmitter,e=a("./lib/oop"),f=function(a,b,c,d,e,f){var g=this;this.length=b,this.session=a,this.doc=a.getDocument(),this.mainClass=e,this.othersClass=f,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=d,this.$onCursorChange=function(){setTimeout(function(){g.onCursorChange()})},this.$pos=c;var h=a.getUndoManager().$undoStack||a.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=h.length,this.setup(),a.selection.on("changeCursor",this.$onCursorChange)};!function(){e.implement(this,d),this.setup=function(){var a=this,b=this.doc,d=this.session,e=this.$pos;this.pos=b.createAnchor(e.row,e.column),this.markerId=d.addMarker(new c(e.row,e.column,e.row,e.column+this.length),this.mainClass,null,!1),this.pos.on("change",function(b){d.removeMarker(a.markerId),a.markerId=d.addMarker(new c(b.value.row,b.value.column,b.value.row,b.value.column+a.length),a.mainClass,null,!1)}),this.others=[],this.$others.forEach(function(c){var d=b.createAnchor(c.row,c.column);a.others.push(d)}),d.setUndoSelect(!1)},this.showOtherMarkers=function(){if(!this.othersActive){var a=this.session,b=this;this.othersActive=!0,this.others.forEach(function(d){d.markerId=a.addMarker(new c(d.row,d.column,d.row,d.column+b.length),b.othersClass,null,!1),d.on("change",function(e){a.removeMarker(d.markerId),d.markerId=a.addMarker(new c(e.value.row,e.value.column,e.value.row,e.value.column+b.length),b.othersClass,null,!1) })})}},this.hideOtherMarkers=function(){if(this.othersActive){this.othersActive=!1;for(var a=0;a=this.pos.column&&d.start.column<=this.pos.column+this.length+1){var f=d.start.column-this.pos.column;if(this.length+=e,!this.session.$fromUndo){if("insertText"===b.action)for(var g=this.others.length-1;g>=0;g--){var h=this.others[g],i={row:h.row,column:h.column+f};h.row===d.start.row&&d.start.column=0;g--){var h=this.others[g],i={row:h.row,column:h.column+f};h.row===d.start.row&&d.start.column=this.pos.column&&b.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",a)):(this.hideOtherMarkers(),this._emit("cursorLeave",a))}},this.detach=function(){this.session.removeMarker(this.markerId),this.hideOtherMarkers(),this.doc.removeEventListener("change",this.$onUpdate),this.session.selection.removeEventListener("changeCursor",this.$onCursorChange),this.pos.detach();for(var a=0;ac;c++)a.undo(!0)}}.call(f.prototype),b.PlaceHolder=f}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(a,b){var c=a("../../range").Range,d=b.FoldMode=function(){};!function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(a,b,c){var d=a.getLine(c);return this.foldingStartMarker.test(d)?"start":"markbeginend"==b&&this.foldingStopMarker&&this.foldingStopMarker.test(d)?"end":""},this.getFoldWidgetRange=function(){return null},this.indentationBlock=function(a,b,d){var e=/\S/,f=a.getLine(b),g=f.search(e);if(-1!=g){for(var h=d||f.length,i=a.getLength(),j=b,k=b;++b=l)break;k=b}}if(k>j){var m=a.getLine(k).length;return new c(j,h,k,m)}}},this.openingBracketBlock=function(a,b,d,e,f){var g={row:d,column:e+1},h=a.$findClosingBracket(b,g,f);if(h){var i=a.foldWidgets[h.row];return null==i&&(i=this.getFoldWidget(a,h.row)),"start"==i&&h.row>g.row&&(h.row--,h.column=a.getLine(h.row).length),c.fromPoints(g,h)}},this.closingBracketBlock=function(a,b,d,e){var f={row:d,column:e},g=a.$findOpeningBracket(b,f);return g?(g.column++,f.column--,c.fromPoints(g,f)):void 0}}.call(d.prototype)}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(a,b){b.isDark=!1,b.cssClass="ace-tm",b.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;}.ace-tm .ace_cursor {border-left: 2px solid black;}.ace-tm .ace_overwrite-cursors .ace_cursor {border-left: 0px;border-bottom: 1px solid black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_markup.ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_markup.ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;border-radius: 2px;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var c=a("../lib/dom");c.importCssString(b.cssText,b.cssClass)}),function(){ace.require(["ace/ace"],function(a){a&&a.config.init(),window.ace||(window.ace={});for(var b in a)a.hasOwnProperty(b)&&(ace[b]=a[b])})}(),ace.define("ace/theme/clouds",["require","exports","module","ace/lib/dom"],function(a,b){b.isDark=!1,b.cssClass="ace-clouds",b.cssText='.ace-clouds .ace_gutter {background: #ebebeb;color: #333}.ace-clouds .ace_print-margin {width: 1px;background: #e8e8e8}.ace-clouds {background-color: #FFFFFF;color: #000000}.ace-clouds .ace_cursor {border-left: 2px solid #000000}.ace-clouds .ace_overwrite-cursors .ace_cursor {border-left: 0px;border-bottom: 1px solid #000000}.ace-clouds .ace_marker-layer .ace_selection {background: #BDD5FC}.ace-clouds.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #FFFFFF;border-radius: 2px}.ace-clouds .ace_marker-layer .ace_step {background: rgb(255, 255, 0)}.ace-clouds .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #BFBFBF}.ace-clouds .ace_marker-layer .ace_active-line {background: #FFFBD1}.ace-clouds .ace_gutter-active-line {background-color : #dcdcdc}.ace-clouds .ace_marker-layer .ace_selected-word {border: 1px solid #BDD5FC}.ace-clouds .ace_invisible {color: #BFBFBF}.ace-clouds .ace_keyword,.ace-clouds .ace_meta,.ace-clouds .ace_support.ace_constant.ace_property-value {color: #AF956F}.ace-clouds .ace_keyword.ace_operator {color: #484848}.ace-clouds .ace_keyword.ace_other.ace_unit {color: #96DC5F}.ace-clouds .ace_constant.ace_language {color: #39946A}.ace-clouds .ace_constant.ace_numeric {color: #46A609}.ace-clouds .ace_constant.ace_character.ace_entity {color: #BF78CC}.ace-clouds .ace_invalid {background-color: #FF002A}.ace-clouds .ace_fold {background-color: #AF956F;border-color: #000000}.ace-clouds .ace_storage,.ace-clouds .ace_support.ace_class,.ace-clouds .ace_support.ace_function,.ace-clouds .ace_support.ace_other,.ace-clouds .ace_support.ace_type {color: #C52727}.ace-clouds .ace_string {color: #5D90CD}.ace-clouds .ace_comment {color: #BCC8BA}.ace-clouds .ace_entity.ace_name.ace_tag,.ace-clouds .ace_entity.ace_other.ace_attribute-name {color: #606060}.ace-clouds .ace_markup.ace_underline {text-decoration: underline}.ace-clouds .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y}';var c=a("../lib/dom");c.importCssString(b.cssText,b.cssClass)}),ace.define("ace/mode/css",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/css","ace/mode/folding/cstyle"],function(a,b){var c=a("../lib/oop"),d=a("./text").Mode,e=a("../tokenizer").Tokenizer,f=a("./css_highlight_rules").CssHighlightRules,g=a("./matching_brace_outdent").MatchingBraceOutdent,h=a("../worker/worker_client").WorkerClient,i=a("./behaviour/css").CssBehaviour,j=a("./folding/cstyle").FoldMode,k=function(){this.$tokenizer=new e((new f).getRules()),this.$outdent=new g,this.$behaviour=new i,this.foldingRules=new j};c.inherits(k,d),function(){this.foldingRules="cStyle",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a).tokens;if(e.length&&"comment"==e[e.length-1].type)return d;var f=b.match(/^.*\{\s*$/);return f&&(d+=c),d},this.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},this.autoOutdent=function(a,b,c){this.$outdent.autoOutdent(b,c)},this.createWorker=function(a){var b=new h(["ace"],"ace/mode/css_worker","Worker");return b.attachToDocument(a.getDocument()),b.on("csslint",function(b){a.setAnnotations(b.data)}),b.on("terminate",function(){a.clearAnnotations()}),b}}.call(k.prototype),b.Mode=k}),ace.define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"],function(a,b){var c=a("../lib/oop"),d=a("../lib/lang"),e=a("./text_highlight_rules").TextHighlightRules,f=b.supportType="animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index",g=b.supportFunction="rgb|rgba|url|attr|counter|counters",h=b.supportConstant="absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero",i=b.supportConstantColor="aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow",j=b.supportConstantFonts="arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace",k=b.numRe="\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))",l=b.pseudoElements="(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b",m=b.pseudoClasses="(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b",n=function(){var a=this.createKeywordMapper({"support.function":g,"support.constant":h,"support.type":f,"support.constant.color":i,"support.constant.fonts":j},"text",!0),b=[{token:"comment",regex:"\\/\\*",next:"ruleset_comment"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:["constant.numeric","keyword"],regex:"("+k+")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"},{token:"constant.numeric",regex:k},{token:"constant.numeric",regex:"#[a-f0-9]{6}"},{token:"constant.numeric",regex:"#[a-f0-9]{3}"},{token:["punctuation","entity.other.attribute-name.pseudo-element.css"],regex:l},{token:["punctuation","entity.other.attribute-name.pseudo-class.css"],regex:m},{token:["support.function","string","support.function"],regex:"(url\\()(.*)(\\))"},{token:a,regex:"\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"},{caseInsensitive:!0}],c=d.copyArray(b);c.unshift({token:"paren.rparen",regex:"\\}",next:"start"});var e=d.copyArray(b);e.unshift({token:"paren.rparen",regex:"\\}",next:"media"});var n=[{token:"comment",regex:".+"}],o=d.copyArray(n);o.unshift({token:"comment",regex:".*?\\*\\/",next:"start"});var p=d.copyArray(n);p.unshift({token:"comment",regex:".*?\\*\\/",next:"media"});var q=d.copyArray(n);q.unshift({token:"comment",regex:".*?\\*\\/",next:"ruleset"}),this.$rules={start:[{token:"comment",regex:"\\/\\*",next:"comment"},{token:"paren.lparen",regex:"\\{",next:"ruleset"},{token:"string",regex:"@.*?{",next:"media"},{token:"keyword",regex:"#[a-z0-9-_]+"},{token:"variable",regex:"\\.[a-z0-9-_]+"},{token:"string",regex:":[a-z0-9-_]+"},{token:"constant",regex:"[a-z0-9-_]+"},{caseInsensitive:!0}],media:[{token:"comment",regex:"\\/\\*",next:"media_comment"},{token:"paren.lparen",regex:"\\{",next:"media_ruleset"},{token:"string",regex:"\\}",next:"start"},{token:"keyword",regex:"#[a-z0-9-_]+"},{token:"variable",regex:"\\.[a-z0-9-_]+"},{token:"string",regex:":[a-z0-9-_]+"},{token:"constant",regex:"[a-z0-9-_]+"},{caseInsensitive:!0}],comment:o,ruleset:c,ruleset_comment:q,media_ruleset:e,media_comment:p}};c.inherits(n,e),b.CssHighlightRules=n}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(a,b){var c=a("../range").Range,d=function(){};!function(){this.checkOutdent=function(a,b){return/^\s+$/.test(a)?/^\s*\}/.test(b):!1},this.autoOutdent=function(a,b){var d=a.getLine(b),e=d.match(/^(\s*\})/);if(!e)return 0;var f=e[1].length,g=a.findMatchingBracket({row:b,column:f});if(!g||g.row==b)return 0;var h=this.$getIndent(a.getLine(g.row));a.replace(new c(b,0,b,f-1),h)},this.$getIndent=function(a){return a.match(/^\s*/)[0]}}.call(d.prototype),b.MatchingBraceOutdent=d}),ace.define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"],function(a,b){var c=a("../../lib/oop");a("../behaviour").Behaviour;var d=a("./cstyle").CstyleBehaviour,e=a("../../token_iterator").TokenIterator,f=function(){this.inherit(d),this.add("colon","insertion",function(a,b,c,d,f){if(":"===f){var g=c.getCursorPosition(),h=new e(d,g.row,g.column),i=h.getCurrentToken();if(i&&i.value.match(/\s+/)&&(i=h.stepBackward()),i&&"support.type"===i.type){var j=d.doc.getLine(g.row),k=j.substring(g.column,g.column+1);if(":"===k)return{text:"",selection:[1,1]};if(!j.substring(g.column).match(/^\s*;/))return{text:":;",selection:[1,1]}}}}),this.add("colon","deletion",function(a,b,c,d,f){var g=d.doc.getTextRange(f);if(!f.isMultiLine()&&":"===g){var h=c.getCursorPosition(),i=new e(d,h.row,h.column),j=i.getCurrentToken();if(j&&j.value.match(/\s+/)&&(j=i.stepBackward()),j&&"support.type"===j.type){var k=d.doc.getLine(f.start.row),l=k.substring(f.end.column,f.end.column+1);if(";"===l)return f.end.column++,f}}}),this.add("semicolon","insertion",function(a,b,c,d,e){if(";"===e){var f=c.getCursorPosition(),g=d.doc.getLine(f.row),h=g.substring(f.column,f.column+1);if(";"===h)return{text:"",selection:[1,1]}}})};c.inherits(f,d),b.CssBehaviour=f}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(a,b){var c=a("../../lib/oop"),d=a("../behaviour").Behaviour,e=a("../../token_iterator").TokenIterator,f=a("../../lib/lang"),g=["text","paren.rparen","punctuation.operator"],h=["text","paren.rparen","punctuation.operator","comment"],i=0,j=-1,k="",l=0,m=-1,n="",o="",p=function(){p.isSaneInsertion=function(a,b){var c=a.getCursorPosition(),d=new e(b,c.row,c.column);if(!this.$matchTokenType(d.getCurrentToken()||"text",g)){var f=new e(b,c.row,c.column+1);if(!this.$matchTokenType(f.getCurrentToken()||"text",g))return!1}return d.stepForward(),d.getCurrentTokenRow()!==c.row||this.$matchTokenType(d.getCurrentToken()||"text",h)},p.$matchTokenType=function(a,b){return b.indexOf(a.type||a)>-1},p.recordAutoInsert=function(a,b,c){var d=a.getCursorPosition(),e=b.doc.getLine(d.row);this.isAutoInsertedClosing(d,e,k[0])||(i=0),j=d.row,k=c+e.substr(d.column),i++},p.recordMaybeInsert=function(a,b,c){var d=a.getCursorPosition(),e=b.doc.getLine(d.row);this.isMaybeInsertedClosing(d,e)||(l=0),m=d.row,n=e.substr(0,d.column)+c,o=e.substr(d.column),l++},p.isAutoInsertedClosing=function(a,b,c){return i>0&&a.row===j&&c===k[0]&&b.substr(a.column)===k},p.isMaybeInsertedClosing=function(a,b){return l>0&&a.row===m&&b.substr(a.column)===o&&b.substr(0,a.column)==n},p.popAutoInsertedClosing=function(){k=k.substr(1),i--},p.clearMaybeInsertedClosing=function(){l=0,m=-1},this.add("braces","insertion",function(a,b,c,d,e){var g=c.getCursorPosition(),h=d.doc.getLine(g.row);if("{"==e){var i=c.getSelectionRange(),j=d.doc.getTextRange(i);if(""!==j&&"{"!==j&&c.getWrapBehavioursEnabled())return{text:"{"+j+"}",selection:!1};if(p.isSaneInsertion(c,d))return/[\]\}\)]/.test(h[g.column])?(p.recordAutoInsert(c,d,"}"),{text:"{}",selection:[1,1]}):(p.recordMaybeInsert(c,d,"{"),{text:"{",selection:[1,1]})}else if("}"==e){var k=h.substring(g.column,g.column+1);if("}"==k){var m=d.$findOpeningBracket("}",{column:g.column+1,row:g.row});if(null!==m&&p.isAutoInsertedClosing(g,h,e))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else if("\n"==e||"\r\n"==e){var n="";p.isMaybeInsertedClosing(g,h)&&(n=f.stringRepeat("}",l),p.clearMaybeInsertedClosing());var k=h.substring(g.column,g.column+1);if("}"==k||""!==n){var o=d.findMatchingBracket({row:g.row,column:g.column},"}");if(!o)return null;var q=this.getNextLineIndent(a,h.substring(0,g.column),d.getTabString()),r=this.$getIndent(h);return{text:"\n"+q+"\n"+r+n,selection:[1,q.length,1,q.length]}}}}),this.add("braces","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&"{"==f){var g=d.doc.getLine(e.start.row),h=g.substring(e.end.column,e.end.column+1);if("}"==h)return e.end.column++,e;l--}}),this.add("parens","insertion",function(a,b,c,d,e){if("("==e){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);if(""!==g&&c.getWrapBehavioursEnabled())return{text:"("+g+")",selection:!1};if(p.isSaneInsertion(c,d))return p.recordAutoInsert(c,d,")"),{text:"()",selection:[1,1]}}else if(")"==e){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(")"==j){var k=d.$findOpeningBracket(")",{column:h.column+1,row:h.row});if(null!==k&&p.isAutoInsertedClosing(h,i,e))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&"("==f){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(")"==h)return e.end.column++,e}}),this.add("brackets","insertion",function(a,b,c,d,e){if("["==e){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);if(""!==g&&c.getWrapBehavioursEnabled())return{text:"["+g+"]",selection:!1};if(p.isSaneInsertion(c,d))return p.recordAutoInsert(c,d,"]"),{text:"[]",selection:[1,1]}}else if("]"==e){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if("]"==j){var k=d.$findOpeningBracket("]",{column:h.column+1,row:h.row});if(null!==k&&p.isAutoInsertedClosing(h,i,e))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&"["==f){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if("]"==h)return e.end.column++,e}}),this.add("string_dquotes","insertion",function(a,b,c,d,e){if('"'==e||"'"==e){var f=e,g=c.getSelectionRange(),h=d.doc.getTextRange(g);if(""!==h&&"'"!==h&&'"'!=h&&c.getWrapBehavioursEnabled())return{text:f+h+f,selection:!1};var i=c.getCursorPosition(),j=d.doc.getLine(i.row),k=j.substring(i.column-1,i.column);if("\\"==k)return null;for(var l,m=d.getTokens(g.start.row),n=0,o=-1,q=0;qo&&(o=l.value.indexOf(f)),!(l.value.length+n>g.start.column));q++)n+=m[q].value.length;if(!l||0>o&&"comment"!==l.type&&("string"!==l.type||g.start.column!==l.value.length+n-1&&l.value.lastIndexOf(f)===l.value.length-1)){if(!p.isSaneInsertion(c,d))return;return{text:f+f,selection:[1,1]}}if(l&&"string"===l.type){var r=j.substring(i.column,i.column+1);if(r==f)return{text:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&('"'==f||"'"==f)){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(h==f)return e.end.column++,e}})};c.inherits(p,d),b.CstyleBehaviour=p}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(a,b){var c=a("../../lib/oop");a("../../range").Range;var d=a("./fold_mode").FoldMode,e=b.FoldMode=function(a){a&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+a.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+a.end)))};c.inherits(e,d),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.getFoldWidgetRange=function(a,b,c){var d=a.getLine(c),e=d.match(this.foldingStartMarker);if(e){var f=e.index;return e[1]?this.openingBracketBlock(a,e[1],c,f):a.getCommentFoldRange(c,f+e[0].length,1)}if("markbeginend"===b){var e=d.match(this.foldingStopMarker);if(e){var f=e.index+e[0].length;return e[1]?this.closingBracketBlock(a,e[1],c,f):a.getCommentFoldRange(c,f,-1)}}}}.call(e.prototype)}),function(){var a,b=function(a,b){return function(){return a.apply(b,arguments)}},c=[].slice,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};a={},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),a.Binding=function(){function d(a,c,d,e,f,g){var h,i,j,k;if(this.view=a,this.el=c,this.type=d,this.key=e,this.keypath=f,this.options=null!=g?g:{},this.update=b(this.update,this),this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.publish=b(this.publish,this),this.sync=b(this.sync,this),this.set=b(this.set,this),this.eventHandler=b(this.eventHandler,this),this.formattedValue=b(this.formattedValue,this),!(this.binder=this.view.binders[d])){k=this.view.binders;for(h in k)j=k[h],"*"!==h&&-1!==h.indexOf("*")&&(i=new RegExp("^"+h.replace("*",".+")+"$"),i.test(d)&&(this.binder=j,this.args=new RegExp("^"+h.replace("*","(.+)")+"$").exec(d),this.args.shift()))}this.binder||(this.binder=this.view.binders["*"]),this.binder instanceof Function&&(this.binder={routine:this.binder}),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return d.prototype.formattedValue=function(a){var b,d,e,f,g,h;for(h=this.formatters,f=0,g=h.length;g>f;f++)d=h[f],b=d.split(/\s+/),e=b.shift(),d=this.model[e]instanceof Function?this.model[e]:this.view.formatters[e],(null!=d?d.read:void 0)instanceof Function?a=d.read.apply(d,[a].concat(c.call(b))):d instanceof Function&&(a=d.apply(null,[a].concat(c.call(b))));return a},d.prototype.eventHandler=function(a){var b,c;return c=(b=this).view.config.handler,function(d){return c.call(a,this,d,b)}},d.prototype.set=function(a){var b;return a=a instanceof Function&&!this.binder["function"]?this.formattedValue(a.call(this.model)):this.formattedValue(a),null!=(b=this.binder.routine)?b.call(this,this.el,a):void 0},d.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:this.view.config.adapter.read(this.model,this.keypath))},d.prototype.publish=function(){var b,d,e,f,g,h,i,j,k;for(f=a.Util.getInputValue(this.el),i=this.formatters.slice(0).reverse(),g=0,h=i.length;h>g;g++)d=i[g],b=d.split(/\s+/),e=b.shift(),(null!=(j=this.view.formatters[e])?j.publish:void 0)&&(f=(k=this.view.formatters[e]).publish.apply(k,[f].concat(c.call(b))));return this.view.config.adapter.publish(this.model,this.keypath,f)},d.prototype.bind=function(){var a,b,c,d,e,f,g,h,i;if(null!=(f=this.binder.bind)&&f.call(this,this.el),this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync()),null!=(g=this.options.dependencies)?g.length:void 0){for(h=this.options.dependencies,i=[],d=0,e=h.length;e>d;d++)a=h[d],/^\./.test(a)?(c=this.model,b=a.substr(1)):(a=a.split("."),c=this.view.models[a.shift()],b=a.join(".")),i.push(this.view.config.adapter.subscribe(c,b,this.sync));return i}},d.prototype.unbind=function(){var a,b,c,d,e,f,g,h,i;if(null!=(f=this.binder.unbind)&&f.call(this,this.el),this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),null!=(g=this.options.dependencies)?g.length:void 0){for(h=this.options.dependencies,i=[],d=0,e=h.length;e>d;d++)a=h[d],/^\./.test(a)?(c=this.model,b=a.substr(1)):(a=a.split("."),c=this.view.models[a.shift()],b=a.join(".")),i.push(this.view.config.adapter.unsubscribe(c,b,this.sync));return i}},d.prototype.update=function(a){var b;return null==a&&(a={}),this.key?a[this.key]&&(this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),this.model=a[this.key],this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync())):this.sync(),null!=(b=this.binder.update)?b.call(this,a):void 0},d}(),a.ComponentBinding=function(c){function d(c,d,e){var g,h,i,j,k;for(this.view=c,this.el=d,this.type=e,this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.update=b(this.update,this),this.locals=b(this.locals,this),this.component=a.components[this.type],this.attributes={},this.inflections={},j=this.el.attributes||[],h=0,i=j.length;i>h;h++)g=j[h],k=g.name,f.call(this.component.attributes,k)>=0?this.attributes[g.name]=g.value:this.inflections[g.name]=g.value -}return e(d,c),d.prototype.sync=function(){},d.prototype.locals=function(a){var b,c,d,e,f,g,h,i,j;null==a&&(a=this.view.models),f={},i=this.inflections;for(c in i)for(b=i[c],j=b.split("."),g=0,h=j.length;h>g;g++)e=j[g],f[c]=(f[c]||a)[e];for(c in a)d=a[c],null==f[c]&&(f[c]=d);return f},d.prototype.update=function(a){var b;return null!=(b=this.componentView)?b.update(this.locals(a)):void 0},d.prototype.bind=function(){var b,c;return null!=this.componentView?null!=(c=this.componentView)?c.bind():void 0:(b=this.component.build.call(this.attributes),(this.componentView=new a.View(b,this.locals(),this.view.options)).bind(),this.el.parentNode.replaceChild(b,this.el))},d.prototype.unbind=function(){var a;return null!=(a=this.componentView)?a.unbind():void 0},d}(a.Binding),a.TextBinding=function(a){function c(a,c,d,e,f,g){this.view=a,this.el=c,this.type=d,this.key=e,this.keypath=f,this.options=null!=g?g:{},this.sync=b(this.sync,this),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return e(c,a),c.prototype.binder={routine:function(a,b){return a.data=null!=b?b:""}},c.prototype.sync=function(){return c.__super__.sync.apply(this,arguments)},c}(a.Binding),a.View=function(){function d(c,d,e){var f,g,h,i,j,k,l,m,n;for(this.els=c,this.models=d,this.options=null!=e?e:{},this.update=b(this.update,this),this.publish=b(this.publish,this),this.sync=b(this.sync,this),this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.select=b(this.select,this),this.build=b(this.build,this),this.componentRegExp=b(this.componentRegExp,this),this.bindingRegExp=b(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),l=["config","binders","formatters"],j=0,k=l.length;k>j;j++){if(g=l[j],this[g]={},this.options[g]){m=this.options[g];for(f in m)h=m[f],this[g][f]=h}n=a[g];for(f in n)h=n[f],null==(i=this[g])[f]&&(i[f]=h)}this.build()}return d.prototype.bindingRegExp=function(){var a;return a=this.config.prefix,a?new RegExp("^data-"+a+"-"):/^data-/},d.prototype.componentRegExp=function(){var a,b;return new RegExp("^"+(null!=(a=null!=(b=this.config.prefix)?b.toUpperCase():void 0)?a:"RV")+"-")},d.prototype.build=function(){var b,d,e,g,h,i,j,k,l,m=this;for(this.bindings=[],i=[],b=this.bindingRegExp(),e=this.componentRegExp(),d=function(b,c,d,e){var f,g,h,i,j,k,l,n,o,p;return k={},o=function(){var a,b,c,d;for(c=e.split("|"),d=[],a=0,b=c.length;b>a;a++)n=c[a],d.push(n.trim());return d}(),f=function(){var a,b,c,d;for(c=o.shift().split("<"),d=[],a=0,b=c.length;b>a;a++)g=c[a],d.push(g.trim());return d}(),l=f.shift(),p=l.split(/\.|:/),k.formatters=o,k.bypass=-1!==l.indexOf(":"),p[0]?i=p.shift():(i=null,p.shift()),j=p.join("."),(h=f.shift())&&(k.dependencies=h.split(/\s+/)),m.bindings.push(new a[b](m,c,d,i,j,k))},h=function(g){var j,k,l,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;if(f.call(i,g)<0){if(g.nodeType===Node.TEXT_NODE){if(r=a.TextTemplateParser,(o=m.config.templateDelimiters)&&(x=r.parse(g.data,o)).length&&(1!==x.length||x[0].type!==r.types.text))for(u=x[0],t=2<=x.length?c.call(x,1):[],g.data=u.value,0===u.type?g.data=u.value:d("TextBinding",g,null,u.value),A=0,E=t.length;E>A;A++)w=t[A],v=document.createTextNode(w.value),g.parentNode.appendChild(v),1===w.type&&d("TextBinding",v,null,w.value)}else if(e.test(g.tagName))y=g.tagName.replace(e,"").toLowerCase(),m.bindings.push(new a.ComponentBinding(m,g,y));else if(null!=g.attributes){for(K=g.attributes,B=0,F=K.length;F>B;B++)if(j=K[B],b.test(j.name)){if(y=j.name.replace(b,""),!(l=m.binders[y])){L=m.binders;for(p in L)z=L[p],"*"!==p&&-1!==p.indexOf("*")&&(s=new RegExp("^"+p.replace("*",".+")+"$"),s.test(y)&&(l=z))}if(l||(l=m.binders["*"]),l.block){for(M=g.childNodes,C=0,G=M.length;G>C;C++)q=M[C],i.push(q);k=[j]}}for(N=k||g.attributes,D=0,H=N.length;H>D;D++)j=N[D],b.test(j.name)&&(y=j.name.replace(b,""),d("Binding",g,y,j.value))}for(O=g.childNodes,P=[],J=0,I=O.length;I>J;J++)n=O[J],P.push(h(n));return P}},l=this.els,j=0,k=l.length;k>j;j++)g=l[j],h(g)},d.prototype.select=function(a){var b,c,d,e,f;for(e=this.bindings,f=[],c=0,d=e.length;d>c;c++)b=e[c],a(b)&&f.push(b);return f},d.prototype.bind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.bind());return e},d.prototype.unbind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e},d.prototype.sync=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.sync());return e},d.prototype.publish=function(){var a,b,c,d,e;for(d=this.select(function(a){return a.binder.publishes}),e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.publish());return e},d.prototype.update=function(a){var b,c,d,e,f,g,h;null==a&&(a={});for(c in a)d=a[c],this.models[c]=d;for(g=this.bindings,h=[],e=0,f=g.length;f>e;e++)b=g[e],h.push(b.update(a));return h},d}(),a.TextTemplateParser=function(){function a(){}return a.types={text:0,binding:1},a.parse=function(a,b){var c,d,e,f,g,h,i;for(h=[],f=a.length,c=0,d=0;f>d;){if(c=a.indexOf(b[0],d),0>c){h.push({type:this.types.text,value:a.slice(d)});break}if(c>0&&c>d&&h.push({type:this.types.text,value:a.slice(d,c)}),d=c+2,c=a.indexOf(b[1],d),0>c){g=a.slice(d-2),e=h[h.length-1],(null!=e?e.type:void 0)===this.types.text?e.value+=g:h.push({type:this.types.text,value:g});break}i=a.slice(d,c).trim(),h.push({type:this.types.binding,value:i}),d=c+2}return h},a}(),a.Util={bindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.on?a.on(b,c):a.bind(b,c)):null!=window.addEventListener?a.addEventListener(b,c,!1):(b="on"+b,a.attachEvent(b,c))},unbindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.off?a.off(b,c):a.unbind(b,c)):null!=window.removeEventListener?a.removeEventListener(b,c,!1):(b="on"+b,a.detachEvent(b,c))},getInputValue:function(a){var b,c,d,e;if(null!=window.jQuery)switch(a=jQuery(a),a[0].type){case"checkbox":return a.is(":checked");default:return a.val()}else switch(a.type){case"checkbox":return a.checked;case"select-multiple":for(e=[],c=0,d=a.length;d>c;c++)b=a[c],b.selected&&e.push(b.value);return e;default:return a.value}}},a.binders={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)===(null!=b?b.toString():void 0):!!b}},unchecked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)!==(null!=b?b.toString():void 0):!b}},show:function(a,b){return a.style.display=b?"":"none"},hide:function(a,b){return a.style.display=b?"none":""},html:function(a,b){return a.innerHTML=null!=b?b:""},value:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c,d,e,g,h,i,j;if(null!=window.jQuery){if(a=jQuery(a),(null!=b?b.toString():void 0)!==(null!=(g=a.val())?g.toString():void 0))return a.val(null!=b?b:"")}else if("select-multiple"===a.type){if(null!=b){for(j=[],d=0,e=a.length;e>d;d++)c=a[d],j.push(c.selected=(h=c.value,f.call(b,h)>=0));return j}}else if((null!=b?b.toString():void 0)!==(null!=(i=a.value)?i.toString():void 0))return a.value=null!=b?b:""}},text:function(a,b){return null!=a.innerText?a.innerText=null!=b?b:"":a.textContent=null!=b?b:""},"if":{block:!0,bind:function(a){var b,c;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),c=a.getAttribute(b),this.marker=document.createComment(" rivets: "+this.type+" "+c+" "),a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a;return null!=(a=this.nested)?a.unbind():void 0},routine:function(b,c){var d,e,f,g,h;if(!!c==(null==this.nested)){if(c){f={},h=this.view.models;for(d in h)e=h[d],f[d]=e;return g={binders:this.view.options.binders,formatters:this.view.options.formatters,config:this.view.options.config},(this.nested=new a.View(b,f,g)).bind(),this.marker.parentNode.insertBefore(b,this.marker.nextSibling)}return b.parentNode.removeChild(b),this.nested.unbind(),delete this.nested}},update:function(a){var b;return null!=(b=this.nested)?b.update(a):void 0}},unless:{block:!0,bind:function(b){return a.binders["if"].bind.call(this,b)},unbind:function(){return a.binders["if"].unbind.call(this)},routine:function(b,c){return a.binders["if"].routine.call(this,b,!c)},update:function(b){return a.binders["if"].update.call(this,b)}},"on-*":{"function":!0,unbind:function(b){return this.handler?a.Util.unbindEvent(b,this.args[0],this.handler):void 0},routine:function(b,c){return this.handler&&a.Util.unbindEvent(b,this.args[0],this.handler),a.Util.bindEvent(b,this.args[0],this.handler=this.eventHandler(c))}},"each-*":{block:!0,bind:function(a){var b;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),this.marker=document.createComment(" rivets: "+this.type+" "),this.iterated=[],a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a,b,c,d,e;if(null!=this.iterated){for(d=this.iterated,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e}},routine:function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;if(j=this.args[0],c=c||[],this.iterated.length>c.length)for(t=Array(this.iterated.length-c.length),p=0,r=t.length;r>p;p++)e=t[p],o=this.iterated.pop(),o.unbind(),this.marker.parentNode.removeChild(o.els[0]);for(w=[],f=q=0,s=c.length;s>q;f=++q)if(i=c[f],d={},d[j]=i,null==this.iterated[f]){u=this.view.models;for(h in u)i=u[h],null==d[h]&&(d[h]=i);l=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,k={binders:this.view.options.binders,formatters:this.view.options.formatters,config:{}},v=this.view.options.config;for(g in v)n=v[g],k.config[g]=n;k.config.preloadData=!0,m=b.cloneNode(!0),o=new a.View(m,d,k),o.bind(),this.iterated.push(o),w.push(this.marker.parentNode.insertBefore(m,l.nextSibling))}else this.iterated[f].models[j]!==i?w.push(this.iterated[f].update(d)):w.push(void 0);return w},update:function(a){var b,c,d,e,f,g,h,i;b={};for(c in a)d=a[c],c!==this.args[0]&&(b[c]=d);for(h=this.iterated,i=[],f=0,g=h.length;g>f;f++)e=h[f],i.push(e.update(b));return i}},"class-*":function(a,b){var c;return c=" "+a.className+" ",!b==(-1!==c.indexOf(" "+this.args[0]+" "))?a.className=b?""+a.className+" "+this.args[0]:c.replace(" "+this.args[0]+" "," ").trim():void 0},"*":function(a,b){return b?a.setAttribute(this.type,b):a.removeAttribute(this.type)}},a.components={},a.config={preloadData:!0,handler:function(a,b,c){return this.call(a,b,c.view.models)}},a.formatters={},a.factory=function(b){return b._=a,b.binders=a.binders,b.components=a.components,b.formatters=a.formatters,b.config=a.config,b.configure=function(b){var c,d;null==b&&(b={});for(c in b)d=b[c],a.config[c]=d},b.bind=function(b,c,d){var e;return null==c&&(c={}),null==d&&(d={}),e=new a.View(b,c,d),e.bind(),e}},"object"==typeof exports?a.factory(exports):"function"==typeof define&&define.amd?define(["exports"],function(b){return a.factory(this.rivets=b),b}):a.factory(this.rivets={})}.call(this),OpenLayers.ImgPath="http://js.mapbox.com/theme/dark/",rivets.configure({prefix:"rv",adapter:{subscribe:function(a,b,c){a.on("change:"+b,c)},unsubscribe:function(a,b,c){a.off("change:"+b,c)},read:function(a,b){return a.get(b)},publish:function(a,b,c){a.set(b,c)}}}),Neatline=new Backbone.Marionette.Application,Neatline.module("Shared.Exhibit",function(a,b,c){a.Model=c.Model.extend({url:function(){return b.g.neatline.exhibits_api},defaults:function(){return b.g.neatline.exhibit}})}),Neatline.module("Shared.Record",function(a,b,c){a.Model=c.Model.extend({url:function(){var a=b.g.neatline.records_api;return this.id&&(a+="/"+this.id),a},defaults:function(){return{exhibit_id:b.g.neatline.exhibit.id,presenter:"StaticBubble",fill_color:"#00aeff",fill_color_select:"#00aeff",stroke_color:"#000000",stroke_color_select:"#000000",fill_opacity:.3,fill_opacity_select:.4,stroke_opacity:.9,stroke_opacity_select:1,point_radius:10,stroke_width:2}}})}),Neatline.module("Shared.Record",function(a,b,c,d,e,f){a.Collection=c.Neatline.Collection.extend({model:b.Shared.Record.Model,update:function(a,c){a=f.extend(a,{exhibit_id:b.g.neatline.exhibit.id}),this.fetch({reset:!0,data:e.param(a),success:c})},url:function(){return b.g.neatline.records_api},parse:function(a){return this.offset=parseInt(a.offset,10),this.count=parseInt(a.count,10),a.records}})}),Neatline.module("Shared.Widget",function(a,b,c,d,e){a.View=c.Neatline.View.extend({className:"widget",initialize:function(){e("#"+this.id).length||this.$el.appendTo(e("#neatline-map")),a.View.__super__.initialize.apply(this)}})}),Neatline.module("Map.Layers.Google",function(a,b){a.ID="MAP:LAYERS:Google";var c=function(a){switch(a.properties.provider){case"physical":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.TERRAIN});case"streets":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.ROADMAP,numZoomLevels:25});case"satellite":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.SATELLITE,numZoomLevels:25});case"hybrid":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.HYBRID,numZoomLevels:25})}};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.OpenStreetMap",function(a,b){a.ID="MAP:LAYERS:OpenStreetMap";var c=function(a){return new OpenLayers.Layer.OSM(a.title)};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.Stamen",function(a,b){a.ID="MAP:LAYERS:Stamen";var c=function(a){var b=new OpenLayers.Layer.Stamen(a.properties.provider);return b.name=a.title,b};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.WMS",function(a,b){a.ID="MAP:LAYERS:WMS";var c=function(a){return new OpenLayers.Layer.WMS(a.title,a.properties.address,{layers:a.properties.layers})};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers",function(a,b){a.ID="MAP:LAYERS";var c=function(a){try{return b.request("MAP:LAYERS:"+a.type,a)}catch(c){return null}};b.reqres.setHandler(a.ID+":getLayer",c)}),Neatline.module("Map",function(a,b){a.ID="MAP",a.addInitializer(function(){a.__collection=new b.Shared.Record.Collection,a.__view=new b.Map.View,a.__view.requestRecords()})}),Neatline.module("Map",function(a,b){var c=function(b){a.__collection.update(b,function(b){a.__view.ingest(b)})};b.commands.setHandler(a.ID+":load",c);var d=function(){a.__view.removeAllLayers(),a.__view.requestRecords()};b.commands.setHandler(a.ID+":refresh",d),b.vent.on("refresh",d);var e=function(b){b.source!==a.ID&&(i(b.model),a.__view.selectByModel(b.model))};b.commands.setHandler(a.ID+":select",e),b.vent.on("select",e);var f=function(b){a.__view.highlightByModel(b.model)};b.commands.setHandler(a.ID+":highlight",f),b.vent.on("highlight",f);var g=function(b){a.__view.unhighlightByModel(b.model)};b.commands.setHandler(a.ID+":unhighlight",g),b.vent.on("unhighlight",g);var h=function(b){a.__view.unselectByModel(b.model)};b.commands.setHandler(a.ID+":unselect",h),b.vent.on("unselect",h);var i=function(b){a.__view.focusByModel(b)};b.commands.setHandler(a.ID+":focusByModel",i);var j=function(b){a.__view.setFilter(b.key,b.evaluator)};b.commands.setHandler(a.ID+":setFilter",j),b.vent.on("setFilter",j);var k=function(b){a.__view.removeFilter(b.key)};b.commands.setHandler(a.ID+":removeFilter",k),b.vent.on("removeFilter",k);var l=function(){a.__view.map.updateSize()};b.commands.setHandler(a.ID+":updateSize",l);var m=function(){return a.__view.map};b.reqres.setHandler(a.ID+":getMap",m);var n=function(){return a.__collection};b.reqres.setHandler(a.ID+":getRecords",n);var o=function(){return a.__view.map.getCenter()};b.reqres.setHandler(a.ID+":getCenter",o);var p=function(){return a.__view.map.getZoom()};b.reqres.setHandler(a.ID+":getZoom",p)}),Neatline.module("Map",function(a,b,c,d,e,f){a.View=c.View.extend({el:"#neatline-map",options:{defaultZoom:6},initialize:function(){this._initGlobals(),this._initOpenLayers(),this._initControls(),this._initEvents(),this._initBaseLayers(),this._initViewport()},_initGlobals:function(){this.exhibit=b.g.neatline.exhibit,this.formatWkt=new OpenLayers.Format.WKT,this.layers={vector:{},wms:{}},this.filters={},this.selectedModel=null,this.loading=!1},_initOpenLayers:function(){this.map=new OpenLayers.Map(this.el,{theme:null,zoomMethod:null,panMethod:null,controls:[new OpenLayers.Control.PanZoomBar,new OpenLayers.Control.LayerSwitcher,new OpenLayers.Control.Navigation({dragPanOptions:{enableKinetic:!1},documentDrag:!0})]})},_initControls:function(){f.bindAll(this,"onBeforeHighlight","onHighlight","onUnhighlight","onSelect","onUnselect"),this.highlightControl=new OpenLayers.Control.SelectFeature(this.getVectorLayers(),{hover:!0,renderIntent:"temporary",highlightOnly:!0,eventListeners:{beforefeaturehighlighted:this.onBeforeHighlight,featurehighlighted:this.onHighlight,featureunhighlighted:this.onUnhighlight}}),this.selectControl=new OpenLayers.Control.SelectFeature(this.getVectorLayers(),{onSelect:this.onSelect,onUnselect:this.onUnselect}),this.highlightControl.handlers.feature.stopDown=!1,this.selectControl.handlers.feature.stopDown=!1,this.map.addControls([this.highlightControl,this.selectControl]),this.activatePublicControls()},_initEvents:function(){this.exhibit.spatial_querying&&this.map.events.register("moveend",this.map,f.bind(function(){this.requestRecords()},this))},_initBaseLayers:function(){var a=f.isString(this.exhibit.image_layer),b=f.isString(this.exhibit.wms_address)&&f.isString(this.exhibit.wms_layers);a?this._initImageLayer():b?this._initWmsLayer():this._initSpatialLayers()},_initImageLayer:function(){var a=this.exhibit.image_height,b=this.exhibit.image_width,c=new OpenLayers.Layer.Image(this.exhibit.title,this.exhibit.image_layer,new OpenLayers.Bounds(0,0,b,a),new OpenLayers.Size(b/5,a/5));this.map.addLayer(c)},_initWmsLayer:function(){var a=new OpenLayers.Layer.WMS(this.exhibit.title,this.exhibit.wms_address,{layers:this.exhibit.wms_layers},{maxZoomLevel:20});this.map.addLayer(a)},_initSpatialLayers:function(){var a={};f.each(b.g.neatline.spatial_layers,function(c){var d=b.request("MAP:LAYERS:getLayer",c);f.isObject(d)&&(a[c.id]=d)}),f.each(f.values(a),f.bind(function(a){this.map.addLayer(a),this.map.setLayerIndex(a,0)},this)),this.map.setBaseLayer(a[this.exhibit.spatial_layer])},_initViewport:function(){var a=b.g.neatline.exhibit.map_focus,c=b.g.neatline.exhibit.map_zoom;f.isString(a)&&f.isNumber(c)?this.setViewport(a,c):(this.map.zoomTo(this.options.defaultZoom),this.geolocate())},activatePublicControls:function(){this.highlightControl.activate(),this.selectControl.activate()},deactivatePublicControls:function(){this.highlightControl.deactivate(),this.selectControl.deactivate()},updateControls:function(){var a=this.getVectorLayers();this.highlightControl.setLayer(a),this.selectControl.setLayer(a),f.isNull(this.selectedModel)||this.selectByModel(this.selectedModel)},focusByModel:function(a){var c=this.layers.vector[a.id];c||(c=this.buildVectorLayer(a));var d=a.get("map_focus"),e=a.get("map_zoom");f.isString(d)&&f.isNumber(e)?this.setViewport(d,e):a.get("coverage")&&!a.get("is_wms")&&this.map.zoomToExtent(c.getDataExtent()),b.vent.trigger("MAP:focused")},setViewport:function(a,b){this.map.setCenter(a.split(","),b)},geolocate:function(){var a=new OpenLayers.Control.Geolocate({bind:!0,watch:!1});this.map.addControl(a),a.activate()},ingest:function(a){this.map.dragging||(this.ingestVectorLayers(a),this.ingestWmsLayers(a),b.vent.trigger("MAP:ingest",a),this.updateControls(),this.records=a,this.loading=!1)},ingestVectorLayers:function(a){var b=[];a.each(f.bind(function(a){b.push(a.id),f.has(this.layers.vector,a.id)||this.buildVectorLayer(a)},this)),f.each(this.layers.vector,f.bind(function(a,c){f.contains(b,parseInt(c,10))||a.nFrozen||this.removeVectorLayer(a)},this))},ingestWmsLayers:function(a){var b=[];a.each(f.bind(function(a){var c=a.get("wms_address")&&a.get("wms_layers");b.push(a.id),!f.has(this.layers.wms,a.id)&&c&&this.buildWmsLayer(a)},this)),f.each(this.layers.wms,f.bind(function(a,c){f.contains(b,parseInt(c,10))||this.removeWmsLayer(a)},this))},buildVectorLayer:function(a){var b=new OpenLayers.Layer.Vector(a.get("title"),{styleMap:this.getStyleMap(a),displayInLayerSwitcher:!1});return a.get("coverage")&&b.addFeatures(this.formatWkt.read(a.get("coverage"))),b.nModel=a,b.nFrozen=!1,this.filterLayer(b),this.layers.vector[a.id]=b,this.map.addLayer(b),this.setZIndex(b,a.get("zindex")),b},buildWmsLayer:function(a){var b=new OpenLayers.Layer.WMS(a.get("title"),a.get("wms_address"),{layers:a.get("wms_layers"),transparent:!0},{displayOutsideMaxExtent:!0,opacity:parseFloat(a.get("fill_opacity")),isBaseLayer:!1});return b.nModel=a,this.filterLayer(b),this.layers.wms[a.id]=b,this.map.addLayer(b),this.setZIndex(b,a.get("zindex")),b},removeVectorLayer:function(a){this.map.removeLayer(a),delete this.layers.vector[a.nModel.id]},removeWmsLayer:function(a){this.map.removeLayer(a),delete this.layers.wms[a.nModel.id]},removeAllLayers:function(){f.each(f.keys(this.layers.vector),f.bind(function(a){this.layers.vector[a].nFrozen||this.removeVectorLayer(this.layers.vector[a])},this)),f.each(f.keys(this.layers.wms),f.bind(function(a){this.removeWmsLayer(this.layers.wms[a])},this))},setFilter:function(a,b){this.filters[a]=b,this.filterAllLayers()},removeFilter:function(a){delete this.filters[a],this.filterAllLayers()},filterLayer:function(a){var b=!0;f.each(this.filters,f.bind(function(c){b=b&&c(a.nModel)},this)),a.setVisibility(b)},filterAllLayers:function(){f.each(this.layers,f.bind(function(a){f.each(a,f.bind(function(a){this.filterLayer(a)},this))},this))},getStyleMap:function(a){var b=a.get("fill_color"),c=a.get("fill_color_select"),d=a.get("stroke_color"),e=a.get("stroke_color_select"),f=a.get("fill_opacity"),g=a.get("fill_opacity_select"),h=a.get("stroke_opacity"),i=a.get("stroke_opacity_select"),j=a.get("point_image"),k=a.get("stroke_width"),l=a.get("point_radius");return f=parseFloat(f),g=parseFloat(g),h=parseFloat(h),i=parseFloat(i),k=parseInt(k),l=parseInt(l),new OpenLayers.StyleMap({"default":new OpenLayers.Style({fillColor:b,strokeColor:d,fillOpacity:f,graphicOpacity:f,strokeOpacity:h,strokeWidth:k,pointRadius:l,externalGraphic:j}),select:new OpenLayers.Style({fillColor:c,strokeColor:e,fillOpacity:g,graphicOpacity:g,strokeOpacity:i,strokeWidth:k,pointRadius:l,externalGraphic:j}),temporary:new OpenLayers.Style({fillColor:c,strokeColor:e,fillOpacity:g,graphicOpacity:g,strokeOpacity:i,strokeWidth:k,pointRadius:l,externalGraphic:j})})},highlightByModel:function(a){var b=this.layers.vector[a.id];b&&!this.modelIsSelected(a)&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.highlightControl.highlight(a)},this)),this.stopPropagation=!1)},unhighlightByModel:function(a){var b=this.layers.vector[a.id];b&&!this.modelIsSelected(a)&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.highlightControl.unhighlight(a)},this)),this.stopPropagation=!1)},selectByModel:function(a){var b=this.layers.vector[a.id];b&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.selectControl.select(a)},this)),this.stopPropagation=!1,this.selectedModel=a)},unselectByModel:function(a){var b=this.layers.vector[a.id];b&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.selectControl.unselect(a)},this)),this.stopPropagation=!1,this.selectedModel=null)},onBeforeHighlight:function(){return!this.map.dragging&&!this.loading},onHighlight:function(c){this.stopPropagation||(this.highlightByModel(c.feature.layer.nModel),b.vent.trigger("highlight",{model:c.feature.layer.nModel,source:a.ID}))},onUnhighlight:function(c){this.stopPropagation||(this.unhighlightByModel(c.feature.layer.nModel),b.vent.trigger("unhighlight",{model:c.feature.layer.nModel,source:a.ID}))},onSelect:function(c){this.stopPropagation||(this.selectByModel(c.layer.nModel),b.vent.trigger("select",{model:c.layer.nModel,source:a.ID}))},onUnselect:function(c){this.stopPropagation||(this.unselectByModel(c.layer.nModel),b.vent.trigger("unselect",{model:c.layer.nModel,source:a.ID}))},requestRecords:function(){var a={};this.exhibit.spatial_querying&&(a.extent=this.getExtentAsWKT(),a.zoom=this.getZoom()),this.loading=!0,b.execute("MAP:load",a)},setZIndex:function(a,b){this.map.setLayerIndex(a,1+b)},getZoom:function(){return this.map.getZoom()},getExtentAsWKT:function(){var a=this.map.getExtent().toGeometry(),b=new OpenLayers.Feature.Vector(a);return this.formatWkt.write(b)},getVectorLayers:function(){return f.values(this.layers.vector)},getWmsLayers:function(){return f.values(this.layers.wms)},modelIsSelected:function(a){return this.selectedModel?this.selectedModel.id==a.id:!1}})}),Neatline.module("Presenter",function(a,b){a.ID="PRESENTER";var c=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":highlight",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:highlight",c),b.vent.on("highlight",c);var d=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":unhighlight",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:unhighlight",d),b.vent.on("unhighlight",d);var e=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":select",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:select",e),b.vent.on("select",e);var f=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":unselect",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:unselect",f),b.vent.on("unselect",f)}),Neatline.module("Presenter.None",function(a,b){a.ID="PRESENTER:None";var c=function(){};b.commands.setHandler(a.ID+":highlight",c),b.commands.setHandler(a.ID+":unhighlight",c),b.commands.setHandler(a.ID+":select",c),b.commands.setHandler(a.ID+":unselect",c),b.vent.on("PRESENTER:activate",c),b.vent.on("PRESENTER:deactivate",c)}),Neatline.module("Presenter.StaticBubble",function(a){a.ID="PRESENTER:StaticBubble",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Presenter.StaticBubble",function(a,b){var c=function(b){a.__view.highlight(b)};b.commands.setHandler(a.ID+":highlight",c);var d=function(){a.__view.unhighlight()};b.commands.setHandler(a.ID+":unhighlight",d);var e=function(b){a.__view.select(b)};b.commands.setHandler(a.ID+":select",e);var f=function(){a.__view.unselect()};b.commands.setHandler(a.ID+":unselect",f);var g=function(){a.__view.activate()};b.vent.on("PRESENTER:activate",g);var h=function(){a.__view.deactivate(),a.__view.unselect()};b.vent.on("PRESENTER:deactivate",h)}),Neatline.module("Presenter.StaticBubble",function(a,b,c,d,e,f){a.View=b.Shared.Widget.View.extend({id:"static-bubble",events:{"click .close":"onClose"},ui:{close:".close",body:".body"},init:function(){a.View.__super__.init.apply(this),this.active=!0,this.selected=!1,this.template=f.template(e("#static-bubble-template").html())},onClose:function(){this.unselect(),b.vent.trigger("unselect",{model:this.model,source:a.ID})},bind:function(a){this.model=a,this.onMouseOut=f.bind(this.unhighlight,this);var c=b.request("MAP:getMap");c.events.register("mouseout",null,this.onMouseOut),this.$el.html(this.template({record:this.model})),this.$el.addClass("bound")},unbind:function(){var a=b.request("MAP:getMap");a.events.unregister("mouseout",null,this.onMouseOut),this.$el.empty(),this.$el.removeClass("bound")},highlight:function(a){!this.selected&&this.active&&this.bind(a)},unhighlight:function(){this.selected||this.unbind()},select:function(a){this.active&&(a.get("body")&&this.$el.addClass("body"),this.$el.addClass("selected"),this.selected=!0,this.bind(a))},unselect:function(){this.$el.removeClass("selected body"),this.selected=!1,this.unbind()},activate:function(){this.active=!0},deactivate:function(){this.active=!1}})}),$(function(){var a=$("#loader");$(document).ajaxStart(function(){a.show()}).ajaxStop(function(){a.hide()})}),rivets.formatters.recordLink=function(a){return"#records/"+a},rivets.formatters.recordTitle=function(a){return a=_.string.truncate(a,100),a?_.string.stripTags(a):STRINGS.record.placeholders.title},rivets.formatters.recordId=function(a){return a?"#"+a+":":null},rivets.formatters.commaDelimited={read:function(a){return _.isString(a)?a.split(","):_.isNull(a)?[]:void 0},publish:function(a){return _.isArray(a)&&(a=a.join()),a}},toastr.options={timeOut:2500,fadeIn:200,fadeOut:200},Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c){a.ID="EDITOR",b.on("initialize:before",function(){a.start()}),b.on("initialize:after",function(){a.Map.start(),c.history.start()}),a.addInitializer(function(){a.__view=new a.View({el:"body"})})}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c,d,e,f){var g=function(c){a.__view.__ui.editor.children().detach(),f.each(c,function(c){b.execute(c+":display",a.__view.__ui.editor)})};b.commands.setHandler(a.ID+":display",g);var h=function(b){a.__view.notifySuccess(b)};b.commands.setHandler(a.ID+":notifySuccess",h);var i=function(b){a.__view.notifyError(b)};b.commands.setHandler(a.ID+":notifyError",i);var j=function(){return a.__view.__ui.editor};b.reqres.setHandler(a.ID+":getContainer",j);var k=function(a){c.history.navigate(a,{replace:!0})};b.commands.setHandler(a.ID+":setRoute",k)}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c){a.Router=c.Router.extend({before:function(){b.vent.trigger("ROUTER:before")}})}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({ui:{exhibit:"#neatline",map:"#neatline-map",editor:"#editor"},init:function(){this.width=this.__ui.editor.outerWidth(),this.window=e(window),this.window.resize(f.bind(this.position,this)),this.position()},position:function(){var a=this.window.height(),b=this.window.width();this.__ui.editor.css({height:a,width:this.width}),this.__ui.map.css({height:a,width:b-this.width}),this.__ui.exhibit.css({left:this.width})},notifySuccess:function(a){toastr.info(a)},notifyError:function(a){toastr.error(a)}})}}),Neatline.module("Editor.Exhibit",function(a){a.ID="EDITOR:EXHIBIT",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Editor.Exhibit",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(b){a.__view.activateTab(b)};b.commands.setHandler(a.ID+":activateTab",d)}),Neatline.module("Editor.Exhibit",function(a,b,c){a.View=c.Neatline.View.extend({template:"#exhibit-menu-template",tagName:"header",ui:{dropdowns:"li.dropdown",tabs:"li.tab"},activateTab:function(a){this.__ui.dropdowns.removeClass("active"),this.__ui.tabs.removeClass("active");var a=this.__ui.tabs.filter('[data-slug="'+a+'"]');a.addClass("active"),a.parents("li.dropdown").addClass("active")}})}),Neatline.module("Editor.Exhibit.Records",function(a,b){a.ID="EDITOR:EXHIBIT:RECORDS",a.addInitializer(function(){a.__collection=new b.Shared.Record.Collection,a.__router=new a.Router,a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Records",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(b){a.__collection.update(b,function(a){e(a)})};b.commands.setHandler(a.ID+":load",d);var e=function(b){a.__view.ingest(b)};b.commands.setHandler(a.ID+":ingest",e);var f=function(){a.__router.navigate("records",!0)};b.commands.setHandler(a.ID+":navToList",f);var g=function(b,c){a.__collection.getOrFetch(b,c)};b.reqres.setHandler(a.ID+":getModel",g)}),Neatline.module("Editor.Exhibit.Records",function(a,b){this.Router=b.Editor.Router.extend({routes:{"":"records","records(/search)(/query=:q)(/start=:s)":"records"},records:function(a,c){b.execute("EDITOR:display",["EDITOR:EXHIBIT","EDITOR:EXHIBIT:SEARCH","EDITOR:EXHIBIT:RECORDS"]),b.execute("EDITOR:EXHIBIT:activateTab","records"),b.execute("EDITOR:EXHIBIT:SEARCH:initialize",a,c) -}})}),Neatline.module("Editor.Exhibit.Records",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({className:"records",events:{"mouseenter a[data-id]":"onMouseenter","mouseleave a[data-id]":"onMouseleave","click a[data-id]":"onClick"},init:function(){this.template=f.template(e("#record-list-template").html())},ingest:function(a){this.records=a;var c=b.request("EDITOR:EXHIBIT:SEARCH:getQueryForUrl");this.$el.html(this.template({records:this.records,limit:b.g.neatline.per_page,query:c}))},getModelByEvent:function(a){return this.records.get(parseInt(e(a.currentTarget).attr("data-id"),10))},onMouseenter:function(c){b.vent.trigger("highlight",{model:this.getModelByEvent(c),source:a.ID})},onMouseleave:function(c){b.vent.trigger("unhighlight",{model:this.getModelByEvent(c),source:a.ID})},onClick:function(c){b.vent.trigger("select",{model:this.getModelByEvent(c),source:a.ID})}})}),Neatline.module("Editor.Exhibit.Search",function(a){a.ID="EDITOR:EXHIBIT:SEARCH",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Search",function(a,b,c,d,e,f){var g=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",g);var h=function(c,d){if(c=c||null,d=d||0,a.__view.setQueryFromUrl(c),!a.__view.mirroring){var e=f.extend(a.__view.query,{limit:b.g.neatline.per_page,offset:d});b.execute("EDITOR:EXHIBIT:RECORDS:load",e)}};b.commands.setHandler(a.ID+":initialize",h);var i=function(c){c=c||b.request("MAP:getRecords"),c&&a.__view.mirroring&&b.execute("EDITOR:EXHIBIT:RECORDS:ingest",c)};b.commands.setHandler(a.ID+":mirrorMap",i),b.vent.on("MAP:ingest",i);var j=function(){return a.__view.getQueryForUrl()};b.reqres.setHandler(a.ID+":getQueryForUrl",j)}),Neatline.module("Editor.Exhibit.Search",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#search-template",className:"search",tagName:"form",events:{"keyup input":"onKeystroke"},ui:{search:"input"},init:function(){this.mirroring=!1},setQueryFromUrl:function(a){f.isString(a)&&(a=a.replace(/\+/g," ")),this.__ui.search.val(a),this.parse()},getQueryForUrl:function(){return this.__ui.search.val().replace(/\s/g,"+")},getUrlFromQuery:function(){var a=this.getQueryForUrl();return""!=a?"records/search/query="+a:"records"},parse:function(){this.query={};var a=this.__ui.search.val();if(this.mirroring=!1,f.string.startsWith(a,"tags:")){var c=f.string.trim(f.string.strRight(a,"tags:"));this.query.tags=c.replace(/\s/g,"").split(","),this.bold()}else f.string.startsWith(a,"map:")?(this.mirroring=!0,b.execute("EDITOR:EXHIBIT:SEARCH:mirrorMap"),this.bold()):f.isEmpty(a)?this.unbold():(this.query.query=a,this.unbold())},onKeystroke:function(){this.parse(),b.execute("EDITOR:setRoute",this.getUrlFromQuery());var a=f.extend(this.query,{limit:b.g.neatline.per_page,offset:0});this.mirroring||b.execute("EDITOR:EXHIBIT:RECORDS:load",a)},bold:function(){this.__ui.search.addClass("bold")},unbold:function(){this.__ui.search.removeClass("bold")}})}),Neatline.module("Editor.Exhibit.Styles",function(a){a.ID="EDITOR:EXHIBIT:STYLES",a.addInitializer(function(){a.__router=new a.Router,a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Styles",function(a,b){var c=function(b){a.__view.showIn(b),a.__view.model.fetch({success:function(){a.__view.buildEditor()}})};b.commands.setHandler(a.ID+":display",c)}),Neatline.module("Editor.Exhibit.Styles",function(a,b){a.Router=b.Editor.Router.extend({routes:{styles:"styles"},styles:function(){b.execute("EDITOR:display",["EDITOR:EXHIBIT","EDITOR:EXHIBIT:STYLES"]),b.execute("EDITOR:EXHIBIT:activateTab","styles")}})}),Neatline.module("Editor.Exhibit.Styles",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#exhibit-styles-template",className:"form-stacked styles",tagName:"form",events:{'click a[name="set-focus"]':"onSetFocus",'click a[name="save"]':"save"},ui:{styles:"#styles",mapFocus:'input[name="map-focus"]',mapZoom:'input[name="map-zoom"]'},init:function(){this.model=new b.Shared.Exhibit.Model,rivets.bind(this.$el,{exhibit:this.model})},buildEditor:function(){this.styles=ace.edit("styles"),this.styles.getSession().setUseWorker(!1),this.styles.getSession().setMode("ace/mode/css"),this.styles.renderer.setShowGutter(!1),this.styles.setHighlightActiveLine(!1),this.styles.getSession().setTabSize(2),this.setStyles(this.model.get("styles")),this.styles.on("change",f.bind(function(){this.model.set("styles",this.getStyles())},this))},getStyles:function(){return this.styles.getSession().getValue()},setStyles:function(a){this.styles.getSession().setValue(a)},onSetFocus:function(){var a=b.request("MAP:getCenter"),c=b.request("MAP:getZoom");this.__ui.mapFocus.val(a.lon+","+a.lat).change(),this.__ui.mapZoom.val(c).change()},save:function(){this.model.save(null,{success:f.bind(this.onSaveSuccess,this),error:f.bind(this.onSaveError,this)})},onSaveSuccess:function(){b.vent.trigger("refresh",{source:a.ID}),b.execute("EDITOR:notifySuccess",STRINGS.exhibit.save.success)},onSaveError:function(){b.execute("EDITOR:notifyError",STRINGS.exhibit.save.error)}})}),Neatline.module("Editor.Record.Map",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:MAP",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Map",{startWithParent:!1,define:function(a,b,c,d,e){a.View=c.Neatline.View.extend({events:{"shown.bs.tab ul.nav a":"onTabChange","change div.map input":"onControlChange","keyup div.map input":"onControlChange",'click a[name="parse"]':"onParseClick",'click a[name="clear"]':"onClearClick"},selectors:{mode:'input[name="mode"]',modify:'input[name="modify"]'},ui:{pan:'input[value="pan"]',sides:'input[name="sides"]',snap:'input[name="snap"]',irreg:'input[name="irreg"]',svg:'textarea[name="svg"]',density:'input[name="density"]',modal:"#svg-modal"},init:function(){this.tab=null},onTabChange:function(a){this.tab=a.target.hash,this.setPresenterStatus(),this.resetEditMode()},onControlChange:function(){b.execute("EDITOR:MAP:updateEdit",{mode:this.getEditMode(),poly:this.getPolyOptions()})},onParseClick:function(){var a=this.__ui.svg.val();try{SVGtoWKT.DENSITY=parseFloat(this.__ui.density.val());var c=SVGtoWKT.convert(a);b.execute("EDITOR:MAP:updateWKT",c),b.execute("EDITOR:notifySuccess",STRINGS.svg.parse.success),this.__ui.modal.modal("hide")}catch(d){b.execute("EDITOR:notifyError",STRINGS.svg.parse.error)}},onClearClick:function(){b.execute("EDITOR:MAP:clearEditLayer")},setPresenterStatus:function(){b.vent.trigger(this.mapTabActive()?"PRESENTER:deactivate":"PRESENTER:activate")},mapTabActive:function(){return"#record-map"==this.tab},resetEditMode:function(){this.__ui.pan[0].checked=!0,this.__ui.pan.trigger("change")},getEditMode:function(){return e(this.selectors.mode+":checked").val()},getPolyOptions:function(){return{sides:this.__ui.sides.val(),snap:this.__ui.snap.val(),irreg:this.__ui.irreg.is(":checked")}}})}}),Neatline.module("Editor.Record",function(a){a.ID="EDITOR:RECORD",a.addInitializer(function(){a.__view=new a.View,a.__router=new a.Router})}),Neatline.module("Editor.Record",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(c,d){c=parseInt(c,10),b.request("EDITOR:EXHIBIT:RECORDS:getModel",c,function(b){a.__view.bind(b),a.__view.activateTab(d)})};b.commands.setHandler(a.ID+":bindId",d);var e=function(c){var d=new b.Shared.Record.Model;a.__view.bind(d),a.__view.activateTab(c)};b.commands.setHandler(a.ID+":bindNew",e);var f=function(){a.__view.open&&a.__view.unbind()};b.commands.setHandler(a.ID+":unbind",f),b.vent.on("ROUTER:before",f);var g=function(b){a.__view.open||a.__router.navigate("record/"+b.model.id,!0)};b.commands.setHandler(a.ID+":navToForm",g),b.vent.on("select",g);var h=function(b){a.__view.model.set("coverage",b)};b.commands.setHandler(a.ID+":setCoverage",h);var i=function(){return a.__view.$el};b.reqres.setHandler(a.ID+":getElement",i);var j=function(){return a.__view.model};b.reqres.setHandler(a.ID+":getModel",j)}),Neatline.module("Editor.Record",function(a,b){a.Router=b.Editor.Router.extend({routes:{"record/add":"record/add","record/add/:tab":"record/add/:tab","record/:id":"record/:id","record/:id/:tab":"record/:id/:tab"},"record/add":function(){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindNew","text")},"record/add/:tab":function(a){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindNew",a)},"record/:id":function(a){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindId",a,"text")},"record/:id/:tab":function(a,c){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindId",a,c)}})}),Neatline.module("Editor.Record",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#record-form-template",className:"form-stacked record",tagName:"form",events:{"shown.bs.tab ul.nav a":"onTabChange",'click a[name="close"]':"onCloseClick",'click a[name="save"]':"onSaveClick",'click a[name="delete"]':"onDeleteClick"},ui:{tabs:"li.tab a",modal:"#delete-modal"},init:function(){this.open=!1,this.tab=null},bind:function(a){this.model=a,this.open=!0,b.execute("EDITOR:MAP:startEdit",this.model),rivets.bind(this.$el,{record:this.model}),this.listenTo(this.model,"change",f.bind(function(){b.execute("EDITOR:MAP:updateModel",this.model)},this))},unbind:function(){b.execute("EDITOR:MAP:endEdit",this.model),b.vent.trigger("PRESENTER:activate"),b.vent.trigger("unselect",{model:this.model,source:a.ID}),this.stopListening(this.model),this.open=!1},activateTab:function(a){this.__ui.tabs.filter('[data-slug="'+a+'"]').tab("show")},onTabChange:function(a){this.tab=e(a.target).attr("data-slug");var c=this.model.id||"add";b.execute("EDITOR:setRoute","record/"+c+"/"+this.tab),b.vent.trigger("EDITOR:RECORD:#"+this.tab)},onCloseClick:function(){b.execute("EDITOR:EXHIBIT:RECORDS:navToList"),b.vent.trigger("refresh",{source:a.ID}),this.unbind()},onSaveClick:function(){this.model.save(null,{success:f.bind(this.onSaveSuccess,this),error:f.bind(this.onSaveError,this)})},onDeleteClick:function(){this.model.destroy({success:f.bind(this.onDeleteSuccess,this),error:f.bind(this.onDeleteError,this)})},onSaveSuccess:function(){b.execute("EDITOR:notifySuccess",STRINGS.record.save.success),b.execute("EDITOR:setRoute","record/"+this.model.id+"/"+this.tab),b.vent.trigger("refresh",{source:a.ID})},onSaveError:function(){b.execute("EDITOR:notifyError",STRINGS.record.save.error)},onDeleteSuccess:function(){b.execute("EDITOR:notifySuccess",STRINGS.record.remove.success),this.__ui.modal.modal("hide"),this.onCloseClick(),b.vent.trigger("refresh",{source:a.ID})},onDeleteError:function(){b.execute("EDITOR:notifyError",STRINGS.record.remove.error)}})}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:STYLE",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b){var c=function(){a.__view.buildWidgets()};b.commands.setHandler(a.ID+":activate",c),b.vent.on("EDITOR:RECORD:#style",c)}}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b,c,d,e){a.View=c.Neatline.View.extend({events:{'click a[name="set-min-zoom"]':"onSetMinZoom",'click a[name="set-max-zoom"]':"onSetMaxZoom",'click a[name="set-focus"]':"onSetFocus","keyup input.preview":"onStyleKeyup"},ui:{minZoom:'input[name="min-zoom"]',maxZoom:'input[name="max-zoom"]',mapFocus:'input[name="map-focus"]',mapZoom:'input[name="map-zoom"]'},buildWidgets:function(){this.$("input.color").spectrum({move:function(a){e(this).val(a.toHexString()).trigger("change")},showButtons:!1,clickoutFiresChange:!0,showInput:!0}),this.$("input.opacity").draggableInput({type:"float",min:0,max:1,scrollPrecision:.002}),this.$("input.integer").draggableInput({type:"integer",min:0,max:1e3})},onSetMinZoom:function(){var a=b.request("MAP:getZoom");this.__ui.minZoom.val(a).change()},onSetMaxZoom:function(){var a=b.request("MAP:getZoom");this.__ui.maxZoom.val(a).change()},onSetFocus:function(){var a=b.request("MAP:getCenter"),c=b.request("MAP:getZoom");this.__ui.mapFocus.val(a.lon+","+a.lat).change(),this.__ui.mapZoom.val(c).change()},onStyleKeyup:function(a){e(a.target).trigger("change")}})}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:TEXT",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b){var c=function(){a.__view.buildWidgets()};b.commands.setHandler(a.ID+":activate",c),b.vent.on("EDITOR:RECORD:#text",c)}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({events:{"click a[data-textarea]":"onEditHtmlClick"},ui:{item:'input[name="item-id"]',title:'textarea[name="title"]',body:'textarea[name="body"]'},buildWidgets:function(){this.__ui.item.autocomplete({source:f.bind(this.onSearch,this),select:f.bind(this.onSelect,this)})},onSearch:function(a,c){e.get(b.g.neatline.items_api,{output:"omeka-xml",search:a.term},function(a){var b=[];e(a).find("item").each(function(a,c){b.push({label:e(c).find('*[elementId="50"] text').first().text(),value:e(c).attr("itemId")})}),c(b)})},onSelect:function(a,b){this.__ui.title.val(b.item.label).change(),this.__ui.item.val(b.item.value).change()},onEditHtmlClick:function(a){var b=e(a.target).attr("data-textarea"),c=CKEDITOR.replace(b),d=e("#"+b);c.on("instanceReady",function(){c.execCommand("maximize"),c.on("maximize",function(){c.destroy(),d.change()})})}})}}),Neatline.module("Editor.Map",{startWithParent:!1,define:function(a){a.ID="EDITOR:MAP",a.addInitializer(function(){a.__collection=Neatline.Map.__collection,a.__view=Neatline.Map.__view,a.__view.__initEditor()})}}),Neatline.module("Editor.Map",{startWithParent:!1,define:function(a){var b=function(b){a.__view.startEdit(b)};Neatline.commands.setHandler(a.ID+":startEdit",b);var c=function(){a.__view.endEdit()};Neatline.commands.setHandler(a.ID+":endEdit",c);var d=function(b){a.__view.updateEdit(b)};Neatline.commands.setHandler(a.ID+":updateEdit",d);var e=function(b){a.__view.updateWKT(b)};Neatline.commands.setHandler(a.ID+":updateWKT",e);var f=function(b){a.__view.updateModel(b)};Neatline.commands.setHandler(a.ID+":updateModel",f);var g=function(){a.__view.clearEditLayer()};Neatline.commands.setHandler(a.ID+":clearEditLayer",g)}}),_.extend(Neatline.Map.View.prototype,{__initEditor:function(){this.editLayer=null},startEdit:function(a){this.editLayer=this.layers.vector[a.id],this.editLayer||(this.editLayer=this.buildVectorLayer(a)),this.map.setLayerIndex(this.editLayer,9999),this.editLayer.nFrozen=!0,this.controls={point:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Point,{featureAdded:_.bind(this.publishWKT,this)}),line:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Path,{featureAdded:_.bind(this.publishWKT,this)}),poly:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Polygon,{featureAdded:_.bind(this.publishWKT,this)}),regPoly:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.RegularPolygon,{featureAdded:_.bind(this.publishWKT,this)}),svg:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Geometry,{featureAdded:_.bind(this.publishWKT,this)}),edit:new OpenLayers.Control.ModifyFeature(this.editLayer,{onModification:_.bind(this.publishWKT,this)}),remove:new OpenLayers.Control.ModifyFeature(this.editLayer,{onModificationStart:_.bind(this.removeFeature,this)})},this.map.addControls(_.values(this.controls))},endEdit:function(){this.removeEditorControls(),this.deactivateEditorControls(),this.activatePublicControls(),this.editLayer&&(this.editLayer.nFrozen=!1,this.editLayer=null)},updateEdit:function(a){this.deactivateEditorControls(),this.activatePublicControls();var b=OpenLayers.Control.ModifyFeature;switch(a.mode){case"point":this.controls.point.activate();break;case"line":this.controls.line.activate();break;case"poly":this.controls.poly.activate();break;case"svg":this.controls.svg.activate();break;case"regPoly":this.controls.regPoly.activate();break;case"modify":this.controls.edit.mode=b.RESHAPE,this.activateModifying();break;case"rotate":this.controls.edit.mode=b.ROTATE,this.activateModifying();break;case"resize":this.controls.edit.mode=b.RESIZE,this.activateModifying();break;case"drag":this.controls.edit.mode=b.DRAG,this.activateModifying();break;case"remove":this.controls.remove.activate()}var c=parseFloat(a.poly.snap)||0;this.controls.regPoly.handler.snapAngle=Math.max(0,c);var d=parseInt(a.poly.sides,10)||0;this.controls.regPoly.handler.sides=Math.max(3,d),this.controls.regPoly.handler.irregular=a.poly.irreg},activateModifying:function(){this.deactivatePublicControls(),this.controls.edit.activate()},updateWKT:function(a){var b=OpenLayers.Geometry.fromWKT(a);this.controls.svg.handler.setGeometry(b)},updateModel:function(a){a.hasChanged("id")&&(delete this.layers.vector[a.previous("id")],this.layers.vector[a.id]=this.editLayer),this.editLayer.nModel=a,this.editLayer.styleMap=this.getStyleMap(a),this.editLayer.redraw()},publishWKT:function(){var a=[],b=null;_.each(this.editLayer.features,function(b){b._sketch||("OpenLayers.Geometry.Collection"==b.geometry.CLASS_NAME?_.each(b.geometry.components,function(b){a.push(new OpenLayers.Feature.Vector(b))}):a.push(b))}),_.isEmpty(a)||(b=this.formatWkt.write(a)),Neatline.execute("EDITOR:RECORD:setCoverage",b)},deactivateEditorControls:function(){_.each(this.controls,function(a){a.deactivate()})},removeEditorControls:function(){_.each(this.controls,_.bind(function(a){this.map.removeControl(a)},this))},removeFeature:function(a){this.controls.remove.unselectFeature(a),this.editLayer.destroyFeatures([a]),this.publishWKT()},clearEditLayer:function(){this.editLayer.destroyFeatures(),this.publishWKT()}}); \ No newline at end of file +}return e(d,c),d.prototype.sync=function(){},d.prototype.locals=function(a){var b,c,d,e,f,g,h,i,j;null==a&&(a=this.view.models),f={},i=this.inflections;for(c in i)for(b=i[c],j=b.split("."),g=0,h=j.length;h>g;g++)e=j[g],f[c]=(f[c]||a)[e];for(c in a)d=a[c],null==f[c]&&(f[c]=d);return f},d.prototype.update=function(a){var b;return null!=(b=this.componentView)?b.update(this.locals(a)):void 0},d.prototype.bind=function(){var b,c;return null!=this.componentView?null!=(c=this.componentView)?c.bind():void 0:(b=this.component.build.call(this.attributes),(this.componentView=new a.View(b,this.locals(),this.view.options)).bind(),this.el.parentNode.replaceChild(b,this.el))},d.prototype.unbind=function(){var a;return null!=(a=this.componentView)?a.unbind():void 0},d}(a.Binding),a.TextBinding=function(a){function c(a,c,d,e,f,g){this.view=a,this.el=c,this.type=d,this.key=e,this.keypath=f,this.options=null!=g?g:{},this.sync=b(this.sync,this),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return e(c,a),c.prototype.binder={routine:function(a,b){return a.data=null!=b?b:""}},c.prototype.sync=function(){return c.__super__.sync.apply(this,arguments)},c}(a.Binding),a.View=function(){function d(c,d,e){var f,g,h,i,j,k,l,m,n;for(this.els=c,this.models=d,this.options=null!=e?e:{},this.update=b(this.update,this),this.publish=b(this.publish,this),this.sync=b(this.sync,this),this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.select=b(this.select,this),this.build=b(this.build,this),this.componentRegExp=b(this.componentRegExp,this),this.bindingRegExp=b(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),l=["config","binders","formatters"],j=0,k=l.length;k>j;j++){if(g=l[j],this[g]={},this.options[g]){m=this.options[g];for(f in m)h=m[f],this[g][f]=h}n=a[g];for(f in n)h=n[f],null==(i=this[g])[f]&&(i[f]=h)}this.build()}return d.prototype.bindingRegExp=function(){var a;return a=this.config.prefix,a?new RegExp("^data-"+a+"-"):/^data-/},d.prototype.componentRegExp=function(){var a,b;return new RegExp("^"+(null!=(a=null!=(b=this.config.prefix)?b.toUpperCase():void 0)?a:"RV")+"-")},d.prototype.build=function(){var b,d,e,g,h,i,j,k,l,m=this;for(this.bindings=[],i=[],b=this.bindingRegExp(),e=this.componentRegExp(),d=function(b,c,d,e){var f,g,h,i,j,k,l,n,o,p;return k={},o=function(){var a,b,c,d;for(c=e.split("|"),d=[],a=0,b=c.length;b>a;a++)n=c[a],d.push(n.trim());return d}(),f=function(){var a,b,c,d;for(c=o.shift().split("<"),d=[],a=0,b=c.length;b>a;a++)g=c[a],d.push(g.trim());return d}(),l=f.shift(),p=l.split(/\.|:/),k.formatters=o,k.bypass=-1!==l.indexOf(":"),p[0]?i=p.shift():(i=null,p.shift()),j=p.join("."),(h=f.shift())&&(k.dependencies=h.split(/\s+/)),m.bindings.push(new a[b](m,c,d,i,j,k))},h=function(g){var j,k,l,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;if(f.call(i,g)<0){if(g.nodeType===Node.TEXT_NODE){if(r=a.TextTemplateParser,(o=m.config.templateDelimiters)&&(x=r.parse(g.data,o)).length&&(1!==x.length||x[0].type!==r.types.text))for(u=x[0],t=2<=x.length?c.call(x,1):[],g.data=u.value,0===u.type?g.data=u.value:d("TextBinding",g,null,u.value),A=0,E=t.length;E>A;A++)w=t[A],v=document.createTextNode(w.value),g.parentNode.appendChild(v),1===w.type&&d("TextBinding",v,null,w.value)}else if(e.test(g.tagName))y=g.tagName.replace(e,"").toLowerCase(),m.bindings.push(new a.ComponentBinding(m,g,y));else if(null!=g.attributes){for(K=g.attributes,B=0,F=K.length;F>B;B++)if(j=K[B],b.test(j.name)){if(y=j.name.replace(b,""),!(l=m.binders[y])){L=m.binders;for(p in L)z=L[p],"*"!==p&&-1!==p.indexOf("*")&&(s=new RegExp("^"+p.replace("*",".+")+"$"),s.test(y)&&(l=z))}if(l||(l=m.binders["*"]),l.block){for(M=g.childNodes,C=0,G=M.length;G>C;C++)q=M[C],i.push(q);k=[j]}}for(N=k||g.attributes,D=0,H=N.length;H>D;D++)j=N[D],b.test(j.name)&&(y=j.name.replace(b,""),d("Binding",g,y,j.value))}for(O=g.childNodes,P=[],J=0,I=O.length;I>J;J++)n=O[J],P.push(h(n));return P}},l=this.els,j=0,k=l.length;k>j;j++)g=l[j],h(g)},d.prototype.select=function(a){var b,c,d,e,f;for(e=this.bindings,f=[],c=0,d=e.length;d>c;c++)b=e[c],a(b)&&f.push(b);return f},d.prototype.bind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.bind());return e},d.prototype.unbind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e},d.prototype.sync=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.sync());return e},d.prototype.publish=function(){var a,b,c,d,e;for(d=this.select(function(a){return a.binder.publishes}),e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.publish());return e},d.prototype.update=function(a){var b,c,d,e,f,g,h;null==a&&(a={});for(c in a)d=a[c],this.models[c]=d;for(g=this.bindings,h=[],e=0,f=g.length;f>e;e++)b=g[e],h.push(b.update(a));return h},d}(),a.TextTemplateParser=function(){function a(){}return a.types={text:0,binding:1},a.parse=function(a,b){var c,d,e,f,g,h,i;for(h=[],f=a.length,c=0,d=0;f>d;){if(c=a.indexOf(b[0],d),0>c){h.push({type:this.types.text,value:a.slice(d)});break}if(c>0&&c>d&&h.push({type:this.types.text,value:a.slice(d,c)}),d=c+2,c=a.indexOf(b[1],d),0>c){g=a.slice(d-2),e=h[h.length-1],(null!=e?e.type:void 0)===this.types.text?e.value+=g:h.push({type:this.types.text,value:g});break}i=a.slice(d,c).trim(),h.push({type:this.types.binding,value:i}),d=c+2}return h},a}(),a.Util={bindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.on?a.on(b,c):a.bind(b,c)):null!=window.addEventListener?a.addEventListener(b,c,!1):(b="on"+b,a.attachEvent(b,c))},unbindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.off?a.off(b,c):a.unbind(b,c)):null!=window.removeEventListener?a.removeEventListener(b,c,!1):(b="on"+b,a.detachEvent(b,c))},getInputValue:function(a){var b,c,d,e;if(null!=window.jQuery)switch(a=jQuery(a),a[0].type){case"checkbox":return a.is(":checked");default:return a.val()}else switch(a.type){case"checkbox":return a.checked;case"select-multiple":for(e=[],c=0,d=a.length;d>c;c++)b=a[c],b.selected&&e.push(b.value);return e;default:return a.value}}},a.binders={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)===(null!=b?b.toString():void 0):!!b}},unchecked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)!==(null!=b?b.toString():void 0):!b}},show:function(a,b){return a.style.display=b?"":"none"},hide:function(a,b){return a.style.display=b?"none":""},html:function(a,b){return a.innerHTML=null!=b?b:""},value:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c,d,e,g,h,i,j;if(null!=window.jQuery){if(a=jQuery(a),(null!=b?b.toString():void 0)!==(null!=(g=a.val())?g.toString():void 0))return a.val(null!=b?b:"")}else if("select-multiple"===a.type){if(null!=b){for(j=[],d=0,e=a.length;e>d;d++)c=a[d],j.push(c.selected=(h=c.value,f.call(b,h)>=0));return j}}else if((null!=b?b.toString():void 0)!==(null!=(i=a.value)?i.toString():void 0))return a.value=null!=b?b:""}},text:function(a,b){return null!=a.innerText?a.innerText=null!=b?b:"":a.textContent=null!=b?b:""},"if":{block:!0,bind:function(a){var b,c;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),c=a.getAttribute(b),this.marker=document.createComment(" rivets: "+this.type+" "+c+" "),a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a;return null!=(a=this.nested)?a.unbind():void 0},routine:function(b,c){var d,e,f,g,h;if(!!c==(null==this.nested)){if(c){f={},h=this.view.models;for(d in h)e=h[d],f[d]=e;return g={binders:this.view.options.binders,formatters:this.view.options.formatters,config:this.view.options.config},(this.nested=new a.View(b,f,g)).bind(),this.marker.parentNode.insertBefore(b,this.marker.nextSibling)}return b.parentNode.removeChild(b),this.nested.unbind(),delete this.nested}},update:function(a){var b;return null!=(b=this.nested)?b.update(a):void 0}},unless:{block:!0,bind:function(b){return a.binders["if"].bind.call(this,b)},unbind:function(){return a.binders["if"].unbind.call(this)},routine:function(b,c){return a.binders["if"].routine.call(this,b,!c)},update:function(b){return a.binders["if"].update.call(this,b)}},"on-*":{"function":!0,unbind:function(b){return this.handler?a.Util.unbindEvent(b,this.args[0],this.handler):void 0},routine:function(b,c){return this.handler&&a.Util.unbindEvent(b,this.args[0],this.handler),a.Util.bindEvent(b,this.args[0],this.handler=this.eventHandler(c))}},"each-*":{block:!0,bind:function(a){var b;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),this.marker=document.createComment(" rivets: "+this.type+" "),this.iterated=[],a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a,b,c,d,e;if(null!=this.iterated){for(d=this.iterated,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e}},routine:function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;if(j=this.args[0],c=c||[],this.iterated.length>c.length)for(t=Array(this.iterated.length-c.length),p=0,r=t.length;r>p;p++)e=t[p],o=this.iterated.pop(),o.unbind(),this.marker.parentNode.removeChild(o.els[0]);for(w=[],f=q=0,s=c.length;s>q;f=++q)if(i=c[f],d={},d[j]=i,null==this.iterated[f]){u=this.view.models;for(h in u)i=u[h],null==d[h]&&(d[h]=i);l=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,k={binders:this.view.options.binders,formatters:this.view.options.formatters,config:{}},v=this.view.options.config;for(g in v)n=v[g],k.config[g]=n;k.config.preloadData=!0,m=b.cloneNode(!0),o=new a.View(m,d,k),o.bind(),this.iterated.push(o),w.push(this.marker.parentNode.insertBefore(m,l.nextSibling))}else this.iterated[f].models[j]!==i?w.push(this.iterated[f].update(d)):w.push(void 0);return w},update:function(a){var b,c,d,e,f,g,h,i;b={};for(c in a)d=a[c],c!==this.args[0]&&(b[c]=d);for(h=this.iterated,i=[],f=0,g=h.length;g>f;f++)e=h[f],i.push(e.update(b));return i}},"class-*":function(a,b){var c;return c=" "+a.className+" ",!b==(-1!==c.indexOf(" "+this.args[0]+" "))?a.className=b?""+a.className+" "+this.args[0]:c.replace(" "+this.args[0]+" "," ").trim():void 0},"*":function(a,b){return b?a.setAttribute(this.type,b):a.removeAttribute(this.type)}},a.components={},a.config={preloadData:!0,handler:function(a,b,c){return this.call(a,b,c.view.models)}},a.formatters={},a.factory=function(b){return b._=a,b.binders=a.binders,b.components=a.components,b.formatters=a.formatters,b.config=a.config,b.configure=function(b){var c,d;null==b&&(b={});for(c in b)d=b[c],a.config[c]=d},b.bind=function(b,c,d){var e;return null==c&&(c={}),null==d&&(d={}),e=new a.View(b,c,d),e.bind(),e}},"object"==typeof exports?a.factory(exports):"function"==typeof define&&define.amd?define(["exports"],function(b){return a.factory(this.rivets=b),b}):a.factory(this.rivets={})}.call(this),OpenLayers.ImgPath="http://js.mapbox.com/theme/dark/",rivets.configure({prefix:"rv",adapter:{subscribe:function(a,b,c){a.on("change:"+b,c)},unsubscribe:function(a,b,c){a.off("change:"+b,c)},read:function(a,b){return a.get(b)},publish:function(a,b,c){a.set(b,c)}}}),Neatline=new Backbone.Marionette.Application,Neatline.module("Shared.Exhibit",function(a,b,c){a.Model=c.Model.extend({url:function(){return b.g.neatline.exhibits_api},defaults:function(){return b.g.neatline.exhibit}})}),Neatline.module("Shared.Record",function(a,b,c){a.Model=c.Model.extend({url:function(){var a=b.g.neatline.records_api;return this.id&&(a+="/"+this.id),a},defaults:function(){var a=b.g.neatline.styles;return{exhibit_id:b.g.neatline.exhibit.id,presenter:a.presenter,fill_color:a.fill_color,fill_color_select:a.fill_color_select,stroke_color:a.stroke_color,stroke_color_select:a.stroke_color_select,fill_opacity:Number(a.fill_opacity),fill_opacity_select:Number(a.fill_opacity_select),stroke_opacity:Number(a.stroke_opacity),stroke_opacity_select:Number(a.stroke_opacity_select),point_radius:Number(a.point_radius),stroke_width:Number(a.stroke_width)}}})}),Neatline.module("Shared.Record",function(a,b,c,d,e,f){a.Collection=c.Neatline.Collection.extend({model:b.Shared.Record.Model,update:function(a,c){a=f.extend(a,{exhibit_id:b.g.neatline.exhibit.id}),this.fetch({reset:!0,data:e.param(a),success:c})},url:function(){return b.g.neatline.records_api},parse:function(a){return this.offset=Number(a.offset),this.count=Number(a.count),a.records}})}),Neatline.module("Shared.Widget",function(a,b,c,d,e){a.View=c.Neatline.View.extend({className:"widget",initialize:function(){e("#"+this.id).length||this.$el.appendTo(e("#neatline-map")),a.View.__super__.initialize.apply(this)}})}),Neatline.module("Map.Layers.Google",function(a,b){a.ID="MAP:LAYERS:Google";var c=function(a){switch(a.properties.provider){case"physical":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.TERRAIN});case"streets":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.ROADMAP,numZoomLevels:25});case"satellite":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.SATELLITE,numZoomLevels:25});case"hybrid":return new OpenLayers.Layer.Google(a.title,{type:google.maps.MapTypeId.HYBRID,numZoomLevels:25})}};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.OpenStreetMap",function(a,b){a.ID="MAP:LAYERS:OpenStreetMap";var c=function(a){return new OpenLayers.Layer.OSM(a.title)};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.Stamen",function(a,b){a.ID="MAP:LAYERS:Stamen";var c=function(a){var b=new OpenLayers.Layer.Stamen(a.properties.provider);return b.name=a.title,b};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers.WMS",function(a,b){a.ID="MAP:LAYERS:WMS";var c=function(a){return new OpenLayers.Layer.WMS(a.title,a.properties.address,{layers:a.properties.layers})};b.reqres.setHandler(a.ID,c)}),Neatline.module("Map.Layers",function(a,b){a.ID="MAP:LAYERS";var c=function(a){try{return b.request("MAP:LAYERS:"+a.type,a)}catch(c){return null}};b.reqres.setHandler(a.ID+":getLayer",c)}),Neatline.module("Map",function(a,b){a.ID="MAP",a.addInitializer(function(){a.__collection=new b.Shared.Record.Collection,a.__view=new b.Map.View,a.__view.requestRecords()})}),Neatline.module("Map",function(a,b){var c=function(b){a.__collection.update(b,function(b){a.__view.ingest(b)})};b.commands.setHandler(a.ID+":load",c);var d=function(){a.__view.removeAllLayers(),a.__view.requestRecords()};b.commands.setHandler(a.ID+":refresh",d),b.vent.on("refresh",d);var e=function(b){b.source!==a.ID&&(i(b.model),a.__view.selectByModel(b.model))};b.commands.setHandler(a.ID+":select",e),b.vent.on("select",e);var f=function(b){a.__view.highlightByModel(b.model)};b.commands.setHandler(a.ID+":highlight",f),b.vent.on("highlight",f);var g=function(b){a.__view.unhighlightByModel(b.model)};b.commands.setHandler(a.ID+":unhighlight",g),b.vent.on("unhighlight",g);var h=function(b){a.__view.unselectByModel(b.model)};b.commands.setHandler(a.ID+":unselect",h),b.vent.on("unselect",h);var i=function(b){a.__view.focusByModel(b)};b.commands.setHandler(a.ID+":focusByModel",i);var j=function(b){a.__view.setFilter(b.key,b.evaluator)};b.commands.setHandler(a.ID+":setFilter",j),b.vent.on("setFilter",j);var k=function(b){a.__view.removeFilter(b.key)};b.commands.setHandler(a.ID+":removeFilter",k),b.vent.on("removeFilter",k);var l=function(){a.__view.map.updateSize()};b.commands.setHandler(a.ID+":updateSize",l);var m=function(){return a.__view.map};b.reqres.setHandler(a.ID+":getMap",m);var n=function(){return a.__collection};b.reqres.setHandler(a.ID+":getRecords",n);var o=function(){return a.__view.map.getCenter()};b.reqres.setHandler(a.ID+":getCenter",o);var p=function(){return a.__view.map.getZoom()};b.reqres.setHandler(a.ID+":getZoom",p)}),Neatline.module("Map",function(a,b,c,d,e,f){a.View=c.View.extend({el:"#neatline-map",options:{defaultZoom:6},initialize:function(){this._initGlobals(),this._initOpenLayers(),this._initControls(),this._initEvents(),this._initBaseLayers(),this._initViewport()},_initGlobals:function(){this.exhibit=b.g.neatline.exhibit,this.formatWkt=new OpenLayers.Format.WKT,this.layers={vector:{},wms:{}},this.filters={},this.selectedModel=null,this.loading=!1},_initOpenLayers:function(){this.map=new OpenLayers.Map(this.el,{theme:null,zoomMethod:null,panMethod:null,controls:[new OpenLayers.Control.PanZoomBar,new OpenLayers.Control.LayerSwitcher,new OpenLayers.Control.Navigation({dragPanOptions:{enableKinetic:!1},documentDrag:!0})]})},_initControls:function(){f.bindAll(this,"onBeforeHighlight","onHighlight","onUnhighlight","onSelect","onUnselect"),this.highlightControl=new OpenLayers.Control.SelectFeature(this.getVectorLayers(),{hover:!0,renderIntent:"temporary",highlightOnly:!0,eventListeners:{beforefeaturehighlighted:this.onBeforeHighlight,featurehighlighted:this.onHighlight,featureunhighlighted:this.onUnhighlight}}),this.selectControl=new OpenLayers.Control.SelectFeature(this.getVectorLayers(),{onSelect:this.onSelect,onUnselect:this.onUnselect}),this.highlightControl.handlers.feature.stopDown=!1,this.selectControl.handlers.feature.stopDown=!1,this.map.addControls([this.highlightControl,this.selectControl]),this.activatePublicControls()},_initEvents:function(){this.exhibit.spatial_querying&&this.map.events.register("moveend",this.map,f.bind(function(){this.requestRecords()},this))},_initBaseLayers:function(){var a=f.isString(this.exhibit.image_layer),b=f.isString(this.exhibit.wms_address)&&f.isString(this.exhibit.wms_layers);a?this._initImageLayer():b?this._initWmsLayer():this._initSpatialLayers()},_initImageLayer:function(){var a=this.exhibit.image_height,b=this.exhibit.image_width,c=new OpenLayers.Layer.Image(this.exhibit.title,this.exhibit.image_layer,new OpenLayers.Bounds(0,0,b,a),new OpenLayers.Size(b/5,a/5));this.map.addLayer(c)},_initWmsLayer:function(){var a=new OpenLayers.Layer.WMS(this.exhibit.title,this.exhibit.wms_address,{layers:this.exhibit.wms_layers},{maxZoomLevel:20});this.map.addLayer(a)},_initSpatialLayers:function(){var a={};f.each(b.g.neatline.spatial_layers,function(c){var d=b.request("MAP:LAYERS:getLayer",c);f.isObject(d)&&(a[c.id]=d)}),f.each(f.values(a),f.bind(function(a){this.map.addLayer(a),this.map.setLayerIndex(a,0)},this)),this.map.setBaseLayer(a[this.exhibit.spatial_layer])},_initViewport:function(){var a=b.g.neatline.exhibit.map_focus,c=b.g.neatline.exhibit.map_zoom;f.isString(a)&&f.isNumber(c)?this.setViewport(a,c):(this.map.zoomTo(this.options.defaultZoom),this.geolocate())},activatePublicControls:function(){this.highlightControl.activate(),this.selectControl.activate()},deactivatePublicControls:function(){this.highlightControl.deactivate(),this.selectControl.deactivate()},updateControls:function(){var a=this.getVectorLayers();this.highlightControl.setLayer(a),this.selectControl.setLayer(a),f.isNull(this.selectedModel)||this.selectByModel(this.selectedModel)},focusByModel:function(a){var c=this.layers.vector[a.id];c||(c=this.buildVectorLayer(a));var d=a.get("map_focus"),e=a.get("map_zoom");f.isString(d)&&f.isNumber(e)?this.setViewport(d,e):a.get("coverage")&&!a.get("is_wms")&&this.map.zoomToExtent(c.getDataExtent()),b.vent.trigger("MAP:focused")},setViewport:function(a,b){this.map.setCenter(a.split(","),b)},geolocate:function(){var a=new OpenLayers.Control.Geolocate({bind:!0,watch:!1});this.map.addControl(a),a.activate()},ingest:function(a){this.map.dragging||(this.ingestVectorLayers(a),this.ingestWmsLayers(a),b.vent.trigger("MAP:ingest",a),this.updateControls(),this.records=a,this.loading=!1)},ingestVectorLayers:function(a){var b=[];a.each(f.bind(function(a){b.push(a.id),f.has(this.layers.vector,a.id)||this.buildVectorLayer(a)},this)),f.each(this.layers.vector,f.bind(function(a,c){f.contains(b,Number(c))||a.nFrozen||this.removeVectorLayer(a)},this))},ingestWmsLayers:function(a){var b=[];a.each(f.bind(function(a){var c=a.get("wms_address")&&a.get("wms_layers");b.push(a.id),!f.has(this.layers.wms,a.id)&&c&&this.buildWmsLayer(a)},this)),f.each(this.layers.wms,f.bind(function(a,c){f.contains(b,Number(c))||this.removeWmsLayer(a)},this))},buildVectorLayer:function(a){var b=new OpenLayers.Layer.Vector(a.get("title"),{styleMap:this.getStyleMap(a),displayInLayerSwitcher:!1});return a.get("coverage")&&b.addFeatures(this.formatWkt.read(a.get("coverage"))),b.nModel=a,b.nFrozen=!1,this.filterLayer(b),this.layers.vector[a.id]=b,this.map.addLayer(b),this.setZIndex(b,a.get("zindex")),b},buildWmsLayer:function(a){var b=new OpenLayers.Layer.WMS(a.get("title"),a.get("wms_address"),{layers:a.get("wms_layers"),transparent:!0},{displayOutsideMaxExtent:!0,opacity:parseFloat(a.get("fill_opacity")),isBaseLayer:!1});return b.nModel=a,this.filterLayer(b),this.layers.wms[a.id]=b,this.map.addLayer(b),this.setZIndex(b,a.get("zindex")),b},removeVectorLayer:function(a){this.map.removeLayer(a),delete this.layers.vector[a.nModel.id]},removeWmsLayer:function(a){this.map.removeLayer(a),delete this.layers.wms[a.nModel.id]},removeAllLayers:function(){f.each(f.keys(this.layers.vector),f.bind(function(a){this.layers.vector[a].nFrozen||this.removeVectorLayer(this.layers.vector[a])},this)),f.each(f.keys(this.layers.wms),f.bind(function(a){this.removeWmsLayer(this.layers.wms[a])},this))},setFilter:function(a,b){this.filters[a]=b,this.filterAllLayers()},removeFilter:function(a){delete this.filters[a],this.filterAllLayers()},filterLayer:function(a){var b=!0;f.each(this.filters,f.bind(function(c){b=b&&c(a.nModel)},this)),a.setVisibility(b)},filterAllLayers:function(){f.each(this.layers,f.bind(function(a){f.each(a,f.bind(function(a){this.filterLayer(a)},this))},this))},getStyleMap:function(a){var b=a.get("fill_color"),c=a.get("fill_color_select"),d=a.get("stroke_color"),e=a.get("stroke_color_select"),f=a.get("fill_opacity"),g=a.get("fill_opacity_select"),h=a.get("stroke_opacity"),i=a.get("stroke_opacity_select"),j=a.get("point_image"),k=a.get("stroke_width"),l=a.get("point_radius");return f=parseFloat(f),g=parseFloat(g),h=parseFloat(h),i=parseFloat(i),k=Number(k),l=Number(l),new OpenLayers.StyleMap({"default":new OpenLayers.Style({fillColor:b,strokeColor:d,fillOpacity:f,graphicOpacity:f,strokeOpacity:h,strokeWidth:k,pointRadius:l,externalGraphic:j}),select:new OpenLayers.Style({fillColor:c,strokeColor:e,fillOpacity:g,graphicOpacity:g,strokeOpacity:i,strokeWidth:k,pointRadius:l,externalGraphic:j}),temporary:new OpenLayers.Style({fillColor:c,strokeColor:e,fillOpacity:g,graphicOpacity:g,strokeOpacity:i,strokeWidth:k,pointRadius:l,externalGraphic:j})})},highlightByModel:function(a){var b=this.layers.vector[a.id];b&&!this.modelIsSelected(a)&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.highlightControl.highlight(a)},this)),this.stopPropagation=!1)},unhighlightByModel:function(a){var b=this.layers.vector[a.id];b&&!this.modelIsSelected(a)&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.highlightControl.unhighlight(a)},this)),this.stopPropagation=!1)},selectByModel:function(a){var b=this.layers.vector[a.id];b&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.selectControl.select(a)},this)),this.stopPropagation=!1,this.selectedModel=a)},unselectByModel:function(a){var b=this.layers.vector[a.id];b&&(this.stopPropagation=!0,f.each(b.features,f.bind(function(a){this.selectControl.unselect(a)},this)),this.stopPropagation=!1,this.selectedModel=null)},onBeforeHighlight:function(){return!this.map.dragging&&!this.loading},onHighlight:function(c){this.stopPropagation||(this.highlightByModel(c.feature.layer.nModel),b.vent.trigger("highlight",{model:c.feature.layer.nModel,source:a.ID}))},onUnhighlight:function(c){this.stopPropagation||(this.unhighlightByModel(c.feature.layer.nModel),b.vent.trigger("unhighlight",{model:c.feature.layer.nModel,source:a.ID}))},onSelect:function(c){this.stopPropagation||(this.selectByModel(c.layer.nModel),b.vent.trigger("select",{model:c.layer.nModel,source:a.ID}))},onUnselect:function(c){this.stopPropagation||(this.unselectByModel(c.layer.nModel),b.vent.trigger("unselect",{model:c.layer.nModel,source:a.ID}))},requestRecords:function(){var a={};this.exhibit.spatial_querying&&(a.extent=this.getExtentAsWKT(),a.zoom=this.getZoom()),this.loading=!0,b.execute("MAP:load",a)},setZIndex:function(a,b){this.map.setLayerIndex(a,1+b)},getZoom:function(){return this.map.getZoom()},getExtentAsWKT:function(){var a=this.map.getExtent().toGeometry(),b=new OpenLayers.Feature.Vector(a);return this.formatWkt.write(b)},getVectorLayers:function(){return f.values(this.layers.vector)},getWmsLayers:function(){return f.values(this.layers.wms)},modelIsSelected:function(a){return this.selectedModel?this.selectedModel.id==a.id:!1}})}),Neatline.module("Presenter",function(a,b){a.ID="PRESENTER";var c=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":highlight",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:highlight",c),b.vent.on("highlight",c);var d=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":unhighlight",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:unhighlight",d),b.vent.on("unhighlight",d);var e=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":select",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:select",e),b.vent.on("select",e);var f=function(a){try{b.execute("PRESENTER:"+a.model.get("presenter")+":unselect",a.model)}catch(c){}};b.commands.setHandler("PRESENTER:unselect",f),b.vent.on("unselect",f)}),Neatline.module("Presenter.None",function(a,b){a.ID="PRESENTER:None";var c=function(){};b.commands.setHandler(a.ID+":highlight",c),b.commands.setHandler(a.ID+":unhighlight",c),b.commands.setHandler(a.ID+":select",c),b.commands.setHandler(a.ID+":unselect",c),b.vent.on("PRESENTER:activate",c),b.vent.on("PRESENTER:deactivate",c)}),Neatline.module("Presenter.StaticBubble",function(a){a.ID="PRESENTER:StaticBubble",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Presenter.StaticBubble",function(a,b){var c=function(b){a.__view.highlight(b)};b.commands.setHandler(a.ID+":highlight",c);var d=function(){a.__view.unhighlight()};b.commands.setHandler(a.ID+":unhighlight",d);var e=function(b){a.__view.select(b)};b.commands.setHandler(a.ID+":select",e);var f=function(){a.__view.unselect()};b.commands.setHandler(a.ID+":unselect",f);var g=function(){a.__view.activate()};b.vent.on("PRESENTER:activate",g);var h=function(){a.__view.deactivate(),a.__view.unselect()};b.vent.on("PRESENTER:deactivate",h)}),Neatline.module("Presenter.StaticBubble",function(a,b,c,d,e,f){a.View=b.Shared.Widget.View.extend({id:"static-bubble",events:{"click .close":"onClose"},ui:{close:".close",body:".body"},init:function(){a.View.__super__.init.apply(this),this.active=!0,this.selected=!1,this.template=f.template(e("#static-bubble-template").html())},onClose:function(){this.unselect(),b.vent.trigger("unselect",{model:this.model,source:a.ID})},bind:function(a){this.model=a,this.onMouseOut=f.bind(this.unhighlight,this);var c=b.request("MAP:getMap");c.events.register("mouseout",null,this.onMouseOut),this.$el.html(this.template({record:this.model})),this.$el.addClass("bound")},unbind:function(){var a=b.request("MAP:getMap");a.events.unregister("mouseout",null,this.onMouseOut),this.$el.empty(),this.$el.removeClass("bound")},highlight:function(a){!this.selected&&this.active&&this.bind(a)},unhighlight:function(){this.selected||this.unbind()},select:function(a){this.active&&(a.get("body")&&this.$el.addClass("body"),this.$el.addClass("selected"),this.selected=!0,this.bind(a))},unselect:function(){this.$el.removeClass("selected body"),this.selected=!1,this.unbind()},activate:function(){this.active=!0},deactivate:function(){this.active=!1}})}),$(function(){var a=$("#loader");$(document).ajaxStart(function(){a.show()}).ajaxStop(function(){a.hide()})}),rivets.formatters.recordLink=function(a){return"#records/"+a},rivets.formatters.recordTitle=function(a){return a=_.string.truncate(a,100),a?_.string.stripTags(a):STRINGS.record.placeholders.title},rivets.formatters.recordId=function(a){return a?"#"+a+":":null},rivets.formatters.commaDelimited={read:function(a){return _.isString(a)?a.split(","):_.isNull(a)?[]:void 0},publish:function(a){return _.isArray(a)&&(a=a.join()),a}},toastr.options={timeOut:2500,fadeIn:200,fadeOut:200},Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c){a.ID="EDITOR",b.on("initialize:before",function(){a.start()}),b.on("initialize:after",function(){a.Map.start(),c.history.start()}),a.addInitializer(function(){a.__view=new a.View({el:"body"})})}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c,d,e,f){var g=function(c){a.__view.__ui.editor.children().detach(),f.each(c,function(c){b.execute(c+":display",a.__view.__ui.editor)})};b.commands.setHandler(a.ID+":display",g);var h=function(b){a.__view.notifySuccess(b)};b.commands.setHandler(a.ID+":notifySuccess",h);var i=function(b){a.__view.notifyError(b)};b.commands.setHandler(a.ID+":notifyError",i);var j=function(){return a.__view.__ui.editor};b.reqres.setHandler(a.ID+":getContainer",j);var k=function(a){c.history.navigate(a,{replace:!0})};b.commands.setHandler(a.ID+":setRoute",k)}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c){a.Router=c.Router.extend({before:function(){b.vent.trigger("ROUTER:before")}})}}),Neatline.module("Editor",{startWithParent:!1,define:function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({ui:{exhibit:"#neatline",map:"#neatline-map",editor:"#editor"},init:function(){this.width=this.__ui.editor.outerWidth(),this.window=e(window),this.window.resize(f.bind(this.position,this)),this.position()},position:function(){var a=this.window.height(),b=this.window.width();this.__ui.editor.css({height:a,width:this.width}),this.__ui.map.css({height:a,width:b-this.width}),this.__ui.exhibit.css({left:this.width})},notifySuccess:function(a){toastr.info(a)},notifyError:function(a){toastr.error(a)}})}}),Neatline.module("Editor.Exhibit",function(a){a.ID="EDITOR:EXHIBIT",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Editor.Exhibit",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(b){a.__view.activateTab(b)};b.commands.setHandler(a.ID+":activateTab",d)}),Neatline.module("Editor.Exhibit",function(a,b,c){a.View=c.Neatline.View.extend({template:"#exhibit-menu-template",tagName:"header",ui:{dropdowns:"li.dropdown",tabs:"li.tab"},activateTab:function(a){this.__ui.dropdowns.removeClass("active"),this.__ui.tabs.removeClass("active");var a=this.__ui.tabs.filter('[data-slug="'+a+'"]');a.addClass("active"),a.parents("li.dropdown").addClass("active")}})}),Neatline.module("Editor.Exhibit.Records",function(a,b){a.ID="EDITOR:EXHIBIT:RECORDS",a.addInitializer(function(){a.__collection=new b.Shared.Record.Collection,a.__router=new a.Router,a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Records",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(b){a.__collection.update(b,function(a){e(a)})};b.commands.setHandler(a.ID+":load",d);var e=function(b){a.__view.ingest(b)};b.commands.setHandler(a.ID+":ingest",e);var f=function(){a.__router.navigate("records",!0)};b.commands.setHandler(a.ID+":navToList",f);var g=function(b,c){a.__collection.getOrFetch(b,c)};b.reqres.setHandler(a.ID+":getModel",g) +}),Neatline.module("Editor.Exhibit.Records",function(a,b){this.Router=b.Editor.Router.extend({routes:{"":"records","records(/search)(/query=:q)(/start=:s)":"records"},records:function(a,c){b.execute("EDITOR:display",["EDITOR:EXHIBIT","EDITOR:EXHIBIT:SEARCH","EDITOR:EXHIBIT:RECORDS"]),b.execute("EDITOR:EXHIBIT:activateTab","records"),b.execute("EDITOR:EXHIBIT:SEARCH:initialize",a,c)}})}),Neatline.module("Editor.Exhibit.Records",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({className:"records",events:{"mouseenter a[data-id]":"onMouseenter","mouseleave a[data-id]":"onMouseleave","click a[data-id]":"onClick"},init:function(){this.template=f.template(e("#record-list-template").html())},ingest:function(a){this.records=a;var c=b.request("EDITOR:EXHIBIT:SEARCH:getQueryForUrl");this.$el.html(this.template({records:this.records,limit:b.g.neatline.per_page,query:c}))},getModelByEvent:function(a){return this.records.get(Number(e(a.currentTarget).attr("data-id")))},onMouseenter:function(c){b.vent.trigger("highlight",{model:this.getModelByEvent(c),source:a.ID})},onMouseleave:function(c){b.vent.trigger("unhighlight",{model:this.getModelByEvent(c),source:a.ID})},onClick:function(c){b.vent.trigger("select",{model:this.getModelByEvent(c),source:a.ID})}})}),Neatline.module("Editor.Exhibit.Search",function(a){a.ID="EDITOR:EXHIBIT:SEARCH",a.addInitializer(function(){a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Search",function(a,b,c,d,e,f){var g=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",g);var h=function(c,d){if(c=c||null,d=d||0,a.__view.setQueryFromUrl(c),!a.__view.mirroring){var e=f.extend(a.__view.query,{limit:b.g.neatline.per_page,offset:d});b.execute("EDITOR:EXHIBIT:RECORDS:load",e)}};b.commands.setHandler(a.ID+":initialize",h);var i=function(c){c=c||b.request("MAP:getRecords"),c&&a.__view.mirroring&&b.execute("EDITOR:EXHIBIT:RECORDS:ingest",c)};b.commands.setHandler(a.ID+":mirrorMap",i),b.vent.on("MAP:ingest",i);var j=function(){return a.__view.getQueryForUrl()};b.reqres.setHandler(a.ID+":getQueryForUrl",j)}),Neatline.module("Editor.Exhibit.Search",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#search-template",className:"search",tagName:"form",events:{"keyup input":"onKeystroke"},ui:{search:"input"},init:function(){this.mirroring=!1},setQueryFromUrl:function(a){f.isString(a)&&(a=a.replace(/\+/g," ")),this.__ui.search.val(a),this.parse()},getQueryForUrl:function(){return this.__ui.search.val().replace(/\s/g,"+")},getUrlFromQuery:function(){var a=this.getQueryForUrl();return""!=a?"records/search/query="+a:"records"},parse:function(){this.query={};var a=this.__ui.search.val();if(this.mirroring=!1,f.string.startsWith(a,"tags:")){var c=f.string.trim(f.string.strRight(a,"tags:"));this.query.tags=c.replace(/\s/g,"").split(","),this.bold()}else f.string.startsWith(a,"map:")?(this.mirroring=!0,b.execute("EDITOR:EXHIBIT:SEARCH:mirrorMap"),this.bold()):f.isEmpty(a)?this.unbold():(this.query.query=a,this.unbold())},onKeystroke:function(){this.parse(),b.execute("EDITOR:setRoute",this.getUrlFromQuery());var a=f.extend(this.query,{limit:b.g.neatline.per_page,offset:0});this.mirroring||b.execute("EDITOR:EXHIBIT:RECORDS:load",a)},bold:function(){this.__ui.search.addClass("bold")},unbold:function(){this.__ui.search.removeClass("bold")}})}),Neatline.module("Editor.Exhibit.Styles",function(a){a.ID="EDITOR:EXHIBIT:STYLES",a.addInitializer(function(){a.__router=new a.Router,a.__view=new a.View})}),Neatline.module("Editor.Exhibit.Styles",function(a,b){var c=function(b){a.__view.showIn(b),a.__view.model.fetch({success:function(){a.__view.buildEditor()}})};b.commands.setHandler(a.ID+":display",c)}),Neatline.module("Editor.Exhibit.Styles",function(a,b){a.Router=b.Editor.Router.extend({routes:{styles:"styles"},styles:function(){b.execute("EDITOR:display",["EDITOR:EXHIBIT","EDITOR:EXHIBIT:STYLES"]),b.execute("EDITOR:EXHIBIT:activateTab","styles")}})}),Neatline.module("Editor.Exhibit.Styles",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#exhibit-styles-template",className:"form-stacked styles",tagName:"form",events:{'click a[name="set-focus"]':"onSetFocus",'click a[name="save"]':"save"},ui:{styles:"#styles",mapFocus:'input[name="map-focus"]',mapZoom:'input[name="map-zoom"]'},init:function(){this.model=new b.Shared.Exhibit.Model,rivets.bind(this.$el,{exhibit:this.model})},buildEditor:function(){this.styles=ace.edit("styles"),this.styles.getSession().setUseWorker(!1),this.styles.getSession().setMode("ace/mode/css"),this.styles.renderer.setShowGutter(!1),this.styles.setHighlightActiveLine(!1),this.styles.getSession().setTabSize(2),this.setStyles(this.model.get("styles")),this.styles.on("change",f.bind(function(){this.model.set("styles",this.getStyles())},this))},getStyles:function(){return this.styles.getSession().getValue()},setStyles:function(a){this.styles.getSession().setValue(a)},onSetFocus:function(){var a=b.request("MAP:getCenter"),c=b.request("MAP:getZoom");this.__ui.mapFocus.val(a.lon+","+a.lat).change(),this.__ui.mapZoom.val(c).change()},save:function(){this.model.save(null,{success:f.bind(this.onSaveSuccess,this),error:f.bind(this.onSaveError,this)})},onSaveSuccess:function(){b.vent.trigger("refresh",{source:a.ID}),b.execute("EDITOR:notifySuccess",STRINGS.exhibit.save.success)},onSaveError:function(){b.execute("EDITOR:notifyError",STRINGS.exhibit.save.error)}})}),Neatline.module("Editor.Record.Map",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:MAP",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Map",{startWithParent:!1,define:function(a,b,c,d,e){a.View=c.Neatline.View.extend({events:{"shown.bs.tab ul.nav a":"onTabChange","change div.map input":"onControlChange","keyup div.map input":"onControlChange",'click a[name="parse"]':"onParseClick",'click a[name="clear"]':"onClearClick"},selectors:{mode:'input[name="mode"]',modify:'input[name="modify"]'},ui:{pan:'input[value="pan"]',sides:'input[name="sides"]',snap:'input[name="snap"]',irreg:'input[name="irreg"]',svg:'textarea[name="svg"]',density:'input[name="density"]',modal:"#svg-modal"},init:function(){this.tab=null},onTabChange:function(a){this.tab=a.target.hash,this.setPresenterStatus(),this.resetEditMode()},onControlChange:function(){b.execute("EDITOR:MAP:updateEdit",{mode:this.getEditMode(),poly:this.getPolyOptions()})},onParseClick:function(){var a=this.__ui.svg.val();try{SVGtoWKT.DENSITY=parseFloat(this.__ui.density.val());var c=SVGtoWKT.convert(a);b.execute("EDITOR:MAP:updateWKT",c),b.execute("EDITOR:notifySuccess",STRINGS.svg.parse.success),this.__ui.modal.modal("hide")}catch(d){b.execute("EDITOR:notifyError",STRINGS.svg.parse.error)}},onClearClick:function(){b.execute("EDITOR:MAP:clearEditLayer")},setPresenterStatus:function(){b.vent.trigger(this.mapTabActive()?"PRESENTER:deactivate":"PRESENTER:activate")},mapTabActive:function(){return"#record-map"==this.tab},resetEditMode:function(){this.__ui.pan[0].checked=!0,this.__ui.pan.trigger("change")},getEditMode:function(){return e(this.selectors.mode+":checked").val()},getPolyOptions:function(){return{sides:this.__ui.sides.val(),snap:this.__ui.snap.val(),irreg:this.__ui.irreg.is(":checked")}}})}}),Neatline.module("Editor.Record",function(a){a.ID="EDITOR:RECORD",a.addInitializer(function(){a.__view=new a.View,a.__router=new a.Router})}),Neatline.module("Editor.Record",function(a,b){var c=function(b){a.__view.showIn(b)};b.commands.setHandler(a.ID+":display",c);var d=function(c,d){b.request("EDITOR:EXHIBIT:RECORDS:getModel",Number(c),function(b){a.__view.bind(b),a.__view.activateTab(d)})};b.commands.setHandler(a.ID+":bindId",d);var e=function(c){var d=new b.Shared.Record.Model;a.__view.bind(d),a.__view.activateTab(c)};b.commands.setHandler(a.ID+":bindNew",e);var f=function(){a.__view.open&&a.__view.unbind()};b.commands.setHandler(a.ID+":unbind",f),b.vent.on("ROUTER:before",f);var g=function(b){a.__view.open||a.__router.navigate("record/"+b.model.id,!0)};b.commands.setHandler(a.ID+":navToForm",g),b.vent.on("select",g);var h=function(b){a.__view.model.set("coverage",b)};b.commands.setHandler(a.ID+":setCoverage",h);var i=function(){return a.__view.$el};b.reqres.setHandler(a.ID+":getElement",i);var j=function(){return a.__view.model};b.reqres.setHandler(a.ID+":getModel",j)}),Neatline.module("Editor.Record",function(a,b){a.Router=b.Editor.Router.extend({routes:{"record/add":"record/add","record/add/:tab":"record/add/:tab","record/:id":"record/:id","record/:id/:tab":"record/:id/:tab"},"record/add":function(){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindNew","text")},"record/add/:tab":function(a){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindNew",a)},"record/:id":function(a){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindId",a,"text")},"record/:id/:tab":function(a,c){b.execute("EDITOR:display",["EDITOR:RECORD"]),b.execute("EDITOR:RECORD:bindId",a,c)}})}),Neatline.module("Editor.Record",function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({template:"#record-form-template",className:"form-stacked record",tagName:"form",events:{"shown.bs.tab ul.nav a":"onTabChange",'click a[name="close"]':"onCloseClick",'click a[name="save"]':"onSaveClick",'click a[name="delete"]':"onDeleteClick"},ui:{tabs:"li.tab a",modal:"#delete-modal"},init:function(){this.open=!1,this.tab=null},bind:function(a){this.model=a,this.open=!0,b.execute("EDITOR:MAP:startEdit",this.model),rivets.bind(this.$el,{record:this.model}),this.listenTo(this.model,"change",f.bind(function(){b.execute("EDITOR:MAP:updateModel",this.model)},this))},unbind:function(){b.execute("EDITOR:MAP:endEdit",this.model),b.vent.trigger("PRESENTER:activate"),b.vent.trigger("unselect",{model:this.model,source:a.ID}),this.stopListening(this.model),this.open=!1},activateTab:function(a){this.__ui.tabs.filter('[data-slug="'+a+'"]').tab("show")},onTabChange:function(a){this.tab=e(a.target).attr("data-slug");var c=this.model.id||"add";b.execute("EDITOR:setRoute","record/"+c+"/"+this.tab),b.vent.trigger("EDITOR:RECORD:#"+this.tab)},onCloseClick:function(){b.execute("EDITOR:EXHIBIT:RECORDS:navToList"),b.vent.trigger("refresh",{source:a.ID}),this.unbind()},onSaveClick:function(){this.model.save(null,{success:f.bind(this.onSaveSuccess,this),error:f.bind(this.onSaveError,this)})},onDeleteClick:function(){this.model.destroy({success:f.bind(this.onDeleteSuccess,this),error:f.bind(this.onDeleteError,this)})},onSaveSuccess:function(){b.execute("EDITOR:notifySuccess",STRINGS.record.save.success),b.execute("EDITOR:setRoute","record/"+this.model.id+"/"+this.tab),b.vent.trigger("refresh",{source:a.ID})},onSaveError:function(){b.execute("EDITOR:notifyError",STRINGS.record.save.error)},onDeleteSuccess:function(){b.execute("EDITOR:notifySuccess",STRINGS.record.remove.success),this.__ui.modal.modal("hide"),this.onCloseClick(),b.vent.trigger("refresh",{source:a.ID})},onDeleteError:function(){b.execute("EDITOR:notifyError",STRINGS.record.remove.error)}})}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:STYLE",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b){var c=function(){a.__view.buildWidgets()};b.commands.setHandler(a.ID+":activate",c),b.vent.on("EDITOR:RECORD:#style",c)}}),Neatline.module("Editor.Record.Style",{startWithParent:!1,define:function(a,b,c,d,e){a.View=c.Neatline.View.extend({events:{'click a[name="set-min-zoom"]':"onSetMinZoom",'click a[name="set-max-zoom"]':"onSetMaxZoom",'click a[name="set-focus"]':"onSetFocus","keyup input.preview":"onStyleKeyup"},ui:{minZoom:'input[name="min-zoom"]',maxZoom:'input[name="max-zoom"]',mapFocus:'input[name="map-focus"]',mapZoom:'input[name="map-zoom"]'},buildWidgets:function(){this.$("input.color").spectrum({move:function(a){e(this).val(a.toHexString()).trigger("change")},showButtons:!1,clickoutFiresChange:!0,showInput:!0}),this.$("input.opacity").draggableInput({type:"float",min:0,max:1,scrollPrecision:.002}),this.$("input.integer").draggableInput({type:"integer",min:0,max:1e3})},onSetMinZoom:function(){var a=b.request("MAP:getZoom");this.__ui.minZoom.val(a).change()},onSetMaxZoom:function(){var a=b.request("MAP:getZoom");this.__ui.maxZoom.val(a).change()},onSetFocus:function(){var a=b.request("MAP:getCenter"),c=b.request("MAP:getZoom");this.__ui.mapFocus.val(a.lon+","+a.lat).change(),this.__ui.mapZoom.val(c).change()},onStyleKeyup:function(a){e(a.target).trigger("change")}})}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b){a.ID="EDITOR:RECORD:TEXT",b.Editor.Record.on("start",function(){a.start()}),a.addInitializer(function(){a.__view=new a.View({el:b.request("EDITOR:RECORD:getElement")})})}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b){var c=function(){a.__view.buildWidgets()};b.commands.setHandler(a.ID+":activate",c),b.vent.on("EDITOR:RECORD:#text",c)}}),Neatline.module("Editor.Record.Text",{startWithParent:!1,define:function(a,b,c,d,e,f){a.View=c.Neatline.View.extend({events:{"click a[data-textarea]":"onEditHtmlClick"},ui:{item:'input[name="item-id"]',title:'textarea[name="title"]',body:'textarea[name="body"]'},buildWidgets:function(){this.__ui.item.autocomplete({source:f.bind(this.onSearch,this),select:f.bind(this.onSelect,this)})},onSearch:function(a,c){e.get(b.g.neatline.items_api,{output:"omeka-xml",search:a.term},function(a){var b=[];e(a).find("item").each(function(a,c){b.push({label:e(c).find('*[elementId="50"] text').first().text(),value:e(c).attr("itemId")})}),c(b)})},onSelect:function(a,b){this.__ui.title.val(b.item.label).change(),this.__ui.item.val(b.item.value).change()},onEditHtmlClick:function(a){var b=e(a.target).attr("data-textarea"),c=CKEDITOR.replace(b),d=e("#"+b);c.on("instanceReady",function(){c.execCommand("maximize"),c.on("maximize",function(){c.destroy(),d.change()})})}})}}),Neatline.module("Editor.Map",{startWithParent:!1,define:function(a){a.ID="EDITOR:MAP",a.addInitializer(function(){a.__collection=Neatline.Map.__collection,a.__view=Neatline.Map.__view,a.__view.__initEditor()})}}),Neatline.module("Editor.Map",{startWithParent:!1,define:function(a){var b=function(b){a.__view.startEdit(b)};Neatline.commands.setHandler(a.ID+":startEdit",b);var c=function(){a.__view.endEdit()};Neatline.commands.setHandler(a.ID+":endEdit",c);var d=function(b){a.__view.updateEdit(b)};Neatline.commands.setHandler(a.ID+":updateEdit",d);var e=function(b){a.__view.updateWKT(b)};Neatline.commands.setHandler(a.ID+":updateWKT",e);var f=function(b){a.__view.updateModel(b)};Neatline.commands.setHandler(a.ID+":updateModel",f);var g=function(){a.__view.clearEditLayer()};Neatline.commands.setHandler(a.ID+":clearEditLayer",g)}}),_.extend(Neatline.Map.View.prototype,{__initEditor:function(){this.editLayer=null},startEdit:function(a){this.editLayer=this.layers.vector[a.id],this.editLayer||(this.editLayer=this.buildVectorLayer(a)),this.map.setLayerIndex(this.editLayer,9999),this.editLayer.nFrozen=!0,this.controls={point:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Point,{featureAdded:_.bind(this.publishWKT,this)}),line:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Path,{featureAdded:_.bind(this.publishWKT,this)}),poly:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Polygon,{featureAdded:_.bind(this.publishWKT,this)}),regPoly:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.RegularPolygon,{featureAdded:_.bind(this.publishWKT,this)}),svg:new OpenLayers.Control.DrawFeature(this.editLayer,OpenLayers.Handler.Geometry,{featureAdded:_.bind(this.publishWKT,this)}),edit:new OpenLayers.Control.ModifyFeature(this.editLayer,{onModification:_.bind(this.publishWKT,this)}),remove:new OpenLayers.Control.ModifyFeature(this.editLayer,{onModificationStart:_.bind(this.removeFeature,this)})},this.map.addControls(_.values(this.controls))},endEdit:function(){this.removeEditorControls(),this.deactivateEditorControls(),this.activatePublicControls(),this.editLayer&&(this.editLayer.nFrozen=!1,this.editLayer=null)},updateEdit:function(a){this.deactivateEditorControls(),this.activatePublicControls();var b=OpenLayers.Control.ModifyFeature;switch(a.mode){case"point":this.controls.point.activate();break;case"line":this.controls.line.activate();break;case"poly":this.controls.poly.activate();break;case"svg":this.controls.svg.activate();break;case"regPoly":this.controls.regPoly.activate();break;case"modify":this.controls.edit.mode=b.RESHAPE,this.activateModifying();break;case"rotate":this.controls.edit.mode=b.ROTATE,this.activateModifying();break;case"resize":this.controls.edit.mode=b.RESIZE,this.activateModifying();break;case"drag":this.controls.edit.mode=b.DRAG,this.activateModifying();break;case"remove":this.controls.remove.activate()}var c=Number(a.poly.snap)||0;this.controls.regPoly.handler.snapAngle=Math.max(0,c);var d=Number(a.poly.sides)||0;this.controls.regPoly.handler.sides=Math.max(3,d),this.controls.regPoly.handler.irregular=a.poly.irreg},activateModifying:function(){this.deactivatePublicControls(),this.controls.edit.activate()},updateWKT:function(a){var b=OpenLayers.Geometry.fromWKT(a);this.controls.svg.handler.setGeometry(b)},updateModel:function(a){a.hasChanged("id")&&(delete this.layers.vector[a.previous("id")],this.layers.vector[a.id]=this.editLayer),this.editLayer.nModel=a,this.editLayer.styleMap=this.getStyleMap(a),this.editLayer.redraw()},publishWKT:function(){var a=[],b=null;_.each(this.editLayer.features,function(b){b._sketch||("OpenLayers.Geometry.Collection"==b.geometry.CLASS_NAME?_.each(b.geometry.components,function(b){a.push(new OpenLayers.Feature.Vector(b))}):a.push(b))}),_.isEmpty(a)||(b=this.formatWkt.write(a)),Neatline.execute("EDITOR:RECORD:setCoverage",b)},deactivateEditorControls:function(){_.each(this.controls,function(a){a.deactivate()})},removeEditorControls:function(){_.each(this.controls,_.bind(function(a){this.map.removeControl(a)},this))},removeFeature:function(a){this.controls.remove.unselectFeature(a),this.editLayer.destroyFeatures([a]),this.publishWKT()},clearEditLayer:function(){this.editLayer.destroyFeatures(),this.publishWKT()}}); \ No newline at end of file diff --git a/views/shared/javascripts/payloads/neatline-public.js b/views/shared/javascripts/payloads/neatline-public.js index 6b055f299..1293ab3f6 100644 --- a/views/shared/javascripts/payloads/neatline-public.js +++ b/views/shared/javascripts/payloads/neatline-public.js @@ -34,4 +34,4 @@ return i.fid=g,i},_getChildValue:function(a,b,c,d){var e,f=this.getElementsByTag }f.push("x e");var j=f.join(" "),k=(e.getWidth()-e.getHeight())/2;return k>0?(e.bottom=e.bottom-k,e.top=e.top+k):(e.left=e.left+k,e.right=e.right-k),c={path:j,size:e.getWidth(),left:e.left,bottom:e.bottom},this.symbolCache[b]=c,c},CLASS_NAME:"OpenLayers.Renderer.VML"}),OpenLayers.Renderer.VML.LABEL_SHIFT={l:0,c:.5,r:1,t:0,m:.5,b:1},OpenLayers.Control.CacheRead=OpenLayers.Class(OpenLayers.Control,{fetchEvent:"tileloadstart",layers:null,autoActivate:!0,setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments);var b,c=this.layers||a.layers;for(b=c.length-1;b>=0;--b)this.addLayer({layer:c[b]});this.layers||a.events.on({addlayer:this.addLayer,removeLayer:this.removeLayer,scope:this})},addLayer:function(a){a.layer.events.register(this.fetchEvent,this,this.fetch)},removeLayer:function(a){a.layer.events.unregister(this.fetchEvent,this,this.fetch)},fetch:function(a){if(this.active&&window.localStorage&&a.tile instanceof OpenLayers.Tile.Image){var b=a.tile,c=b.url;!b.layer.crossOriginKeyword&&OpenLayers.ProxyHost&&0===c.indexOf(OpenLayers.ProxyHost)&&(c=OpenLayers.Control.CacheWrite.urlMap[c]);var d=window.localStorage.getItem("olCache_"+c);d&&(b.url=d,"tileerror"===a.type&&b.setImgSrc(d))}},destroy:function(){if(this.layers||this.map){var a,b=this.layers||this.map.layers;for(a=b.length-1;a>=0;--a)this.removeLayer({layer:b[a]})}this.map&&this.map.events.un({addlayer:this.addLayer,removeLayer:this.removeLayer,scope:this}),OpenLayers.Control.prototype.destroy.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.CacheRead"}),OpenLayers.Protocol.WFS.v1_0_0=OpenLayers.Class(OpenLayers.Protocol.WFS.v1,{version:"1.0.0",CLASS_NAME:"OpenLayers.Protocol.WFS.v1_0_0"}),OpenLayers.Control.WMTSGetFeatureInfo=OpenLayers.Class(OpenLayers.Control,{hover:!1,requestEncoding:"KVP",drillDown:!1,maxFeatures:10,clickCallback:"click",layers:null,queryVisible:!0,infoFormat:"text/html",vendorParams:{},format:null,formatOptions:null,handler:null,hoverRequest:null,pending:0,initialize:function(a){if(a=a||{},a.handlerOptions=a.handlerOptions||{},OpenLayers.Control.prototype.initialize.apply(this,[a]),this.format||(this.format=new OpenLayers.Format.WMSGetFeatureInfo(a.formatOptions)),this.drillDown===!0&&(this.hover=!1),this.hover)this.handler=new OpenLayers.Handler.Hover(this,{move:this.cancelHover,pause:this.getInfoForHover},OpenLayers.Util.extend(this.handlerOptions.hover||{},{delay:250}));else{var b={};b[this.clickCallback]=this.getInfoForClick,this.handler=new OpenLayers.Handler.Click(this,b,this.handlerOptions.click||{})}},getInfoForClick:function(a){this.request(a.xy,{})},getInfoForHover:function(a){this.request(a.xy,{hover:!0})},cancelHover:function(){this.hoverRequest&&(--this.pending,this.pending<=0&&(OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait"),this.pending=0),this.hoverRequest.abort(),this.hoverRequest=null)},findLayers:function(){for(var a,b=this.layers||this.map.layers,c=[],d=b.length-1;d>=0&&(a=b[d],!(a instanceof OpenLayers.Layer.WMTS&&a.requestEncoding===this.requestEncoding)||this.queryVisible&&!a.getVisibility()||(c.push(a),this.drillDown&&!this.hover));--d);return c},buildRequestOptions:function(a,b){var c=this.map.getLonLatFromPixel(b),d=a.getURL(new OpenLayers.Bounds(c.lon,c.lat,c.lon,c.lat)),e=OpenLayers.Util.getParameters(d),f=a.getTileInfo(c);return OpenLayers.Util.extend(e,{service:"WMTS",version:a.version,request:"GetFeatureInfo",infoFormat:this.infoFormat,i:f.i,j:f.j}),OpenLayers.Util.applyDefaults(e,this.vendorParams),{url:OpenLayers.Util.isArray(a.url)?a.url[0]:a.url,params:OpenLayers.Util.upperCaseObject(e),callback:function(c){this.handleResponse(b,c,a)},scope:this}},request:function(a,b){b=b||{};var c=this.findLayers();if(c.length>0){for(var d,e,f=0,g=c.length;g>f;f++)if(e=c[f],d=this.events.triggerEvent("beforegetfeatureinfo",{xy:a,layer:e}),d!==!1){++this.pending;var h=this.buildRequestOptions(e,a),i=OpenLayers.Request.GET(h);b.hover===!0&&(this.hoverRequest=i)}this.pending>0&&OpenLayers.Element.addClass(this.map.viewPortDiv,"olCursorWait")}},handleResponse:function(a,b,c){if(--this.pending,this.pending<=0&&(OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait"),this.pending=0),b.status&&(b.status<200||b.status>=300))this.events.triggerEvent("exception",{xy:a,request:b,layer:c});else{var d=b.responseXML;d&&d.documentElement||(d=b.responseText);var e,f;try{e=this.format.read(d)}catch(g){f=!0,this.events.triggerEvent("exception",{xy:a,request:b,error:g,layer:c})}f||this.events.triggerEvent("getfeatureinfo",{text:b.responseText,features:e,request:b,xy:a,layer:c})}},CLASS_NAME:"OpenLayers.Control.WMTSGetFeatureInfo"}),OpenLayers.Protocol.CSW.v2_0_2=OpenLayers.Class(OpenLayers.Protocol,{formatOptions:null,initialize:function(a){OpenLayers.Protocol.prototype.initialize.apply(this,[a]),a.format||(this.format=new OpenLayers.Format.CSWGetRecords.v2_0_2(OpenLayers.Util.extend({},this.formatOptions)))},destroy:function(){this.options&&!this.options.format&&this.format.destroy(),this.format=null,OpenLayers.Protocol.prototype.destroy.apply(this)},read:function(a){a=OpenLayers.Util.extend({},a),OpenLayers.Util.applyDefaults(a,this.options||{});var b=new OpenLayers.Protocol.Response({requestType:"read"}),c=this.format.write(a.params||a);return b.priv=OpenLayers.Request.POST({url:a.url,callback:this.createCallback(this.handleRead,b,a),params:a.params,headers:a.headers,data:c}),b},handleRead:function(a,b){if(b.callback){var c=a.priv;c.status>=200&&c.status<300?(a.data=this.parseData(c),a.code=OpenLayers.Protocol.Response.SUCCESS):a.code=OpenLayers.Protocol.Response.FAILURE,b.callback.call(b.scope,a)}},parseData:function(a){var b=a.responseXML;return b&&b.documentElement||(b=a.responseText),!b||b.length<=0?null:this.format.read(b)},CLASS_NAME:"OpenLayers.Protocol.CSW.v2_0_2"}),OpenLayers.Control.SLDSelect=OpenLayers.Class(OpenLayers.Control,{clearOnDeactivate:!1,layers:null,callbacks:null,selectionSymbolizer:{Polygon:{fillColor:"#FF0000",stroke:!1},Line:{strokeColor:"#FF0000",strokeWidth:2},Point:{graphicName:"square",fillColor:"#FF0000",pointRadius:5}},layerOptions:null,sketchStyle:null,wfsCache:{},layerCache:{},initialize:function(a,b){OpenLayers.Control.prototype.initialize.apply(this,[b]),this.callbacks=OpenLayers.Util.extend({done:this.select,click:this.select},this.callbacks),this.handlerOptions=this.handlerOptions||{},this.layerOptions=OpenLayers.Util.applyDefaults(this.layerOptions,{displayInLayerSwitcher:!1,tileOptions:{maxGetUrlLength:2048}}),this.sketchStyle&&(this.handlerOptions.layerOptions=OpenLayers.Util.applyDefaults(this.handlerOptions.layerOptions,{styleMap:new OpenLayers.StyleMap({"default":this.sketchStyle})})),this.handler=new a(this,this.callbacks,this.handlerOptions)},destroy:function(){for(var a in this.layerCache)delete this.layerCache[a];for(var a in this.wfsCache)delete this.wfsCache[a];OpenLayers.Control.prototype.destroy.apply(this,arguments)},coupleLayerVisiblity:function(a){this.setVisibility(a.object.getVisibility())},createSelectionLayer:function(a){var b;return this.layerCache[a.id]?b=this.layerCache[a.id]:(b=new OpenLayers.Layer.WMS(a.name,a.url,a.params,OpenLayers.Util.applyDefaults(this.layerOptions,a.getOptions())),this.layerCache[a.id]=b,this.layerOptions.displayInLayerSwitcher===!1&&a.events.on({visibilitychanged:this.coupleLayerVisiblity,scope:b}),this.map.addLayer(b)),b},createSLD:function(a,b,c){for(var d={version:"1.0.0",namedLayers:{}},e=[a.params.LAYERS].join(",").split(","),f=0,g=e.length;g>f;f++){var h=e[f];d.namedLayers[h]={name:h,userStyles:[]};var i=this.selectionSymbolizer,j=c[f];j.type.indexOf("Polygon")>=0?i={Polygon:this.selectionSymbolizer.Polygon}:j.type.indexOf("LineString")>=0?i={Line:this.selectionSymbolizer.Line}:j.type.indexOf("Point")>=0&&(i={Point:this.selectionSymbolizer.Point});var k=b[f];d.namedLayers[h].userStyles.push({name:"default",rules:[new OpenLayers.Rule({symbolizer:i,filter:k,maxScaleDenominator:a.options.minScale})]})}return new OpenLayers.Format.SLD({srsName:this.map.getProjection()}).write(d)},parseDescribeLayer:function(a){var b=new OpenLayers.Format.WMSDescribeLayer,c=a.responseXML;c&&c.documentElement||(c=a.responseText);for(var d=b.read(c),e=[],f=null,g=0,h=d.length;h>g;g++)"WFS"==d[g].owsType&&(e.push(d[g].typeName),f=d[g].owsURL);var i={url:f,params:{SERVICE:"WFS",TYPENAME:e.toString(),REQUEST:"DescribeFeatureType",VERSION:"1.0.0"},callback:function(a){var b=new OpenLayers.Format.WFSDescribeFeatureType,c=a.responseXML;c&&c.documentElement||(c=a.responseText);var d=b.read(c);this.control.wfsCache[this.layer.id]=d,this.control._queue&&this.control.applySelection()},scope:this};OpenLayers.Request.GET(i)},getGeometryAttributes:function(a){for(var b=[],c=this.wfsCache[a.id],d=0,e=c.featureTypes.length;e>d;d++)for(var f=c.featureTypes[d],g=f.properties,h=0,i=g.length;i>h;h++){var j=g[h],k=j.type;(k.indexOf("LineString")>=0||k.indexOf("GeometryAssociationType")>=0||k.indexOf("GeometryPropertyType")>=0||k.indexOf("Point")>=0||k.indexOf("Polygon")>=0)&&b.push(j)}return b},activate:function(){var a=OpenLayers.Control.prototype.activate.call(this);if(a)for(var b=0,c=this.layers.length;c>b;b++){var d=this.layers[b];if(d&&!this.wfsCache[d.id]){var e={url:d.url,params:{SERVICE:"WMS",VERSION:d.params.VERSION,LAYERS:d.params.LAYERS,REQUEST:"DescribeLayer"},callback:this.parseDescribeLayer,scope:{layer:d,control:this}};OpenLayers.Request.GET(e)}}return a},deactivate:function(){var a=OpenLayers.Control.prototype.deactivate.call(this);if(a)for(var b=0,c=this.layers.length;c>b;b++){var d=this.layers[b];if(d&&this.clearOnDeactivate===!0){var e=this.layerCache,f=e[d.id];f&&(d.events.un({visibilitychanged:this.coupleLayerVisiblity,scope:f}),f.destroy(),delete e[d.id])}}return a},setLayers:function(a){this.active?(this.deactivate(),this.layers=a,this.activate()):this.layers=a},createFilter:function(a,b){var c=null;return this.handler instanceof OpenLayers.Handler.RegularPolygon?c=this.handler.irregular===!0?new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,property:a.name,value:b.getBounds()}):new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.INTERSECTS,property:a.name,value:b}):this.handler instanceof OpenLayers.Handler.Polygon?c=new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.INTERSECTS,property:a.name,value:b}):this.handler instanceof OpenLayers.Handler.Path?c=a.type.indexOf("Point")>=0?new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.DWITHIN,property:a.name,distance:.01*this.map.getExtent().getWidth(),distanceUnits:this.map.getUnits(),value:b}):new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.INTERSECTS,property:a.name,value:b}):this.handler instanceof OpenLayers.Handler.Click&&(c=a.type.indexOf("Polygon")>=0?new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.INTERSECTS,property:a.name,value:b}):new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.DWITHIN,property:a.name,distance:.01*this.map.getExtent().getWidth(),distanceUnits:this.map.getUnits(),value:b})),c},select:function(a){this._queue=function(){for(var b=0,c=this.layers.length;c>b;b++){for(var d=this.layers[b],e=this.getGeometryAttributes(d),f=[],g=0,h=e.length;h>g;g++){var i=e[g];if(null!==i){if(!(a instanceof OpenLayers.Geometry)){var j=this.map.getLonLatFromPixel(a.xy);a=new OpenLayers.Geometry.Point(j.lon,j.lat)}var k=this.createFilter(i,a);null!==k&&f.push(k)}}var l=this.createSelectionLayer(d);this.events.triggerEvent("selected",{layer:d,filters:f});var m=this.createSLD(d,f,e);l.mergeNewParams({SLD_BODY:m}),delete this._queue}},this.applySelection()},applySelection:function(){for(var a=!0,b=0,c=this.layers.length;c>b;b++)if(!this.wfsCache[this.layers[b].id]){a=!1;break}a&&this._queue.call(this)},CLASS_NAME:"OpenLayers.Control.SLDSelect"}),OpenLayers.Control.Graticule=OpenLayers.Class(OpenLayers.Control,{autoActivate:!0,intervals:[45,30,20,10,5,2,1,.5,.2,.1,.05,.01,.005,.002,.001],displayInLayerSwitcher:!0,visible:!0,numPoints:50,targetSize:200,layerName:null,labelled:!0,labelFormat:"dm",lineSymbolizer:{strokeColor:"#333",strokeWidth:1,strokeOpacity:.5},labelSymbolizer:{},gratLayer:null,initialize:function(a){a=a||{},a.layerName=a.layerName||OpenLayers.i18n("Graticule"),OpenLayers.Control.prototype.initialize.apply(this,[a]),this.labelSymbolizer.stroke=!1,this.labelSymbolizer.fill=!1,this.labelSymbolizer.label="${label}",this.labelSymbolizer.labelAlign="${labelAlign}",this.labelSymbolizer.labelXOffset="${xOffset}",this.labelSymbolizer.labelYOffset="${yOffset}"},destroy:function(){this.deactivate(),OpenLayers.Control.prototype.destroy.apply(this,arguments),this.gratLayer&&(this.gratLayer.destroy(),this.gratLayer=null)},draw:function(){if(OpenLayers.Control.prototype.draw.apply(this,arguments),!this.gratLayer){var a=new OpenLayers.Style({},{rules:[new OpenLayers.Rule({symbolizer:{Point:this.labelSymbolizer,Line:this.lineSymbolizer}})]});this.gratLayer=new OpenLayers.Layer.Vector(this.layerName,{styleMap:new OpenLayers.StyleMap({"default":a}),visibility:this.visible,displayInLayerSwitcher:this.displayInLayerSwitcher})}return this.div},activate:function(){return OpenLayers.Control.prototype.activate.apply(this,arguments)?(this.map.addLayer(this.gratLayer),this.map.events.register("moveend",this,this.update),this.update(),!0):!1},deactivate:function(){return OpenLayers.Control.prototype.deactivate.apply(this,arguments)?(this.map.events.unregister("moveend",this,this.update),this.map.removeLayer(this.gratLayer),!0):!1},update:function(){var a=this.map.getExtent();if(a){this.gratLayer.destroyFeatures();var b=new OpenLayers.Projection("EPSG:4326"),c=this.map.getProjectionObject(),d=this.map.getResolution();c.proj&&"longlat"==c.proj.projName&&(this.numPoints=1);var e=this.map.getCenter(),f=new OpenLayers.Pixel(e.lon,e.lat);OpenLayers.Projection.transform(f,c,b);var g=this.targetSize*d;g*=g;for(var h,i=0;i=m)break}f.x=Math.floor(f.x/h)*h,f.y=Math.floor(f.y/h)*h;var n,o=0,p=[f.clone()],q=f.clone();do q=q.offset({x:0,y:h}),n=OpenLayers.Projection.transform(q.clone(),b,c),p.unshift(q);while(a.containsPixel(n)&&++o<1e3);q=f.clone();do q=q.offset({x:0,y:-h}),n=OpenLayers.Projection.transform(q.clone(),b,c),p.push(q);while(a.containsPixel(n)&&++o<1e3);o=0;var r=[f.clone()];q=f.clone();do q=q.offset({x:-h,y:0}),n=OpenLayers.Projection.transform(q.clone(),b,c),r.unshift(q);while(a.containsPixel(n)&&++o<1e3);q=f.clone();do q=q.offset({x:h,y:0}),n=OpenLayers.Projection.transform(q.clone(),b,c),r.push(q);while(a.containsPixel(n)&&++o<1e3);for(var s=[],i=0;i=a.bottom&&!v&&(v=B)}if(this.labelled){var C=new OpenLayers.Geometry.Point(v.x,a.bottom),D={value:t,label:this.labelled?OpenLayers.Util.getFormattedLonLat(t,"lon",this.labelFormat):"",labelAlign:"cb",xOffset:0,yOffset:2};this.gratLayer.addFeatures(new OpenLayers.Feature.Vector(C,D))}var E=new OpenLayers.Geometry.LineString(u);s.push(new OpenLayers.Feature.Vector(E))}for(var A=0;Az||z>90)){for(var u=[],F=r[0].x,G=r[r.length-1].x,H=(G-F)/this.numPoints,t=F,v=null,i=0;i<=this.numPoints;++i){var B=new OpenLayers.Geometry.Point(t,z);B.transform(b,c),u.push(B),t+=H,B.x"+a.innerHTML+""},_roundTopCorners:function(a,b,c){for(var d=this._createCorner(c),e=0;e=0;e--)d.appendChild(this._createCornerSlice(b,c,e,"bottom"));a.style.paddingBottom=0,a.appendChild(d)},_createCorner:function(a){var b=document.createElement("div");return b.style.backgroundColor=this._isTransparent()?"transparent":a,b},_createCornerSlice:function(a,b,c,d){var e=document.createElement("span"),f=e.style;f.backgroundColor=a,f.display="block",f.height="1px",f.overflow="hidden",f.fontSize="1px";var g=this._borderColor(a,b);return this.options.border&&0==c?(f.borderTopStyle="solid",f.borderTopWidth="1px",f.borderLeftWidth="0px",f.borderRightWidth="0px",f.borderBottomWidth="0px",f.height="0px",f.borderColor=g):g&&(f.borderColor=g,f.borderStyle="solid",f.borderWidth="0px 1px"),this.options.compact||c!=this.options.numSlices-1||(f.height="2px"),this._setMargin(e,c,d),this._setBorder(e,c,d),e},_setOptions:function(a){this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:!0,border:!1,compact:!1},OpenLayers.Util.extend(this.options,a||{}),this.options.numSlices=this.options.compact?2:4,this._isTransparent()&&(this.options.blend=!1)},_whichSideTop:function(){return this._hasString(this.options.corners,"all","top")?"":this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0?"":this.options.corners.indexOf("tl")>=0?"left":this.options.corners.indexOf("tr")>=0?"right":""},_whichSideBottom:function(){return this._hasString(this.options.corners,"all","bottom")?"":this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0?"":this.options.corners.indexOf("bl")>=0?"left":this.options.corners.indexOf("br")>=0?"right":""},_borderColor:function(a,b){return"transparent"==a?b:this.options.border?this.options.border:this.options.blend?this._blend(b,a):""},_setMargin:function(a,b,c){var d=this._marginSize(b),e="top"==c?this._whichSideTop():this._whichSideBottom();"left"==e?(a.style.marginLeft=d+"px",a.style.marginRight="0px"):"right"==e?(a.style.marginRight=d+"px",a.style.marginLeft="0px"):(a.style.marginLeft=d+"px",a.style.marginRight=d+"px")},_setBorder:function(a,b,c){var d=this._borderSize(b),e="top"==c?this._whichSideTop():this._whichSideBottom();"left"==e?(a.style.borderLeftWidth=d+"px",a.style.borderRightWidth="0px"):"right"==e?(a.style.borderRightWidth=d+"px",a.style.borderLeftWidth="0px"):(a.style.borderLeftWidth=d+"px",a.style.borderRightWidth=d+"px"),0!=this.options.border&&(a.style.borderLeftWidth=d+"px",a.style.borderRightWidth=d+"px")},_marginSize:function(a){if(this._isTransparent())return 0;var b=[5,3,2,1],c=[3,2,1,0],d=[2,1],e=[1,0];return this.options.compact&&this.options.blend?e[a]:this.options.compact?d[a]:this.options.blend?c[a]:b[a]},_borderSize:function(a){var b=[5,3,2,1],c=[2,1,1,1],d=[1,0],e=[0,2,0,0];return this.options.compact&&(this.options.blend||this._isTransparent())?1:this.options.compact?d[a]:this.options.blend?c[a]:this.options.border?e[a]:this._isTransparent()?b[a]:0},_hasString:function(a){for(var b=1;b=0)return!0;return!1},_blend:function(a,b){var c=OpenLayers.Rico.Color.createFromHex(a);return c.blend(OpenLayers.Rico.Color.createFromHex(b)),c},_background:function(a){try{return OpenLayers.Rico.Color.createColorFromBackground(a).asHex()}catch(b){return"#ffffff"}},_isTransparent:function(){return"transparent"==this.options.color},_isTopRounded:function(){return this._hasString(this.options.corners,"all","top","tl","tr")},_isBottomRounded:function(){return this._hasString(this.options.corners,"all","bottom","bl","br")},_hasSingleTextChild:function(a){return 1==a.childNodes.length&&3==a.childNodes[0].nodeType}},OpenLayers.Layer.UTFGrid=OpenLayers.Class(OpenLayers.Layer.XYZ,{isBaseLayer:!1,projection:new OpenLayers.Projection("EPSG:900913"),useJSONP:!1,tileClass:OpenLayers.Tile.UTFGrid,initialize:function(a){OpenLayers.Layer.Grid.prototype.initialize.apply(this,[a.name,a.url,{},a]),this.tileOptions=OpenLayers.Util.extend({utfgridResolution:this.utfgridResolution},this.tileOptions)},createBackBuffer:function(){},clone:function(a){return null==a&&(a=new OpenLayers.Layer.UTFGrid(this.getOptions())),a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a])},getFeatureInfo:function(a){var b=null,c=this.getTileData(a);return c&&c.tile&&(b=c.tile.getFeatureInfo(c.i,c.j)),b},getFeatureId:function(a){var b=null,c=this.getTileData(a);return c.tile&&(b=c.tile.getFeatureId(c.i,c.j)),b},CLASS_NAME:"OpenLayers.Layer.UTFGrid"}),OpenLayers.TileManager=OpenLayers.Class({cacheSize:256,tilesPerFrame:2,frameDelay:16,moveDelay:100,zoomDelay:200,maps:null,tileQueueId:null,tileQueue:null,tileCache:null,tileCacheIndex:null,initialize:function(a){OpenLayers.Util.extend(this,a),this.maps=[],this.tileQueueId={},this.tileQueue={},this.tileCache={},this.tileCacheIndex=[]},addMap:function(a){if(!this._destroyed&&OpenLayers.Layer.Grid){this.maps.push(a),this.tileQueue[a.id]=[];for(var b=0,c=a.layers.length;c>b;++b)this.addLayer({layer:a.layers[b]});a.events.on({move:this.move,zoomend:this.zoomEnd,changelayer:this.changeLayer,addlayer:this.addLayer,preremovelayer:this.removeLayer,scope:this})}},removeMap:function(a){if(!this._destroyed&&OpenLayers.Layer.Grid){if(window.clearTimeout(this.tileQueueId[a.id]),a.layers)for(var b=0,c=a.layers.length;c>b;++b)this.removeLayer({layer:a.layers[b]});a.events&&a.events.un({move:this.move,zoomend:this.zoomEnd,changelayer:this.changeLayer,addlayer:this.addLayer,preremovelayer:this.removeLayer,scope:this}),delete this.tileQueue[a.id],delete this.tileQueueId[a.id],OpenLayers.Util.removeItem(this.maps,a)}},move:function(a){this.updateTimeout(a.object,this.moveDelay,!0)},zoomEnd:function(a){this.updateTimeout(a.object,this.zoomDelay)},changeLayer:function(a){("visibility"===a.property||"params"===a.property)&&this.updateTimeout(a.object,0)},addLayer:function(a){var b=a.layer;if(b instanceof OpenLayers.Layer.Grid){b.events.on({addtile:this.addTile,retile:this.clearTileQueue,scope:this});var c,d,e;for(c=b.grid.length-1;c>=0;--c)for(d=b.grid[c].length-1;d>=0;--d)e=b.grid[c][d],this.addTile({tile:e}),e.url&&!e.imgDiv&&this.manageTileCache({object:e})}},removeLayer:function(a){var b=a.layer;if(b instanceof OpenLayers.Layer.Grid&&(this.clearTileQueue({object:b}),b.events&&b.events.un({addtile:this.addTile,retile:this.clearTileQueue,scope:this}),b.grid)){var c,d,e;for(c=b.grid.length-1;c>=0;--c)for(d=b.grid[c].length-1;d>=0;--d)e=b.grid[c][d],this.unloadTile({object:e})}},updateTimeout:function(a,b,c){window.clearTimeout(this.tileQueueId[a.id]);var d=this.tileQueue[a.id];(!c||d.length)&&(this.tileQueueId[a.id]=window.setTimeout(OpenLayers.Function.bind(function(){this.drawTilesFromQueue(a),d.length&&this.updateTimeout(a,this.frameDelay)},this),b))},addTile:function(a){a.tile instanceof OpenLayers.Tile.Image?a.tile.events.on({beforedraw:this.queueTileDraw,beforeload:this.manageTileCache,loadend:this.addToCache,unload:this.unloadTile,scope:this}):this.removeLayer({layer:a.tile.layer})},unloadTile:function(a){var b=a.object;b.events.un({beforedraw:this.queueTileDraw,beforeload:this.manageTileCache,loadend:this.addToCache,unload:this.unloadTile,scope:this}),OpenLayers.Util.removeItem(this.tileQueue[b.layer.map.id],b)},queueTileDraw:function(a){var b=a.object,c=!1,d=b.layer,e=d.getURL(b.bounds),f=this.tileCache[e];if(f&&"olTileImage"!==f.className&&(delete this.tileCache[e],OpenLayers.Util.removeItem(this.tileCacheIndex,e),f=null),d.url&&(d.async||!f)){var g=this.tileQueue[d.map.id];~OpenLayers.Util.indexOf(g,b)||g.push(b),c=!0}return!c},drawTilesFromQueue:function(a){for(var b=this.tileQueue[a.id],c=this.tilesPerFrame,d=a.zoomTween&&a.zoomTween.playing;!d&&b.length&&c;)b.shift().draw(!0),--c},manageTileCache:function(a){var b=a.object,c=this.tileCache[b.url];c&&(c.parentNode&&OpenLayers.Element.hasClass(c.parentNode,"olBackBuffer")&&(c.parentNode.removeChild(c),c.id=null),c.parentNode||(c.style.visibility="hidden",c.style.opacity=0,b.setImage(c),OpenLayers.Util.removeItem(this.tileCacheIndex,b.url),this.tileCacheIndex.push(b.url)))},addToCache:function(a){var b=a.object;this.tileCache[b.url]||OpenLayers.Element.hasClass(b.imgDiv,"olImageLoadError")||(this.tileCacheIndex.length>=this.cacheSize&&(delete this.tileCache[this.tileCacheIndex[0]],this.tileCacheIndex.shift()),this.tileCache[b.url]=b.imgDiv,this.tileCacheIndex.push(b.url))},clearTileQueue:function(a){for(var b=a.object,c=this.tileQueue[b.map.id],d=c.length-1;d>=0;--d)c[d].layer===b&&c.splice(d,1)},destroy:function(){for(var a=this.maps.length-1;a>=0;--a)this.removeMap(this.maps[a]);this.maps=null,this.tileQueue=null,this.tileQueueId=null,this.tileCache=null,this.tileCacheIndex=null,this._destroyed=!0}}),OpenLayers.Handler.Geometry=OpenLayers.Class(OpenLayers.Handler.Drag,{layerOptions:null,geometry:null,feature:null,angle:0,width:null,layer:null,origin:null,wkt:null,initialize:function(a,b,c){c&&c.layerOptions&&c.layerOptions.styleMap||(this.style=OpenLayers.Util.extend(OpenLayers.Feature.Vector.style["default"],{})),OpenLayers.Handler.Drag.prototype.initialize.apply(this,[a,b,c]),this.options=c?c:{}},setOptions:function(a){OpenLayers.Util.extend(this.options,a),OpenLayers.Util.extend(this,a)},setGeometry:function(a){this.geometry=a},activate:function(){var a=!1;return OpenLayers.Handler.Drag.prototype.activate.apply(this,arguments)&&(this.layer=new OpenLayers.Layer.Vector(this.CLASS_NAME,OpenLayers.Util.extend({displayInLayerSwitcher:!1,calculateInRange:OpenLayers.Function.True},this.layerOptions)),this.map.addLayer(this.layer),a=!0),a},deactivate:function(){var a=!1;return OpenLayers.Handler.Drag.prototype.deactivate.apply(this,arguments)&&(null!==this.layer.map&&(this.layer.destroy(!1),this.feature&&this.feature.destroy()),this.layer=null,this.feature=null,a=!0),a},down:function(a){if(this.geometry){this.clear(),this.dragGeometry=this.geometry.clone();var b=this.layer.getLonLatFromViewPortPx(a.xy);this.origin=new OpenLayers.Geometry.Point(b.lon,b.lat),this.radius=this.measureWidth(),this.feature=new OpenLayers.Feature.Vector,this.feature.geometry=this.dragGeometry,this.layer.addFeatures([this.feature],{silent:!0});var c=b.lon-this.dragGeometry.bounds.left,d=b.lat-this.dragGeometry.bounds.bottom;this.dragGeometry.move(c,d),this.callback("create",[this.origin,this.feature])}},move:function(a){if(this.geometry){var b=this.layer.getLonLatFromViewPortPx(a.xy),c=new OpenLayers.Geometry.Point(b.lon,b.lat),d=this.angle;this.angle=this.calculateAngle(c,a),this.dragGeometry.rotate(this.angle-d,this.origin);var e=this.radius;this.radius=c.distanceTo(this.origin),this.dragGeometry.resize(this.radius/e,this.origin),this.layer.drawFeature(this.feature,this.style)}},calculateAngle:function(a){return Math.atan2(a.y-this.origin.y,a.x-this.origin.x)*(180/Math.PI)},measureWidth:function(){return this.dragGeometry.calculateBounds(),Math.abs(this.dragGeometry.bounds.right-this.dragGeometry.bounds.left)},up:function(){this.finalize()},out:function(){this.finalize()},cancel:function(){this.callback("cancel",null),this.finalize()},finalize:function(){this.origin=null,this.angle=0},clear:function(){this.layer&&(this.layer.renderer.clear(),this.layer.destroyFeatures())},callback:function(a){this.geometry&&(("done"==a||"cancel"==a)&&this.clear(),this.callbacks[a]&&this.callbacks[a].apply(this.control,[this.dragGeometry.clone()]))},CLASS_NAME:"OpenLayers.Handler.Geometry"}),OpenLayers.Protocol.Script=OpenLayers.Class(OpenLayers.Protocol,{url:null,params:null,callback:null,callbackTemplate:"OpenLayers.Protocol.Script.registry.${id}",callbackKey:"callback",callbackPrefix:"",scope:null,format:null,pendingRequests:null,srsInBBOX:!1,initialize:function(a){if(a=a||{},this.params={},this.pendingRequests={},OpenLayers.Protocol.prototype.initialize.apply(this,arguments),this.format||(this.format=new OpenLayers.Format.GeoJSON),!this.filterToParams&&OpenLayers.Format.QueryStringFilter){var b=new OpenLayers.Format.QueryStringFilter({srsInBBOX:this.srsInBBOX}); this.filterToParams=function(a,c){return b.write(a,c)}}},read:function(a){OpenLayers.Protocol.prototype.read.apply(this,arguments),a=OpenLayers.Util.applyDefaults(a,this.options),a.params=OpenLayers.Util.applyDefaults(a.params,this.options.params),a.filter&&this.filterToParams&&(a.params=this.filterToParams(a.filter,a.params));var b=new OpenLayers.Protocol.Response({requestType:"read"}),c=this.createRequest(a.url,a.params,OpenLayers.Function.bind(function(c){b.data=c,this.handleRead(b,a)},this));return b.priv=c,b},createRequest:function(a,b,c){var d=OpenLayers.Protocol.Script.register(c),e=OpenLayers.String.format(this.callbackTemplate,{id:d});b=OpenLayers.Util.extend({},b),b[this.callbackKey]=this.callbackPrefix+e,a=OpenLayers.Util.urlAppend(a,OpenLayers.Util.getParameterString(b));var f=document.createElement("script");f.type="text/javascript",f.src=a,f.id="OpenLayers_Protocol_Script_"+d,this.pendingRequests[f.id]=f;var g=document.getElementsByTagName("head")[0];return g.appendChild(f),f},destroyRequest:function(a){OpenLayers.Protocol.Script.unregister(a.id.split("_").pop()),delete this.pendingRequests[a.id],a.parentNode&&a.parentNode.removeChild(a)},handleRead:function(a,b){this.handleResponse(a,b)},handleResponse:function(a,b){b.callback&&(a.data?(a.features=this.parseFeatures(a.data),a.code=OpenLayers.Protocol.Response.SUCCESS):a.code=OpenLayers.Protocol.Response.FAILURE,this.destroyRequest(a.priv),b.callback.call(b.scope,a))},parseFeatures:function(a){return this.format.read(a)},abort:function(a){if(a)this.destroyRequest(a.priv);else for(var b in this.pendingRequests)this.destroyRequest(this.pendingRequests[b])},destroy:function(){this.abort(),delete this.params,delete this.format,OpenLayers.Protocol.prototype.destroy.apply(this)},CLASS_NAME:"OpenLayers.Protocol.Script"}),function(){var a=OpenLayers.Protocol.Script,b=0;a.registry={},a.register=function(c){var d="c"+ ++b;return a.registry[d]=function(){c.apply(this,arguments)},d},a.unregister=function(b){delete a.registry[b]}}(),OpenLayers.Control.TransformFeature=OpenLayers.Class(OpenLayers.Control,{geometryTypes:null,layer:null,preserveAspectRatio:!1,rotate:!0,feature:null,renderIntent:"temporary",rotationHandleSymbolizer:null,box:null,center:null,scale:1,ratio:1,rotation:0,handles:null,rotationHandles:null,dragControl:null,irregular:!1,initialize:function(a,b){OpenLayers.Control.prototype.initialize.apply(this,[b]),this.layer=a,this.rotationHandleSymbolizer||(this.rotationHandleSymbolizer={stroke:!1,pointRadius:10,fillOpacity:0,cursor:"pointer"}),this.createBox(),this.createControl()},activate:function(){var a=!1;return OpenLayers.Control.prototype.activate.apply(this,arguments)&&(this.dragControl.activate(),this.layer.addFeatures([this.box]),this.rotate&&this.layer.addFeatures(this.rotationHandles),this.layer.addFeatures(this.handles),a=!0),a},deactivate:function(){var a=!1;return OpenLayers.Control.prototype.deactivate.apply(this,arguments)&&(this.layer.removeFeatures(this.handles),this.rotate&&this.layer.removeFeatures(this.rotationHandles),this.layer.removeFeatures([this.box]),this.dragControl.deactivate(),a=!0),a},setMap:function(a){this.dragControl.setMap(a),OpenLayers.Control.prototype.setMap.apply(this,arguments)},setFeature:function(a,b){b=OpenLayers.Util.applyDefaults(b,{rotation:0,scale:1,ratio:1});var c=this.rotation,d=this.center;OpenLayers.Util.extend(this,b);var e=this.events.triggerEvent("beforesetfeature",{feature:a});if(e!==!1){this.feature=a,this.activate(),this._setfeature=!0;var f=this.feature.geometry.getBounds();this.box.move(f.getCenterLonLat()),this.box.geometry.rotate(-c,d),this._angle=0;var g;if(this.rotation){var h=a.geometry.clone();h.rotate(-this.rotation,this.center);var i=new OpenLayers.Feature.Vector(h.getBounds().toGeometry());i.geometry.rotate(this.rotation,this.center),this.box.geometry.rotate(this.rotation,this.center),this.box.move(i.geometry.getBounds().getCenterLonLat());var j=i.geometry.components[0].components[0];g=j.getBounds().getCenterLonLat()}else g=new OpenLayers.LonLat(f.left,f.bottom);this.handles[0].move(g),delete this._setfeature,this.events.triggerEvent("setfeature",{feature:a})}},unsetFeature:function(){this.active?this.deactivate():(this.feature=null,this.rotation=0,this.scale=1,this.ratio=1)},createBox:function(){var a=this;this.center=new OpenLayers.Geometry.Point(0,0),this.box=new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(-1,-1),new OpenLayers.Geometry.Point(0,-1),new OpenLayers.Geometry.Point(1,-1),new OpenLayers.Geometry.Point(1,0),new OpenLayers.Geometry.Point(1,1),new OpenLayers.Geometry.Point(0,1),new OpenLayers.Geometry.Point(-1,1),new OpenLayers.Geometry.Point(-1,0),new OpenLayers.Geometry.Point(-1,-1)]),null,"string"==typeof this.renderIntent?null:this.renderIntent),this.box.geometry.move=function(b,c){a._moving=!0,OpenLayers.Geometry.LineString.prototype.move.apply(this,arguments),a.center.move(b,c),delete a._moving};for(var b,c,d,e=function(a,b){OpenLayers.Geometry.Point.prototype.move.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.move(a,b),this._handle.geometry.move(a,b)},f=function(a,b,c){OpenLayers.Geometry.Point.prototype.resize.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.resize(a,b,c),this._handle.geometry.resize(a,b,c)},g=function(a,b){OpenLayers.Geometry.Point.prototype.rotate.apply(this,arguments),this._rotationHandle&&this._rotationHandle.geometry.rotate(a,b),this._handle.geometry.rotate(a,b)},h=function(b,c){var d=this.x,e=this.y;if(OpenLayers.Geometry.Point.prototype.move.call(this,b,c),!a._moving){var f=a.dragControl.handlers.drag.evt,g=!a._setfeature&&a.preserveAspectRatio,h=!(g||f&&f.shiftKey),i=new OpenLayers.Geometry.Point(d,e),j=a.center;this.rotate(-a.rotation,j),i.rotate(-a.rotation,j);var k=this.x-j.x,l=this.y-j.y,m=k-(this.x-i.x),n=l-(this.y-i.y);a.irregular&&!a._setfeature&&(k-=(this.x-i.x)/2,l-=(this.y-i.y)/2),this.x=d,this.y=e;var o,p=1;if(h)o=Math.abs(n)<1e-5?1:l/n,p=(Math.abs(m)<1e-5?1:k/m)/o;else{var q=Math.sqrt(m*m+n*n),r=Math.sqrt(k*k+l*l);o=r/q}if(a._moving=!0,a.box.geometry.rotate(-a.rotation,j),delete a._moving,a.box.geometry.resize(o,j,p),a.box.geometry.rotate(a.rotation,j),a.transformFeature({scale:o,ratio:p}),a.irregular&&!a._setfeature){var s=j.clone();s.x+=Math.abs(d-j.x)<1e-5?0:this.x-d,s.y+=Math.abs(e-j.y)<1e-5?0:this.y-e,a.box.geometry.move(this.x-d,this.y-e),a.transformFeature({center:s})}}},i=function(b,c){var d=this.x,e=this.y;if(OpenLayers.Geometry.Point.prototype.move.call(this,b,c),!a._moving){var f=a.dragControl.handlers.drag.evt,g=f&&f.shiftKey?45:1,h=a.center,i=this.x-h.x,j=this.y-h.y,k=i-b,l=j-c;this.x=d,this.y=e;var m=Math.atan2(l,k),n=Math.atan2(j,i),o=n-m;o*=180/Math.PI,a._angle=(a._angle+o)%360;var p=a.rotation%g;(Math.abs(a._angle)>=g||0!==p)&&(o=Math.round(a._angle/g)*g-p,a._angle=0,a.box.geometry.rotate(o,h),a.transformFeature({rotation:o}))}},j=new Array(8),k=new Array(4),l=["sw","s","se","e","ne","n","nw","w"],m=0;8>m;++m)b=this.box.geometry.components[m],c=new OpenLayers.Feature.Vector(b.clone(),{role:l[m]+"-resize"},"string"==typeof this.renderIntent?null:this.renderIntent),0==m%2&&(d=new OpenLayers.Feature.Vector(b.clone(),{role:l[m]+"-rotate"},"string"==typeof this.rotationHandleSymbolizer?null:this.rotationHandleSymbolizer),d.geometry.move=i,b._rotationHandle=d,k[m/2]=d),b.move=e,b.resize=f,b.rotate=g,c.geometry.move=h,b._handle=c,j[m]=c;this.rotationHandles=k,this.handles=j},createControl:function(){var a=this;this.dragControl=new OpenLayers.Control.DragFeature(this.layer,{documentDrag:!0,moveFeature:function(){this.feature===a.feature&&(this.feature=a.box),OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,arguments)},onDrag:function(b){b===a.box&&a.transformFeature({center:a.center})},onStart:function(b){var c=!a.geometryTypes||-1!==OpenLayers.Util.indexOf(a.geometryTypes,b.geometry.CLASS_NAME),d=OpenLayers.Util.indexOf(a.handles,b);d+=OpenLayers.Util.indexOf(a.rotationHandles,b),b!==a.feature&&b!==a.box&&-2==d&&c&&a.setFeature(b)},onComplete:function(){a.events.triggerEvent("transformcomplete",{feature:a.feature})}})},drawHandles:function(){for(var a=this.layer,b=0;8>b;++b)this.rotate&&0===b%2&&a.drawFeature(this.rotationHandles[b/2],this.rotationHandleSymbolizer),a.drawFeature(this.handles[b],this.renderIntent)},transformFeature:function(a){if(!this._setfeature){this.scale*=a.scale||1,this.ratio*=a.ratio||1;var b=this.rotation;if(this.rotation=(this.rotation+(a.rotation||0))%360,this.events.triggerEvent("beforetransform",a)!==!1){var c=this.feature,d=c.geometry,e=this.center;d.rotate(-b,e),a.scale||a.ratio?d.resize(a.scale,e,a.ratio):a.center&&c.move(a.center.getBounds().getCenterLonLat()),d.rotate(this.rotation,e),this.layer.drawFeature(c),c.toState(OpenLayers.State.UPDATE),this.events.triggerEvent("transform",a)}}this.layer.drawFeature(this.box,this.renderIntent),this.drawHandles()},destroy:function(){for(var a,b=0;8>b;++b)a=this.box.geometry.components[b],a._handle.destroy(),a._handle=null,a._rotationHandle&&a._rotationHandle.destroy(),a._rotationHandle=null;this.center=null,this.feature=null,this.handles=null,this.rotationHandleSymbolizer=null,this.rotationHandles=null,this.box.destroy(),this.box=null,this.layer=null,this.dragControl.destroy(),this.dragControl=null,OpenLayers.Control.prototype.destroy.apply(this,arguments)},CLASS_NAME:"OpenLayers.Control.TransformFeature"}),OpenLayers.Layer.ArcGISCache=OpenLayers.Class(OpenLayers.Layer.XYZ,{url:null,tileOrigin:null,tileSize:new OpenLayers.Size(256,256),useArcGISServer:!0,type:"png",useScales:!1,overrideDPI:!1,initialize:function(){if(OpenLayers.Layer.XYZ.prototype.initialize.apply(this,arguments),this.resolutions&&(this.serverResolutions=this.resolutions,this.maxExtent=this.getMaxExtentForResolution(this.resolutions[0])),this.layerInfo){var a=this.layerInfo,b=new OpenLayers.Bounds(a.fullExtent.xmin,a.fullExtent.ymin,a.fullExtent.xmax,a.fullExtent.ymax);if(this.projection="EPSG:"+a.spatialReference.wkid,this.sphericalMercator=102100==a.spatialReference.wkid,this.units="esriFeet"==a.units?"ft":"m",a.tileInfo){this.tileSize=new OpenLayers.Size(a.tileInfo.width||a.tileInfo.cols,a.tileInfo.height||a.tileInfo.rows),this.tileOrigin=new OpenLayers.LonLat(a.tileInfo.origin.x,a.tileInfo.origin.y);var c=new OpenLayers.Geometry.Point(b.left,b.top),d=new OpenLayers.Geometry.Point(b.right,b.bottom);this.useScales?this.scales=[]:this.resolutions=[],this.lods=[];for(var e in a.tileInfo.lods)if(a.tileInfo.lods.hasOwnProperty(e)){var f=a.tileInfo.lods[e];this.useScales?this.scales.push(f.scale):this.resolutions.push(f.resolution);var g=this.getContainingTileCoords(c,f.resolution);f.startTileCol=g.x,f.startTileRow=g.y;var h=this.getContainingTileCoords(d,f.resolution);f.endTileCol=h.x,f.endTileRow=h.y,this.lods.push(f)}this.maxExtent=this.calculateMaxExtentWithLOD(this.lods[0]),this.serverResolutions=this.resolutions,this.overrideDPI&&a.tileInfo.dpi&&(OpenLayers.DOTS_PER_INCH=a.tileInfo.dpi)}}},getContainingTileCoords:function(a,b){return new OpenLayers.Pixel(Math.max(Math.floor((a.x-this.tileOrigin.lon)/(this.tileSize.w*b)),0),Math.max(Math.floor((this.tileOrigin.lat-a.y)/(this.tileSize.h*b)),0))},calculateMaxExtentWithLOD:function(a){var b=a.endTileCol-a.startTileCol+1,c=a.endTileRow-a.startTileRow+1,d=this.tileOrigin.lon+a.startTileCol*this.tileSize.w*a.resolution,e=d+b*this.tileSize.w*a.resolution,f=this.tileOrigin.lat-a.startTileRow*this.tileSize.h*a.resolution,g=f-c*this.tileSize.h*a.resolution;return new OpenLayers.Bounds(d,g,e,f)},calculateMaxExtentWithExtent:function(a,b){var c=new OpenLayers.Geometry.Point(a.left,a.top),d=new OpenLayers.Geometry.Point(a.right,a.bottom),e=this.getContainingTileCoords(c,b),f=this.getContainingTileCoords(d,b),g={resolution:b,startTileCol:e.x,startTileRow:e.y,endTileCol:f.x,endTileRow:f.y};return this.calculateMaxExtentWithLOD(g)},getUpperLeftTileCoord:function(a){var b=new OpenLayers.Geometry.Point(this.maxExtent.left,this.maxExtent.top);return this.getContainingTileCoords(b,a)},getLowerRightTileCoord:function(a){var b=new OpenLayers.Geometry.Point(this.maxExtent.right,this.maxExtent.bottom);return this.getContainingTileCoords(b,a)},getMaxExtentForResolution:function(a){var b=this.getUpperLeftTileCoord(a),c=this.getLowerRightTileCoord(a),d=c.x-b.x+1,e=c.y-b.y+1,f=this.tileOrigin.lon+b.x*this.tileSize.w*a,g=f+d*this.tileSize.w*a,h=this.tileOrigin.lat-b.y*this.tileSize.h*a,i=h-e*this.tileSize.h*a;return new OpenLayers.Bounds(f,i,g,h)},clone:function(a){return null==a&&(a=new OpenLayers.Layer.ArcGISCache(this.name,this.url,this.options)),OpenLayers.Layer.XYZ.prototype.clone.apply(this,[a])},initGriddedTiles:function(){delete this._tileOrigin,OpenLayers.Layer.XYZ.prototype.initGriddedTiles.apply(this,arguments)},getMaxExtent:function(){var a=this.map.getResolution();return this.maxExtent=this.getMaxExtentForResolution(a)},getTileOrigin:function(){if(!this._tileOrigin){var a=this.getMaxExtent();this._tileOrigin=new OpenLayers.LonLat(a.left,a.bottom)}return this._tileOrigin},getURL:function(a){var b=this.getResolution(),c=this.tileOrigin.lon+b*this.tileSize.w/2,d=this.tileOrigin.lat-b*this.tileSize.h/2,e=a.getCenterLonLat();({x:e.lon,y:e.lat});var f=Math.round(Math.abs((e.lon-c)/(b*this.tileSize.w))),g=Math.round(Math.abs((d-e.lat)/(b*this.tileSize.h))),h=this.map.getZoom();if(this.lods){var i=this.lods[this.map.getZoom()];if(fi.endTileCol||gi.endTileRow)return null}else{var j=this.getUpperLeftTileCoord(b),k=this.getLowerRightTileCoord(b);if(f=k.x||g=k.y)return null}var l=this.url,m=""+f+g+h;return OpenLayers.Util.isArray(l)&&(l=this.selectUrl(m,l)),this.useArcGISServer?l+="/tile/${z}/${y}/${x}":(f="C"+OpenLayers.Number.zeroPad(f,8,16),g="R"+OpenLayers.Number.zeroPad(g,8,16),h="L"+OpenLayers.Number.zeroPad(h,2,10),l=l+"/${z}/${y}/${x}."+this.type),l=OpenLayers.String.format(l,{x:f,y:g,z:h}),OpenLayers.Util.urlAppend(l,OpenLayers.Util.getParameterString(this.params))},CLASS_NAME:"OpenLayers.Layer.ArcGISCache"}),OpenLayers.Control.WMSGetFeatureInfo=OpenLayers.Class(OpenLayers.Control,{hover:!1,drillDown:!1,maxFeatures:10,clickCallback:"click",output:"features",layers:null,queryVisible:!1,url:null,layerUrls:null,infoFormat:"text/html",vendorParams:{},format:null,formatOptions:null,handler:null,hoverRequest:null,initialize:function(a){if(a=a||{},a.handlerOptions=a.handlerOptions||{},OpenLayers.Control.prototype.initialize.apply(this,[a]),this.format||(this.format=new OpenLayers.Format.WMSGetFeatureInfo(a.formatOptions)),this.drillDown===!0&&(this.hover=!1),this.hover)this.handler=new OpenLayers.Handler.Hover(this,{move:this.cancelHover,pause:this.getInfoForHover},OpenLayers.Util.extend(this.handlerOptions.hover||{},{delay:250}));else{var b={};b[this.clickCallback]=this.getInfoForClick,this.handler=new OpenLayers.Handler.Click(this,b,this.handlerOptions.click||{})}},getInfoForClick:function(a){this.events.triggerEvent("beforegetfeatureinfo",{xy:a.xy}),OpenLayers.Element.addClass(this.map.viewPortDiv,"olCursorWait"),this.request(a.xy,{})},getInfoForHover:function(a){this.events.triggerEvent("beforegetfeatureinfo",{xy:a.xy}),this.request(a.xy,{hover:!0})},cancelHover:function(){this.hoverRequest&&(this.hoverRequest.abort(),this.hoverRequest=null)},findLayers:function(){for(var a,b,c=this.layers||this.map.layers,d=[],e=c.length-1;e>=0;--e)a=c[e],a instanceof OpenLayers.Layer.WMS&&(!this.queryVisible||a.getVisibility())&&(b=OpenLayers.Util.isArray(a.url)?a.url[0]:a.url,this.drillDown!==!1||this.url||(this.url=b),(this.drillDown===!0||this.urlMatches(b))&&d.push(a));return d},urlMatches:function(a){var b=OpenLayers.Util.isEquivalentUrl(this.url,a);if(!b&&this.layerUrls)for(var c=0,d=this.layerUrls.length;d>c;++c)if(OpenLayers.Util.isEquivalentUrl(this.layerUrls[c],a)){b=!0;break}return b},buildWMSOptions:function(a,b,c,d){for(var e=[],f=[],g=0,h=b.length;h>g;g++)null!=b[g].params.LAYERS&&(e=e.concat(b[g].params.LAYERS),f=f.concat(this.getStyleNames(b[g])));var i=b[0],j=this.map.getProjection(),k=i.projection;k&&k.equals(this.map.getProjectionObject())&&(j=k.getCode());var l=OpenLayers.Util.extend({service:"WMS",version:i.params.VERSION,request:"GetFeatureInfo",exceptions:i.params.EXCEPTIONS,bbox:this.map.getExtent().toBBOX(null,i.reverseAxisOrder()),feature_count:this.maxFeatures,height:this.map.getSize().h,width:this.map.getSize().w,format:d,info_format:i.params.INFO_FORMAT||this.infoFormat},parseFloat(i.params.VERSION)>=1.3?{crs:j,i:parseInt(c.x),j:parseInt(c.y)}:{srs:j,x:parseInt(c.x),y:parseInt(c.y)});return 0!=e.length&&(l=OpenLayers.Util.extend({layers:e,query_layers:e,styles:f},l)),OpenLayers.Util.applyDefaults(l,this.vendorParams),{url:a,params:OpenLayers.Util.upperCaseObject(l),callback:function(b){this.handleResponse(c,b,a)},scope:this}},getStyleNames:function(a){var b;return b=a.params.STYLES?a.params.STYLES:OpenLayers.Util.isArray(a.params.LAYERS)?new Array(a.params.LAYERS.length):a.params.LAYERS.replace(/[^,]/g,"")},request:function(a,b){var c=this.findLayers();if(0==c.length)return this.events.triggerEvent("nogetfeatureinfo"),OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait"),void 0;if(b=b||{},this.drillDown===!1){var d=this.buildWMSOptions(this.url,c,a,c[0].params.FORMAT),e=OpenLayers.Request.GET(d);b.hover===!0&&(this.hoverRequest=e)}else{this._requestCount=0,this._numRequests=0,this.features=[];for(var f,g={},h=0,i=c.length;i>h;h++){var j=c[h];f=OpenLayers.Util.isArray(j.url)?j.url[0]:j.url,f in g?g[f].push(j):(this._numRequests++,g[f]=[j])}var c;for(var f in g){c=g[f];var d=this.buildWMSOptions(f,c,a,c[0].params.FORMAT);OpenLayers.Request.GET(d)}}},triggerGetFeatureInfo:function(a,b,c){this.events.triggerEvent("getfeatureinfo",{text:a.responseText,features:c,request:a,xy:b}),OpenLayers.Element.removeClass(this.map.viewPortDiv,"olCursorWait")},handleResponse:function(a,b,c){var d=b.responseXML;d&&d.documentElement||(d=b.responseText);var e=this.format.read(d);this.drillDown===!1?this.triggerGetFeatureInfo(b,a,e):(this._requestCount++,this._features="object"===this.output?(this._features||[]).concat({url:c,features:e}):(this._features||[]).concat(e),this._requestCount===this._numRequests&&(this.triggerGetFeatureInfo(b,a,this._features.concat()),delete this._features,delete this._requestCount,delete this._numRequests))},CLASS_NAME:"OpenLayers.Control.WMSGetFeatureInfo"}),OpenLayers.Format.WMSCapabilities.v1_3_0=OpenLayers.Class(OpenLayers.Format.WMSCapabilities.v1_3,{version:"1.3.0",CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_3_0"}),OpenLayers.Format.WFS=OpenLayers.Class(OpenLayers.Format.GML,{layer:null,wfsns:"http://www.opengis.net/wfs",ogcns:"http://www.opengis.net/ogc",initialize:function(a,b){OpenLayers.Format.GML.prototype.initialize.apply(this,[a]),this.layer=b,this.layer.featureNS&&(this.featureNS=this.layer.featureNS),this.layer.options.geometry_column&&(this.geometryName=this.layer.options.geometry_column),this.layer.options.typename&&(this.featureName=this.layer.options.typename)},write:function(a){var b=this.createElementNS(this.wfsns,"wfs:Transaction");b.setAttribute("version","1.0.0"),b.setAttribute("service","WFS");for(var c=0;c0){for(var d,e,f={},g=0,h=c.length;h>g;g++)d=c[g],e=OpenLayers.Util.indexOf(this.map.layers,d),f[e]=d.getFeatureInfo(b);this.callback(f,b,a.xy)}}},callback:function(){},reset:function(){this.callback(null)},findLayers:function(){for(var a,b=this.layers||this.map.layers,c=[],d=b.length-1;d>=0;--d)a=b[d],a instanceof OpenLayers.Layer.UTFGrid&&c.push(a);return c},CLASS_NAME:"OpenLayers.Control.UTFGrid"}),OpenLayers.Format.CQL=function(){function a(a,b){return b instanceof RegExp?b.exec(a):b(a)}function b(b,c){var d,e,g=c.length;for(d=0;g>d;d++){e=c[d];var h=f[e],i=a(b,h);if(i){var j=i[0],k=b.substr(j.length).replace(/^\s*/,"");return{type:e,text:j,remainder:k}}}var l="ERROR: In parsing: ["+b+"], expected one of: ";for(d=0;g>d;d++)e=c[d],l+="\n "+e+": "+f[e];throw new Error(l)}function c(a){var c,d=[],e=["NOT","GEOMETRY","SPATIAL","PROPERTY","LPAREN"];do{if(c=b(a,e),a=c.remainder,e=g[c.type],"END"!=c.type&&!e)throw new Error("No follows list for "+c.type);d.push(c)}while("END"!=c.type);return d}function d(a){function b(){var a=d.pop();switch(a.type){case"LOGICAL":var c=b(),e=b();return new OpenLayers.Filter.Logical({filters:[e,c],type:j[a.text.toUpperCase()]});case"NOT":var f=b();return new OpenLayers.Filter.Logical({filters:[f],type:OpenLayers.Filter.Logical.NOT});case"BETWEEN":var g,i,k;return d.pop(),i=b(),g=b(),k=b(),new OpenLayers.Filter.Comparison({property:k,lowerBoundary:g,upperBoundary:i,type:OpenLayers.Filter.Comparison.BETWEEN});case"COMPARISON":var l=b(),k=b();return new OpenLayers.Filter.Comparison({property:k,value:l,type:h[a.text.toUpperCase()]});case"IS_NULL":var k=b();return new OpenLayers.Filter.Comparison({property:k,type:h[a.text.toUpperCase()]});case"VALUE":var m=a.text.match(/^'(.*)'$/);return m?m[1].replace(/''/g,"'"):Number(a.text);case"SPATIAL":switch(a.text.toUpperCase()){case"BBOX":var n=b(),o=b(),p=b(),q=b(),r=b();return new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.BBOX,property:r,value:OpenLayers.Bounds.fromArray([q,p,o,n])});case"INTERSECTS":var l=b(),k=b();return new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.INTERSECTS,property:k,value:l});case"WITHIN":var l=b(),k=b();return new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.WITHIN,property:k,value:l});case"CONTAINS":var l=b(),k=b();return new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.CONTAINS,property:k,value:l});case"DWITHIN":var s=b(),l=b(),k=b();return new OpenLayers.Filter.Spatial({type:OpenLayers.Filter.Spatial.DWITHIN,value:l,property:k,distance:Number(s)})}case"GEOMETRY":return OpenLayers.Geometry.fromWKT(a.text);default:return a.text}}for(var c=[],d=[];a.length;){var e=a.shift();switch(e.type){case"PROPERTY":case"GEOMETRY":case"VALUE":d.push(e);break;case"COMPARISON":case"BETWEEN":case"IS_NULL":case"LOGICAL":for(var f=l[e.type];c.length>0&&l[c[c.length-1].type]<=f;)d.push(c.pop());c.push(e);break;case"SPATIAL":case"NOT":case"LPAREN":c.push(e);break;case"RPAREN":for(;c.length>0&&"LPAREN"!=c[c.length-1].type;)d.push(c.pop());c.pop(),c.length>0&&"SPATIAL"==c[c.length-1].type&&d.push(c.pop());case"COMMA":case"END":break;default:throw new Error("Unknown token type "+e.type)}}for(;c.length>0;)d.push(c.pop());var g=b();if(d.length>0){for(var i="Remaining tokens after building AST: \n",k=d.length-1;k>=0;k--)i+=d[k].type+": "+d[k].text+"\n";throw new Error(i)}return g}var e,f={PROPERTY:/^[_a-zA-Z]\w*/,COMPARISON:/^(=|<>|<=|<|>=|>|LIKE)/i,IS_NULL:/^IS NULL/i,COMMA:/^,/,LOGICAL:/^(AND|OR)/i,VALUE:/^('([^']|'')*'|\d+(\.\d*)?|\.\d+)/,LPAREN:/^\(/,RPAREN:/^\)/,SPATIAL:/^(BBOX|INTERSECTS|DWITHIN|WITHIN|CONTAINS)/i,NOT:/^NOT/i,BETWEEN:/^BETWEEN/i,GEOMETRY:function(a){var b=/^(POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)/.exec(a);if(b){var c=a.length,d=a.indexOf("(",b[0].length);if(d>-1)for(var e=1;c>d&&e>0;)switch(d++,a.charAt(d)){case"(":e++;break;case")":e--}return[a.substr(0,d+1)]}},END:/^$/},g={LPAREN:["GEOMETRY","SPATIAL","PROPERTY","VALUE","LPAREN"],RPAREN:["NOT","LOGICAL","END","RPAREN"],PROPERTY:["COMPARISON","BETWEEN","COMMA","IS_NULL"],BETWEEN:["VALUE"],IS_NULL:["END"],COMPARISON:["VALUE"],COMMA:["GEOMETRY","VALUE","PROPERTY"],VALUE:["LOGICAL","COMMA","RPAREN","END"],SPATIAL:["LPAREN"],LOGICAL:["NOT","VALUE","SPATIAL","PROPERTY","LPAREN"],NOT:["PROPERTY","LPAREN"],GEOMETRY:["COMMA","RPAREN"]},h={"=":OpenLayers.Filter.Comparison.EQUAL_TO,"<>":OpenLayers.Filter.Comparison.NOT_EQUAL_TO,"<":OpenLayers.Filter.Comparison.LESS_THAN,"<=":OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,">":OpenLayers.Filter.Comparison.GREATER_THAN,">=":OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,LIKE:OpenLayers.Filter.Comparison.LIKE,BETWEEN:OpenLayers.Filter.Comparison.BETWEEN,"IS NULL":OpenLayers.Filter.Comparison.IS_NULL},i={},j={AND:OpenLayers.Filter.Logical.AND,OR:OpenLayers.Filter.Logical.OR},k={},l={RPAREN:3,LOGICAL:2,COMPARISON:1};for(e in h)h.hasOwnProperty(e)&&(i[h[e]]=e);for(e in j)j.hasOwnProperty(e)&&(k[j[e]]=e);return OpenLayers.Class(OpenLayers.Format,{read:function(a){var b=d(c(a));return this.keepData&&(this.data=b),b},write:function(a){if(a instanceof OpenLayers.Geometry)return a.toString();switch(a.CLASS_NAME){case"OpenLayers.Filter.Spatial":switch(a.type){case OpenLayers.Filter.Spatial.BBOX:return"BBOX("+a.property+","+a.value.toBBOX()+")";case OpenLayers.Filter.Spatial.DWITHIN:return"DWITHIN("+a.property+", "+this.write(a.value)+", "+a.distance+")";case OpenLayers.Filter.Spatial.WITHIN:return"WITHIN("+a.property+", "+this.write(a.value)+")";case OpenLayers.Filter.Spatial.INTERSECTS:return"INTERSECTS("+a.property+", "+this.write(a.value)+")";case OpenLayers.Filter.Spatial.CONTAINS:return"CONTAINS("+a.property+", "+this.write(a.value)+")";default:throw new Error("Unknown spatial filter type: "+a.type)}case"OpenLayers.Filter.Logical":if(a.type==OpenLayers.Filter.Logical.NOT)return"NOT ("+this.write(a.filters[0])+")";for(var b="(",c=!0,d=0;dc;++c)if(a[c].geometry===b){a.splice(c,1);break}},isEligible:function(a){return a.geometry?a.state!==OpenLayers.State.DELETE&&"function"==typeof a.geometry.split&&this.feature!==a&&(!this.targetFilter||this.targetFilter.evaluate(a.attributes)):!1},considerSplit:function(a){var b=!1,c=!1;if(!this.sourceFilter||this.sourceFilter.evaluate(a.attributes)){for(var d,e,f,g,h,i,j,k=this.layer&&this.layer.features||[],l=[],m=[],n=this.layer===this.source&&this.mutual,o={edge:this.edge,tolerance:this.tolerance,mutual:n},p=[a.geometry],q=0,r=k.length;r>q;++q)if(g=k[q],this.isEligible(g)){h=[g.geometry];for(var s=0;s1&&(j.unshift(s,1),Array.prototype.splice.apply(p,j),s+=j.length-3),e=e[1]),e.length>1&&(e.unshift(t,1),Array.prototype.splice.apply(h,e),t+=e.length-3))))}h&&h.length>1&&(this.geomsToFeatures(g,h),this.events.triggerEvent("split",{original:g,features:h}),Array.prototype.push.apply(l,h),m.push(g),c=!0) }if(p&&p.length>1&&(this.geomsToFeatures(a,p),this.events.triggerEvent("split",{original:a,features:p}),Array.prototype.push.apply(l,p),m.push(a),b=!0),b||c){if(this.deferDelete){for(var u,v=[],q=0,r=m.length;r>q;++q)u=m[q],u.state===OpenLayers.State.INSERT?v.push(u):(u.state=OpenLayers.State.DELETE,this.layer.drawFeature(u));this.layer.destroyFeatures(v,{silent:!0});for(var q=0,r=l.length;r>q;++q)l[q].state=OpenLayers.State.INSERT}else this.layer.destroyFeatures(m,{silent:!0});this.layer.addFeatures(l,{silent:!0}),this.events.triggerEvent("aftersplit",{source:a,features:l})}}return b},geomsToFeatures:function(a,b){var c=a.clone();delete c.geometry;for(var d,e=0,f=b.length;f>e;++e)d=c.clone(),d.geometry=b[e],d.state=OpenLayers.State.INSERT,b[e]=d},destroy:function(){this.active&&this.deactivate(),OpenLayers.Control.prototype.destroy.call(this)},CLASS_NAME:"OpenLayers.Control.Split"}),OpenLayers.Layer.WMTS=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:!0,version:"1.0.0",requestEncoding:"KVP",url:null,layer:null,matrixSet:null,style:null,format:"image/jpeg",tileOrigin:null,tileFullExtent:null,formatSuffix:null,matrixIds:null,dimensions:null,params:null,zoomOffset:0,serverResolutions:null,formatSuffixMap:{"image/png":"png","image/png8":"png","image/png24":"png","image/png32":"png",png:"png","image/jpeg":"jpg","image/jpg":"jpg",jpeg:"jpg",jpg:"jpg"},matrix:null,initialize:function(a){var b={url:!0,layer:!0,style:!0,matrixSet:!0};for(var c in b)if(!(c in a))throw new Error("Missing property '"+c+"' in layer configuration.");a.params=OpenLayers.Util.upperCaseObject(a.params);var d=[a.name,a.url,a.params,a];if(OpenLayers.Layer.Grid.prototype.initialize.apply(this,d),this.formatSuffix||(this.formatSuffix=this.formatSuffixMap[this.format]||this.format.split("/").pop()),this.matrixIds){var e=this.matrixIds.length;if(e&&"string"==typeof this.matrixIds[0]){var f=this.matrixIds;this.matrixIds=new Array(e);for(var g=0;e>g;++g)this.matrixIds[g]={identifier:f[g]}}}},setMap:function(){OpenLayers.Layer.Grid.prototype.setMap.apply(this,arguments)},updateMatrixProperties:function(){this.matrix=this.getMatrix(),this.matrix&&(this.matrix.topLeftCorner&&(this.tileOrigin=this.matrix.topLeftCorner),this.matrix.tileWidth&&this.matrix.tileHeight&&(this.tileSize=new OpenLayers.Size(this.matrix.tileWidth,this.matrix.tileHeight)),this.tileOrigin||(this.tileOrigin=new OpenLayers.LonLat(this.maxExtent.left,this.maxExtent.top)),this.tileFullExtent||(this.tileFullExtent=this.maxExtent))},moveTo:function(a,b){return(b||!this.matrix)&&this.updateMatrixProperties(),OpenLayers.Layer.Grid.prototype.moveTo.apply(this,arguments)},clone:function(a){return null==a&&(a=new OpenLayers.Layer.WMTS(this.options)),a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a])},getIdentifier:function(){return this.getServerZoom()},getMatrix:function(){var a;if(this.matrixIds&&0!==this.matrixIds.length)if("scaleDenominator"in this.matrixIds[0])for(var b,c=OpenLayers.METERS_PER_INCH*OpenLayers.INCHES_PER_UNIT[this.units]*this.getServerResolution()/28e-5,d=Number.POSITIVE_INFINITY,e=0,f=this.matrixIds.length;f>e;++e)b=Math.abs(1-this.matrixIds[e].scaleDenominator/c),d>b&&(d=b,a=this.matrixIds[e]);else a=this.matrixIds[this.getIdentifier()];else a={identifier:this.getIdentifier()};return a},getTileInfo:function(a){var b=this.getServerResolution(),c=(a.lon-this.tileOrigin.lon)/(b*this.tileSize.w),d=(this.tileOrigin.lat-a.lat)/(b*this.tileSize.h),e=Math.floor(c),f=Math.floor(d);return{col:e,row:f,i:Math.floor((c-e)*this.tileSize.w),j:Math.floor((d-f)*this.tileSize.h)}},getURL:function(a){a=this.adjustBounds(a);var b="";if(!this.tileFullExtent||this.tileFullExtent.intersectsBounds(a)){var c=a.getCenterLonLat(),d=this.getTileInfo(c);this.matrix.identifier;var e,f=this.dimensions;if(b=OpenLayers.Util.isArray(this.url)?this.selectUrl([this.version,this.style,this.matrixSet,this.matrix.identifier,d.row,d.col].join(","),this.url):this.url,"REST"===this.requestEncoding.toUpperCase())if(e=this.params,-1!==b.indexOf("{")){var g=b.replace(/\{/g,"${"),h={style:this.style,Style:this.style,TileMatrixSet:this.matrixSet,TileMatrix:this.matrix.identifier,TileRow:d.row,TileCol:d.col};if(f){var i,j;for(j=f.length-1;j>=0;--j)i=f[j],h[i]=e[i.toUpperCase()]}b=OpenLayers.String.format(g,h)}else{var k=this.version+"/"+this.layer+"/"+this.style+"/";if(f)for(var j=0;j=200&&c.status<300?(a.features=this.parseFeatures(c),a.code=OpenLayers.Protocol.Response.SUCCESS):a.code=OpenLayers.Protocol.Response.FAILURE,b.callback.call(b.scope,a)}},parseFeatures:function(a){var b=a.responseXML;return b&&b.documentElement||(b=a.responseText),!b||b.length<=0?null:this.format.read(b)},CLASS_NAME:"OpenLayers.Protocol.SOS.v1_0_0"}),OpenLayers.Layer.KaMapCache=OpenLayers.Class(OpenLayers.Layer.KaMap,{IMAGE_EXTENSIONS:{jpeg:"jpg",gif:"gif",png:"png",png8:"png",png24:"png",dithered:"png"},DEFAULT_FORMAT:"jpeg",initialize:function(){OpenLayers.Layer.KaMap.prototype.initialize.apply(this,arguments),this.extension=this.IMAGE_EXTENSIONS[this.params.i.toLowerCase()||this.DEFAULT_FORMAT]},getURL:function(a){a=this.adjustBounds(a);var b=this.map.getResolution(),c=Math.round(1e4*this.map.getScale())/1e4,d=Math.round(a.left/b),e=-Math.round(a.top/b),f=Math.floor(d/this.tileSize.w/this.params.metaTileSize.w)*this.tileSize.w*this.params.metaTileSize.w,g=Math.floor(e/this.tileSize.h/this.params.metaTileSize.h)*this.tileSize.h*this.params.metaTileSize.h,h=["/",this.params.map,"/",c,"/",this.params.g.replace(/\s/g,"_"),"/def/t",g,"/l",f,"/t",e,"l",d,".",this.extension],i=this.url;return OpenLayers.Util.isArray(i)&&(i=this.selectUrl(h.join(""),i)),i+h.join("")},CLASS_NAME:"OpenLayers.Layer.KaMapCache"}),OpenLayers.Layer.TileCache=OpenLayers.Class(OpenLayers.Layer.Grid,{isBaseLayer:!0,format:"image/png",serverResolutions:null,initialize:function(a,b,c,d){this.layername=c,OpenLayers.Layer.Grid.prototype.initialize.apply(this,[a,b,{},d]),this.extension=this.format.split("/")[1].toLowerCase(),this.extension="jpg"==this.extension?"jpeg":this.extension},clone:function(a){return null==a&&(a=new OpenLayers.Layer.TileCache(this.name,this.url,this.layername,this.getOptions())),a=OpenLayers.Layer.Grid.prototype.clone.apply(this,[a])},getURL:function(a){var b=this.getServerResolution(),c=this.maxExtent,d=this.tileSize,e=Math.round((a.left-c.left)/(b*d.w)),f=Math.round((a.bottom-c.bottom)/(b*d.h)),g=null!=this.serverResolutions?OpenLayers.Util.indexOf(this.serverResolutions,b):this.map.getZoom(),h=[this.layername,OpenLayers.Number.zeroPad(g,2),OpenLayers.Number.zeroPad(parseInt(e/1e6),3),OpenLayers.Number.zeroPad(parseInt(e/1e3)%1e3,3),OpenLayers.Number.zeroPad(parseInt(e)%1e3,3),OpenLayers.Number.zeroPad(parseInt(f/1e6),3),OpenLayers.Number.zeroPad(parseInt(f/1e3)%1e3,3),OpenLayers.Number.zeroPad(parseInt(f)%1e3,3)+"."+this.extension],i=h.join("/"),j=this.url;return OpenLayers.Util.isArray(j)&&(j=this.selectUrl(i,j)),j="/"==j.charAt(j.length-1)?j:j+"/",j+i},CLASS_NAME:"OpenLayers.Layer.TileCache"}),OpenLayers.Format.WMSCapabilities.v1_1_1=OpenLayers.Class(OpenLayers.Format.WMSCapabilities.v1_1,{version:"1.1.1",readers:{wms:OpenLayers.Util.applyDefaults({SRS:function(a,b){b.srs[this.getChildValue(a)]=!0}},OpenLayers.Format.WMSCapabilities.v1_1.prototype.readers.wms)},CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_1_1"}),OpenLayers.Format.WMSCapabilities.v1_1_1_WMSC=OpenLayers.Class(OpenLayers.Format.WMSCapabilities.v1_1_1,{version:"1.1.1",profile:"WMSC",readers:{wms:OpenLayers.Util.applyDefaults({VendorSpecificCapabilities:function(a,b){b.vendorSpecific={tileSets:[]},this.readChildNodes(a,b.vendorSpecific)},TileSet:function(a,b){var c={srs:{},bbox:{},resolutions:[]};this.readChildNodes(a,c),b.tileSets.push(c)},Resolutions:function(a,b){for(var c=this.getChildValue(a).split(" "),d=0,e=c.length;e>d;d++)""!=c[d]&&b.resolutions.push(parseFloat(c[d]))},Width:function(a,b){b.width=parseInt(this.getChildValue(a))},Height:function(a,b){b.height=parseInt(this.getChildValue(a))},Layers:function(a,b){b.layers=this.getChildValue(a)},Styles:function(a,b){b.styles=this.getChildValue(a)}},OpenLayers.Format.WMSCapabilities.v1_1_1.prototype.readers.wms)},CLASS_NAME:"OpenLayers.Format.WMSCapabilities.v1_1_1_WMSC"}),OpenLayers.Control.LayerSwitcher=OpenLayers.Class(OpenLayers.Control,{layerStates:null,layersDiv:null,baseLayersDiv:null,baseLayers:null,dataLbl:null,dataLayersDiv:null,dataLayers:null,minimizeDiv:null,maximizeDiv:null,ascending:!0,initialize:function(){OpenLayers.Control.prototype.initialize.apply(this,arguments),this.layerStates=[]},destroy:function(){this.clearLayersArray("base"),this.clearLayersArray("data"),this.map.events.un({buttonclick:this.onButtonClick,addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this}),this.events.unregister("buttonclick",this,this.onButtonClick),OpenLayers.Control.prototype.destroy.apply(this,arguments)},setMap:function(){OpenLayers.Control.prototype.setMap.apply(this,arguments),this.map.events.on({addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this}),this.outsideViewport?(this.events.attachToElement(this.div),this.events.register("buttonclick",this,this.onButtonClick)):this.map.events.register("buttonclick",this,this.onButtonClick)},draw:function(){return OpenLayers.Control.prototype.draw.apply(this),this.loadContents(),this.outsideViewport||this.minimizeControl(),this.redraw(),this.div},onButtonClick:function(a){var b=a.buttonElement;b===this.minimizeDiv?this.minimizeControl():b===this.maximizeDiv?this.maximizeControl():b._layerSwitcher===this.id&&(b["for"]&&(b=document.getElementById(b["for"])),b.disabled||("radio"==b.type?(b.checked=!0,this.map.setBaseLayer(this.map.getLayer(b._layer))):(b.checked=!b.checked,this.updateMap())))},clearLayersArray:function(a){this[a+"LayersDiv"].innerHTML="",this[a+"Layers"]=[]},checkRedraw:function(){if(!this.layerStates.length||this.map.layers.length!=this.layerStates.length)return!0;for(var a=0,b=this.layerStates.length;b>a;a++){var c=this.layerStates[a],d=this.map.layers[a];if(c.name!=d.name||c.inRange!=d.inRange||c.id!=d.id||c.visibility!=d.visibility)return!0}return!1},redraw:function(){if(!this.checkRedraw())return this.div;this.clearLayersArray("base"),this.clearLayersArray("data");var a=!1,b=!1,c=this.map.layers.length;this.layerStates=new Array(c);for(var d=0;c>d;d++){var e=this.map.layers[d];this.layerStates[d]={name:e.name,visibility:e.visibility,inRange:e.inRange,id:e.id}}var f=this.map.layers.slice();this.ascending||f.reverse();for(var d=0,c=f.length;c>d;d++){var e=f[d],g=e.isBaseLayer;if(e.displayInLayerSwitcher){g?b=!0:a=!0;var h=g?e==this.map.baseLayer:e.getVisibility(),i=document.createElement("input"),j=OpenLayers.Util.createUniqueID(this.id+"_input_");i.id=j,i.name=g?this.id+"_baseLayers":e.name,i.type=g?"radio":"checkbox",i.value=e.name,i.checked=h,i.defaultChecked=h,i.className="olButton",i._layer=e.id,i._layerSwitcher=this.id,g||e.inRange||(i.disabled=!0);var k=document.createElement("label");k["for"]=i.id,OpenLayers.Element.addClass(k,"labelSpan olButton"),k._layer=e.id,k._layerSwitcher=this.id,g||e.inRange||(k.style.color="gray"),k.innerHTML=e.name,k.style.verticalAlign=g?"bottom":"baseline";var l=document.createElement("br"),m=g?this.baseLayers:this.dataLayers;m.push({layer:e,inputElem:i,labelSpan:k});var n=g?this.baseLayersDiv:this.dataLayersDiv;n.appendChild(i),n.appendChild(k),n.appendChild(l)}}return this.dataLbl.style.display=a?"":"none",this.baseLbl.style.display=b?"":"none",this.div},updateMap:function(){for(var a=0,b=this.baseLayers.length;b>a;a++){var c=this.baseLayers[a];c.inputElem.checked&&this.map.setBaseLayer(c.layer,!1)}for(var a=0,b=this.dataLayers.length;b>a;a++){var c=this.dataLayers[a];c.layer.setVisibility(c.inputElem.checked)}},maximizeControl:function(a){this.div.style.width="",this.div.style.height="",this.showControls(!1),null!=a&&OpenLayers.Event.stop(a)},minimizeControl:function(a){this.div.style.width="0px",this.div.style.height="0px",this.showControls(!0),null!=a&&OpenLayers.Event.stop(a)},showControls:function(a){this.maximizeDiv.style.display=a?"":"none",this.minimizeDiv.style.display=a?"none":"",this.layersDiv.style.display=a?"none":""},loadContents:function(){this.layersDiv=document.createElement("div"),this.layersDiv.id=this.id+"_layersDiv",OpenLayers.Element.addClass(this.layersDiv,"layersDiv"),this.baseLbl=document.createElement("div"),this.baseLbl.innerHTML=OpenLayers.i18n("Base Layer"),OpenLayers.Element.addClass(this.baseLbl,"baseLbl"),this.baseLayersDiv=document.createElement("div"),OpenLayers.Element.addClass(this.baseLayersDiv,"baseLayersDiv"),this.dataLbl=document.createElement("div"),this.dataLbl.innerHTML=OpenLayers.i18n("Overlays"),OpenLayers.Element.addClass(this.dataLbl,"dataLbl"),this.dataLayersDiv=document.createElement("div"),OpenLayers.Element.addClass(this.dataLayersDiv,"dataLayersDiv"),this.ascending?(this.layersDiv.appendChild(this.baseLbl),this.layersDiv.appendChild(this.baseLayersDiv),this.layersDiv.appendChild(this.dataLbl),this.layersDiv.appendChild(this.dataLayersDiv)):(this.layersDiv.appendChild(this.dataLbl),this.layersDiv.appendChild(this.dataLayersDiv),this.layersDiv.appendChild(this.baseLbl),this.layersDiv.appendChild(this.baseLayersDiv)),this.div.appendChild(this.layersDiv);var a=OpenLayers.Util.getImageLocation("layer-switcher-maximize.png");this.maximizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MaximizeDiv",null,null,a,"absolute"),OpenLayers.Element.addClass(this.maximizeDiv,"maximizeDiv olButton"),this.maximizeDiv.style.display="none",this.div.appendChild(this.maximizeDiv);var a=OpenLayers.Util.getImageLocation("layer-switcher-minimize.png");this.minimizeDiv=OpenLayers.Util.createAlphaImageDiv("OpenLayers_Control_MinimizeDiv",null,null,a,"absolute"),OpenLayers.Element.addClass(this.minimizeDiv,"minimizeDiv olButton"),this.minimizeDiv.style.display="none",this.div.appendChild(this.minimizeDiv)},CLASS_NAME:"OpenLayers.Control.LayerSwitcher"}),OpenLayers.Tile.Image.IFrame={useIFrame:null,blankImageUrl:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAQAIBRAA7",draw:function(){var a=OpenLayers.Tile.Image.prototype.shouldDraw.call(this);if(a){var b=this.layer.getURL(this.bounds),c=this.useIFrame;this.useIFrame=null!==this.maxGetUrlLength&&!this.layer.async&&b.length>this.maxGetUrlLength;var d=c&&!this.useIFrame,e=!c&&this.useIFrame;(d||e)&&(this.imgDiv&&this.imgDiv.parentNode===this.frame&&this.frame.removeChild(this.imgDiv),this.imgDiv=null,d&&this.frame.removeChild(this.frame.firstChild))}return OpenLayers.Tile.Image.prototype.draw.apply(this,arguments)},getImage:function(){if(this.useIFrame===!0){if(!this.frame.childNodes.length){var a=document.createElement("div"),b=a.style;b.position="absolute",b.width="100%",b.height="100%",b.zIndex=1,b.backgroundImage="url("+this.blankImageUrl+")",this.frame.appendChild(a)}var c,d=this.id+"_iFrame";return parseFloat(navigator.appVersion.split("MSIE")[1])<9?(c=document.createElement('