diff --git a/Gemfile b/Gemfile index e3e19bb..ce3e5f5 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' +# gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. @@ -48,9 +48,7 @@ group :development do gem 'spring' end -group :test do - gem 'webmock' -end +gem 'webmock', group: :test gem 'blacklight', '>= 5.3.0' gem 'jettywrapper', '>= 2.0' @@ -62,6 +60,7 @@ gem 'blacklight-marc', '~> 5.0' gem 'config', '~> 1.0.0.beta3' gem 'mods_display', '0.3.4' gem 'coderay' +gem 'blacklight_range_limit' group :deployment do gem 'capistrano', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index d38298e..6b85f82 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,10 @@ GEM blacklight (~> 5.10) marc (>= 0.4.3, < 1.1) rails + blacklight_range_limit (5.2.0) + blacklight (~> 5.15) + jquery-rails + rails (>= 3.0, < 5.0) bootstrap-sass (3.3.5.1) autoprefixer-rails (>= 5.0.0.1) sass (>= 3.3.0) @@ -292,8 +296,6 @@ GEM thread_safe (0.3.5) tilt (2.0.1) tins (1.6.0) - turbolinks (2.5.3) - coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.7.2) @@ -325,6 +327,7 @@ PLATFORMS DEPENDENCIES blacklight (>= 5.3.0) blacklight-marc (~> 5.0) + blacklight_range_limit byebug capistrano (~> 3.0) capistrano-bundler @@ -351,7 +354,6 @@ DEPENDENCIES spring sqlite3 therubyracer - turbolinks tzinfo-data uglifier (>= 1.3.0) web-console (~> 2.0) diff --git a/Rakefile b/Rakefile index 1917855..94b37ff 100644 --- a/Rakefile +++ b/Rakefile @@ -12,9 +12,10 @@ desc 'Execute the test build that runs on travis' task ci: [:environment] do if Rails.env.test? Rake::Task['db:migrate'].invoke - Rake::Task['jetty:download'].invoke - Rake::Task['jetty:unzip'].invoke + Rake::Task['colligo:download_and_unzip_jetty'].invoke + Rake::Task['colligo:copy_solr_configs'].invoke Jettywrapper.wrap(Jettywrapper.load_config) do + Rake::Task['colligo:fixtures'].invoke Rake::Task['spec'].invoke end else diff --git a/app/assets/fonts/FontAwesome.otf b/app/assets/fonts/FontAwesome.otf new file mode 100644 index 0000000..3461e3f Binary files /dev/null and b/app/assets/fonts/FontAwesome.otf differ diff --git a/app/assets/fonts/fontawesome-webfont.eot b/app/assets/fonts/fontawesome-webfont.eot new file mode 100644 index 0000000..6cfd566 Binary files /dev/null and b/app/assets/fonts/fontawesome-webfont.eot differ diff --git a/app/assets/fonts/fontawesome-webfont.svg b/app/assets/fonts/fontawesome-webfont.svg new file mode 100644 index 0000000..a9f8469 --- /dev/null +++ b/app/assets/fonts/fontawesome-webfont.svg @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/fonts/fontawesome-webfont.ttf b/app/assets/fonts/fontawesome-webfont.ttf new file mode 100644 index 0000000..5cd6cff Binary files /dev/null and b/app/assets/fonts/fontawesome-webfont.ttf differ diff --git a/app/assets/fonts/fontawesome-webfont.woff b/app/assets/fonts/fontawesome-webfont.woff new file mode 100644 index 0000000..9eaecb3 Binary files /dev/null and b/app/assets/fonts/fontawesome-webfont.woff differ diff --git a/app/assets/images/iiif-logo.png b/app/assets/images/iiif-logo.png new file mode 100644 index 0000000..3280c1f Binary files /dev/null and b/app/assets/images/iiif-logo.png differ diff --git a/app/assets/images/other.png b/app/assets/images/other.png new file mode 100644 index 0000000..a51b777 Binary files /dev/null and b/app/assets/images/other.png differ diff --git a/app/assets/images/parker.png b/app/assets/images/parker.png new file mode 100644 index 0000000..7b50e80 Binary files /dev/null and b/app/assets/images/parker.png differ diff --git a/app/assets/images/play-arrow-16-1.png b/app/assets/images/play-arrow-16-1.png new file mode 100644 index 0000000..e6e3eff Binary files /dev/null and b/app/assets/images/play-arrow-16-1.png differ diff --git a/app/assets/images/play-arrow-20-1.png b/app/assets/images/play-arrow-20-1.png new file mode 100644 index 0000000..1150058 Binary files /dev/null and b/app/assets/images/play-arrow-20-1.png differ diff --git a/app/assets/images/play-arrow-32-1.png b/app/assets/images/play-arrow-32-1.png new file mode 100644 index 0000000..2719f26 Binary files /dev/null and b/app/assets/images/play-arrow-32-1.png differ diff --git a/app/assets/images/stanford.png b/app/assets/images/stanford.png new file mode 100644 index 0000000..bae37c2 Binary files /dev/null and b/app/assets/images/stanford.png differ diff --git a/app/assets/images/walter.png b/app/assets/images/walter.png new file mode 100644 index 0000000..e9bdd0d Binary files /dev/null and b/app/assets/images/walter.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 10d55ca..84df3a0 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,8 +12,21 @@ // //= require jquery //= require jquery_ujs -//= require turbolinks// +//= require jquery-ui +// require turbolinks +// For Mirador viewer +//= require mirador +// require openseadragon-viewerinputhook +// For scaling fonts +//= require flowtype // Required by Blacklight //= require blacklight/blacklight - +//= require affix +//= require scrollspy +//= require "jquery.tablesorter" //= require_tree . +// +// For blacklight_range_limit built-in JS, if you don't want it you don't need +// this: +//= require 'blacklight_range_limit' + diff --git a/app/assets/javascripts/browse_century.js b/app/assets/javascripts/browse_century.js new file mode 100644 index 0000000..ae4ca45 --- /dev/null +++ b/app/assets/javascripts/browse_century.js @@ -0,0 +1,205 @@ +window.onload = function () { + var century = $("#century"); + if (century.length == 0) { + return; + } + // Vertical slider + var century_slider = $("#century_slider"); + var boundaries = century_slider.data('boundaries'); + // var slider_ticks = century_slider.data('ticks'); + var min = boundaries[0]; + var max = boundaries[1]; + //*******Century HORIZONTAL BAR CHART + //http://www.jqueryflottutorial.com/how-to-make-jquery-flot-horizontal-bar-chart.html + var century_panel = $('#century_panel'); + century_panel.width(century.width() - century_slider.width()); + var rawData = century_panel.data('rawdata'); + var ticks = century_panel.data('ticks'); + var pointer_lookup = century_panel.data('pointerlookup'); + // var display_ratio = 1/(1.618 * 2); + century_panel.height( century_panel.width() * 2 ); + var dataSet = [{ label: "", data: rawData, color: "#009933" }]; + var options = { + series: { + bars: { + show: true + } + }, + bars: { + align: "center", + barWidth: 80, + horizontal: true, + fillColor: { colors: [{ opacity: 0.5 }, { opacity: 1}] }, + lineWidth: 1 + }, + yaxis: { + //axisLabel: "Precious Metals", + //axisLabelUseCanvas: true, + //axisLabelFontSizePixels: 12, + //axisLabelFontFamily: 'Verdana, Arial', + //axisLabelPadding: 3, + //tickColor: "#5E5E5E", + ticks: ticks, + color: "white", + tickDecimals: 0 + }, + //legend: { + // noColumns: 0, + // labelBoxBorderColor: "#858585", + // position: "ne" + //}, + grid: { + hoverable: true, + borderWidth: 0, + backgroundColor: { colors: ["#ffffff", "#ffffff"] }, + autoHighlight: true, + clickable: true + } + }; + //******Plot the graph, draw the slider, and define event handlers + $(document).ready(function () { + var plot; + var browse_century = $("#browse_century"); + var form = century.parent().find("form.range_limit"); + var begin_el = form.find("input.range_begin"); + var end_el = form.find("input.range_end"); + // Plot the graph + plot = $.plot(browse_century, dataSet, options); + var find_segment_for = function_for_find_segment(pointer_lookup); + var last_segment = null; + // plothover event + browse_century.bind("plothover", function (event, pos, item) { + if (item) { + var segment = find_segment_for(pos.y); + var msg = segment.label + ' (' + segment.count + ')'; + if (segment == last_segment) { + $("#tooltip").remove(); + last_segment = null; + } else { + $("#tooltip").remove(); + showTooltip(item.pageX, item.pageY, '#000000', msg); + last_segment = segment; + } + } + }); + // define the slider + var placeholder_input = $('').appendTo(century_slider); + if (placeholder_input.bootstrapSlider !== undefined) { + placeholder_input.bootstrapSlider({ + min: min, + max: max, + value: [min, max], + tooltip_position: "right", + orientation: 'vertical', + reversed: true, + //step: 100, + //ticks: slider_ticks, + handle: 'custom' + }); + } + // Match slider height to plot + var slider_body = $(".slider.slider-vertical"); + slider_body.height( plot.height()-35 ); + slider_body.css('margin-top',"25px"); + // set values of form elements to min and max + begin_el.val(min); + end_el.val(max); + // on plot click + browse_century.bind("plotclick", function (event, pos, item) { + if ( plot.getSelection() == null) { + var segment = find_segment_for(pos.y); + plot.setSelection( normalized_selection(segment.from, segment.to)); + begin_el.val(segment.from); + end_el.val(segment.to); + var slider_placeholder = century_slider.find("[data-slider-placeholder]"); + if (slider_placeholder) { + slider_placeholder.bootstrapSlider("setValue", [segment.from, segment.to]); + } + } + }); + // on plot select + browse_century.bind("plotselected plotselecting", function(event, ranges) { + if (ranges != null ) { + var from = Math.floor(ranges.yaxis.from); + var to = Math.floor(ranges.yaxis.to); + begin_el.val(from); + end_el.val(to); + var slider_placeholder = century_slider.find("[data-slider-placeholder]"); + if (slider_placeholder) { + slider_placeholder.bootstrapSlider("setValue", [from, to+1]); + } + } + }); + // on form input fields value change + form.find("input.range_begin, input.range_end").change(function () { + plot.setSelection( form_selection(form, min, max) , true ); + }); + begin_el.change( function() { + var val = BlacklightRangeLimit.parseNum($(this).val()); + if ( isNaN(val) || val < min) { + //for weird data, set slider at min + val = min; + } + var values = placeholder_input.data("bootstrapSlider").getValue(); + values[0] = val; + placeholder_input.bootstrapSlider("setValue", values); + }); + end_el.change( function() { + var val = BlacklightRangeLimit.parseNum($(this).val()); + if ( isNaN(val) || val > max ) { + //weird entry, set slider to max + val = max; + } + var values = placeholder_input.data("bootstrapSlider").getValue(); + values[1] = val; + placeholder_input.bootstrapSlider("setValue", values); + }); + // on slider value change + var slider_placeholder = century_slider.find("[data-slider-placeholder]"); + slider_placeholder.on("change", function(event) { + var values = $(event.target).data("bootstrapSlider").getValue(); + begin_el.val(values[0]); + end_el.val(values[1]); + plot.setSelection( normalized_selection(values[0], Math.max(values[0], values[1]-1)), true); + }); + }); + + function showTooltip(x, y, color, contents) { + $('
' + contents + '
').css({ + position: 'absolute', + display: 'none', + top: y - 10, + left: x + 10, + border: '2px solid ' + color, + padding: '3px', + 'font-size': '12px', + 'border-radius': '5px', + 'background-color': '#fff', + 'font-family': 'Verdana, Arial, Helvetica, Tahoma, sans-serif', + opacity: 0.9 + }).appendTo("body").fadeIn(200); + } + + function function_for_find_segment(pointer_lookup_arr) { + return function(y_coord) { + for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) { + var hash = pointer_lookup_arr[i]; + if (y_coord >= hash.from) { + return hash; + } + } + return pointer_lookup_arr[0]; + }; + } + + function normalized_selection(min, max) { + max += 0.99999; + return {xaxis: { 'from':min, 'to':max}} + } + + /* + function isInt(n) { + return n % 1 === 0; + } + */ +}; diff --git a/app/assets/javascripts/colligo.js b/app/assets/javascripts/colligo.js new file mode 100644 index 0000000..cabaf73 --- /dev/null +++ b/app/assets/javascripts/colligo.js @@ -0,0 +1,43 @@ +// Tabs on homepage +$(document).on('click', '.search-tabs li', function() { + $(".search-tabs li").removeClass("active"); + $(this).addClass("active"); + $("#main_search_field").val($(this).data("field")); + $("#q" ).focus(); +}); + +// Tabs on folio page +$(document).on('click', '.folio-tabs li', function() { + $(".folio-tabs li").removeClass("active"); + $(".tab-pane").removeClass("active"); + $(this).addClass("active"); + var tab_ele = $(this).data('tab-id'); + $("#"+tab_ele).addClass("active"); + $("#folio-title").html(tab_ele[0].toUpperCase() + tab_ele.slice(1)); +}); + + +// nav on manuscript show +$(document).on('click', '.navbar-green li', function() { + $(".navbar-green li").removeClass("active"); + $(this).addClass("active"); +}); + +// enable top on scroll +$(window).scroll(function() { + if ($(window).scrollTop() > 0) { + $("#nav_top").css('display', 'block'); + } else { + $("#nav_top").css('display', 'none'); + } +}); + + +$(document).on("focus", ".ui-autocomplete-input", function() { + $(this).val(""); +}); + +$(document).on("click", "#home_modal_button", function(){ + lookup_init('facet-language'); + $(".tablesorter").tablesorter({}); +}); diff --git a/app/assets/javascripts/folio_viewer.js b/app/assets/javascripts/folio_viewer.js new file mode 100644 index 0000000..ca8ccc2 --- /dev/null +++ b/app/assets/javascripts/folio_viewer.js @@ -0,0 +1,214 @@ +$(function() { + var viewer = $("#folio_viewer"); + if (viewer.length == 0) { + return; + } + + // Initialize the mirador viewer + var vc = $("#viewer_container"); + var manifest_uri = viewer.data("manifest-uri"); + var canvas_id = viewer.data("canvas-id"); + viewer.width(vc.width()); + // var display_ratio = 1/(1.618 * 2); + viewer.height(viewer.width() * 1.25); + Mirador({ + "id": "folio_viewer", + "layout": "1x1", + "mainMenuSettings" : { + 'show' : false + }, + 'showAddFromURLBox' : false, + "saveSession": false, + "data": [ + { + "manifestUri": manifest_uri, + "location": "Stanford University"} + ], + "windowObjects": [ + { + "loadedManifest": manifest_uri, + "canvasID" : canvas_id, + "viewType" : "ImageView", + "displayLayout": false, + "bottomPanel" : false, + "sidePanel" : false, + "annotationLayer" : true, + "annotationState": 'annoOnCreateOff' + } + ] + }); + viewer.css('position', 'relative'); + var viewer_text = $("#viewer_text"); + viewer_text.height(viewer.height()); + viewer_text.css('overflow', 'hidden'); + var text_class = 'transcription_text'; + if ($('.folio-tabs li.active').data('tab-id') == 'annotations') { + text_class = 'annotation_text'; + } + var delta_left = viewer_text.offset().left - viewer.offset().left; + var viewer_text_left = viewer_text.offset().left; + var viewer_text_width = viewer_text.outerWidth(); + var max_text_length = get_max_text_length(text_class); + + // var delta_top = viewer_text.offset().top - viewer.offset().top; + + var anno_check_count = 0; + $.subscribe('imageRectangleUpdated', image_rect_updated_handle); + $.subscribe('focusUpdated', focus_updated_handle); + // $.subscribe('windowAdded', window_added_handle); + // $.subscribe('imageBoundsUpdated', image_bounds_handle); + + function image_rect_updated_handle(event, data) { + var win_id = data['id']; + anno_check_count += 1; + var annos = $(".annotation"); + var texts = $("." + text_class); + if (annos.length == 0 && anno_check_count < 5) { + setTimeout(image_rect_updated_handle, 1, event, data); + } else { + $.publish('disableTooltips.' + win_id); + var index = 0; + var number_of_cols = get_annotation_columns(annos); + var col_width = viewer_text_width / number_of_cols; + var font_ratio = get_font_ratio(max_text_length, number_of_cols); + annos.each(function(){ + var p = $(this).offset(); + var w = $(this).outerWidth(); + var h = $(this).outerHeight(); + // Set the col width to the max if the anno box is less than the max width + // If anno box is greater than the max, use that (i.e zoomed in) + // Offset the width by height, to account for start of text within the annotation box + var screen_w = col_width - p.left - delta_left - (h/2) + viewer_text_left; + if (texts.length > index) { + $(texts[index]).offset({top: p.top + (h/3), left: p.left + delta_left + (h/2)}); + if (w < screen_w) { + $(texts[index]).width(screen_w); + } else { + $(texts[index]).width(w); + } + $(texts[index]).flowtype({ + //minFont : 6, + //maxFont : 40 + fontRatio : font_ratio + }); + index = index + 1; + } + }); + // $.publish('disableRectTool.' + win_id); + } + } + + function focus_updated_handle() { + anno_check_count = 0; + } + + function window_added_handle(event, windowId, slotId) { + console.log('In window added handle'); + console.log(windowId['id']); + $.subscribe('currentCanvasIDUpdated.' + windowId['id'], canvas_updated_handle); + } + + function canvas_updated_handle(event, data) { + console.log('In canvas updated handle'); + if (data != canvas_id) { + // Get label of new canvas navigated to + $.ajax({ + type: 'get', + url: window.location.pathname + '/folio_label', + data: 'canvas_id=' + data, + success: function(data) { + url = next_url(data['folio']); + // window.location.pathname = url; + } + }); + } + } + + function image_bounds_handle() { + console.log('In image bounds handle'); + var osd_id = $('.mirador-osd').attr('id'); + console.log(osd_id); + var osd_viewer = OpenSeadragon({ + 'id': osd_id + }); + var viewerInputHook = new OpenSeadragonImaging.ViewerInputHook({ + viewer: osd_viewer, + hooks: [ + {tracker: 'viewer', handler: 'clickHandler', hookHandler: onHookOsdViewerClick} + ] + }); + } + + function onHookOsdViewerClick(event, data) { + console.log('In onHookOsdViewerClick'); + console.log(data); + //if (data != canvas_id) { + // // Get label of new canvas navigated to + // $.ajax({ + // type: 'get', + // url: window.location.pathname + '/folio_label', + // data: 'canvas_id=' + data, + // success: function(data) { + // url = next_url(data['folio']); + // // window.location.pathname = url; + // } + // }); + //} + // set event.stopHandlers = true to prevent any more handlers in the chain from being called + // set event.stopBubbling = true to prevent the original event from bubbling + // set event.preventDefaultAction = true to prevent viewer's default action + //if (event.quick) { + // var logPoint = imagingHelper.physicalToLogicalPoint(event.position); + // if (event.shift) { + // imagingHelper.zoomOutAboutLogicalPoint(logPoint); + // } + // else { + // imagingHelper.zoomInAboutLogicalPoint(logPoint); + // } + //} + //event.stopBubbling = true; + //event.preventDefaultAction = true; + } + + function get_max_text_length(text_class) { + var max_length = 0; + $("." + text_class).each(function(){ + var tn = $(this).text().length; + if (tn > max_length) { + max_length = tn; + } + }); + return max_length; + } + + function get_annotation_columns(annos) { + var cols = []; + annos.each(function(){ + var l = $(this).offset().left; + if (cols.indexOf(l) == -1) { + cols.push(l); + } + }); + return cols.length; + } + + function get_font_ratio(max_text_length, number_of_cols) { + var ideal_text_length = 75; + var text_length_for_col = ideal_text_length / number_of_cols; + if (max_text_length > text_length_for_col) { + return 40 + } else { + return 30 + } + } + + function next_url(folio) { + path = window.location.pathname; + path = path.replace(/\/$/, ""); + path = path.split('/'); + path[path.length-1] = folio; + path = path.join('/') + window.location.search; + return path; + } + +}); \ No newline at end of file diff --git a/app/assets/javascripts/refine_facets.js b/app/assets/javascripts/refine_facets.js new file mode 100644 index 0000000..21d2a9b --- /dev/null +++ b/app/assets/javascripts/refine_facets.js @@ -0,0 +1,59 @@ +$(function() { + var refine_tabs = $("#myTabs"); + if (refine_tabs.length == 0) { + return; + } + + // refine width + var refine_width = $('.refine').parent().width() - $('.refine').outerWidth(true) - 5; + $('.summary').width(refine_width); + + + var first_tab = refine_tabs.find('.nav-tabs li').first().data('tab-id'); + $('#'+first_tab).addClass('active'); + lookup_init(first_tab); + + refine_tabs.on('click', '.nav-tabs li', function () { + $(this).closest('.dropdown').addClass('dontClose'); + var activeTab = $(this).data('tab-id'); + lookup_init(activeTab); + $(".nav-tabs li").removeClass("active"); + $(".tab-pane").removeClass("active"); + $(this).addClass("active"); + $("#"+activeTab).addClass("active"); + }); + + refine_tabs.on('click', '.lookup-widget input', function () { + $(this).closest('.dropdown').addClass('dontClose'); + }); + + $('#myDropDown').on('hide.bs.dropdown', function (e) { + if ($(this).hasClass('dontClose')) { + e.preventDefault(); + } + $(this).removeClass('dontClose'); + }); + + $(".tablesorter").tablesorter({}); +}); + +function lookup_init(activeTab) { + var possibleValues = []; + $("#" + activeTab + " tbody tr").each(function(){ + var a_ele = $(this).find("td:first a"); + if (!a_ele.hasClass("remove")) { + possibleValues.push({value: a_ele.attr("href"), label: a_ele.text()}); //put elements into array + } + }); + $( "#" + activeTab + "-lookup" ).autocomplete({ + source: possibleValues, + appendTo: "#" + activeTab + "-popover-div", + messages: { + noResults: '', + results: function() {} + }, + select: function( event, ui ) { + window.location.href = ui.item.value; + } + }) +} \ No newline at end of file diff --git a/app/assets/javascripts/viewer.js b/app/assets/javascripts/viewer.js new file mode 100644 index 0000000..1b05651 --- /dev/null +++ b/app/assets/javascripts/viewer.js @@ -0,0 +1,132 @@ +$(function() { + var viewer = $("#viewer"); + if (viewer.length == 0) { + return; + } + + // Initialize the mirador viewer + var vc = $("#viewer_container"); + var manifest_uri = viewer.data("manifest-uri"); + var canvas_id = viewer.data("canvas-id"); + viewer.width(vc.width()); + // var display_ratio = 1/(1.618 * 2); + viewer.height(viewer.width() * 0.5); + Mirador({ + "id": "viewer", + "mainMenuSettings" : { + 'show' : false + }, + 'showAddFromURLBox' : false, + "saveSession": false, + "data": [ + { + "manifestUri": manifest_uri, + "location": "Stanford University"} + ], + "windowObjects": [ + { + "loadedManifest": manifest_uri, + "canvasID" : canvas_id, + "viewType" : "BookView", + "displayLayout": false, + "bottomPanel" : true, + "bottomPanelVisible": true, + "sidePanel" : false, + "annotationLayer" : false + } + ] + }); + viewer.css('position', 'relative'); + + function handle() { + // `e` is the event object passed to handle - don't care about it. + var highlighted_pages = $("ul.panel-listing-thumbs li.highlight"); + var current_page = highlighted_pages.first(); + var current_panel = $(".folio-recto"); + var param_start = current_panel.data("start"); + if (highlighted_pages.length == 2) { + current_page = highlighted_pages.eq(0); + fill_folio(current_page, current_panel, param_start); + current_page = highlighted_pages.eq(1); + current_panel = $(".folio-verso"); + current_panel.css('display', 'block') + } else { + $(".folio-verso").css('display', 'none'); + } + fill_folio(current_page, current_panel, param_start); + } + + function fill_folio(current_page, current_panel, param_start) { + var current_folio = current_page.find('div').text(); + // Folio thumbnail + var img_ele = current_page.find('img').clone(); + if ( !img_ele.attr('src') ) { + img_ele.attr('src', img_ele.attr('data')); + } + img_ele.removeClass('thumbnail-image highlight'); + current_panel.find(".folio-img").html(img_ele); + // Folio title + current_panel.find(".foliotitle").html(current_folio); + // Get related content + $.ajax({ + type: 'get', + url: window.location.pathname + '/related_content', + data: 'folio=' + current_folio, + success: function(data) { + // Annotations + var cls = 'noresult-inverse'; + if (data['annotations'] > 0) { + cls = 'result-inverse'; + } + ele = $(''); + var url = window.location.pathname + '/folio/' + current_folio + '?view=annotations'; + if (param_start || param_start === 0) { + url = url + '&start=' + param_start; + } + ele.attr("href", url); + ele.attr("class", "btn btn-sm " + cls); + ele.html(' Annotations'); + current_panel.find(".folio-annotations").html(ele); + // Transcriptions + cls = 'noresult-inverse'; + if (data['transcriptions'] > 0) { + cls = 'result-inverse'; + } + ele = $(''); + url = window.location.pathname + '/folio/' + current_folio + '?view=transcriptions'; + if (param_start || param_start === 0) { + url = url + '&start=' + param_start; + } + ele.attr("href", url); + ele.attr("class", "btn btn-sm " + cls); + ele.html(' Transcriptions'); + current_panel.find(".folio-transcriptions").html(ele); + // First transcription + if (data['first_transcription']) { + var ele = $('

'); + ele.html('"'+data['first_transcription']+'"'); + current_panel.find(".folio-first-transcription").html(ele) + } + } + }); + } + + // update the current page thumbnail each time the focus changes + $.subscribe('focusUpdated', handle); + + // Set width and data-offset-top on navbar for affixing to top + function affixWidth() { + // ensure the affix element maintains it width + var affix = $('.navbar-green'); + var width = affix.width(); + var top_pos = $('#manuscript-description').position().top - 50; + affix.attr('data-offset-top', top_pos); + affix.width(width); + } + affixWidth(); + + $(window).on("resize", function(){ + affixWidth(); + }) + +}); diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9cd5b3..cc45506 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,6 +10,13 @@ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * + * Used by blacklight_range_limit + *= require 'blacklight_range_limit' + *= require mirador-combined + *= require jquery-tablesorter + * *= require_tree . *= require_self - */ + * + * +*/ diff --git a/app/assets/stylesheets/colligo.css.scss b/app/assets/stylesheets/colligo.css.scss new file mode 100644 index 0000000..a69bde4 --- /dev/null +++ b/app/assets/stylesheets/colligo.css.scss @@ -0,0 +1,794 @@ +@media (max-width: 767px) { + .container { + margin:0px 5px; + } + + .flash_messages { + margin-top: 20px; + } + + .affix { + top: 125px; + } +} +@media (min-width: 768px) { + .affix { + top: 50px; + } +} + +body { + overflow: scroll; +} + +#header-navbar .navbar-brand { + width: 200px; + height: 50px; + background: transparent none no-repeat scroll left top; + display: inline-block; + white-space: nowrap; + overflow: hidden; + padding-right: 0px; + margin-right: 20px; + padding-left: 5px; + text-indent: 50px; + font-size: 2.5em; + color: #fff; + margin-left: -50px; +} + +#header-navbar .navbar-brand:hover { + color: #000; +} + +.navbar-inverse { + background-color: #fff; + border-color: #fff; +} + +#header-navbar .container { + background-color: #666; + border-color: #090909; + padding: 0px 15px; +} + +.container > .navbar-header { + width: 100%; + margin-right: 0px; + margin-left: 0px; +} + +.navbar-inverse .navbar-nav { + /* margin: 0px -15px; */ + float: right; + /* padding-right: 15px; */ +} + +.navbar-inverse .navbar-nav > li { + border-left: 1px solid #aaa; + display: inline-block; + float: right; + /* padding-left: 10px; */ +} + +.navbar-inverse .navbar-nav > li > a { + color: #fff; + font-weight: bold; + font-size: 1.2em; +} + +.navbar-inverse .navbar-nav > li > a:hover { + color: #000; +} + +.navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus { + background-color: #b3d9ff; + color: #000; +} + +.navbar-toggle { + margin: 4px 7px; +} + +.refine { + display: inline-block; + float:left; + padding: 25px 10px; + margin-right: 10px; +} + +.summary { + display: inline-block; + float:left; + width: 100%; +} + +#myDropDown { + border: 1px solid #aaa; + padding: 0px 5px; + background-color: #ccc; +} + +#myDropDown.open { + background-color: transparent; + border-bottom: 1px solid white; + margin-bottom: -1px; +} + +#myDropDown a h4 { + color: black; +} + +#myDropDown:hover, #myDropDown a:hover, #myDropDown a:hover h4 { + text-decoration: none; + background-color: #fff; + color: #000; +} + +#myTabs { + margin-left: -10px; + right: auto; + left: 5px; +} + +#myTabs > div.row { + min-width: 500px; + max-height: 600px; + overflow: auto; +} + +#myDropDown .filter-clear-all { + padding: 5px 0px 5px 5px; +} + +#myDropDown .filter-clear-all .btn { + border: none; + text-decoration: underline; + color: #23527c; + cursor: pointer; +} + +#myDropDown .filter-clear-all .btn:hover { + color: red; + text-decoration-color: red; +} + +#myDropDown .filter-clear-all .btn .text { + padding-left: 5px; +} + +.dropdown li { + margin: 0; + cursor: pointer; + box-sizing: border-box; + background-color: #fff; + padding: 3px; + width: 100%; + text-align: left; +} + +.dropdown li:hover { + background-color: #fff; + padding-left: 3px; +} + +.dropdown li a:hover{ + background-color: #fff; +} + +.dropdown-menu { + right: 5px; + left: auto; +} + +.dropdown-menu .divider, .dropdown-menu .divider:hover { + height: 1px; + margin: 9px 0; + overflow: hidden; + background-color: #e5e5e5; + border-left: none; +} + +.facet-label .remove { + padding-left: 5px; + color: red; +} + +.facet_extended_list a { + padding-left: 10px; +} + +#main-container { + margin-top: 70px; +} + +.top_padding { + margin-top: 60px; +} + +/* application search */ +.searchbar { + display: block; + float: left; + +} + +.search-query-form .form-control { + border-radius: unset; + border-color: #666; + margin-left: -4px; + padding: 5px 5px 5px 7px; +} + +#search_field { + background-color: #ccc; + font-weight: bold; + color: #000; + width: 100% +} + +#search { + background-color: #ccc; + color: #000; + width: 100% +} + +#search:hover { + background-color: #666; + color: #fff; +} + +.navbar-form .form-group { + padding: 0px +} + +/* Home page search */ +.navbar-form .nav-tabs { + border-bottom: 0px; +} + +.navbar-form .nav-tabs > li { + border-bottom: 1px solid #cccccc; +} + +.navbar-form .nav-tabs > li:active { + border-bottom: 0px; +} + +.navbar-form .input-group { + width: 100%; + border-top: 0px; + height: 35px; + border-top: 0px; +} + +.navbar-form .input-group > input { + border-top: 0px; +} + +.home-search-btn { + vertical-align: top; +} + +.home-search-btn .btn { + background-color: #ccc; + color: #000; +} + +.home-search-btn .btn:hover { + background-color: #666; + color: #fff; +} + +#q:focus { + border-color: #ccc; +} + +/* results page */ + +h2, h3, h4 { + color: #999; + font-weight: bold; +} + +.facet_limit > .panel-heading { + background-color: #b3d9ff; +} + +.facet_limit > .panel-heading.collapsed { + background-color: #f5f5f5; +} + +.facet_limit-active { + border-color: #ddd; +} + +.facet_limit-active > .panel-heading { + background-color: #b3d9ff; + color: #000; + border-color: #ddd; +} + +.facet_limit-active > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #ddd; +} + +.facet-values li .selected { + color: #000; +} + +.panel-body .btn-secondary { + margin: 3px; + padding: 3px; + border: 1px solid #cccccc; + width: 100%; + text-align: left; +} + +.panel-body .btn > img { + padding-right: 5px; +} + +.panel-body .btn-primary-outline { + color: #0275D8; + background-color: transparent; + background-image: none; + border-color: #0275D8; +} + +.panel-body .btn-primary { + margin: 0 5px 5px 0; +} + +.panel-footer .pull-left { + padding-right: 0px; +} + +.panel-footer .pull-right { + padding-left: 0px; +} + +#century_panel { + height: 400px; + text-align: center; + float:left; + position: relative; + padding-left: 0px; +} + +#century_slider { + height: auto; + width: 25px; + float: left; + position: relative; + padding-right: 0px; +} + +#century, #annotations_recent, #annotations_author { + margin-left: 15px; +} + +.simple-query > .constraint-value > .filterName{ + font-weight: bold; +} + +.simple-query > .constraint-value > .filterValue{ + font-weight: bold; +} + +.simple-filter > .constraint-value > .filterName{ + font-weight: bold; +} + +.simple-filter > .constraint-value > .filterValue{ + font-weight: bold; +} + +.btn-link { + background:none!important; + border: none; + padding: 0!important; + font: inherit; + cursor: pointer; +} + +.tabbed { + padding: 0px 0px 10px 10px; +} + +.panel-results-summary { + margin: 0px 20px 20px 0px; + border: 1px solid #cccccc; +} + +.inline-headers h1, .inline-headers h2, .inline-headers h4 { + display: inline-block; + vertical-align: baseline; +} + +.search-panel { + margin-bottom: 10px; + border: 1px solid #cccccc; +} + +.search-panel-auto { + width: auto; + display: block; + float: left; + margin-right: 20px; +} + +.search-panel > .panel-body { + padding: 5px; +} + +#sort-dropdown > .btn { + border: none; + text-decoration: none; +} + +#sort-dropdown > .btn > .btn-value { + text-decoration: underline; + margin-left: 5px; +} + +#searchinfo { + margin-bottom: 0.5em; + padding-bottom: 0.5em; +} + +.results-thumbnail { + width: 75px; + max-height: 100px; + display: block; +} + +.iiif-logo { + padding: 2px; + border: 1px solid #ccc; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; +} + +.iiif-logo > a > img { + width: 24px; +} + +.results-footer { + background-color: #666; + color: #fff; + padding: 0px 3px; + margin: 0px; + border-bottom-right-radius: 0px; + border-bottom-left-radius: 0px; + max-height: 25px; +} + +.bookmark_add, .bookmark_remove, .checkbox.toggle_bookmark { + background-color: #666; + /* border: 1px solid #ccc;*/ + border: none; + min-height: 14px; + padding: 0px; + //padding: 3px 5px; +} + +.toggle_bookmark > input[type="checkbox"] { + opacity: 0; +} + +.bookmark_add, label.toggle_bookmark { + color: #fff; +} + +.bookmark_remove, label.toggle_bookmark.checked { + color: orange; +} + +label.toggle_bookmark > span::before { + font-family: 'Glyphicons Halflings'; + content:"\e044"; + padding-right: 5px; + vertical-align: middle; +} + +.bookmark_inverse_add, .bookmark_inverse .checkbox.toggle_bookmark{ + background-color: #fff; + /* border: 1px solid #ccc;*/ + border: none; + float: right; + padding: 3px 5px; +} + +.bookmark_inverse_remove, .bookmark_inverse label.toggle_bookmark { + color: #000; +} + +.bookmark_inverse_remove, .bookmark_inverse label.toggle_bookmark.checked { + color: #ff8700; +} + +a.result { + color: #fff; + font-weight: bold; + padding-top: 0px; + padding-bottom: 0px; +} + +a.noresult { + color: #aaa; + font-weight: bold; + pointer-events: none; + cursor: not-allowed; + padding-top: 0px; + padding-bottom: 0px; +} + +.prev-page { + top: 50%; + transform: translateY(25%); +} + +.btn-paginate-next, .btn-paginate-prev, .btn-top { + border: 1px solid #aaa; + background-color: #fff; + color: #aaa; + text-align: right; +} + +.btn-paginate-next:hover, .btn-paginate-prev:hover, .btn-top:hover { + border-color: #000; + background-color: #666; + color: #fff; +} + +.btn-paginate-next { + padding: 10px; + margin: 10px 0px 10px 10px; + //border-right: none; +} + +.btn-paginate-prev { + padding: 10px; + margin: 10px 10px 10px 0px; + //border-left: none; +} + +.btn-paginate-next > .col-md-3 { + padding: 5px; + vertical-align: center; +} + +.btn-paginate-next > .col-md-9 { + padding: 5px; +} + +.footer-per-page { + margin: 10px; + text-align: center; + content-align: center; + top: 50%; + transform: translateY(150%); +} + +.page-count { + padding: 0px 5px; +} + +/* .page-count span:not(:first-child):not(:last-child)::after {*/ +.page-count span:not(:last-child)::after { + content: " | "; +} + +.page-count span:first-child { + padding-left: 5px; +} + +.page-count span:last-child { + padding-right: 5px; +} + +.footer-top { + //top: 50%; + //transform: translateY(60%); + margin: 10px 0px; + padding: 10px 0px; +} + +/* annotation results page */ +.annotation-result .media-body { + width: auto; +} + +/* transcription results page */ +.transcription-result .media-body { + width: auto; +} + +/* Manuscript show */ +.inline { + display: inline; +} + +.navbar-green .container, .navbar-green .container .navbar-collapse { + margin-left: 0px; + padding: 0px; +} + +.navbar-green, +.navbar-green .navbar-nav { + background-color: #b3e5b3; + border-color: #3bab3b; + font-weight: bold; + margin-bottom: 0px; + border-radius: 0px; +} + +.navbar-green .navbar-nav li a { + color: #333; +} + +.navbar-green .navbar-nav > .active > a, +.navbar-green .navbar-nav > .active > a:hover, +.navbar-green .navbar-nav > .active > a:focus { + background-color: #3bab3b; + color: #fff; +} + +.panel-content { + border-radius: 0px; +} + +#summary p, #description dd { + text-align: left; +} + +a.result-inverse { + color: #666; + font-weight: bold; +} + +a.noresult-inverse { + color: #aaa; + font-weight: bold; + pointer-events: none; + cursor: not-allowed; +} + +.panel-default > .results-header { + background-color: #666; + color: #fff; + padding: 3px; + margin: 0px; +} + +.panel-default > .panel-body > dl { + margin-bottom: 0px; +} + +#viewer { + width: 100%; + height: 100%; + margin-bottom: 10px; +} + +/* folio show */ + +.tabbable { + border: 1px solid #ccc; +} + +.tab-content { + padding: 10px; +} + +.folio-first-transcription p { + text-align: center; + padding-top: 5px; +} + +.folio-footer { + margin: 30px 0px; +} + +.media-body-center { + vertical-align: middle; +} + +.folio-panel { + //margin: 10px 30px; + border: 1px solid #cccccc; + //max-width: 250px; + margin: auto auto 10px; +} + +.folio-verso { + display: none; +} + +.folio-panel > .panel-body { + padding: 5px; +} + +.folio-img img { + max-width: 70px; +} + +.folio-tabs { + border: 2px solid #aaa; + border-radius: 0px; +} + +.folio-tabs > li { + background-color: #aaa; + color: #666; + border: 2px solid #666; + border-radius: 0px; + margin: -1px; + padding: 10px; +} + +.folio-tabs > li.active { + background-color: #fff; + color: #000; + border: 2px solid #666; + border-radius: 0px; + border-top: none; + margin: -2px; + height: 45px; +} + +.folio-tabs > li:hover, .folio-tabs > li.active:hover { + background-color: #333; + color: #fff; +} + +.transcription_text, .annotation_text { + //border-bottom: 1px solid #ccc; + margin: 0px 0px 3px 0px; +} + +/* +// Annotations displayed in mirador +.annotation { + border: none; + box-shadow: none; +} +.annotation.selected { + border: none; + box-shadow: none; +} +.annotation.hovered { + border: none; + box-shadow: none; +} +*/ + +#nav_top { + display: none; +} + +.tabs-left > li > a { + color: #000; +} + +.tabs-left > li { + margin-left: 5px; + border: none; + border-right: 1px solid #ccc; +} + +.tabs-left > li.active { + border: 1px solid #ccc; + border-right: none; + color: #000; +} + +.tabs-left > li.active > a, .tabs-left > li.active > a:hover, .tabs-left > li.active > a:focus { + border: none; + color: #000; +} + +.tabs-left > li:hover, .tabs-left > li > a:hover { + font-weight: normal; +} \ No newline at end of file diff --git a/app/assets/stylesheets/colligo_slider.css.scss b/app/assets/stylesheets/colligo_slider.css.scss new file mode 100644 index 0000000..d125c61 --- /dev/null +++ b/app/assets/stylesheets/colligo_slider.css.scss @@ -0,0 +1,47 @@ +.slider-tick { + width: 2px; + height: 2px; +} + +.slider-handle.custom { + background: transparent asset_url('play-arrow-16-1.png') no-repeat scroll 0% 50%; +} +/* +.slider-track-low::before { + line-height: 20px; + font-size: 20px; + content: ; + color: #ccc; +} +*/ + +.slider-handle.custom::before { + content: none; + color: #ccc; +} + +.slider-tick.custom::before { + content: "-"; + color: #726204; +} + +.slider-selection.tick-slider-selection { + background-image: linear-gradient(to bottom, #aab 0%, #aaa 100%); + background-repeat: repeat-x; +} + +.slider-selection { + background-image: linear-gradient(to bottom, #aab 0%, #aaa 100%); + background-repeat: repeat-x; +} + +.slider-track { + background-image: linear-gradient(to bottom, #e5e5e5 0%, #e9e9e9 100%); + background-repeat: repeat-x; + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1) inset; + border-radius: 4px; +} + +.slider.slider-vertical .slider-track { + width: 2px; +} diff --git a/app/assets/stylesheets/form_input_with_glyph.css.scss b/app/assets/stylesheets/form_input_with_glyph.css.scss new file mode 100644 index 0000000..2be89b3 --- /dev/null +++ b/app/assets/stylesheets/form_input_with_glyph.css.scss @@ -0,0 +1,32 @@ +.inner-addon { + position: relative; + display: inline; + float: left; + margin-bottom: 5px; +} +.lookup-label { + position: relative; + display: inline; + float: left; + vertical-align: middle; + padding: 7px 3px; +} + +/* style icon */ +.inner-addon .glyphicon { + position: absolute; + padding: 10px; + pointer-events: none; +} + +/* align icon */ +.left-addon .glyphicon { left: 0px;} +.right-addon .glyphicon { right: 0px;} + +/* add padding */ +.left-addon input { padding-left: 30px; } +.right-addon input { padding-right: 30px; } + +.ui-widget-content { + background: #fff; +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8b79ffe..b40b8f1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,4 +6,30 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + helper_method :on_home_page, :request_path + + def on_home_page + request_path[:controller] == 'catalog' && request_path[:action] == 'index' && params[:f].blank? && params[:q].blank? && params[:range].blank? + end + + def on_bento_page + request_path[:controller] == 'catalog' && request_path[:action] == 'index' && params[:search_field] == 'all_fields' + end + + def on_manuscripts_page + request_path[:controller] == 'catalog' && request_path[:action] == 'index' && params[:search_field] == 'descriptions' + end + + def on_annotations_page + request_path[:controller] == 'catalog' && request_path[:action] == 'index' && params[:search_field] == 'annotations' + end + + def on_transcriptions_page + request_path[:controller] == 'catalog' && request_path[:action] == 'index' && params[:search_field] == 'transcriptions' + end + + def request_path + Rails.application.routes.recognize_path(request.path) + end end diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb new file mode 100644 index 0000000..5f4d04d --- /dev/null +++ b/app/controllers/bookmarks_controller.rb @@ -0,0 +1,25 @@ +# -*- encoding : utf-8 -*- +class BookmarksController < CatalogController + include Blacklight::Bookmarks + include Colligo::SearchManuscripts + + def index + @bookmarks = token_or_current_or_guest_user.bookmarks + bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s } + + @response_m, @document_list_m = fetch(bookmark_ids) + related_annotations + related_transcriptions + respond_to do |format| + format.html {} + format.rss { render layout: false } + format.atom { render layout: false } + format.json do + render json: render_search_results_as_json + end + + additional_response_formats(format) + document_export_formats(format) + end + end +end diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 1e5dd7b..b1cf085 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -1,75 +1,64 @@ # -*- encoding : utf-8 -*- class CatalogController < ApplicationController - include Blacklight::Marc::Catalog - include Blacklight::Catalog + include Colligo::SearchManuscripts + + layout :resolve_layout configure_blacklight do |config| ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters config.default_solr_params = { qt: 'search', - rows: 10 + rows: 10, + 'facet.limit' => -1, + 'facet.sort' => 'count' } - # solr path which will be added to solr base url before the other solr params. - # config.solr_path = 'select' - - # items to show per page, each number in the array represent another option to choose from. - # config.per_page = [10,20,50,100] - - ## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or - ## parameters included in the Blacklight-jetty document requestHandler. - # - # config.default_document_solr_params = { - # :qt => 'document', - # ## These are hard-coded in the blacklight 'document' requestHandler - # # :fl => '*', - # # :rows => 1 - # # :q => '{!raw f=id v=$id}' - # } - # solr field configuration for search results/index views config.index.title_field = 'title_display' config.index.display_type_field = 'format' - # solr field configuration for document/show views - # config.show.title_field = 'title_display' - # config.show.display_type_field = 'format' - - # solr fields that will be treated as facets by the blacklight application - # The ordering of the field names is the order of the display - # - # Setting a limit will trigger Blacklight's 'more' facet values link. - # * If left unset, then all facet values returned by solr will be displayed. - # * If set to an integer, then "f.somefield.facet.limit" will be added to - # solr request, with actual solr request being +1 your configured limit -- - # you configure the number of items you actually want _displayed_ in a page. - # * If set to 'true', then no additional parameters will be sent to solr, - # but any 'sniffed' request limit parameters will be used for paging, with - # paging at requested limit -1. Can sniff from facet.limit or - # f.specific_field.facet.limit solr request params. This 'true' config - # can be used if you set limits in :default_solr_params, or as defaults - # on the solr side in the request handler itself. Request handler defaults - # sniffing requires solr requests to be made with "echoParams=all", for - # app code to actually have it echo'd back to see it. - # - # :show may be set to false if you don't want the facet to be drawn in the - # facet bar config.add_facet_field 'format', label: 'Format' - config.add_facet_field 'pub_date', label: 'Publication Year', single: true - config.add_facet_field 'subject_topic_facet', label: 'Topic', limit: 20 - config.add_facet_field 'language_facet', label: 'Language', limit: true - config.add_facet_field 'lc_1letter_facet', label: 'Call Number' - config.add_facet_field 'subject_geo_facet', label: 'Region' - config.add_facet_field 'subject_era_facet', label: 'Era' - - config.add_facet_field 'example_pivot_field', label: 'Pivot Field', pivot: %w(format language_facet) - - config.add_facet_field 'example_query_facet_field', label: 'Publish Date', query: { - years_5: { label: 'within 5 Years', fq: "pub_date:[#{Time.now.year - 5} TO *]" }, - years_10: { label: 'within 10 Years', fq: "pub_date:[#{Time.now.year - 10} TO *]" }, - years_25: { label: 'within 25 Years', fq: "pub_date:[#{Time.now.year - 25} TO *]" } + config.add_facet_field 'type_of_resource_facet', label: 'Type of resource' + config.add_facet_field 'authors_all_facet', label: 'Authors' + config.add_facet_field 'topic_facet', label: 'Topic'#, limit: 20 + config.add_facet_field 'geographic_facet', label: 'Region' + config.add_facet_field 'era_facet', label: 'Era' + config.add_facet_field 'manuscript_facet', label: 'Manuscript' + config.add_facet_field 'language', label: 'Language', solr_params: { 'facet.limit' => -1 } + config.add_facet_field 'place_facet', label: 'Place of origin' + config.add_facet_field 'model', label: 'Type' + config.add_facet_field 'folio', label: 'Folio' + config.add_facet_field 'collection', label: 'Repository' + # config.add_facet_field 'example_pivot_field', label: 'Pivot Field', pivot: %w(format language) + config.add_facet_field 'date_range', if: false, label: 'Century', query: { + years_21: { label: '21st', fq: 'pub_date_t:[2000 TO *]' }, + years_20: { label: '20th', fq: 'pub_date_t:[1900 TO 1999]' }, + years_19: { label: '19th', fq: 'pub_date_t:[1800 TO 1899]' }, + years_18: { label: '18th', fq: 'pub_date_t:[1700 TO 1799]' }, + years_17: { label: '17th', fq: 'pub_date_t:[1600 TO 1699]' }, + years_16: { label: '16th', fq: 'pub_date_t:[1500 TO 1599]' }, + years_15: { label: '15th', fq: 'pub_date_t:[1400 TO 1499]' }, + years_14: { label: '14th', fq: 'pub_date_t:[1300 TO 1399]' }, + years_13: { label: '13th', fq: 'pub_date_t:[1200 TO 1299]' }, + years_12: { label: '12th', fq: 'pub_date_t:[1100 TO 1199]' }, + years_11: { label: '11th', fq: 'pub_date_t:[1000 TO 1099]' }, + years_10: { label: '10th', fq: 'pub_date_t:[900 TO 999]' }, + years_9: { label: '9th', fq: 'pub_date_t:[800 TO 899]' }, + years_8: { label: '8th', fq: 'pub_date_t:[700 TO 799]' }, + years_7: { label: '7th', fq: 'pub_date_t:[600 TO 699]' }, + years_6: { label: '6th', fq: 'pub_date_t:[500 TO 599]' }, + years_5: { label: '5th', fq: 'pub_date_t:[400 TO 499]' }, + years_4: { label: '4th', fq: 'pub_date_t:[300 TO 399]' }, + years_3: { label: '3rd', fq: 'pub_date_t:[200 TO 299]' }, + years_2: { label: '2nd', fq: 'pub_date_t:[100 TO 199]' }, + years_1: { label: '1st', fq: 'pub_date_t:[0 TO 99]' } } + config.add_facet_field 'pub_date_t', label: 'Publication Year', range: { + num_segments: 21, + assumed_boundaries: [0, 2999], + segments: true + } # Have BL send all facet field names to Solr, which has been the default # previously. Simply remove these lines if you'd rather use Solr request @@ -79,101 +68,171 @@ class CatalogController < ApplicationController # solr fields to be displayed in the index (search results) view # The ordering of the field names is the order of the display config.add_index_field 'title_display', label: 'Title' - config.add_index_field 'title_vern_display', label: 'Title' - config.add_index_field 'author_display', label: 'Author' - config.add_index_field 'author_vern_display', label: 'Author' + config.add_index_field 'authors_all_display', label: 'Author' config.add_index_field 'format', label: 'Format' - config.add_index_field 'language_facet', label: 'Language' - config.add_index_field 'published_display', label: 'Published' - config.add_index_field 'published_vern_display', label: 'Published' - config.add_index_field 'lc_callnum_display', label: 'Call number' - + config.add_index_field 'language', label: 'Language' + config.add_index_field 'abstract_display', label: 'Abstract' + config.add_index_field 'topic_display', label: 'Topic' + config.add_index_field 'geographic_display', label: 'Region' + config.add_index_field 'era_display', label: 'Era' + config.add_index_field 'pub_date_display', label: 'Date' + config.add_index_field 'collection', label: 'Repository' # solr fields to be displayed in the show (single result) view # The ordering of the field names is the order of the display config.add_show_field 'title_display', label: 'Title' - config.add_show_field 'title_vern_display', label: 'Title' config.add_show_field 'subtitle_display', label: 'Subtitle' - config.add_show_field 'subtitle_vern_display', label: 'Subtitle' - config.add_show_field 'author_display', label: 'Author' - config.add_show_field 'author_vern_display', label: 'Author' + config.add_show_field 'title_alternate_display', label: 'Alternate titles' + config.add_show_field 'title_other_display', label: 'Other titles' + config.add_show_field 'authors_all_display', label: 'Author' config.add_show_field 'format', label: 'Format' - config.add_show_field 'url_fulltext_display', label: 'URL' - config.add_show_field 'url_suppl_display', label: 'More Information' - config.add_show_field 'language_facet', label: 'Language' - config.add_show_field 'published_display', label: 'Published' - config.add_show_field 'published_vern_display', label: 'Published' - config.add_show_field 'lc_callnum_display', label: 'Call number' - config.add_show_field 'isbn_t', label: 'ISBN' + config.add_show_field 'language', label: 'Language' + config.add_show_field 'pub_date_display', label: 'Date' + config.add_show_field 'collection', label: 'Repository' # "fielded" search configuration. Used by pulldown among other places. # For supported keys in hash, see rdoc for Blacklight::SearchFields - # - # Search fields will inherit the :qt solr request handler from - # config[:default_solr_parameters], OR can specify a different one - # with a :qt key/value. Below examples inherit, except for subject - # that specifies the same :qt as default for our own internal - # testing purposes. - # - # The :key is what will be used to identify this BL search field internally, - # as well as in URLs -- so changing it after deployment may break bookmarked - # urls. A display label will be automatically calculated from the :key, - # or can be specified manually to be different. - - # This one uses all the defaults set by the solr request handler. Which - # solr request handler? The one set in config[:default_solr_parameters][:qt], - # since we aren't specifying it otherwise. - - config.add_search_field 'all_fields', label: 'All Fields' - - # Now we see how to over-ride Solr request handler defaults, in this - # case for a BL "search field", which is really a dismax aggregate - # of Solr search fields. - - config.add_search_field('title') do |field| - # solr_parameters hash are sent to Solr as ordinary url query params. - field.solr_parameters = { 'spellcheck.dictionary': 'title' } - - # :solr_local_parameters will be sent using Solr LocalParams - # syntax, as eg {! qf=$title_qf }. This is neccesary to use - # Solr parameter de-referencing like $title_qf. - # See: http://wiki.apache.org/solr/LocalParams - field.solr_local_parameters = { - qf: '$title_qf', - pf: '$title_pf' - } + config.add_search_field 'all_fields', label: 'All Content' + config.add_search_field('descriptions') do |field| + field.qt = 'descriptions' end - config.add_search_field('author') do |field| - field.solr_parameters = { 'spellcheck.dictionary': 'author' } - field.solr_local_parameters = { - qf: '$author_qf', - pf: '$author_pf' - } + config.add_search_field('transcriptions') do |field| + field.qt = 'transcriptions' end - # Specifying a :qt only to show it's possible, and so our internal automated - # tests can test it. In this case it's the same as - # config[:default_solr_parameters][:qt], so isn't actually neccesary. - config.add_search_field('subject') do |field| - field.solr_parameters = { 'spellcheck.dictionary': 'subject' } - field.qt = 'search' - field.solr_local_parameters = { - qf: '$subject_qf', - pf: '$subject_pf' - } + config.add_search_field('annotations') do |field| + field.qt = 'annotations' end # "sort results by" select (pulldown) # label in pulldown is followed by the name of the SOLR field to sort by and # whether the sort is ascending or descending (it must be asc or desc # except in the relevancy case). - config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', label: 'relevance' - config.add_sort_field 'pub_date_sort desc, title_sort asc', label: 'year' - config.add_sort_field 'author_sort asc, title_sort asc', label: 'author' - config.add_sort_field 'title_sort asc, pub_date_sort desc', label: 'title' + config.add_sort_field 'score desc, title_sort asc', label: 'relevance' + # config.add_sort_field 'authors_all_facet asc, title_sort asc', label: 'author' # If there are more than this many search results, no spelling ("did you # mean") suggestion is offered. config.spell_max = 5 end + + def index + if on_home_page + blacklight_config.default_solr_params['facet.limit'] = 6 + manuscripts + annotations + plot_data + render 'homepage' + elsif on_bento_page + manuscripts + annotations + transcriptions + session_save_manuscript_search + render 'bentopage' + elsif on_manuscripts_page + blacklight_config.add_sort_field 'title_sort asc, pub_date_sort asc', label: 'title' + blacklight_config.add_sort_field 'pub_date_sort asc, title_sort asc', label: 'century' + blacklight_config.add_sort_field 'collection asc, title_sort asc', label: 'repository' + manuscripts + related_annotations + related_transcriptions + session_save_manuscript_search + render 'manuscript_results' + elsif on_transcriptions_page + blacklight_config.add_sort_field 'folio_sort asc, manuscript_sort asc', label: 'folio' + blacklight_config.add_sort_field 'manuscript_sort asc, folio_sort asc', label: 'manuscript' + blacklight_config.add_sort_field 'last_updated desc', label: 'most recent' + transcriptions + render 'transcription_results' + elsif on_annotations_page + blacklight_config.add_sort_field 'folio_sort asc, manuscript_sort asc', label: 'folio' + blacklight_config.add_sort_field 'manuscript_sort asc, folio_sort asc', label: 'manuscript' + blacklight_config.add_sort_field 'last_updated desc', label: 'most recent' + annotations + render 'annotation_results' + else + super + end + end + + private + + def resolve_layout + if on_home_page + 'homepage' + else + 'blacklight' + end + end + + def all_results + self.search_params_logic += [:all_search_filter] + self.search_params_logic -= [:add_manuscript_filter, :add_annotation_filter, :add_transcription_filter] + (@response_all, @document_list_all) = search_results(params || {}, self.search_params_logic) + end + + def manuscripts + self.search_params_logic += [:add_manuscript_filter] + self.search_params_logic -= [:all_search_filter, :add_annotation_filter, :add_transcription_filter] + (@response_m, @document_list_m) = search_results(params || {}, self.search_params_logic) + end + + def session_save_manuscript_search + m_params = request.query_parameters.except(:controller, :action, :search_field, :page) + m_params[:numFound] = @response_m['response']['numFound'] + session[:m_last_search_query] = m_params.to_json + session.delete(:m_current_display_query) + end + + def annotations + self.search_params_logic += [:add_annotation_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_transcription_filter] + (@response_a, @document_list_a) = search_results(params || {}, self.search_params_logic) + end + + def transcriptions + self.search_params_logic += [:add_transcription_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_annotation_filter] + (@response_t, @document_list_t) = search_results(params || {}, self.search_params_logic) + end + + def plot_data + data = solr_range_queries_to_a('pub_date_t') + @data_array = [] + @data_ticks = [] + @pointer_lookup = [] + @slider_ticks = [] + @boundaries = [] + # @slider_labels = [] + data.each do |val| + @data_array << [val[:count], val[:from]] + if val[:from] == 0 + label = '1st' + elsif val[:from] == 100 + label = '2nd' + elsif val[:from] == 200 + label = '3rd' + else + label = "#{((val[:from] / 100) + 1)}th" + end + @data_ticks << [val[:from], label] + @slider_ticks << val[:from] + # @slider_labels << label + @pointer_lookup << { 'from': val[:from], 'to': val[:to], 'count': val[:count], 'label': "#{val[:from]} to #{val[:to]}" } + end + if @data_array.any? + @boundaries = [@data_array.first.last, @data_array.last.last] + end + end + + def solr_range_queries_to_a(solr_field) + return [] unless @response_m['facet_counts'] && @response_m['facet_counts']['facet_queries'] + array = [] + @response_m['facet_counts']['facet_queries'].each_pair do |query, count| + if query =~ /#{solr_field}: *\[ *(\d+) *TO *(\d+) *\]/ + array << { from: Regexp.last_match(1).to_i, to: Regexp.last_match(2).to_i, count: count.to_i } + end + end + array.sort_by { |hash| hash[:from].to_i } + end end diff --git a/app/controllers/concerns/colligo/search_manuscripts.rb b/app/controllers/concerns/colligo/search_manuscripts.rb new file mode 100644 index 0000000..8801c1e --- /dev/null +++ b/app/controllers/concerns/colligo/search_manuscripts.rb @@ -0,0 +1,26 @@ +# -*- encoding : utf-8 -*- +module Colligo::SearchManuscripts + extend ActiveSupport::Concern + + def related_annotations + @related_annotations = {} + @document_list_m.each do |doc| + query_params = { q: "manuscript_search:\"#{doc['title_display']}\"", rows: 0 } + self.search_params_logic += [:add_annotation_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_transcription_filter] + (resp, _doc_list) = search_results(query_params, self.search_params_logic) + @related_annotations[doc['druid']] = resp['response']['numFound'] + end + end + + def related_transcriptions + @related_transcriptions = {} + @document_list_m.each do |doc| + query_params = { q: "manuscript_search:\"#{doc['title_display']}\"", rows: 0 } + self.search_params_logic += [:add_transcription_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_annotation_filter] + (resp, _doc_list) = search_results(query_params, self.search_params_logic) + @related_transcriptions[doc['druid']] = resp['response']['numFound'] + end + end +end diff --git a/app/controllers/folio_controller.rb b/app/controllers/folio_controller.rb new file mode 100644 index 0000000..d087423 --- /dev/null +++ b/app/controllers/folio_controller.rb @@ -0,0 +1,104 @@ +class FolioController < ApplicationController + include Blacklight::Configurable + include Blacklight::SearchHelper + include Blacklight::SearchContext + copy_blacklight_config_from(CatalogController) + blacklight_config.max_per_page = 1000 + + layout 'blacklight' + + def show + # Get details of manuscript + manuscript + # Get current canvas id, previous and next folio + current_prev_and_next_folio + # Get all transcriptions and annotations + annotations + transcriptions + # If no annotation or transcriptions add a flash notice + if @annotations.blank? && @transcriptions.blank? + flash[:notice] = "There are no transcriptions or annotations for folio #{params[:id]}" + # redirect_to manuscript_path(params[:manuscript_id]) and return # + end + # Set a value for the active tab + if !params.key?(:view) && @annotations.present? + params[:view] = 'annotations' + elsif !params.key?(:view) && @transcriptions.present? + params[:view] = 'transcriptions' + end + params[:view] = 'annotations' unless %w(annotations transcriptions).include?(params[:view]) + respond_to do |format| + format.html do + render + end + end + end + + def folio_label + # Get details of manuscript + manuscript + label = folio_from_canvas + respond_to do |format| + format.json do + render json: { folio: label } + end + end + end + + private + + def annotations + query_params = { q: "druid:#{params[:manuscript_id]} AND folio:\"#{params[:id]}\"", rows: 1000, sort: 'sort_index asc' } + self.search_params_logic += [:add_annotation_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_transcription_filter] + (_resp, @annotations) = search_results(query_params, self.search_params_logic) + end + + def transcriptions + query_params = { q: "druid:#{params[:manuscript_id]} AND folio:\"#{params[:id]}\"", rows: 1000, sort: 'sort_index asc' } + self.search_params_logic += [:add_transcription_filter] + self.search_params_logic -= [:all_search_filter, :add_manuscript_filter, :add_annotation_filter] + (_resp, @transcriptions) = search_results(query_params, self.search_params_logic) + end + + def manuscript + @manuscript = nil + query_params = { q: "druid:#{params[:manuscript_id]}", rows: 1 } + self.search_params_logic += [:add_manuscript_filter] + self.search_params_logic -= [:all_search_filter, :add_annotation_filter, :add_transcription_filter] + (_resp, doc) = search_results(query_params, self.search_params_logic) + @manuscript = doc.first if doc + end + + def canvas_id + # The canvas id in the annotations target can be different from the manifest + # - using the one from the manifest - see current_prev_and_next_folio + if @annotations.present? + @canvas_id = @annotations[0]['target_url'][0].split('#')[0] + elsif @transcriptions.present? + @canvas_id = @transcriptions[0]['target_url'][0].split('#')[0] + end + end + + def current_prev_and_next_folio + # TODO: For now I am downloading manifest - Should I index the manifest and read the data from solr instead? + # The canvas id in the annotations can be different from the manifest - using the one in the manifest + # This method subsumes the method canvas_id + contents = [] + contents = IiifManifest.new(@manuscript['manifest_urls'].first).contents unless @manuscript['manifest_urls'].blank? + @previous_folio = nil + @next_folio = nil + @canvas_id = nil + page_number = contents.index { |c| c['label'] == params[:id] } + @canvas_id = contents[page_number]['@id'] if page_number + @previous_folio = contents[page_number - 1] if page_number && page_number > 0 + @next_folio = contents[page_number + 1] if page_number && page_number < contents.length + end + + def folio_from_canvas + contents = [] + contents = IiifManifest.new(@manuscript['manifest_urls'].first).contents unless @manuscript['manifest_urls'].blank? + page_number = contents.index { |c| c['@id'] == params[:canvas_id] } + contents[page_number]['label'] + end +end diff --git a/app/controllers/manuscript_controller.rb b/app/controllers/manuscript_controller.rb new file mode 100644 index 0000000..7f4492f --- /dev/null +++ b/app/controllers/manuscript_controller.rb @@ -0,0 +1,108 @@ +class ManuscriptController < ApplicationController + include Blacklight::Configurable + include Blacklight::SearchHelper + include Blacklight::SearchContext + copy_blacklight_config_from(CatalogController) + + layout 'blacklight' + + def show + @response, @document = fetch(params[:id]) + # Sanitize results for the viewer + sd = SolrDocument.new + @document.each do |k, v| + @document[k] = [] if v.blank? && !sd.single_valued_display_fields.include?(k) + end + sd.all_display_fields.each do |k| + unless @document.include?(k) + @document[k] = [] unless sd.single_valued_display_fields.include?(k) + end + end + # Get the contents from the manifest - need this for getting first folio + # TODO: Index manifest and use that to retrieve the details + @contents = [] + @contents = IiifManifest.new(@document['manifest_urls'].first).contents unless @document['manifest_urls'].blank? + # Get related annotations and transcriptions + @related_annotations = folio_related_annotations[0] + @related_transcriptions = folio_related_transcriptions[0] + # Get the next and previous docs + m_previous_and_next_documents + respond_to do |format| + format.html do + render + end + end + end + + def related_content + transcriptions = folio_related_transcriptions + ans = { + annotations: folio_related_annotations, + transcriptions: transcriptions[0], + first_transcription: transcriptions[1] + } + respond_to do |format| + format.json do + render json: ans + end + end + end + + private + + def folio_related_annotations + if params.key?(:folio) && params[:folio].present? + query_params = { q: "druid:#{params[:id]} AND folio:\"#{params[:folio]}\"", rows: 0 } + else + query_params = { q: "druid:#{params[:id]}", rows: 0 } + end + search_params_logic = self.search_params_logic + [:add_annotation_filter] - [:all_search_filter, :add_manuscript_filter, :add_transcription_filter] + (resp, _doc_list) = search_results(query_params, search_params_logic) + resp['response']['numFound'] + end + + def folio_related_transcriptions + if params.key?(:folio) && params[:folio].present? + query_params = { q: "druid:#{params[:id]} AND folio:\"#{params[:folio]}\"", rows: 1, sort: 'sort_index asc' } + else + query_params = { q: "druid:#{params[:id]}", rows: 1, sort: 'sort_index asc' } + end + search_params_logic = self.search_params_logic + [:add_transcription_filter] - [:all_search_filter, :add_manuscript_filter, :add_annotation_filter] + (resp, doc_list) = search_results(query_params, search_params_logic) + if doc_list.present? + [resp['response']['numFound'], doc_list[0]['body_chars_display']] + else + [resp['response']['numFound'], nil] + end + end + + def m_previous_and_next_documents + m_params = current_query + @prev_doc = {} + @next_doc = {} + return if m_params.blank? || m_params[:start].blank? + nav_docs = get_previous_and_next_documents_for_search(m_params[:start], m_params, {}) + if nav_docs.second && nav_docs.second.first.present? && m_params[:start] > 0 + index = m_params[:start] - 1 + @prev_doc['path'] = url_for(controller: 'manuscript', action: 'show', id: nav_docs.second.first['druid'], params: { start: index }) + @prev_doc['title'] = nav_docs.second.first['title_display'] || nav_docs.second.first['druid'] + end + if nav_docs.second && nav_docs.second.second.present? && m_params[:start] < nav_docs.first['response']['numFound'] - 1 + index = m_params[:start] + 1 + @next_doc['path'] = url_for(controller: 'manuscript', action: 'show', id: nav_docs.second.second['druid'], params: { start: index }) + @next_doc['title'] = nav_docs.second.second['title_display'] || nav_docs.second.second['druid'] + end + end + + def current_query + return nil if session[:m_last_search_query].blank? || !params.key?(:start) || params[:start].blank? + m_params = JSON.parse(session[:m_last_search_query]) + begin + m_params['start'] = Integer(params[:start]) + rescue + return nil + end + m_params['qt'] = 'descriptions' + m_params.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo } + end +end diff --git a/app/helpers/blacklight_helper.rb b/app/helpers/blacklight_helper.rb new file mode 100644 index 0000000..3830259 --- /dev/null +++ b/app/helpers/blacklight_helper.rb @@ -0,0 +1,7 @@ +module BlacklightHelper + include Blacklight::BlacklightHelperBehavior + + def application_name + 'Colligo' + end +end diff --git a/app/helpers/colligo/render_breadcrumbs_helper_behavior.rb b/app/helpers/colligo/render_breadcrumbs_helper_behavior.rb new file mode 100644 index 0000000..64b834e --- /dev/null +++ b/app/helpers/colligo/render_breadcrumbs_helper_behavior.rb @@ -0,0 +1,54 @@ +# Includes methods for rendering constraints graphically on the +# search results page (render_constraints(_*)) +module Colligo + module RenderBreadcrumbsHelperBehavior + ## + # Render the facet constraints + # @param [Hash] localized_params query parameters + # @return [String] + def render_breadcrumb_constraints_filters(localized_params = params) + return ''.html_safe unless localized_params[:f] + content = [] + remaining_params = localized_params.except(:f) + localized_params[:f].each_pair do |facet, values| + content << render_breadcrumb_filter_element(facet, values, remaining_params) + end + safe_join(content.flatten, ' > ') + end + + ## + # Render a single facet's constraint + # @param [String] facet field + # @param [Array] values selected facet values + # @param path query parameters + # @return [String] + def render_breadcrumb_filter_element(facet, values, remaining_params) + facet_config = facet_configuration_for_field(facet) + safe_join(values.map do |val| + next if val.blank? # skip empty string + local_params = add_facet_params(facet, val, source_params = remaining_params) + render_breadcrumb_constraint_element(facet_field_label(facet_config.key), facet_display_value(facet, val), + search_path: search_action_path(local_params), + classes: ['filter', 'breadcrumb-filter', 'filter-' + facet.parameterize]) + end, ' | ') + end + + # Render a label/value constraint on the screen. Can be called + # by plugins and such to get application-defined rendering. + # + # Can be over-ridden locally to render differently if desired, + # although in most cases you can just change CSS instead. + # + # Can pass in nil label if desired. + # + # @param [String] label to display + # @param [String] value to display + # @param [Hash] options + # @option options [String] :remove url to execute for a 'remove' action + # @option options [Array] :classes an array of classes to add to container span for constraint. + # @return [String] + def render_breadcrumb_constraint_element(label, value, options = {}) + render(partial: 'shared/breadcrumb_constraints_element', locals: { label: label, value: value, options: options }) + end + end +end diff --git a/app/helpers/colligo/render_simple_constraints_helper_behavior.rb b/app/helpers/colligo/render_simple_constraints_helper_behavior.rb new file mode 100644 index 0000000..995a91b --- /dev/null +++ b/app/helpers/colligo/render_simple_constraints_helper_behavior.rb @@ -0,0 +1,124 @@ +# Includes methods for rendering constraints graphically on the +# search results page (render_constraints(_*)) +module Colligo::RenderSimpleConstraintsHelperBehavior + ## + # Check if the query has any search constraints defined + # + # @param [Hash] query parameters + # @return [Boolean] + def query_has_search_constraints?(localized_params = params) + localized_params[:q].present? + end + + ## + # Check if the query has any facet constraints defined + # + # @param [Hash] query parameters + # @return [Boolean] + def query_has_facet_constraints?(localized_params = params) + return false unless localized_params.key?(:f) + return false if localized_params[:f].blank? + facetvals = localized_params[:f].each { |_k, v| v.reject!(&:blank?) } + facetvals.any? { |_k, v| !v.blank? && v.any? } + end + + ## + # Render the actual constraints, not including header or footer + # info. + # + # @param [Hash] query parameters + # @return [String] + def render_simple_constraints(localized_params = params) + render_simple_constraints_query(localized_params) + render_simple_constraints_filters(localized_params) + end + + ## + # Render the query constraints + # + # @param [Hash] query parameters + # @return [String] + def render_simple_constraints_query(localized_params = params) + # So simple don't need a view template, we can just do it here. + scope = localized_params.delete(:route_set) || self + return ''.html_safe if localized_params[:q].blank? + render_simple_constraint_element(simple_constraint_query_label(localized_params), + localized_params[:q], + classes: ['simple-query query']) + #:remove => scope.url_for(localized_params.merge(:q=>nil, :action=>'index')) ) + end + + ## + # Render the facet constraints + # @param [Hash] localized_params query parameters + # @return [String] + def render_simple_constraints_filters(localized_params = params) + return ''.html_safe unless localized_params[:f] + content = [] + localized_params[:f].each_pair do |facet, values| + content << render_simple_filter_element(facet, values, localized_params) + end + + safe_join(content.flatten, "\n") + end + + ## + # Render a single facet's constraint + # @param [String] facet field + # @param [Array] values selected facet values + # @param [Hash] path query parameters + # @return [String] + def render_simple_filter_element(facet, values, localized_params) + facet_config = facet_configuration_for_field(facet) + + safe_join(values.map do |val| + next if val.blank? # skip empty string + render_simple_constraint_element(facet_field_label(facet_config.key), facet_display_value(facet, val), + remove: search_action_path(remove_facet_params(facet, val, localized_params)), + classes: ['filter', 'simple-filter', 'filter-' + facet.parameterize]) + end, "\n") + end + + # Render a label/value constraint on the screen. Can be called + # by plugins and such to get application-defined rendering. + # + # Can be over-ridden locally to render differently if desired, + # although in most cases you can just change CSS instead. + # + # Can pass in nil label if desired. + # + # @param [String] label to display + # @param [String] value to display + # @param [Hash] options + # @option options [String] :remove url to execute for a 'remove' action + # @option options [Array] :classes an array of classes to add to container span for constraint. + # @return [String] + def render_simple_constraint_element(label, value, options = {}) + render(partial: 'shared/simple_constraints_element', locals: { label: label, value: value, options: options }) + end + + def simple_constraint_query_label(localized_params = params) + label_for_search_field(localized_params[:search_field]) + end + + # Render a clear all filters constraint on the screen. + # + # @param [String] label + # @param [Hash] query parameters + # @return [String] + def render_clear_all(label, localized_params) + render_clear_all_element(label, + remove: search_action_path(localized_params.except(:f, :range)), + classes: %w(filter filter-clear-all)) + end + + # Render a clear all element on the screen. + # + # @param [String] label to display + # @param [Hash] options + # @option options [String] :remove url to execute for a 'remove' action + # @option options [Array] :classes an array of classes to add to container span for constraint. + # @return [String] + def render_clear_all_element(label, options = {}) + render(partial: 'shared/clear_all_element', locals: { label: label, options: options }) + end +end diff --git a/app/helpers/facets_helper.rb b/app/helpers/facets_helper.rb new file mode 100644 index 0000000..db91172 --- /dev/null +++ b/app/helpers/facets_helper.rb @@ -0,0 +1,111 @@ +module FacetsHelper + include Blacklight::FacetsHelperBehavior + + ## + # Render a collection of facet fields. + # @see #render_refine_facet_limit + # + # @param [Array] + # @param [Hash] options + # @return String + def render_refine_facet_partials(fields = facet_field_names, options = {}) + safe_join(facets_from_request(fields).map do |display_facet| + render_refine_facet_limit(display_facet, options) + end.compact, "\n") + end + + def render_facet_tabs(fields = facet_field_names, options = {}) + count = 0 + tabs = [] + facets_from_request(fields).map do |display_facet| + next unless should_render_facet?(display_facet) + options[:locals] ||= {} + options[:locals][:index] = count + tabs << render_facet_tab(facet_configuration_for_field(display_facet.name), options) + count += 1 + end + safe_join(tabs.compact, "\n") + end + + def render_facet_tab(facet, options) + active = '' + active = 'active' if options[:locals][:index] == 0 + "
  • #{facet['label']}
  • ".html_safe + end + + def render_refine_facet_limit(display_facet, options = {}) + options = options.dup + options[:partial] ||= 'refine_facet_limit' # facet_partial_name(display_facet) + options[:layout] ||= 'refine_facet_layout' unless options.key?(:layout) + options[:locals] ||= {} + options[:locals][:field_name] ||= display_facet.name + options[:locals][:solr_field] ||= display_facet.name # deprecated + options[:locals][:facet_field] ||= facet_configuration_for_field(display_facet.name) + options[:locals][:display_facet] ||= display_facet + options[:locals][:facet_id] ||= facet_field_id(facet_configuration_for_field(display_facet.name)) + options[:locals][:tab_classes] = '' + render(options) + end + + ## + # Renders the list of values + # removes any elements where render_facet_item returns a nil value. This enables an application + # to filter undesireable facet items so they don't appear in the UI + def render_refine_facet_limit_list(paginator, facet_field, wrapping_element = :tr) + safe_join(paginator.items + .map { |item| render_refine_facet_item(facet_field, item) }.compact + .map { |item| content_tag(wrapping_element, item) }) + end + + ## + # Renders a single facet item + def render_refine_facet_item(facet_field, item) + if facet_in_params?(facet_field, item.value) + render_refine_selected_facet_value(facet_field, item) + else + render_refine_facet_value(facet_field, item) + end + end + + ## + # Standard display of a facet value in a list. Used in both _facets sidebar + # partial and catalog/facet expanded list. Will output facet value name as + # a link to add that to your restrictions, with count in parens. + # + # @param [Blacklight::Solr::Response::Facets::FacetField] + # @param [String] facet item + # @param [Hash] options + # @option options [Boolean] :suppress_link display the facet, but don't link to it + # @return [String] + def render_refine_facet_value(facet_field, item, options = {}) + path = path_for_facet(facet_field, item) + content_tag(:td, class: 'facet-label') do + link_to_unless(options[:suppress_link], facet_display_value(facet_field, item), path, class: 'facet_select') + end + render_refine_facet_count(item.hits) + end + + ## + # Standard display of a SELECTED facet value (e.g. without a link and with a remove button) + # @params (see #render_refine_facet_value) + def render_refine_selected_facet_value(facet_field, item) + content_tag(:td, class: 'facet-label') do + content_tag(:span, facet_display_value(facet_field, item), class: 'selected') + + # remove link + link_to(content_tag(:span, '', class: 'glyphicon glyphicon-remove') + content_tag(:span, '[remove]', class: 'sr-only'), + search_action_path(remove_facet_params(facet_field, item, params)), class: 'remove') + end + render_refine_facet_count(item.hits, classes: ['selected']) + # + content_tag(:td) + end + + ## + # Renders a count value for facet limits. Can be over-ridden locally + # to change style. And can be called by plugins to get consistent display. + # + # @num [number of facet results + # @options - hash of options. + # @return [String] + def render_refine_facet_count(num, options = {}) + classes = (options[:classes] || []) << 'facet-count' + content_tag('td', t('blacklight.search.facets.count', number: number_with_delimiter(num)), class: classes) + end +end diff --git a/app/helpers/render_constraints_helper.rb b/app/helpers/render_constraints_helper.rb new file mode 100644 index 0000000..5a77d94 --- /dev/null +++ b/app/helpers/render_constraints_helper.rb @@ -0,0 +1,5 @@ +module RenderConstraintsHelper + include Blacklight::RenderConstraintsHelperBehavior + include Colligo::RenderSimpleConstraintsHelperBehavior + include Colligo::RenderBreadcrumbsHelperBehavior +end diff --git a/app/models/concerns/annotation_data.rb b/app/models/concerns/annotation_data.rb index 690460d..3623267 100644 --- a/app/models/concerns/annotation_data.rb +++ b/app/models/concerns/annotation_data.rb @@ -1,26 +1,32 @@ +# Module with methods to extract content from the open annotation json-ld record module AnnotationData include JsonReader extend ActiveSupport::Concern + # Fetch json-ld based annotation data from a url def read_annotation(url = nil) return nil unless url # self[:annotation_url] @annotation_list = JsonReader::Reader.new.from_url(url) end + # define the oa type used annotations def motivation_for_annotations 'oa:commenting' end + # define the oa type used annotations def motivation_for_transcriptions 'sc:painting' end + # extract all of the resources in the annotations record def resources(annotation_list = nil) return [] unless annotation_list return [] unless annotation_list.key? 'resources' annotation_list['resources'] end + # extract all of the resources in the annotations record of type annotations def annotations(annotation_list = nil) # the motivation for annotations will be: "oa:commenting" # return [] unless self[:annotation_url] @@ -32,6 +38,7 @@ def annotations(annotation_list = nil) al.select { |anno| anno['motivation'] == motivation_for_annotations } end + # extract all of the resources in the annotations record of type transcriptions def transcriptions(annotation_list = nil) # the motivation for transcriptions will be: "sc:painting" # return [] unless self[:annotation_url] @@ -43,6 +50,7 @@ def transcriptions(annotation_list = nil) al.select { |anno| anno['motivation'] == motivation_for_transcriptions } end + # handy method to fetch just the data of interest into a hash def map_annotation(annotation = nil) return {} unless annotation anno = {} @@ -64,8 +72,9 @@ def map_annotation(annotation = nil) anno end + # method to index each annotation / transcription record (single resource) to solr def annotation_to_solr(data = {}) - # data.keys = [:annotation, :manuscript, :folio, :url] + # data.keys = [:annotation, :manuscript, :folio, :url, :img_info] return {} unless data.key?('annotation') || data['annotation'] anno = map_annotation(data['annotation']) return {} unless anno['id'] @@ -74,8 +83,10 @@ def annotation_to_solr(data = {}) solr_doc['druid'] = self['druid'] solr_doc['manifest_urls'] = self['iiif_manifest'] solr_doc['collection'] = self['collection'] + solr_doc['sort_index'] = self['sort_index'] solr_doc['url_sfx'] = data['url'] if data.key?('url') solr_doc['folio'] = data['folio'] if data.key?('folio') + solr_doc['img_info'] = data['img_info'].uniq if data.key?('img_info') solr_doc['manuscript_search'] = data['manuscript'] if data.key?('manuscript') solr_doc['model'] = anno['model'] solr_doc['motivation'] = anno['motivation'] diff --git a/app/models/concerns/iiif_manifest_data.rb b/app/models/concerns/iiif_manifest_data.rb index 34ba7d2..19262e5 100644 --- a/app/models/concerns/iiif_manifest_data.rb +++ b/app/models/concerns/iiif_manifest_data.rb @@ -1,14 +1,17 @@ +# Module to read the IIIF manifest and extract particular content module IiifManifestData include JsonReader extend ActiveSupport::Concern attr_accessor :manifest_url, :manifest, :modsxml + # Read the manifest from the given url def read_manifest return nil unless manifest_url self.manifest = JsonReader::Reader.new.from_url(manifest_url) end + # Get the title/label from the manifest def title return nil unless manifest_url read_manifest unless manifest @@ -16,6 +19,7 @@ def title manifest['label'] end + # Get the pid from the manifest def druid # druid is a 11 digit alphanumeric sring return nil unless manifest_url @@ -24,6 +28,7 @@ def druid manifest['@id'].match(%r{/([a-zA-Z0-9]{11})/}).to_s.delete('/') end + # Get the thumbnail for the resources desribed by the manifest def thumbnail return nil unless manifest_url read_manifest unless manifest @@ -32,19 +37,21 @@ def thumbnail manifest['thumbnail']['@id'] end + # Get the url for the mods metadata listed in the see also in the manifest def mods_url return nil unless manifest_url read_manifest unless manifest return nil unless manifest return nil unless manifest.key?('seeAlso') - if manifest['seeAlso']['dcterms:format'] == 'application/mods+xml' - return manifest['seeAlso']['@id'] - elsif manifest['seeAlso']['format'] == 'application/mods+xml' + if manifest['seeAlso']['dcterms:format'] == 'application/mods+xml' || + manifest['seeAlso']['format'] == 'application/mods+xml' return manifest['seeAlso']['@id'] end nil end + # Get the list of open annotation reources listed in the manifest + # for each cnavas along with the img resource def annotation_lists return [] unless manifest_url read_manifest unless manifest @@ -52,14 +59,49 @@ def annotation_lists annotations = [] manifest['sequences'].each do |s| s['canvases'].each do |c| - if c.key?('otherContent') - annotations += c['otherContent'].select { |item| item['@type'] == 'sc:AnnotationList' }.map { |item| item['label'] = c['label']; item } + img_info = [] + if c.key?('images') + c['images'].each do |i| + if i.key?('resource') && i['resource'].key?('@id') && i['resource']['@id'] && + i['resource'].key?('format') && %w(image/jpeg image/png).include?(i['resource']['format']) + img_info << i['resource']['@id'] + end + end + end + next unless c.key?('otherContent') + annotations += c['otherContent'].select { |item| item['@type'] == 'sc:AnnotationList' }.map do |item| + item['label'] = c['label'] + item['img_info'] = img_info + item end end end annotations end + # Get a list of all the canvases described in the manifest along with their metadata + def contents + return [] unless manifest_url + read_manifest unless manifest + return [] unless manifest + content_list = [] + manifest['sequences'].each do |s| + s['canvases'].each do |c| + data = { '@id' => c['@id'] } + data['label'] = c['label'] if c.key?('label') + if c.key?('images') && !c['images'].blank? + c_img = c['images'].first + data['motivation'] = c_img['motivation'] if c_img.key?('motivation') + data['@type'] = c_img['@type'] if c_img.key?('@type') + data['img'] = c_img['resource']['@id'] if c_img.key?('resource') && c_img['resource'].key?('@id') + end + content_list << data + end + end + content_list + end + + # Extract the contents of the mods-xml pointed to by the mods_url in the manifest def fetch_modsxml self.modsxml = nil url = mods_url @@ -69,7 +111,7 @@ def fetch_modsxml require 'open-uri' begin self.modsxml = open(uri.to_s).read - rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError, + rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenURI::HTTPError => the_error puts "\nOpen URI error for #{uri}\n\t#{the_error.message}" # TODO: Add to log return nil diff --git a/app/models/concerns/json_reader.rb b/app/models/concerns/json_reader.rb index d453de7..bb2e55c 100644 --- a/app/models/concerns/json_reader.rb +++ b/app/models/concerns/json_reader.rb @@ -1,14 +1,18 @@ +# Module to handle json data module JsonReader + # Class to read and parse json from a file, passed in as a string or fetched from a url class Reader + # Parse a json from string def from_str(str) JSON.parse(str) end + # Fetch the json data from the provided url and parse it def from_url(url, _encoding = nil) require 'open-uri' begin JSON.parse(open(url).read) - rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError, + rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenURI::HTTPError => the_error puts "\nOpen URI error for #{url}\n\t#{the_error.message}" # TODO: Add to log return nil diff --git a/app/models/concerns/mods_data.rb b/app/models/concerns/mods_data.rb index d4774c7..501139a 100644 --- a/app/models/concerns/mods_data.rb +++ b/app/models/concerns/mods_data.rb @@ -1,3 +1,4 @@ +# Model for the mods linked in the IIIF manifest module ModsData extend ActiveSupport::Concern included do @@ -16,22 +17,42 @@ module ModsData # after_save :add_to_index # before_destroy :remove_from_index + # render mods for display def mods return nil unless self[:modsxml] @mods ||= render_mods_display(self) end + # fetch the mods xml data def mods_raw return nil unless self[:modsxml] @mods_data = Stanford::Mods::Record.new @mods_data.from_str(self[:modsxml]) end + # fetch the mods data in pretty xml def prettified_mods return nil unless self['modsxml'] @prettified_mods ||= CodeRay::Duo[:xml, :div].highlight(self['modsxml']).html_safe end + # list of display fileds of interest to Colligo + def all_display_fields + %w( title_display abstract_display img_info druid model manifest_urls + title_alternate_display title_other_display subtitle_display corporate_authors_display + personal_authors_display authors_all_display collection topic_display geographic_display + subject_other_display subject_all_display genre_display era_display pub_date_display + place_display physical_description_extent_display physical_description_form_display + physical_description_media_type_display publishers_display type_of_resource_display + physical_location_display access_condition_display language) + end + + # list of single valued fields in the mods + def single_valued_display_fields + %w(title_display abstract_display subtitle_display pub_date_display access_condition_display) + end + + # method to index the mods data def mods_to_solr data = mods_raw return {} unless data @@ -55,8 +76,8 @@ def mods_to_solr type_of_resource << t.text if t.text end solr_doc['type_of_resource_search'] = type_of_resource.uniq - solr_doc['corporate_authors_search'] = (data.sw_corporate_authors).uniq - solr_doc['personal_authors_search'] = (data.sw_person_authors).uniq + solr_doc['corporate_authors_search'] = data.sw_corporate_authors.uniq + solr_doc['personal_authors_search'] = data.sw_person_authors.uniq solr_doc['authors_all_search'] = (data.sw_person_authors + data.sw_impersonal_authors).uniq solr_doc['title_search'] = data.sort_title solr_doc['title_alternate_search'] = data.alternative_titles @@ -98,15 +119,16 @@ def mods_to_solr protected + # Parse the different date formats used across the mods + # 1. Year ["1389"] (eg: mr892jv0716) + # 2. Start and end years ["850","1499"] (eg: kh686yw0435) + # 3. Approximate year ["Ca. 1580 CE"] (eg: gs755tr2814) + # 4. Approximate year ["1500 CE"] (eg: hp976mx6580) + # 5. Approximate century ["14uu"] (eg: tw490xj0071) + # 6. Full date ["February 6, 1486"] (eg: ss222gr9703) + # 7. Partial date ["June 1781"] (eg: zq824dz1346) + # 8. Approximate start and end years ["s. XIII^^ex [ca. 1275-1300]"] (eg: rc145sy7436) def parse_dates(input_dates) - # 1. Year ["1389"] (eg: mr892jv0716) - # 2. Start and end years ["850","1499"] (eg: kh686yw0435) - # 3. Approximate year ["Ca. 1580 CE"] (eg: gs755tr2814) - # 4. Approximate year ["1500 CE"] (eg: hp976mx6580) - # 5. Approximate century ["14uu"] (eg: tw490xj0071) - # 6. Full date ["February 6, 1486"] (eg: ss222gr9703) - # 7. Partial date ["June 1781"] (eg: zq824dz1346) - # 8. Approximate start and end years ["s. XIII^^ex [ca. 1275-1300]"] (eg: rc145sy7436) dates = { all_int: [], sort: '' } return dates if input_dates.blank? input_dates.each do |dt| @@ -125,8 +147,10 @@ def parse_dates(input_dates) dates end + # join the different dates and return a string (example: start and end dates) def display_date(input_dates) return '' if input_dates.blank? + input_dates.delete_if(&:blank?) if input_dates.length <= 2 input_dates.map(&:to_s).join(' to ') else diff --git a/app/models/iiif_manifest.rb b/app/models/iiif_manifest.rb index 678ffe4..a301bc4 100644 --- a/app/models/iiif_manifest.rb +++ b/app/models/iiif_manifest.rb @@ -1,3 +1,4 @@ +# Model for iiif manifest class IiifManifest include IiifManifestData diff --git a/app/models/search_builder.rb b/app/models/search_builder.rb index efcef22..7c418fc 100644 --- a/app/models/search_builder.rb +++ b/app/models/search_builder.rb @@ -1,3 +1,25 @@ +# Solr query filters based on content type +# These can be added to the solr query to restrict queries by content type class SearchBuilder < Blacklight::SearchBuilder include Blacklight::Solr::SearchBuilderBehavior + + # restrict solr to content type 'descriptions' (mods) + def add_manuscript_filter(solr_parameters) + solr_parameters[:qt] = 'descriptions' + end + + # restrict solr to content type 'annotations' + def add_annotation_filter(solr_parameters) + solr_parameters[:qt] = 'annotations' + end + + # restrict solr to content type 'transcriptions' + def add_transcription_filter(solr_parameters) + solr_parameters[:qt] = 'transcriptions' + end + + # restrict solr to content type 'search' which combine them all + def all_search_filter(solr_parameters) + solr_parameters[:qt] = 'search' + end end diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 88e3163..4d3d8a2 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -1,4 +1,5 @@ # -*- encoding : utf-8 -*- +# Module to extract all of the data from a iiif manifest to index in solr class SolrDocument include ModsData include AnnotationData @@ -10,13 +11,6 @@ def initialize(*args) super end - # The following shows how to setup this blacklight document to display marc documents - extension_parameters[:marc_source_field] = :marc_display - extension_parameters[:marc_format_type] = :marcxml - use_extension(Blacklight::Solr::Document::Marc) do |document| - document.key?(:marc_display) - end - field_semantics.merge!( title: 'title_display', author: 'author_display', @@ -37,14 +31,4 @@ def initialize(*args) # and Blacklight::Document::SemanticFields#to_semantic_values # Recommendation: Use field names from Dublin Core use_extension(Blacklight::Document::DublinCore) - - # This abstraction method may become useful while - # we're between using the new and old format facet - def format_key - :format_main_ssim - end - - def file_ids - self[:img_info] || self[:file_id] - end end diff --git a/app/views/_user_util_links.html.erb b/app/views/_user_util_links.html.erb new file mode 100644 index 0000000..cfc577a --- /dev/null +++ b/app/views/_user_util_links.html.erb @@ -0,0 +1,34 @@ + diff --git a/app/views/bookmarks/index.html.erb b/app/views/bookmarks/index.html.erb new file mode 100644 index 0000000..19ce575 --- /dev/null +++ b/app/views/bookmarks/index.html.erb @@ -0,0 +1,29 @@ +<% + @page_title = t('blacklight.bookmarks.page_title', :application_name => application_name) + @response = @response_m + @document_list = @document_list_m +%> +
    +

    <%= @response['response']['numFound'] %> <%= t('blacklight.bookmarks.title') %>

    + <%- if current_or_guest_user.blank? -%> +

    <%= t('blacklight.bookmarks.need_login') %>

    + <%- elsif @document_list.blank? -%> +

    <%= t('blacklight.bookmarks.no_bookmarks') %>

    + <% else %> +
    +
    +
    + <%= render :partial => 'bookmarks/clear_bookmarks_widget' %> + <%= render :partial => 'shared/sort_widget' %> +
    +
    +
    +
    +
    + <%= render partial: 'shared/manuscript', collection: @document_list, as: :document, locals: {show_manifest: true, show_footer: true} %> +
    +
    + <%= render partial: 'shared/results_footer' %> + <% end %> +
    + diff --git a/app/views/catalog/_annotation_search_results.html.erb b/app/views/catalog/_annotation_search_results.html.erb new file mode 100644 index 0000000..3a782ab --- /dev/null +++ b/app/views/catalog/_annotation_search_results.html.erb @@ -0,0 +1,12 @@ +

    <%= t('blacklight.search.search_results') %>

    + +<%- if @document_list_a.empty? %> + <%= render partial: 'catalog/zero_results' %> +<%- else %> +
    +
    + <%= render partial: 'shared/annotation', collection: @document_list_a, as: :document %> +
    +
    + <%= render partial: 'shared/results_footer' %> +<%- end %> diff --git a/app/views/catalog/_bentopage/_annotations.html.erb b/app/views/catalog/_bentopage/_annotations.html.erb new file mode 100644 index 0000000..54ca49c --- /dev/null +++ b/app/views/catalog/_bentopage/_annotations.html.erb @@ -0,0 +1,16 @@ +
    +

    Annotations

    + <% if @response_a['response']['numFound'] > 0 %> +

    + <%= form_tag search_action_url, method: :get, class: 'pull-right', role: 'search' do %> + <%= hidden_field_tag :search_field, 'annotations', id: 'search_field_annotations' %> + <%= hidden_field_tag :q, params[:q], id: 'q_annotations' %> + + <% end %> +

    + <% else %> +

    No results

    + <% end %> +
    + +<%= render partial: 'shared/annotation', collection: @document_list_a[0, 6], as: :document %> diff --git a/app/views/catalog/_bentopage/_constraints.html.erb b/app/views/catalog/_bentopage/_constraints.html.erb new file mode 100644 index 0000000..5ba9f3f --- /dev/null +++ b/app/views/catalog/_bentopage/_constraints.html.erb @@ -0,0 +1,4 @@ +<% if query_has_constraints?(params) %> + <%= t('blacklight.search.simple_filters.title') %> + <%= render_simple_constraints(params) %> +<% end %> diff --git a/app/views/catalog/_bentopage/_manuscripts.html.erb b/app/views/catalog/_bentopage/_manuscripts.html.erb new file mode 100644 index 0000000..035298b --- /dev/null +++ b/app/views/catalog/_bentopage/_manuscripts.html.erb @@ -0,0 +1,16 @@ +
    +

    Manuscripts

    + <% if @response_m['response']['numFound'] > 0 %> +

    + <%= form_tag search_action_url, method: :get, class: 'pull-right', role: 'search' do %> + <%= hidden_field_tag :search_field, 'descriptions', id: 'search_field_descriptions' %> + <%= hidden_field_tag :q, params[:q], id: 'q_descriptions' %> + + <% end %> +

    + <% else %> +

    No results

    + <% end %> +
    + +<%= render partial: 'shared/manuscript', collection: @document_list_m[0, 4], as: :document, locals: {show_manifest: false, show_footer: false} %> diff --git a/app/views/catalog/_bentopage/_results_summary.html.erb b/app/views/catalog/_bentopage/_results_summary.html.erb new file mode 100644 index 0000000..dbf66f5 --- /dev/null +++ b/app/views/catalog/_bentopage/_results_summary.html.erb @@ -0,0 +1,39 @@ +

    Results summary

    +
    +
    +

    <%= render :partial => '/catalog/_bentopage/constraints' %>

    + + <% if @response_m['response']['numFound'] > 0 %> + <%= form_tag search_action_url, method: :get, class: '', role: 'search' do %> + <%= hidden_field_tag :search_field, 'descriptions', id: 'search_field_descriptions_1' %> + <%= hidden_field_tag :q, params[:q], id: 'q_descriptions_1' %> + + <% end %> + <% else %> +
    <%= @response_m['response']['numFound'] %> Manuscripts
    + <% end %> +
    Searched full manuscript descriptions.
    + + <% if @response_t['response']['numFound'] > 0 %> + <%= form_tag search_action_url, method: :get, class: '', role: 'search' do %> + <%= hidden_field_tag :search_field, 'transcriptions', id: 'search_field_transcriptions_1' %> + <%= hidden_field_tag :q, params[:q], id: 'q_transcriptions_1' %> + + <% end %> + <% else %> +
    <%= @response_t['response']['numFound'] %> Transcriptions
    + <% end %> +
    Searched transcription content.
    + + <% if @response_a['response']['numFound'] > 0 %> + <%= form_tag search_action_url, method: :get, class: '', role: 'search' do %> + <%= hidden_field_tag :search_field, 'annotations', id: 'search_field_annotations_1' %> + <%= hidden_field_tag :q, params[:q], id: 'q_annotations_1' %> + + <% end %> + <% else %> +
    <%= @response_a['response']['numFound'] %> Annotations
    + <% end %> +
    Searched annotation content.
    +
    +
    diff --git a/app/views/catalog/_bentopage/_transcriptions.html.erb b/app/views/catalog/_bentopage/_transcriptions.html.erb new file mode 100644 index 0000000..e55c290 --- /dev/null +++ b/app/views/catalog/_bentopage/_transcriptions.html.erb @@ -0,0 +1,16 @@ +
    +

    Transcriptions

    + <% if @response_t['response']['numFound'] > 0 %> +

    + <%= form_tag search_action_url, method: :get, class: 'pull-right', role: 'search' do %> + <%= hidden_field_tag :search_field, 'transcriptions', id: 'search_field_transcriptions' %> + <%= hidden_field_tag :q, params[:q], id: 'q_transcriptions' %> + + <% end %> +

    + <% else %> +

    No results

    + <% end %> +
    + +<%= render partial: 'shared/transcription', collection: @document_list_t[0, 6], as: :document %> diff --git a/app/views/catalog/_homepage/_annotations_author.html.erb b/app/views/catalog/_homepage/_annotations_author.html.erb new file mode 100644 index 0000000..0df38b5 --- /dev/null +++ b/app/views/catalog/_homepage/_annotations_author.html.erb @@ -0,0 +1,6 @@ +
    +
    +

    by author

    +
    +
    + diff --git a/app/views/catalog/_homepage/_annotations_recent.html.erb b/app/views/catalog/_homepage/_annotations_recent.html.erb new file mode 100644 index 0000000..b4c1c1c --- /dev/null +++ b/app/views/catalog/_homepage/_annotations_recent.html.erb @@ -0,0 +1,6 @@ +
    +
    +

    by most recent

    +
    +
    + diff --git a/app/views/catalog/_homepage/_century.html.erb b/app/views/catalog/_homepage/_century.html.erb new file mode 100644 index 0000000..5a27fc6 --- /dev/null +++ b/app/views/catalog/_homepage/_century.html.erb @@ -0,0 +1,26 @@ +<%- # requires solr_config local passed in + label = facet_field_label('pub_date_t') + input_label_range_begin = t('blacklight.range_limit.range_begin', field_label: label) + input_label_range_end = t('blacklight.range_limit.range_end', field_label: label) +-%> + +
    +

    by century

    + <%= content_tag :div, class: 'pull-left', id: 'century_slider', data: {boundaries: @boundaries, ticks: @slider_ticks} do %> + <% end %> + + <%= content_tag :div, class: 'pull-left', id: 'century_panel', data: {rawdata: @data_array, ticks: @data_ticks, pointerlookup: @pointer_lookup} do %> +
    +
    + <% end %> +
    +
    +
    + <%= form_tag catalog_index_path, :method => :get, :class=> 'range_limit subsection range_pub_date_t form-inline' do %> + <%= hidden_field_tag('search_field', 'descriptions', id: 'search_descriptions_century') %> + <%= render_range_input( 'pub_date_t', :begin, input_label_range_begin) %> – <%= render_range_input('pub_date_t', :end, input_label_range_end) %> + <%= submit_tag t('blacklight.range_limit.submit_limit'), :class=>'submit btn btn-default' %> + <% end %> +
    +
    + diff --git a/app/views/catalog/_homepage/_home.html.erb b/app/views/catalog/_homepage/_home.html.erb new file mode 100644 index 0000000..f4d0b2b --- /dev/null +++ b/app/views/catalog/_homepage/_home.html.erb @@ -0,0 +1,51 @@ +<% @response = @response_m %> +<% @document_list = @document_list_m %> + +
    +
    + <%= render :partial=>'/catalog/_homepage/home_text' %> +
    +
    +
    +
    + +
    +
    + <% if @data_array.any? || @response_m['facet_counts']['facet_fields']['collection'].any? || @response_m['facet_counts']['facet_fields']['language'].any? %> +

    Browse manuscripts

    +
    +
    + <% if @response_m['facet_counts']['facet_fields']['collection'].any? %> + <%= render :partial=>'/catalog/_homepage/repository' %> + <% end %> + <% if @response_m['facet_counts']['facet_fields']['language'].any? %> + <%= render :partial=>'/catalog/_homepage/language' %> + <% end %> +
    +
    + <% if @data_array.any? %> + <%= render :partial=>'/catalog/_homepage/century' %> + <% end %> +
    +
    + <% end %> +
    +
    + <% if @document_list_a.any? %> +

    & annotations

    +
    + <%= render :partial=>'/catalog/_homepage/annotations_recent' %> +
    +
    + <%= render :partial=>'/catalog/_homepage/annotations_author' %> +
    + <% end %> +
    +
    diff --git a/app/views/catalog/_homepage/_home_modal.html.erb b/app/views/catalog/_homepage/_home_modal.html.erb new file mode 100644 index 0000000..4e756e8 --- /dev/null +++ b/app/views/catalog/_homepage/_home_modal.html.erb @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/app/views/catalog/_homepage/_home_search_form.html.erb b/app/views/catalog/_homepage/_home_search_form.html.erb new file mode 100644 index 0000000..216ecb1 --- /dev/null +++ b/app/views/catalog/_homepage/_home_search_form.html.erb @@ -0,0 +1,26 @@ +<%= form_tag search_action_url, method: :get, class: 'navbar-form', role: 'search' do %> + <%#= render_hash_as_hidden_fields(params_for_search.except(:q, :search_field, :qt, :page, :utf8)) %> + <%= hidden_field_tag :search_field, search_fields.first.last, id: 'main_search_field' %> + <% if search_fields.length > 1 %> + + <% end %> +
    + <%= text_field_tag :q, params[:q], placeholder: t('blacklight.search.form.search.placeholder'), + class: 'form-control', id: 'q', autofocus: should_autofocus_on_search_box?, style: 'width:100%' %> + <%#, data: { autocomplete_enabled: autocomplete_enabled?, autocomplete_path: blacklight.suggest_index_path } %> + +
    + +
    +
    +<% end %> diff --git a/app/views/catalog/_homepage/_home_text.html.erb b/app/views/catalog/_homepage/_home_text.html.erb new file mode 100644 index 0000000..515643e --- /dev/null +++ b/app/views/catalog/_homepage/_home_text.html.erb @@ -0,0 +1 @@ +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vestibulum dui ut nibh venenatis faucibus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam cursus varius tortor, vitae sodales elit lacinia sit amet. In posuere lacus eros, a viverra ex tristique ac. Mauris et lectus est. Aliquam nec cursus nibh, consequat blandit massa. Vestibulum molestie, nunc ac semper consectetur, mauris ex sodales orci, in accumsan ante justo sed augue. Nunc auctor porttitor libero, vitae lobortis diam tempus eu. Praesent suscipit faucibus nibh, eu fermentum mauris dignissim rhoncus.

    diff --git a/app/views/catalog/_homepage/_language.html.erb b/app/views/catalog/_homepage/_language.html.erb new file mode 100644 index 0000000..4988ba5 --- /dev/null +++ b/app/views/catalog/_homepage/_language.html.erb @@ -0,0 +1,9 @@ +
    +
    +

    by language

    + <%= safe_join(facets_from_request(['language']).map do |display_facet| %> + <%= render_facet_limit(display_facet, {layout: 'catalog/_homepage/language_layout', partial: 'catalog/_homepage/language_facet_limit'}) %> + <% end.compact, "\n") %> +
    +
    + diff --git a/app/views/catalog/_homepage/_language_facet_limit.html.erb b/app/views/catalog/_homepage/_language_facet_limit.html.erb new file mode 100644 index 0000000..c062492 --- /dev/null +++ b/app/views/catalog/_homepage/_language_facet_limit.html.erb @@ -0,0 +1,20 @@ +
      + <% paginator = facet_paginator(facet_field, display_facet) %> + <% params[:search_field] = 'descriptions' %> + <%#= render_facet_limit_list paginator, field_name %> + + <% @response['facet_counts']['facet_fields']['language'].each_with_index do |r, i| %> + <% if i.even? && i < 9 %> + " class="btn btn-primary"> + <%= r %> + + <% end %> + <% end %> + + <% unless paginator.total_count < 6 || params[:action] == 'facet' %> + <%#= link_to t("more_#{field_name}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: facet_field.label), + search_facet_url(id: field_name), class: 'btn btn-primary-outline more_facets_link' %> + + <%= render :partial=>'/catalog/_homepage/home_modal', locals: {display_facet: display_facet, facet_field: facet_field} %> + <% end %> +
    diff --git a/app/views/catalog/_homepage/_language_layout.html.erb b/app/views/catalog/_homepage/_language_layout.html.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/app/views/catalog/_homepage/_language_layout.html.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/catalog/_homepage/_repository.html.erb b/app/views/catalog/_homepage/_repository.html.erb new file mode 100644 index 0000000..de6bebe --- /dev/null +++ b/app/views/catalog/_homepage/_repository.html.erb @@ -0,0 +1,24 @@ +
    +
    +

    by repository

    + <% params[:search_field] = 'descriptions' %> + <% @response['facet_counts']['facet_fields']['collection'].each_with_index do |r, i| %> + <% if i.even? %> + <% case %> + <% when r.include?('Stanford') %> + <% fname = 'stanford.png' %> + <% when r.include?('Parker') %> + <% fname = 'parker.png' %> + <% when r.include?('Walter') %> + <% fname = 'walter.png' %> + <% else %> + <% fname = 'other.png' %> + <% end %> + " class="btn btn-secondary"> + <%= image_tag(fname) %> + <%= r %> + + <% end %> + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/catalog/_manuscript_search_results.html.erb b/app/views/catalog/_manuscript_search_results.html.erb new file mode 100644 index 0000000..ce42a78 --- /dev/null +++ b/app/views/catalog/_manuscript_search_results.html.erb @@ -0,0 +1,24 @@ +

    <%= @response_m['response']['numFound'] %> Manuscripts

    + +<% @page_title = t('blacklight.search.page_title.title', :constraints => render_search_to_page_title(params), :application_name => application_name) %> + +<% content_for(:head) do -%> + <%= render_opensearch_response_metadata %> + <%= auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') ) %> + <%= auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') ) %> +<% end -%> + +<%= render partial: 'shared/results_header' %> + +

    <%= t('blacklight.search.search_results') %>

    + +<%- if @document_list_m.empty? %> + <%= render partial: 'catalog/zero_results' %> +<%- else %> +
    +
    + <%= render partial: 'shared/manuscript', collection: @document_list_m, as: :document, locals: {show_manifest: true, show_footer: true} %> +
    +
    + <%= render partial: 'shared/results_footer' %> +<%- end %> diff --git a/app/views/catalog/_refine_facet_layout.html.erb b/app/views/catalog/_refine_facet_layout.html.erb new file mode 100644 index 0000000..cd9bb66 --- /dev/null +++ b/app/views/catalog/_refine_facet_layout.html.erb @@ -0,0 +1 @@ +<%= yield %> \ No newline at end of file diff --git a/app/views/catalog/_refine_facet_limit.html.erb b/app/views/catalog/_refine_facet_limit.html.erb new file mode 100644 index 0000000..404656f --- /dev/null +++ b/app/views/catalog/_refine_facet_limit.html.erb @@ -0,0 +1,24 @@ +<%#= render partial: 'facet_search' %> +<%#= render partial: 'facet_table' %> +
    +
    + +
    + + +
      +
      +
      + + + + + + + + + <% paginator = facet_paginator(facet_field, display_facet) %> + <%= render_refine_facet_limit_list(paginator, field_name) %> + +
      ValueCount
      +
      diff --git a/app/views/catalog/_refine_facets.html.erb b/app/views/catalog/_refine_facets.html.erb new file mode 100644 index 0000000..d7e09f1 --- /dev/null +++ b/app/views/catalog/_refine_facets.html.erb @@ -0,0 +1,24 @@ +<% # main container for facets/limits menu -%> +<% if has_facet_values? %> + +<% end %> \ No newline at end of file diff --git a/app/views/catalog/_refine_search.html.erb b/app/views/catalog/_refine_search.html.erb new file mode 100644 index 0000000..7adf455 --- /dev/null +++ b/app/views/catalog/_refine_search.html.erb @@ -0,0 +1 @@ +<%= render partial: 'catalog/refine_facets' %> \ No newline at end of file diff --git a/app/views/catalog/_search_form.html.erb b/app/views/catalog/_search_form.html.erb new file mode 100644 index 0000000..b6050fa --- /dev/null +++ b/app/views/catalog/_search_form.html.erb @@ -0,0 +1,20 @@ +<%= form_tag search_action_url, method: :get, class: 'search-query-form clearfix navbar-form', role: 'search' do %> + <%#= render_hash_as_hidden_fields(params_for_search.except(:q, :search_field, :qt, :page, :utf8)) %> + <% if search_fields.length > 1 %> +
      + + <%= select_tag(:search_field, options_for_select(search_fields, h(params[:search_field])), title: t('blacklight.search.form.search_field.title'), id: "search_field", class: "form-control") %> +
      + <% elsif search_fields.length == 1 %> + <%= hidden_field_tag :search_field, search_fields.first.last %> + <% end %> +
      + + <%= text_field_tag :q, params[:q], placeholder: t('blacklight.search.form.search.placeholder'), class: "q form-control", id: "q", autofocus: should_autofocus_on_search_box? %> +
      +
      + +
      +<% end %> diff --git a/app/views/catalog/_transcription_search_results.html.erb b/app/views/catalog/_transcription_search_results.html.erb new file mode 100644 index 0000000..af5fa4d --- /dev/null +++ b/app/views/catalog/_transcription_search_results.html.erb @@ -0,0 +1,12 @@ +

      <%= t('blacklight.search.search_results') %>

      + +<%- if @document_list_t.empty? %> + <%= render partial: 'catalog/zero_results' %> +<%- else %> +
      +
      + <%= render partial: 'shared/transcription', collection: @document_list_t, as: :document %> +
      +
      + <%= render partial: 'shared/results_footer' %> +<%- end %> diff --git a/app/views/catalog/annotation_results.html.erb b/app/views/catalog/annotation_results.html.erb new file mode 100644 index 0000000..86c68ae --- /dev/null +++ b/app/views/catalog/annotation_results.html.erb @@ -0,0 +1,26 @@ +<% @response = @response_a %> +<% @document_list = @document_list_a %> + +<% @page_title = t('blacklight.search.page_title.title', :constraints => render_search_to_page_title(params), :application_name => application_name) %> + +<% content_for(:head) do -%> + <%= render_opensearch_response_metadata %> + <%= auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') ) %> + <%= auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') ) %> +<% end -%> + +
      +
      +
      + <%= render partial: 'catalog/refine_search' %> +
      +
      +

      <%= @response_a['response']['numFound'] %> Annotations

      + <%= render partial: 'shared/results_header' %> +
      +
      +
      + +
      + <%= render partial: 'catalog/annotation_search_results' %> +
      diff --git a/app/views/catalog/bentopage.html.erb b/app/views/catalog/bentopage.html.erb new file mode 100644 index 0000000..08513ab --- /dev/null +++ b/app/views/catalog/bentopage.html.erb @@ -0,0 +1,25 @@ +
      +
      +
      + <%= render :partial => '/catalog/_bentopage/results_summary' %> +
      +
      + <%= render :partial => '/catalog/_bentopage/manuscripts' %> +
      +
      +
      +
      + <%= render :partial => '/catalog/_bentopage/transcriptions' %> +
      +
      +
      +
      + <%= render :partial => '/catalog/_bentopage/annotations' %> +
      +
      +
      +
      + +
      +
      +
      diff --git a/app/views/catalog/homepage.html.erb b/app/views/catalog/homepage.html.erb new file mode 100644 index 0000000..bf91770 --- /dev/null +++ b/app/views/catalog/homepage.html.erb @@ -0,0 +1,5 @@ +
      + <%# if there are no input/search related params, display the "home" partial -%> + <%= render 'catalog/_homepage/home' %> + <%= render 'shared/sitelinks_search_box' %> +
      diff --git a/app/views/catalog/manuscript_results.html.erb b/app/views/catalog/manuscript_results.html.erb new file mode 100644 index 0000000..f9bf57b --- /dev/null +++ b/app/views/catalog/manuscript_results.html.erb @@ -0,0 +1,9 @@ +<% @response = @response_m %> +<% @document_list = @document_list_m %> + + +
      + <%= render partial: 'catalog/manuscript_search_results' %> +
      diff --git a/app/views/catalog/transcription_results.html.erb b/app/views/catalog/transcription_results.html.erb new file mode 100644 index 0000000..ab78e22 --- /dev/null +++ b/app/views/catalog/transcription_results.html.erb @@ -0,0 +1,26 @@ +<% @response = @response_t %> +<% @document_list = @document_list_t %> + +<% @page_title = t('blacklight.search.page_title.title', :constraints => render_search_to_page_title(params), :application_name => application_name) %> + +<% content_for(:head) do -%> + <%= render_opensearch_response_metadata %> + <%= auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') ) %> + <%= auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') ) %> +<% end -%> + +
      +
      +
      + <%= render partial: 'catalog/refine_search' %> +
      +
      +

      <%= @response_t['response']['numFound'] %> Transcriptions

      + <%= render partial: 'shared/results_header' %> +
      +
      +
      + +
      + <%= render partial: 'catalog/transcription_search_results' %> +
      diff --git a/app/views/folio/_breadcrumbs.html.erb b/app/views/folio/_breadcrumbs.html.erb new file mode 100644 index 0000000..112f3ea --- /dev/null +++ b/app/views/folio/_breadcrumbs.html.erb @@ -0,0 +1,14 @@ +<% if (@manuscript.has_key?('collection') && @manuscript['collection'].present?) || + (@manuscript.has_key?('title_display') && @manuscript['title_display'].present?) +%> + <% + breadcrumb_params = { 'search_field' => 'transcriptions', f: { } } + # breadcrumb_params[:f]['place_facet'] = [@manuscript['place_display'].first] unless @manuscript['place_display'].blank? + breadcrumb_params[:f]['collection'] = [@manuscript['collection']] unless @manuscript['collection'].blank? + breadcrumb_params[:f]['manuscript_facet'] = [@manuscript['title_display']] unless @manuscript['title_display'].blank? + %> + <%= render_breadcrumb_constraints_filters(breadcrumb_params) %> + > +<% end %> +<%= params[:id] %> + diff --git a/app/views/folio/_description.html.erb b/app/views/folio/_description.html.erb new file mode 100644 index 0000000..132edb5 --- /dev/null +++ b/app/views/folio/_description.html.erb @@ -0,0 +1,53 @@ +
      +
      + <% + a_class = 'tab-pane' + t_class = 'tab-pane' + li_a_class = '' + li_t_class = '' + if @annotations.blank? + a_class += ' tab-disabled' + end + if @transcriptions.blank? + t_class += ' tab-disabled' + end + if params[:view] == 'annotations' + a_class += ' active' + li_a_class = ' active' + else + t_class += ' active' + li_t_class = ' active' + end + %> +
      + <% if @annotations.any? %> + <% @annotations.each do |annotation| %> +
      + <%= annotation['body_chars_display'] %> +
      + <% end %> + <% else %> +
      There are no annotations for folio <%=params[:id]%>
      + <% end %> +
      +
      + <% if @transcriptions.any? %> + <% @transcriptions.each do |transcription| %> +
      + <%=transcription['body_chars_display']%> +
      + <% end %> + <% else %> +
      There are no transcriptions for folio <%=params[:id]%>
      + <% end %> +
      +
      + +
      \ No newline at end of file diff --git a/app/views/folio/_footer.html.erb b/app/views/folio/_footer.html.erb new file mode 100644 index 0000000..1c987fb --- /dev/null +++ b/app/views/folio/_footer.html.erb @@ -0,0 +1,30 @@ + +
      +
      + <%= render :partial => '/folio/previous_folio' %> +
      +
      +
      +
      + <%= render partial: 'shared/manuscript_body', locals: {document: @manuscript, show_manifest: true, count: params[:start]} %> +
      +
      +
      +
      + <%= render :partial => '/folio/next_folio' %> +
      +
      diff --git a/app/views/folio/_header.html.erb b/app/views/folio/_header.html.erb new file mode 100644 index 0000000..fff41a9 --- /dev/null +++ b/app/views/folio/_header.html.erb @@ -0,0 +1,15 @@ +
      +
      +

      <%= params[:view].capitalize %>

      +
      +
      + <% unless @manuscript['manifest_urls'].blank? %> + + <% end %> +
      +
      +
      + <%= render partial: 'folio/breadcrumbs' %> +
      diff --git a/app/views/folio/_manifest.html.erb b/app/views/folio/_manifest.html.erb new file mode 100644 index 0000000..f2810c7 --- /dev/null +++ b/app/views/folio/_manifest.html.erb @@ -0,0 +1,4 @@ +<% unless @manuscript['manifest_urls'].blank? || @canvas_id.blank? %> +
      +
      +<% end %> \ No newline at end of file diff --git a/app/views/folio/_next_folio.html.erb b/app/views/folio/_next_folio.html.erb new file mode 100644 index 0000000..228a247 --- /dev/null +++ b/app/views/folio/_next_folio.html.erb @@ -0,0 +1,12 @@ +<% if @next_folio.present? %> + <% next_url = "/manuscript/#{params[:manuscript_id]}/folio/#{@next_folio['label']}?start=#{params[:start]}&view=#{params[:view]}" %> + + +<% end %> \ No newline at end of file diff --git a/app/views/folio/_previous_folio.html.erb b/app/views/folio/_previous_folio.html.erb new file mode 100644 index 0000000..8888486 --- /dev/null +++ b/app/views/folio/_previous_folio.html.erb @@ -0,0 +1,12 @@ +<% if @previous_folio.present? %> + <% prev_url = "/manuscript/#{params[:manuscript_id]}/folio/#{@previous_folio['label']}?start=#{params[:start]}&view=#{params[:view]}" %> + + +<% end %> \ No newline at end of file diff --git a/app/views/folio/show.html.erb b/app/views/folio/show.html.erb new file mode 100644 index 0000000..7586d5d --- /dev/null +++ b/app/views/folio/show.html.erb @@ -0,0 +1,20 @@ +
      +
      +
      + <%= render :partial => '/folio/header' %> +
      +
      +
      +
      + <%= render :partial => '/folio/manifest' %> +
      +
      + <%= render :partial => '/folio/description' %> +
      +
      + +
      \ No newline at end of file diff --git a/app/views/kaminari/colligo_compact/_next_page.html.erb b/app/views/kaminari/colligo_compact/_next_page.html.erb new file mode 100644 index 0000000..2c3a266 --- /dev/null +++ b/app/views/kaminari/colligo_compact/_next_page.html.erb @@ -0,0 +1,23 @@ +<%# Link to the "Next" page + - available local variables + url: url to the next page + current_page: a page object for the currently displayed page + num_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<% unless current_page.last? %> + +<% else %> + +<% end %> + diff --git a/app/views/kaminari/colligo_compact/_paginator.html.erb b/app/views/kaminari/colligo_compact/_paginator.html.erb new file mode 100644 index 0000000..81f9f7c --- /dev/null +++ b/app/views/kaminari/colligo_compact/_paginator.html.erb @@ -0,0 +1,33 @@ +<%# The container tag + - available local variables + current_page: a page object for the currently displayed page + num_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote + paginator: the paginator that renders the pagination tags inside + + Paginator now using the Bootstrap paginator class + + page_entries_info is passed into the paginate call, e.g. : + + > paginate collection, :page_entries_info => page_entries_info(collection), :theme => :blacklight_compact + + As of Kaminari 0.15, this paginator doesn't have access to the original collection/scope, so it can't render the page entries info directly. +-%> +<% if total_pages > 1 -%> + <%# #render checks if total_pages > 1, so we can't put our fallback + in here .. -%> + <%= paginator.render do -%> +
      <%= prev_page_tag %>
      +
      + + <%= next_page_tag %> +
      + <% end -%> +<%# else -%> + +<% end -%> diff --git a/app/views/kaminari/colligo_compact/_prev_page.html.erb b/app/views/kaminari/colligo_compact/_prev_page.html.erb new file mode 100644 index 0000000..75f571d --- /dev/null +++ b/app/views/kaminari/colligo_compact/_prev_page.html.erb @@ -0,0 +1,13 @@ +<%# Link to the "Previous" page + - available local variables + url: url to the previous page + current_page: a page object for the currently displayed page + num_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<% unless current_page.first? %> + +<% end %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a693e72..6cb8146 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,7 +6,7 @@ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> - + <%= yield %> diff --git a/app/views/layouts/blacklight.html.erb b/app/views/layouts/blacklight.html.erb new file mode 100644 index 0000000..c81a86e --- /dev/null +++ b/app/views/layouts/blacklight.html.erb @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + <%= render_page_title %> + <%= opensearch_description_tag application_name, opensearch_catalog_url(:format => 'xml') %> + <%= favicon_link_tag 'favicon.ico' %> + <%= stylesheet_link_tag "application", media: "all" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + <%= content_for(:head) %> + + + + + + + <%= render :partial => 'shared/header_navbar' %> + + <%= render partial: 'shared/ajax_modal' %> + +
      + <%= content_tag :h1, application_name, class: 'sr-only application-heading' %> + + <%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %> +
      + <%= yield %> +
      +
      + + <%= render :partial => 'shared/footer' %> + + diff --git a/app/views/layouts/homepage.html.erb b/app/views/layouts/homepage.html.erb new file mode 100644 index 0000000..b7ddfda --- /dev/null +++ b/app/views/layouts/homepage.html.erb @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + <%= render_page_title %> + <%= opensearch_description_tag application_name, opensearch_catalog_url(:format => 'xml') %> + <%= favicon_link_tag 'favicon.ico' %> + <%= stylesheet_link_tag "application", media: "all" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + <%= content_for(:head) %> + + + + + + + <%= render :partial => 'shared/homepage_header_navbar' %> + + <%= render partial: 'shared/ajax_modal' %> + +
      + <%= content_tag :h1, application_name, class: 'sr-only application-heading' %> + + <%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %> + +
      + <%= yield %> +
      +
      + + <%= render :partial => 'shared/footer' %> + + diff --git a/app/views/manuscript/_breadcrumbs.html.erb b/app/views/manuscript/_breadcrumbs.html.erb new file mode 100644 index 0000000..cb856ea --- /dev/null +++ b/app/views/manuscript/_breadcrumbs.html.erb @@ -0,0 +1,15 @@ +<% if @document.has_key?('collection') && !@document['collection'].blank? %> + <% + breadcrumb_params = { 'search_field' => 'descriptions', f: { } } + # @document['place_display'] is an array + # breadcrumb_params[:f]['place_facet'] = @document['place_display'] unless @document['place_display'].blank? + breadcrumb_params[:f]['collection'] = [@document['collection']] unless @document['collection'].blank? + %> + <%= render_breadcrumb_constraints_filters(breadcrumb_params) %> + <% unless @document['authors_all_display'].blank? %> + > + <% end %> +<% end %> +<% unless @document['authors_all_display'].blank? %> + <%= @document['authors_all_display'].join(' | ') %> +<% end %> diff --git a/app/views/manuscript/_description.html.erb b/app/views/manuscript/_description.html.erb new file mode 100644 index 0000000..36be844 --- /dev/null +++ b/app/views/manuscript/_description.html.erb @@ -0,0 +1,31 @@ + +
      +
      + <% if @document['abstract_display'].present? %> +
      +

      Summary

      + <%= render partial: 'manuscript/_description/summary' %> + <%#= render partial: 'shared/lorem_ipsum' %> +
      + <% end %> +
      +

      Description

      + <%= render partial: 'manuscript/_description/description' %> + <%#= render partial: 'shared/lorem_ipsum' %> +
      +
      +
      diff --git a/app/views/manuscript/_description/_description.html.erb b/app/views/manuscript/_description/_description.html.erb new file mode 100644 index 0000000..0c7c1f1 --- /dev/null +++ b/app/views/manuscript/_description/_description.html.erb @@ -0,0 +1,97 @@ +
      + <% + + # @document['title_alternate_display'] = [] if @document['title_alternate_display'].blank? + # @document['title_other_display'] = [] if @document['title_other_display'].blank? + %> + <% unless @document['title_alternate_display'].blank? && @document['title_other_display'].blank? %> +
      Alternate titles
      +
      <%= (@document['title_alternate_display'] + @document['title_other_display']).uniq.join('
      ') %>
      + <% end %> + <% unless @document['subtitle_display'].blank? %> +
      Subtitle
      +
      <%= @document['subtitle_display'] %>
      + <% end %> + <% unless @document['corporate_authors_display'].blank? %> +
      Corporate authors
      +
      <%= raw @document['corporate_authors_display'].join('
      ') %>
      + <% end %> + <% unless @document['personal_authors_display'].blank? %> +
      Personal authors
      +
      <%= raw @document['personal_authors_display'].join('
      ') %>
      + <% end %> + <% + a = @document['authors_all_display'] - @document['personal_authors_display'] - @document['corporate_authors_display'] + unless a.blank? %> +
      Other authors
      +
      <%= raw (@document['authors_all_display'] - @document['personal_authors_display'] - @document['corporate_authors_display']).join('
      ') %>
      + <% end %> + <% unless @document['collection'].blank? %> +
      Repository
      +
      <%= @document['collection'] %>
      + <% end %> + <% unless @document['language'].blank? %> +
      Language
      +
      <%= raw @document['language'].join('
      ') %>
      + <% end %> + <% unless @document['topic_display'].blank? %> +
      Topic
      +
      <%= raw @document['topic_display'].join('
      ') %>
      + <% end %> + <% unless @document['geographic_display'].blank? %> +
      Region
      +
      <%= raw @document['geographic_display'].join('
      ') %>
      + <% end %> + <% + s = (@document['subject_all_display'] + @document['genre_display'] - + @document['topic_display'] - @document['geographic_display'] - @document['era_display']).uniq + unless s.blank? + %> +
      Keyword
      +
      <%= raw s.join('
      ') %>
      + <% end %> + <% unless @document['era_display'].blank? %> +
      Era
      +
      <%= raw @document['era_display'].join('
      ') %>
      + <% end %> + <% unless @document['pub_date_display'].blank? %> +
      Date of publication
      +
      <%= @document['pub_date_display'] %>
      + <% end %> + <% unless @document['place_display'].blank? %> +
      Location
      +
      <%= raw @document['place_display'].join('
      ') %>
      + <% end %> + <% unless @document['physical_description_extent_display'].blank? %> +
      Extent
      +
      <%= raw @document['physical_description_extent_display'].join('
      ') %>
      + <% end %> + <% unless @document['physical_description_form_display'].blank? %> +
      Form
      +
      <%= raw @document['physical_description_form_display'].join('
      ') %>
      + <% end %> + <% unless @document['physical_description_media_type_display'].blank? %> +
      Media type
      +
      <%= raw @document['physical_description_media_type_display'].join('
      ') %>
      + <% end %> + <% unless @document['format'].blank? %> +
      Format
      +
      <%= raw @document['format'].join('
      ') %>
      + <% end %> + <% unless @document['publishers_display'].blank? %> +
      Publisher
      +
      <%= raw @document['publishers_display'].join('
      ') %>
      + <% end %> + <% unless @document['type_of_resource_display'].blank? %> +
      Type of resource
      +
      <%= raw @document['type_of_resource_display'].join('
      ') %>
      + <% end %> + <% unless @document['physical_location_display'].blank? %> +
      Manuscript location
      +
      <%= raw @document['physical_location_display'].join('
      ') %>
      + <% end %> + <% unless @document['access_condition_display'].blank? %> +
      Access condition
      +
      <%= @document['access_condition_display'] %>
      + <% end %> +
      \ No newline at end of file diff --git a/app/views/manuscript/_description/_summary.html.erb b/app/views/manuscript/_description/_summary.html.erb new file mode 100644 index 0000000..104ea97 --- /dev/null +++ b/app/views/manuscript/_description/_summary.html.erb @@ -0,0 +1,3 @@ +<% if @document['abstract_display'].present? %> +

      <%= @document['abstract_display'] %>

      +<% end %> \ No newline at end of file diff --git a/app/views/manuscript/_find_all.html.erb b/app/views/manuscript/_find_all.html.erb new file mode 100644 index 0000000..e4c2f71 --- /dev/null +++ b/app/views/manuscript/_find_all.html.erb @@ -0,0 +1,33 @@ +
      +
      +
      +

      Manuscript

      +
      +
      +
      +
      Find all...
      +
      + + <% a_class = 'noresult-inverse' %> + <% if @related_annotations > 0 %> + <% a_class = 'result-inverse' %> + <% end %> + " class="btn btn-sm <%=a_class%>"> + Annotations + +
      +
      + + <% t_class = 'noresult-inverse' %> + <% if @related_transcriptions > 0 %> + <% t_class = 'result-inverse' %> + <% end %> + " class="btn btn-sm <%=t_class%>"> + Transcriptions + +
      +
      ...for this manuscript
      +
      +
      +
      +
      \ No newline at end of file diff --git a/app/views/manuscript/_folio.html.erb b/app/views/manuscript/_folio.html.erb new file mode 100644 index 0000000..fbf331a --- /dev/null +++ b/app/views/manuscript/_folio.html.erb @@ -0,0 +1,14 @@ +
      +

      Current folio:

      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      diff --git a/app/views/manuscript/_folios.html.erb b/app/views/manuscript/_folios.html.erb new file mode 100644 index 0000000..ebc7dc1 --- /dev/null +++ b/app/views/manuscript/_folios.html.erb @@ -0,0 +1,10 @@ +
      +
      + <%= render :partial => '/manuscript/folio' %> +
      +
      +
      +
      + <%= render :partial => '/manuscript/folio' %> +
      +
      \ No newline at end of file diff --git a/app/views/manuscript/_footer.html.erb b/app/views/manuscript/_footer.html.erb new file mode 100644 index 0000000..b1724a0 --- /dev/null +++ b/app/views/manuscript/_footer.html.erb @@ -0,0 +1,5 @@ +
      + <%= render :partial => '/shared/previous_record' %> + <%= render :partial => '/shared/next_record' %> + +
      \ No newline at end of file diff --git a/app/views/manuscript/_header.html.erb b/app/views/manuscript/_header.html.erb new file mode 100644 index 0000000..bce7fe3 --- /dev/null +++ b/app/views/manuscript/_header.html.erb @@ -0,0 +1,16 @@ +
      +
      +

      <%= @document['title_display'] %>

      +
      +
      + <% unless @document['manifest_urls'].blank? %> + + <% end %> +
      +
      +
      + <%= render partial: 'manuscript/breadcrumbs' %> + <%= render partial: 'shared/bookmark_control', locals: {:document => @document, :formclass => 'bookmark_inverse inline', :buttonclassprefix => 'bookmark_inverse'} %> +
      diff --git a/app/views/manuscript/_manifest.html.erb b/app/views/manuscript/_manifest.html.erb new file mode 100644 index 0000000..e850fc8 --- /dev/null +++ b/app/views/manuscript/_manifest.html.erb @@ -0,0 +1,4 @@ +<% unless @document['manifest_urls'].blank? || @contents.blank? %> +
      +
      +<% end %> \ No newline at end of file diff --git a/app/views/manuscript/show.html.erb b/app/views/manuscript/show.html.erb new file mode 100644 index 0000000..72ecf92 --- /dev/null +++ b/app/views/manuscript/show.html.erb @@ -0,0 +1,32 @@ +
      +
      +
      + <%= render :partial => '/manuscript/header' %> +
      +
      +
      +
      + <%= render :partial => '/manuscript/manifest' %> +
      +
      +
      + +
      + <%= render :partial => '/manuscript/description' %> +
      +
      +
      + <%= render :partial => '/manuscript/folios' %> + <%= render :partial => '/manuscript/find_all' %> +
      +
      +
      +
      + <%= render :partial => '/manuscript/footer' %> +
      +
      \ No newline at end of file diff --git a/app/views/shared/_annotation.html.erb b/app/views/shared/_annotation.html.erb new file mode 100644 index 0000000..b2dd19a --- /dev/null +++ b/app/views/shared/_annotation.html.erb @@ -0,0 +1,31 @@ +
      +
      +
      +
      + <% unless document['img_info'].blank? %> + <%= image_tag(document['img_info'].first, class: 'media-object results-thumbnail') %> + <% end %>  +
      +
      + <% unless document['body_chars_display'].blank? %> +

      <%= truncate(document['body_chars_display'], length: 150) %>

      + <% else %> +

      <%= document['id'] %>

      + <% end %> + <% unless document['authors_all_display'].blank? %> +

      <%= raw document['authors_all_display'].join('
      ') %>

      + <% end %> + <% unless document['language'].blank? %> +

      <%= document['language'].join(', ') %>

      + <% end %> + <% unless document['folio'].blank? %> +

      <%= document['folio'] %>

      + <% end %> + <% unless document['manuscript_display'].blank? %> +

      <%= document['manuscript_display'] %>

      + <% end %> +
      +
      +
      +
      + diff --git a/app/views/shared/_bookmark_control.html.erb b/app/views/shared/_bookmark_control.html.erb new file mode 100644 index 0000000..ecd34dc --- /dev/null +++ b/app/views/shared/_bookmark_control.html.erb @@ -0,0 +1,29 @@ +<% if current_or_guest_user %> + <%- + # Note these two forms are pretty similar but for different :methods, classes, and labels. + # but it was simpler to leave them separate instead of DRYing them, got confusing trying that. + # the data-doc-id attribute is used by our JS that converts to a checkbox/label. + formclass ||= 'pull-right' + buttonclassprefix ||= 'bookmark' + -%> + <% unless bookmarked? document %> + <%= form_tag( bookmark_path( document ), :method => :put, :class => "bookmark_toggle #{formclass}", "data-doc-id" => document.id, + :'data-present' => t('blacklight.search.bookmarks.present'), :'data-absent' => t('blacklight.search.bookmarks.absent'), + :'data-inprogress' => t('blacklight.search.bookmarks.inprogress')) do %> + + <% end %> + + <% else %> + <%= form_tag( bookmark_path( document ), :method => :delete, :class => "bookmark_toggle #{formclass}", "data-doc-id" => document.id, + :'data-present' => t('blacklight.search.bookmarks.present'), :'data-absent' => t('blacklight.search.bookmarks.absent'), + :'data-inprogress' => t('blacklight.search.bookmarks.inprogress')) do %> + + <% end %> + <% end %> +<% else %> +   +<% end %> diff --git a/app/views/shared/_breadcrumb_constraints_element.html.erb b/app/views/shared/_breadcrumb_constraints_element.html.erb new file mode 100644 index 0000000..aeeabe6 --- /dev/null +++ b/app/views/shared/_breadcrumb_constraints_element.html.erb @@ -0,0 +1,13 @@ +<% # local params: + # label + # value + # options => + # :search_path => url for a constraint link + # :classes => array of classes to add to container span + options ||= {} +%> + +"> + <%= link_to(content_tag(:span, value, class: 'breadcrumbValue', title: value), + options[:search_path], class: 'btn btn-default btn-link') %> + diff --git a/app/views/shared/_clear_all_element.html.erb b/app/views/shared/_clear_all_element.html.erb new file mode 100644 index 0000000..e04d931 --- /dev/null +++ b/app/views/shared/_clear_all_element.html.erb @@ -0,0 +1,19 @@ +<% # local params: + # label + # options => + # :remove => url for a remove constraint link + # :classes => array of classes to add to container span + options ||= {} +%> + + + <% unless options[:remove].blank? %> + <% remove_label = content_tag :span, class: 'text' do + label + end + %> + <%= link_to(content_tag(:span, '', class: 'glyphicon glyphicon-remove') + remove_label, + options[:remove], class: 'btn btn-default btn-sm remove dropdown-toggle' + ) %> + <%- end -%> + diff --git a/app/views/shared/_header_navbar.html.erb b/app/views/shared/_header_navbar.html.erb new file mode 100644 index 0000000..13160fc --- /dev/null +++ b/app/views/shared/_header_navbar.html.erb @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/app/views/shared/_homepage_header_navbar.html.erb b/app/views/shared/_homepage_header_navbar.html.erb new file mode 100644 index 0000000..162848b --- /dev/null +++ b/app/views/shared/_homepage_header_navbar.html.erb @@ -0,0 +1,9 @@ + + diff --git a/app/views/shared/_lorem_ipsum.html.erb b/app/views/shared/_lorem_ipsum.html.erb new file mode 100644 index 0000000..120f767 --- /dev/null +++ b/app/views/shared/_lorem_ipsum.html.erb @@ -0,0 +1,31 @@ +

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt tempus neque nec gravida. In nec ante + massa. Sed mollis mollis viverra. In ultrices, leo vel dapibus volutpat, ligula sem consectetur lorem, ac dignissim + mauris nunc ut ligula. Quisque faucibus odio mattis lacus tristique malesuada. Morbi volutpat eros a sodales vehicula. + Morbi a libero vehicula, tincidunt arcu sodales, posuere arcu. Sed in luctus nulla. Integer in iaculis tortor, vel + mattis nisi. Donec tincidunt rutrum nisl, in cursus dolor vestibulum ut.

      + +

      Vestibulum faucibus non mauris et facilisis. Etiam rhoncus, nunc eget varius pharetra, sem mauris tristique nulla, + ut rhoncus leo orci ut urna. Morbi semper velit ac neque venenatis, id blandit mi mollis. Vestibulum massa mauris, + varius ut varius a, sodales et magna. Aliquam vitae ultricies ex. Phasellus vel convallis tortor. Mauris eu felis + blandit, pellentesque urna id, ultricies neque. Morbi commodo maximus scelerisque. In at erat mauris. Aenean rhoncus + accumsan purus id mattis. Vestibulum dictum lobortis felis, ac ultrices tortor ornare quis. Vestibulum rutrum + hendrerit risus vitae finibus. Integer porta luctus faucibus. Etiam tincidunt augue id enim convallis, sed feugiat + ex auctor. Vestibulum magna ex, convallis ut fringilla non, consectetur eu risus.

      + +

      Mauris aliquet lectus ligula, eget porttitor est dapibus condimentum. Nullam sodales ex eget nunc blandit, vel + posuere libero feugiat. Donec ac neque felis. Nulla sit amet porta ante. Maecenas congue nec odio in pellentesque. + Nam luctus mauris non enim semper, non ultrices purus efficitur. Interdum et malesuada fames ac ante ipsum primis + in faucibus. Vivamus in nulla ipsum. Vivamus dapibus velit euismod porta rhoncus. Vivamus ac magna pellentesque, + tincidunt nisi in, vulputate leo.

      + +

      Curabitur feugiat dictum porta. Nullam dapibus lorem vel odio consectetur, ac tincidunt erat dapibus. Fusce nec + finibus erat. Pellentesque ligula urna, elementum non sem id, consectetur faucibus urna. Aenean sodales, nulla sed + dapibus laoreet, nisi ligula sodales urna, vitae semper dui lorem non lorem. Nullam et efficitur tellus, eu + consectetur orci. Quisque rutrum egestas quam. Quisque eget enim tempor, viverra ligula vitae, fermentum turpis. + Nulla facilisi. Phasellus feugiat venenatis tellus, a sollicitudin nibh posuere et. Sed in massa leo. Nulla volutpat + finibus nibh eu ultricies. Vestibulum porttitor hendrerit magna, ac pharetra enim ultricies ut.

      + +

      Duis ligula tortor, sagittis vitae ipsum non, dapibus fringilla nisi. Proin a varius mi, vitae rhoncus arcu. + Nam sagittis semper scelerisque. Integer diam ante, feugiat quis tempus quis, cursus vitae nulla. Ut rhoncus + pretium fermentum. Donec imperdiet ac metus sit amet dignissim. Pellentesque dapibus mauris mauris, et varius + eros commodo sit amet. Maecenas et faucibus nisl.

      \ No newline at end of file diff --git a/app/views/shared/_manuscript.html.erb b/app/views/shared/_manuscript.html.erb new file mode 100644 index 0000000..71f7484 --- /dev/null +++ b/app/views/shared/_manuscript.html.erb @@ -0,0 +1,11 @@ +
      +
      + <% count = document_counter + @response_m['response']['start'] %> + <%= render partial: 'shared/manuscript_body', locals: {document: document, show_manifest: show_manifest, count: count} %> +
      + <% if show_footer == true %> + + <% end %> +
      diff --git a/app/views/shared/_manuscript_body.html.erb b/app/views/shared/_manuscript_body.html.erb new file mode 100644 index 0000000..70f71bb --- /dev/null +++ b/app/views/shared/_manuscript_body.html.erb @@ -0,0 +1,25 @@ +
      +
      + <% unless document['img_info'].blank? %> + <%= image_tag(document['img_info'].first, class: 'media-object results-thumbnail') %> + <% end %>  +
      +
      + + <% if show_manifest == true && !document['manifest_urls'].blank? %> + + <% end %> + +

      + <%= document['title_display'] %> +

      + <% unless document['authors_all_display'].blank? %> +

      <%= raw document['authors_all_display'].join('
      ') %>

      + <% end %> + <% unless document['abstract_display'].blank? %> +

      <%= truncate(document['abstract_display'], length: 150) %>

      + <% end %> +
      +
      \ No newline at end of file diff --git a/app/views/shared/_manuscript_footer.html.erb b/app/views/shared/_manuscript_footer.html.erb new file mode 100644 index 0000000..6a53b15 --- /dev/null +++ b/app/views/shared/_manuscript_footer.html.erb @@ -0,0 +1,32 @@ +
      +
      + <% + a_sf = {:search_field => 'annotations'} + a_local_params = add_facet_params('manuscript_facet', document['title_display'], source_params=a_sf) + a_path = search_action_path(a_local_params) + t_sf = {:search_field => 'transcriptions'} + t_local_params = add_facet_params('manuscript_facet', document['title_display'], source_params=t_sf) + t_path = search_action_path(t_local_params) + %> + + <% a_class = 'noresult' %> + <% if @related_annotations.has_key?( document['druid']) && @related_annotations[document['druid']] > 0 %> + <% a_class = 'result' %> + <% end %> + + Annotations + + + <% t_class = 'noresult' %> + <% if @related_transcriptions.has_key?( document['druid']) && @related_transcriptions[document['druid']] > 0 %> + <% t_class = 'result' %> + <% end %> + + Transcriptions + +
      +
      + + <%= render partial: 'shared/bookmark_control', locals: {:document => document} %> +
      +
      \ No newline at end of file diff --git a/app/views/shared/_next_record.html.erb b/app/views/shared/_next_record.html.erb new file mode 100644 index 0000000..839fad8 --- /dev/null +++ b/app/views/shared/_next_record.html.erb @@ -0,0 +1,20 @@ +<% unless @next_doc.blank? %> + <% + n_midpoint = 25 + @next_doc['title'] = @next_doc['title'].strip + if @next_doc['title'].length < 20 && @next_doc['title'].include?(' ') + n_midpoint = @next_doc['title'].length / 2 + elsif @next_doc['title'].length >= 20 && @next_doc['title'].length < 50 + n_midpoint = @next_doc['title'].length / 2 + end + n_a = truncate(@next_doc['title'], length: n_midpoint, omission: '', separator: ' ') + n_b = truncate(@next_doc['title'], length: 50) + n_b = n_b.sub(n_a, '') + %> + +<% end %> diff --git a/app/views/shared/_paginate_compact.html.erb b/app/views/shared/_paginate_compact.html.erb new file mode 100644 index 0000000..279f86c --- /dev/null +++ b/app/views/shared/_paginate_compact.html.erb @@ -0,0 +1,6 @@ +<%# Call with a Blacklight::Solr::Response or any other kaminari-compatible collection + to render Blacklight's compact pagination info component: + + <%= render :partial => "paginate_compact", :object => @response +-%> +<%= paginate paginate_compact, :page_entries_info => page_entries_info(paginate_compact), :theme => :colligo_compact %> diff --git a/app/views/shared/_per_page_widget.html.erb b/app/views/shared/_per_page_widget.html.erb new file mode 100644 index 0000000..3f40f62 --- /dev/null +++ b/app/views/shared/_per_page_widget.html.erb @@ -0,0 +1,14 @@ +<% if show_sort_and_per_page? and !blacklight_config.per_page.blank? %> + <%= t('blacklight.search.per_page.title') %> +
      + show + <%- per_page_options_for_select.each_with_index do |(label, count), i| %> + <% if count == current_per_page %> + <%= count %> + <% else %> + <%= link_to(count, url_for(params_for_search(per_page: count))) %> + <% end %> + <%- end -%> + per page +
      +<% end %> diff --git a/app/views/shared/_previous_record.html.erb b/app/views/shared/_previous_record.html.erb new file mode 100644 index 0000000..3a41696 --- /dev/null +++ b/app/views/shared/_previous_record.html.erb @@ -0,0 +1,22 @@ +<% unless @prev_doc.blank? %> + <% + p_midpoint = 25 + @prev_doc['title'] = @prev_doc['title'].strip + if @prev_doc['title'].length < 20 && @prev_doc['title'].include?(' ') + p_midpoint = @prev_doc['title'].length / 2 + elsif @prev_doc['title'].length >= 20 && @prev_doc['title'].length < 50 + p_midpoint = @prev_doc['title'].length / 2 + end + p_a = truncate(@prev_doc['title'], length: p_midpoint, omission: '', separator: ' ') + p_b = truncate(@prev_doc['title'], length: 50) + p_b = p_b.sub(p_a, '') + %> + +<% end %> diff --git a/app/views/shared/_results_footer.html.erb b/app/views/shared/_results_footer.html.erb new file mode 100644 index 0000000..0227761 --- /dev/null +++ b/app/views/shared/_results_footer.html.erb @@ -0,0 +1,9 @@ +
      +
      + <%= render :partial => '/shared/paginate_compact', :object => @response if show_pagination? %> + + +
      +
      diff --git a/app/views/shared/_results_header.html.erb b/app/views/shared/_results_header.html.erb new file mode 100644 index 0000000..f9adf22 --- /dev/null +++ b/app/views/shared/_results_header.html.erb @@ -0,0 +1,9 @@ +<%= render :partial => 'catalog/did_you_mean' %> +
      +
      + <%= render :partial => '/shared/simple_constraints' %> +
      +
      + <%= render :partial => 'shared/sort_widget' %> +
      +
      diff --git a/app/views/shared/_simple_constraints.html.erb b/app/views/shared/_simple_constraints.html.erb new file mode 100644 index 0000000..3bd5817 --- /dev/null +++ b/app/views/shared/_simple_constraints.html.erb @@ -0,0 +1,14 @@ +<% if query_has_constraints?(params) %> + <% if query_has_search_constraints?(params) %> +
      + <%= t('blacklight.search.simple_queries.title') %> + <%= render_constraints_query(params) %> +
      + <% end %> + <% if query_has_facet_constraints?(params) %> +
      + <%= t('blacklight.search.simple_filters.title') %> + <%=render_constraints_filters(params) %> +
      + <% end %> +<% end %> diff --git a/app/views/shared/_simple_constraints_element.html.erb b/app/views/shared/_simple_constraints_element.html.erb new file mode 100644 index 0000000..4618a1f --- /dev/null +++ b/app/views/shared/_simple_constraints_element.html.erb @@ -0,0 +1,20 @@ +<% # local params: + # label + # value + # options => + # :remove => url for a remove constraint link + # :classes => array of classes to add to container span + options ||= {} +%> + +"> + + <% unless value.blank? %> + <%= content_tag :span, value, class: 'filterValue', title: value %> + <% end %> + <% unless label.blank? %> + in + <%= label %> + <% end %> + +
      diff --git a/app/views/shared/_sort_widget.html.erb b/app/views/shared/_sort_widget.html.erb new file mode 100644 index 0000000..71df11c --- /dev/null +++ b/app/views/shared/_sort_widget.html.erb @@ -0,0 +1,13 @@ +<% if show_sort_and_per_page? and !active_sort_fields.blank? %> +
      + + + +
      +<% end %> diff --git a/app/views/shared/_top.html.erb b/app/views/shared/_top.html.erb new file mode 100644 index 0000000..ac15ee3 --- /dev/null +++ b/app/views/shared/_top.html.erb @@ -0,0 +1 @@ +Top diff --git a/app/views/shared/_transcription.html.erb b/app/views/shared/_transcription.html.erb new file mode 100644 index 0000000..22afec9 --- /dev/null +++ b/app/views/shared/_transcription.html.erb @@ -0,0 +1,31 @@ +
      +
      +
      +
      + <% unless document['img_info'].blank? %> + <%= image_tag(document['img_info'].first, class: 'media-object results-thumbnail') %> + <% end %>  +
      +
      + <% unless document['body_chars_display'].blank? %> +

      <%= truncate(document['body_chars_display'], length: 150) %>

      + <% else %> +

      <%= document['id'] %>

      + <% end %> + <% unless document['authors_all_display'].blank? %> +

      <%= raw document['authors_all_display'].join('
      ') %>

      + <% end %> + <% unless document['language'].blank? %> +

      <%= document['language'].join(', ') %>

      + <% end %> + <% unless document['folio'].blank? %> +

      <%= document['folio'] %>

      + <% end %> + <% unless document['manuscript_display'].blank? %> +

      <%= document['manuscript_display'] %>

      + <% end %> +
      +
      +
      +
      + diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..e19a27e 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -9,3 +9,4 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js ) +Rails.application.config.assets.precompile += %w( bg.gif asc.gif desc.gif ) diff --git a/config/locales/blacklight.en.yml b/config/locales/blacklight.en.yml index ff834b2..1f86179 100644 --- a/config/locales/blacklight.en.yml +++ b/config/locales/blacklight.en.yml @@ -1,3 +1,27 @@ en: blacklight: - application_name: 'Blacklight' \ No newline at end of file + application_name: 'Colligo' + range_limit: + submit_limit: 'Apply range' + search: + filters: + clear-all: 'Clear all' + simple_queries: + title: 'You searched' + simple_filters: + title: 'You selected' + sort: + label: 'Sorted by' + bookmarks: + present: "bookmarked" + absent: "bookmark" + inprogress: "Saving..." + pagination_info: + pages: + one: '%{start_num}-%{end_num} of
      %{total_num} results' + other: '%{start_num} - %{end_num} of
      %{total_num} results' + bookmarks: + add: + button: "bookmark" + remove: + button: "bookmarked" diff --git a/config/routes.rb b/config/routes.rb index f26935a..9ccb4f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,14 @@ root to: 'catalog#index' blacklight_for :catalog devise_for :users + + resources :manuscript, only: :show do + # adding constraint as folio may have dots and should not be considered as formatted route + resources :folio, only: :show, constraints: { id: /[^\/]+/ } + match 'folio/:id/folio_label', to: 'folio#folio_label', constraints: { id: /[^\/]+/ }, via: :get + end + get '/manuscript/:id/related_content', to: 'manuscript#related_content' + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/config/solr_configs/schema.xml b/config/solr_configs/schema.xml index 0848f50..be59031 100644 --- a/config/solr_configs/schema.xml +++ b/config/solr_configs/schema.xml @@ -108,6 +108,7 @@ + @@ -205,6 +206,7 @@ + - title_exact_search^1750 body_chars_exact_search^1750 - title_unstem_search^500 body_chars_unstem_search^500 - title_search^375 body_chars_search^375 - subtitle_unstem_search^375 - subtitle_search^250 - title_alternate_unstem_search^250 - title_alternate_search^100 - title_other_unstem_search^100 - title_other_search^50 - - - title_search^300 body_chars_search^300 - subtitle_search^225 - title_alternate_search^150 - title_other_search^60 - - - title_search^200 body_chars_search^200 - subtitle_search^150 - title_alternate_search^100 - title_other_search^40 - - - - personal_authors_unstem_search^20 - personal_authors_search^5 - corporate_authors_unstem_search^10 - corporate_authors_search^2 - authors_all_unstem_search^2 - authors_all_search - - - personal_authors_search^100 - corporate_authors_search^50 - authors_all_search^10 - - - personal_authors_search^60 - corporate_authors_search^30 - authors_all_search^5 - - - personal_authors_search^40 - corporate_authors_search^20 - authors_all_search^2 - - - - topic_unstem_search^50 - topic_search^30 - geographic_unstem_search^30 - geographic_search^20 - era_unstem_search^20 - era_search^10 - subject_other_unstem_search^10 - subject_other_search^5 - subject_all_unstem_search^2 - subject_all_search - - - topic_unstem_search^250 - topic_search^150 - geographic_unstem_search^150 - geographic_search^100 - era_unstem_search^100 - era_search^50 - subject_other_unstem_search^25 - subject_other_search^25 - subject_all_unstem_search^10 - subject_all_search^5 - - - topic_search^150 - subject_all_search^75 - - - topic_search^100 - subject_all_search^50 - - - - - id - druid - - - - - abstract_unstem_search^10 - abstract_search - - - abstract_unstem_search^20 - abstract_search^5 - - - abstract_search^3 - - - abstract_search^2 - - true 1 21 @@ -415,78 +300,181 @@ 1 - - - + + - lucene + edismax explicit - score desc, title_sort asc - text + + score desc, pub_date_sort desc, title_sort asc + 20 + *:* + 6<-1 6<90% + 1 + 0 + 0.01 + false + + all_search AND - 1 - - 1 - 3 - 0.01 + + title_exact_search^1000 body_chars_exact_search^1000 + title_unstem_search^500 body_chars_unstem_search^500 + title_search^75 body_chars_search^75 + subtitle_unstem_search^75 + subtitle_search^75 + title_alternate_unstem_search^50 + title_alternate_search^20 + title_other_search^20 + title_other_unstem_search^20 + + personal_authors_unstem_search^25 + personal_authors_search^20 + corporate_authors_unstem_search^20 + corporate_authors_search^10 + authors_all_unstem_search^10 + authors_all_search^5 + + topic_unstem_search^50 + topic_search^20 + geographic_unstem_search^20 + geographic_search^15 + era_unstem_search^15 + era_search^10 + subject_other_unstem_search^10 + subject_other_search^5 + subject_all_unstem_search^5 + subject_all_search^2 + + manuscript_unstem_search^5 + manuscript_search^2 + abstract_unstem_search^5 + abstract_search^2 + + pub_date^2 + id + collection_search + all_unstem_search^5 + all_search + + + title_exact_search^5000 body_chars_exact_search^5000 + title_unstem_search^2500 body_chars_unstem_search^2500 + title_search^375 body_chars_search^375 + subtitle_unstem_search^375 + subtitle_search^250 + title_alternate_unstem_search^250 + title_alternate_search^100 + title_other_unstem_search^100 + title_other_search^75 - - - personal_authors_unstem_search^200 + personal_authors_unstem_search^125 + personal_authors_search^100 corporate_authors_unstem_search^100 + corporate_authors_search^50 authors_all_unstem_search^50 - authors_all_search^20 - - - personal_authors_unstem_search^2000 - corporate_authors_unstem_search^500 - authors_all_unstem_search^300 - authors_all_search^200 - + authors_all_search^25 - - - title_unstem_search^50000 body_chars_unstem_search^50000 - subtitle_unstem_search^25000 - title_alternate_unstem_search^10000 - title_other_unstem_search^5000 - title_search^2500 - - - title_unstem_search^500000 body_chars_unstem_search^50000 - subtitle_unstem_search^250000 - title_alternate_unstem_search^100000 - title_other_unstem_search^50000 - title_search^25000 - + topic_unstem_search^250 + topic_search^150 + geographic_unstem_search^150 + geographic_search^100 + era_unstem_search^100 + era_search^50 + subject_other_unstem_search^50 + subject_other_search^25 + subject_all_unstem_search^25 + subject_all_search^10 + + manuscript_unstem_search^25 + manuscript_search^10 + abstract_unstem_search^25 + abstract_search^10 - - - topic_unstem_search^200 - geographic_unstem_search^125 - era_unstem_search^125 - subject_all_unstem_search^100 - topic_facet^100 + pub_date^10 + collection_search^5 + all_unstem_search^25 + all_search^5 - - topic_unstem_search^2000 - geographic_unstem_search^1250 - era_unstem_search^1000 - subject_all_unstem_search^750 - topic_facet^500 - subject_all_facet^100 + + title_search^1500 body_chars_search^1500 + subtitle_search^225 + title_alternate_search^150 + title_other_search^60 + + personal_authors_search^75 + corporate_authors_search^60 + authors_all_search^30 + + topic_search^150 + geographic_search^60 + era_search^50 + subject_other_search^30 + subject_all_search^15 + + manuscript_search^7.5 + abstract_search^7.5 + collection_search^3 + all_search^3 + + title_search^1000 body_chars_search^1000 + subtitle_search^150 + title_alternate_search^100 + title_other_search^40 + + personal_authors_search^50 + corporate_authors_search^40 + authors_all_search^20 - - droid + topic_search^100 + geographic_search^40 + era_search^30 + subject_other_search^20 + subject_all_search^10 - - text - text^10 + manuscript_search^5 + abstract_search^5 + collection_search^2 + all_search^2 + + true + 1 + 21 + genre_facet + enum + type_of_resource_facet + personal_authors_facet + corporate_authors_facet + authors_all_facet + physical_description_form_facet + physical_description_media_type_facet + physical_location_display + language + enum + folio + enum + topic_facet + geographic_facet + era_facet + subject_all_facet + format + model + collection + enum + format + 20 + enum + pub_date_t + enum + druid + enum + manuscript_facet + enum - + score, id, abstract_display, access_condition_display, @@ -525,49 +513,446 @@ manuscript_display, folio + + + model:Manuscript + + - true - 1 - 10 - type_of_resource_facet - personal_authors_facet - corporate_authors_facet - authors_all_facet - physical_description_form_facet - physical_description_media_type_facet - physical_location_display - language - enum - folio - enum - topic_facet - geographic_facet - era_facet - subject_all_facet - format - model - collection - enum - format - 20 - enum - pub_date_t - enum - druid - enum - manuscript_facet - enum - - true - subject - true - true - false - 5 + + + edismax + explicit + + score desc, pub_date_sort desc, title_sort asc + 20 + *:* + 6<-1 6<90% + 1 + 0 + 0.01 + false + + all_search + AND + + + title_exact_search^1000 body_chars_exact_search^1000 + title_unstem_search^500 body_chars_unstem_search^500 + title_search^75 body_chars_search^75 + subtitle_unstem_search^75 + subtitle_search^75 + title_alternate_unstem_search^50 + title_alternate_search^20 + title_other_search^20 + title_other_unstem_search^20 + + personal_authors_unstem_search^25 + personal_authors_search^20 + corporate_authors_unstem_search^20 + corporate_authors_search^10 + authors_all_unstem_search^10 + authors_all_search^5 + + topic_unstem_search^50 + topic_search^20 + geographic_unstem_search^20 + geographic_search^15 + era_unstem_search^15 + era_search^10 + subject_other_unstem_search^10 + subject_other_search^5 + subject_all_unstem_search^5 + subject_all_search^2 + + manuscript_unstem_search^5 + manuscript_search^2 + abstract_unstem_search^5 + abstract_search^2 + + pub_date^2 + id + collection_search + all_unstem_search^5 + all_search + + + title_exact_search^5000 body_chars_exact_search^5000 + title_unstem_search^2500 body_chars_unstem_search^2500 + title_search^375 body_chars_search^375 + subtitle_unstem_search^375 + subtitle_search^250 + title_alternate_unstem_search^250 + title_alternate_search^100 + title_other_unstem_search^100 + title_other_search^75 + + personal_authors_unstem_search^125 + personal_authors_search^100 + corporate_authors_unstem_search^100 + corporate_authors_search^50 + authors_all_unstem_search^50 + authors_all_search^25 + + topic_unstem_search^250 + topic_search^150 + geographic_unstem_search^150 + geographic_search^100 + era_unstem_search^100 + era_search^50 + subject_other_unstem_search^50 + subject_other_search^25 + subject_all_unstem_search^25 + subject_all_search^10 + + manuscript_unstem_search^25 + manuscript_search^10 + abstract_unstem_search^25 + abstract_search^10 + + pub_date^10 + collection_search^5 + all_unstem_search^25 + all_search^5 + + + title_search^1500 body_chars_search^1500 + subtitle_search^225 + title_alternate_search^150 + title_other_search^60 + + personal_authors_search^75 + corporate_authors_search^60 + authors_all_search^30 + + topic_search^150 + geographic_search^60 + era_search^50 + subject_other_search^30 + subject_all_search^15 + + manuscript_search^7.5 + abstract_search^7.5 + collection_search^3 + all_search^3 + + + title_search^1000 body_chars_search^1000 + subtitle_search^150 + title_alternate_search^100 + title_other_search^40 + + personal_authors_search^50 + corporate_authors_search^40 + authors_all_search^20 + + topic_search^100 + geographic_search^40 + era_search^30 + subject_other_search^20 + subject_all_search^10 + + manuscript_search^5 + abstract_search^5 + collection_search^2 + all_search^2 + + true + 1 + 21 + genre_facet + enum + type_of_resource_facet + personal_authors_facet + corporate_authors_facet + authors_all_facet + physical_description_form_facet + physical_description_media_type_facet + physical_location_display + language + enum + folio + enum + topic_facet + geographic_facet + era_facet + subject_all_facet + format + model + collection + enum + format + 20 + enum + pub_date_t + enum + druid + enum + manuscript_facet + enum + + + score, + id, + abstract_display, + access_condition_display, + type_of_resource_display, + personal_authors_display, + corporate_authors_display, + authors_all_display, + title_display, + subtitle_display, + title_alternate_display, + title_other_display, + language, + physical_description_extent_display, + physical_description_form_display, + physical_description_media_type_display, + physical_location_display, + relateditem_title_display, + pub_date_display, + topic_display, + geographic_display, + era_display, + subject_other_display, + subject_all_display, + format, + model, + url_sfx, + manifest_urls, + collection, + druid, + img_info, + target_url, + target_type, + body_url, + body_type, + body_chars_display, + manuscript_display, + folio + + + + model:Annotation + + + + + + edismax + explicit + + score desc, pub_date_sort desc, title_sort asc + 20 + *:* + 6<-1 6<90% + 1 + 0 + 0.01 + false + + all_search + AND + + + title_exact_search^1000 body_chars_exact_search^1000 + title_unstem_search^500 body_chars_unstem_search^500 + title_search^75 body_chars_search^75 + subtitle_unstem_search^75 + subtitle_search^75 + title_alternate_unstem_search^50 + title_alternate_search^20 + title_other_search^20 + title_other_unstem_search^20 + + personal_authors_unstem_search^25 + personal_authors_search^20 + corporate_authors_unstem_search^20 + corporate_authors_search^10 + authors_all_unstem_search^10 + authors_all_search^5 + + topic_unstem_search^50 + topic_search^20 + geographic_unstem_search^20 + geographic_search^15 + era_unstem_search^15 + era_search^10 + subject_other_unstem_search^10 + subject_other_search^5 + subject_all_unstem_search^5 + subject_all_search^2 + + manuscript_unstem_search^5 + manuscript_search^2 + abstract_unstem_search^5 + abstract_search^2 + + pub_date^2 + id + collection_search + all_unstem_search^5 + all_search + + + title_exact_search^5000 body_chars_exact_search^5000 + title_unstem_search^2500 body_chars_unstem_search^2500 + title_search^375 body_chars_search^375 + subtitle_unstem_search^375 + subtitle_search^250 + title_alternate_unstem_search^250 + title_alternate_search^100 + title_other_unstem_search^100 + title_other_search^75 + + personal_authors_unstem_search^125 + personal_authors_search^100 + corporate_authors_unstem_search^100 + corporate_authors_search^50 + authors_all_unstem_search^50 + authors_all_search^25 + + topic_unstem_search^250 + topic_search^150 + geographic_unstem_search^150 + geographic_search^100 + era_unstem_search^100 + era_search^50 + subject_other_unstem_search^50 + subject_other_search^25 + subject_all_unstem_search^25 + subject_all_search^10 + + manuscript_unstem_search^25 + manuscript_search^10 + abstract_unstem_search^25 + abstract_search^10 + + pub_date^10 + collection_search^5 + all_unstem_search^25 + all_search^5 + + + title_search^1500 body_chars_search^1500 + subtitle_search^225 + title_alternate_search^150 + title_other_search^60 + + personal_authors_search^75 + corporate_authors_search^60 + authors_all_search^30 + + topic_search^150 + geographic_search^60 + era_search^50 + subject_other_search^30 + subject_all_search^15 + + manuscript_search^7.5 + abstract_search^7.5 + collection_search^3 + all_search^3 + + + title_search^1000 body_chars_search^1000 + subtitle_search^150 + title_alternate_search^100 + title_other_search^40 + + personal_authors_search^50 + corporate_authors_search^40 + authors_all_search^20 + + topic_search^100 + geographic_search^40 + era_search^30 + subject_other_search^20 + subject_all_search^10 + + manuscript_search^5 + abstract_search^5 + collection_search^2 + all_search^2 + + true + 1 + 21 + genre_facet + enum + type_of_resource_facet + personal_authors_facet + corporate_authors_facet + authors_all_facet + physical_description_form_facet + physical_description_media_type_facet + physical_location_display + language + enum + folio + enum + topic_facet + geographic_facet + era_facet + subject_all_facet + format + model + collection + enum + format + 20 + enum + pub_date_t + enum + druid + enum + manuscript_facet + enum + + + score, + id, + abstract_display, + access_condition_display, + type_of_resource_display, + personal_authors_display, + corporate_authors_display, + authors_all_display, + title_display, + subtitle_display, + title_alternate_display, + title_other_display, + language, + physical_description_extent_display, + physical_description_form_display, + physical_description_media_type_display, + physical_location_display, + relateditem_title_display, + pub_date_display, + topic_display, + geographic_display, + era_display, + subject_other_display, + subject_all_display, + format, + model, + url_sfx, + manifest_urls, + collection, + druid, + img_info, + target_url, + target_type, + body_url, + body_type, + body_chars_display, + manuscript_display, + folio + + + + model:Transcription - - spellcheck - ")&&c.getElementsByTagName("i")[0];a+=1);return a>4?a:0/0}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||E};z=e.prototype,z._when=function(a){return d.when.apply(d,a)},z.render=function(a){if(this.rendered||this.destroyed)return this;var b,c=this,e=this.options,f=this.cache,g=this.elements,h=e.content.text,i=e.content.title,j=e.content.button,k=e.position,l=("."+this._id+" ",[]);return d.attr(this.target[0],"aria-describedby",this._id),f.posClass=this._createPosClass((this.position={my:k.my,at:k.at}).my),this.tooltip=g.tooltip=b=d("
      ",{id:this._id,"class":[S,Z,e.style.classes,f.posClass].join(" "),width:e.style.width||"",height:e.style.height||"",tracking:"mouse"===k.target&&k.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":E,"aria-describedby":this._id+"-content","aria-hidden":D}).toggleClass(ab,this.disabled).attr(U,this.id).data(S,this).appendTo(k.container).append(g.content=d("
      ",{"class":S+"-content",id:this._id+"-content","aria-atomic":D})),this.rendered=-1,this.positioning=D,i&&(this._createTitle(),d.isFunction(i)||l.push(this._updateTitle(i,E))),j&&this._createButton(),d.isFunction(h)||l.push(this._updateContent(h,E)),this.rendered=D,this._setWidget(),d.each(R,function(a){var b;"render"===this.initialize&&(b=this(c))&&(c.plugins[a]=b)}),this._unassignEvents(),this._assignEvents(),this._when(l).then(function(){c._trigger("render"),c.positioning=E,c.hiddenDuringWait||!e.show.ready&&!a||c.toggle(D,f.event,E),c.hiddenDuringWait=E}),y.api[this.id]=this,this},z.destroy=function(a){function b(){if(!this.destroyed){this.destroyed=D;var a,b=this.target,c=b.attr(cb);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),d.each(this.plugins,function(){this.destroy&&this.destroy()});for(a in this.timers)clearTimeout(this.timers[a]);b.removeData(S).removeAttr(U).removeAttr(T).removeAttr("aria-describedby"),this.options.suppress&&c&&b.attr("title",c).removeAttr(cb),this._unassignEvents(),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=F,delete y.api[this.id]}}return this.destroyed?this.target:(a===D&&"hide"!==this.triggering||!this.rendered?b.call(this):(this.tooltip.one("tooltiphidden",d.proxy(b,this)),!this.triggering&&this.hide()),this.target)},B=z.checks={builtin:{"^id$":function(a,b,c,e){var f=c===D?y.nextid:c,g=S+"-"+f;f!==E&&f.length>0&&!d("#"+g).length?(this._id=g,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):a[b]=e},"^prerender":function(a,b,c){c&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(a,b,c){this._updateContent(c)},"^content.attr$":function(a,b,c,d){this.options.content.text===this.target.attr(d)&&this._updateContent(this.target.attr(c))},"^content.title$":function(a,b,c){return c?(c&&!this.elements.title&&this._createTitle(),void this._updateTitle(c)):this._removeTitle()},"^content.button$":function(a,b,c){this._updateButton(c)},"^content.title.(text|button)$":function(a,b,c){this.set("content."+b,c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(this.position[b]=a[b]=new A(c,"at"===b))},"^position.container$":function(a,b,c){this.rendered&&this.tooltip.appendTo(c)},"^show.ready$":function(a,b,c){c&&(!this.rendered&&this.render(D)||this.toggle(D))},"^style.classes$":function(a,b,c,d){this.rendered&&this.tooltip.removeClass(d).addClass(c)},"^style.(width|height)":function(a,b,c){this.rendered&&this.tooltip.css(b,c)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(a,b,c){this.rendered&&this.tooltip.toggleClass(Z,!!c)},"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){this.rendered&&this.tooltip[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var a=this.options.position;this.tooltip.attr("tracking","mouse"===a.target&&a.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},z.get=function(a){if(this.destroyed)return this;var b=i(this.options,a.toLowerCase()),c=b[0][b[1]];return c.precedance?c.string():c};var eb=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,fb=/^prerender|show\.ready/i;z.set=function(a,b){if(this.destroyed)return this;{var c,e=this.rendered,f=E,g=this.options;this.checks}return"string"==typeof a?(c=a,a={},a[c]=b):a=d.extend({},a),d.each(a,function(b,c){if(e&&fb.test(b))return void delete a[b];var h,j=i(g,b.toLowerCase());h=j[0][j[1]],j[0][j[1]]=c&&c.nodeType?d(c):c,f=eb.test(b)||f,a[b]=[j[0],j[1],c,h]}),h(g),this.positioning=D,d.each(a,d.proxy(j,this)),this.positioning=E,this.rendered&&this.tooltip[0].offsetWidth>0&&f&&this.reposition("mouse"===g.position.target?F:this.cache.event),this},z._update=function(a,b){var c=this,e=this.cache;return this.rendered&&a?(d.isFunction(a)&&(a=a.call(this.elements.target,e.event,this)||""),d.isFunction(a.then)?(e.waiting=D,a.then(function(a){return e.waiting=E,c._update(a,b)},F,function(a){return c._update(a,b)})):a===E||!a&&""!==a?E:(a.jquery&&a.length>0?b.empty().append(a.css({display:"block",visibility:"visible"})):b.html(a),this._waitForContent(b).then(function(a){c.rendered&&c.tooltip[0].offsetWidth>0&&c.reposition(e.event,!a.length)}))):E},z._waitForContent=function(a){var b=this.cache;return b.waiting=D,(d.fn.imagesLoaded?a.imagesLoaded():d.Deferred().resolve([])).done(function(){b.waiting=E}).promise()},z._updateContent=function(a,b){this._update(a,this.elements.content,b)},z._updateTitle=function(a,b){this._update(a,this.elements.title,b)===E&&this._removeTitle(E)},z._createTitle=function(){var a=this.elements,b=this._id+"-title";a.titlebar&&this._removeTitle(),a.titlebar=d("
      ",{"class":S+"-titlebar "+(this.options.style.widget?k("header"):"")}).append(a.title=d("
      ",{id:b,"class":S+"-title","aria-atomic":D})).insertBefore(a.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus","down"===a.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover","mouseover"===a.type)}),this.options.content.button&&this._createButton()},z._removeTitle=function(a){var b=this.elements;b.title&&(b.titlebar.remove(),b.titlebar=b.title=b.button=F,a!==E&&this.reposition())},z._createPosClass=function(a){return S+"-pos-"+(a||this.options.position.my).abbrev()},z.reposition=function(c,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=D;var f,g,h,i,j=this.cache,k=this.tooltip,l=this.options.position,m=l.target,n=l.my,o=l.at,p=l.viewport,q=l.container,r=l.adjust,s=r.method.split(" "),t=k.outerWidth(E),u=k.outerHeight(E),v=0,w=0,x=k.css("position"),y={left:0,top:0},z=k[0].offsetWidth>0,A=c&&"scroll"===c.type,B=d(a),C=q[0].ownerDocument,F=this.mouse;if(d.isArray(m)&&2===m.length)o={x:L,y:K},y={left:m[0],top:m[1]};else if("mouse"===m)o={x:L,y:K},(!r.mouse||this.options.hide.distance)&&j.origin&&j.origin.pageX?c=j.origin:!c||c&&("resize"===c.type||"scroll"===c.type)?c=j.event:F&&F.pageX&&(c=F),"static"!==x&&(y=q.offset()),C.body.offsetWidth!==(a.innerWidth||C.documentElement.clientWidth)&&(g=d(b.body).offset()),y={left:c.pageX-y.left+(g&&g.left||0),top:c.pageY-y.top+(g&&g.top||0)},r.mouse&&A&&F&&(y.left-=(F.scrollX||0)-B.scrollLeft(),y.top-=(F.scrollY||0)-B.scrollTop());else{if("event"===m?c&&c.target&&"scroll"!==c.type&&"resize"!==c.type?j.target=d(c.target):c.target||(j.target=this.elements.target):"event"!==m&&(j.target=d(m.jquery?m:this.elements.target)),m=j.target,m=d(m).eq(0),0===m.length)return this;m[0]===b||m[0]===a?(v=db.iOS?a.innerWidth:m.width(),w=db.iOS?a.innerHeight:m.height(),m[0]===a&&(y={top:(p||m).scrollTop(),left:(p||m).scrollLeft()})):R.imagemap&&m.is("area")?f=R.imagemap(this,m,o,R.viewport?s:E):R.svg&&m&&m[0].ownerSVGElement?f=R.svg(this,m,o,R.viewport?s:E):(v=m.outerWidth(E),w=m.outerHeight(E),y=m.offset()),f&&(v=f.width,w=f.height,g=f.offset,y=f.position),y=this.reposition.offset(m,y,q),(db.iOS>3.1&&db.iOS<4.1||db.iOS>=4.3&&db.iOS<4.33||!db.iOS&&"fixed"===x)&&(y.left-=B.scrollLeft(),y.top-=B.scrollTop()),(!f||f&&f.adjustable!==E)&&(y.left+=o.x===N?v:o.x===O?v/2:0,y.top+=o.y===M?w:o.y===O?w/2:0)}return y.left+=r.x+(n.x===N?-t:n.x===O?-t/2:0),y.top+=r.y+(n.y===M?-u:n.y===O?-u/2:0),R.viewport?(h=y.adjusted=R.viewport(this,y,l,v,w,t,u),g&&h.left&&(y.left+=g.left),g&&h.top&&(y.top+=g.top),h.my&&(this.position.my=h.my)):y.adjusted={left:0,top:0},j.posClass!==(i=this._createPosClass(this.position.my))&&k.removeClass(j.posClass).addClass(j.posClass=i),this._trigger("move",[y,p.elem||p],c)?(delete y.adjusted,e===E||!z||isNaN(y.left)||isNaN(y.top)||"mouse"===m||!d.isFunction(l.effect)?k.css(y):d.isFunction(l.effect)&&(l.effect.call(k,this,d.extend({},y)),k.queue(function(a){d(this).css({opacity:"",height:""}),db.ie&&this.style.removeAttribute("filter"),a()})),this.positioning=E,this):this},z.reposition.offset=function(a,c,e){function f(a,b){c.left+=b*a.scrollLeft(),c.top+=b*a.scrollTop()}if(!e[0])return c;var g,h,i,j,k=d(a[0].ownerDocument),l=!!db.ie&&"CSS1Compat"!==b.compatMode,m=e[0];do"static"!==(h=d.css(m,"position"))&&("fixed"===h?(i=m.getBoundingClientRect(),f(k,-1)):(i=d(m).position(),i.left+=parseFloat(d.css(m,"borderLeftWidth"))||0,i.top+=parseFloat(d.css(m,"borderTopWidth"))||0),c.left-=i.left+(parseFloat(d.css(m,"marginLeft"))||0),c.top-=i.top+(parseFloat(d.css(m,"marginTop"))||0),g||"hidden"===(j=d.css(m,"overflow"))||"visible"===j||(g=d(m)));while(m=m.offsetParent);return g&&(g[0]!==k[0]||l)&&f(g,1),c};var gb=(A=z.reposition.Corner=function(a,b){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,O).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!b;var c=a.charAt(0);this.precedance="t"===c||"b"===c?H:G}).prototype;gb.invert=function(a,b){this[a]=this[a]===L?N:this[a]===N?L:b||this[a]},gb.string=function(a){var b=this.x,c=this.y,d=b!==c?"center"===b||"center"!==c&&(this.precedance===H||this.forceY)?[c,b]:[b,c]:[b];return a!==!1?d.join(" "):d},gb.abbrev=function(){var a=this.string(!1);return a[0].charAt(0)+(a[1]&&a[1].charAt(0)||"")},gb.clone=function(){return new A(this.string(),this.forceY)},z.toggle=function(a,c){var e=this.cache,f=this.options,g=this.tooltip;if(c){if(/over|enter/.test(c.type)&&e.event&&/out|leave/.test(e.event.type)&&f.show.target.add(c.target).length===f.show.target.length&&g.has(c.relatedTarget).length)return this;e.event=d.event.fix(c)}if(this.waiting&&!a&&(this.hiddenDuringWait=D),!this.rendered)return a?this.render(1):this;if(this.destroyed||this.disabled)return this;var h,i,j,k=a?"show":"hide",l=this.options[k],m=(this.options[a?"hide":"show"],this.options.position),n=this.options.content,o=this.tooltip.css("width"),p=this.tooltip.is(":visible"),q=a||1===l.target.length,r=!c||l.target.length<2||e.target[0]===c.target;return(typeof a).search("boolean|number")&&(a=!p),h=!g.is(":animated")&&p===a&&r,i=h?F:!!this._trigger(k,[90]),this.destroyed?this:(i!==E&&a&&this.focus(c),!i||h?this:(d.attr(g[0],"aria-hidden",!a),a?(this.mouse&&(e.origin=d.event.fix(this.mouse)),d.isFunction(n.text)&&this._updateContent(n.text,E),d.isFunction(n.title)&&this._updateTitle(n.title,E),!C&&"mouse"===m.target&&m.adjust.mouse&&(d(b).bind("mousemove."+S,this._storeMouse),C=D),o||g.css("width",g.outerWidth(E)),this.reposition(c,arguments[2]),o||g.css("width",""),l.solo&&("string"==typeof l.solo?d(l.solo):d(W,l.solo)).not(g).not(l.target).qtip("hide",d.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete e.origin,C&&!d(W+'[tracking="true"]:visible',l.solo).not(g).length&&(d(b).unbind("mousemove."+S),C=E),this.blur(c)),j=d.proxy(function(){a?(db.ie&&g[0].style.removeAttribute("filter"),g.css("overflow",""),"string"==typeof l.autofocus&&d(this.options.show.autofocus,g).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):g.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(a?"visible":"hidden")},this),l.effect===E||q===E?(g[k](),j()):d.isFunction(l.effect)?(g.stop(1,1),l.effect.call(g,this),g.queue("fx",function(a){j(),a()})):g.fadeTo(90,a?1:0,j),a&&l.target.trigger("qtip-"+this.id+"-inactive"),this))},z.show=function(a){return this.toggle(D,a)},z.hide=function(a){return this.toggle(E,a)},z.focus=function(a){if(!this.rendered||this.destroyed)return this;var b=d(W),c=this.tooltip,e=parseInt(c[0].style.zIndex,10),f=y.zindex+b.length;return c.hasClass($)||this._trigger("focus",[f],a)&&(e!==f&&(b.each(function(){this.style.zIndex>e&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+$).qtip("blur",a)),c.addClass($)[0].style.zIndex=f),this},z.blur=function(a){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass($),this._trigger("blur",[this.tooltip.css("zIndex")],a),this)},z.disable=function(a){return this.destroyed?this:("toggle"===a?a=!(this.rendered?this.tooltip.hasClass(ab):this.disabled):"boolean"!=typeof a&&(a=D),this.rendered&&this.tooltip.toggleClass(ab,a).attr("aria-disabled",a),this.disabled=!!a,this)},z.enable=function(){return this.disable(E)},z._createButton=function(){var a=this,b=this.elements,c=b.tooltip,e=this.options.content.button,f="string"==typeof e,g=f?e:"Close tooltip";b.button&&b.button.remove(),b.button=e.jquery?e:d("",{"class":"qtip-close "+(this.options.style.widget?"":S+"-icon"),title:g,"aria-label":g}).prepend(d("",{"class":"ui-icon ui-icon-close",html:"×"})),b.button.appendTo(b.titlebar||c).attr("role","button").click(function(b){return c.hasClass(ab)||a.hide(b),E})},z._updateButton=function(a){if(!this.rendered)return E;var b=this.elements.button;a?this._createButton():b.remove()},z._setWidget=function(){var a=this.options.style.widget,b=this.elements,c=b.tooltip,d=c.hasClass(ab);c.removeClass(ab),ab=a?"ui-state-disabled":"qtip-disabled",c.toggleClass(ab,d),c.toggleClass("ui-helper-reset "+k(),a).toggleClass(Z,this.options.style.def&&!a),b.content&&b.content.toggleClass(k("content"),a),b.titlebar&&b.titlebar.toggleClass(k("header"),a),b.button&&b.button.toggleClass(S+"-icon",!a)},z._storeMouse=function(a){return(this.mouse=d.event.fix(a)).type="mousemove",this},z._bind=function(a,b,c,e,f){if(a&&c&&b.length){var g="."+this._id+(e?"-"+e:"");return d(a).bind((b.split?b:b.join(g+" "))+g,d.proxy(c,f||this)),this}},z._unbind=function(a,b){return a&&d(a).unbind("."+this._id+(b?"-"+b:"")),this},z._trigger=function(a,b,c){var e=d.Event("tooltip"+a);return e.originalEvent=c&&d.extend({},c)||this.cache.event||F,this.triggering=a,this.tooltip.trigger(e,[this].concat(b||[])),this.triggering=E,!e.isDefaultPrevented()},z._bindEvents=function(a,b,c,e,f,g){var h=c.filter(e).add(e.filter(c)),i=[];h.length&&(d.each(b,function(b,c){var e=d.inArray(c,a);e>-1&&i.push(a.splice(e,1)[0])}),i.length&&(this._bind(h,i,function(a){var b=this.rendered?this.tooltip[0].offsetWidth>0:!1;(b?g:f).call(this,a)}),c=c.not(h),e=e.not(h))),this._bind(c,a,f),this._bind(e,b,g)},z._assignInitialEvents=function(a){function b(a){return this.disabled||this.destroyed?E:(this.cache.event=a&&d.event.fix(a),this.cache.target=a&&d(a.target),clearTimeout(this.timers.show),void(this.timers.show=l.call(this,function(){this.render("object"==typeof a||c.show.ready)},c.prerender?0:c.show.delay)))}var c=this.options,e=c.show.target,f=c.hide.target,g=c.show.event?d.trim(""+c.show.event).split(" "):[],h=c.hide.event?d.trim(""+c.hide.event).split(" "):[];this._bind(this.elements.target,["remove","removeqtip"],function(){this.destroy(!0)},"destroy"),/mouse(over|enter)/i.test(c.show.event)&&!/mouse(out|leave)/i.test(c.hide.event)&&h.push("mouseleave"),this._bind(e,"mousemove",function(a){this._storeMouse(a),this.cache.onTarget=D}),this._bindEvents(g,h,e,f,b,function(){return this.timers?void clearTimeout(this.timers.show):E}),(c.show.ready||c.prerender)&&b.call(this,a)},z._assignEvents=function(){var c=this,e=this.options,f=e.position,g=this.tooltip,h=e.show.target,i=e.hide.target,j=f.container,k=f.viewport,l=d(b),q=(d(b.body),d(a)),r=e.show.event?d.trim(""+e.show.event).split(" "):[],s=e.hide.event?d.trim(""+e.hide.event).split(" "):[];d.each(e.events,function(a,b){c._bind(g,"toggle"===a?["tooltipshow","tooltiphide"]:["tooltip"+a],b,null,g)}),/mouse(out|leave)/i.test(e.hide.event)&&"window"===e.hide.leave&&this._bind(l,["mouseout","blur"],function(a){/select|option/.test(a.target.nodeName)||a.relatedTarget||this.hide(a)}),e.hide.fixed?i=i.add(g.addClass(Y)):/mouse(over|enter)/i.test(e.show.event)&&this._bind(i,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+e.hide.event).indexOf("unfocus")>-1&&this._bind(j.closest("html"),["mousedown","touchstart"],function(a){var b=d(a.target),c=this.rendered&&!this.tooltip.hasClass(ab)&&this.tooltip[0].offsetWidth>0,e=b.parents(W).filter(this.tooltip[0]).length>0;b[0]===this.target[0]||b[0]===this.tooltip[0]||e||this.target.has(b[0]).length||!c||this.hide(a)}),"number"==typeof e.hide.inactive&&(this._bind(h,"qtip-"+this.id+"-inactive",o,"inactive"),this._bind(i.add(g),y.inactiveEvents,o)),this._bindEvents(r,s,h,i,m,n),this._bind(h.add(g),"mousemove",function(a){if("number"==typeof e.hide.distance){var b=this.cache.origin||{},c=this.options.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&this.hide(a)}this._storeMouse(a)}),"mouse"===f.target&&f.adjust.mouse&&(e.hide.event&&this._bind(h,["mouseenter","mouseleave"],function(a){return this.cache?void(this.cache.onTarget="mouseenter"===a.type):E}),this._bind(l,"mousemove",function(a){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(ab)&&this.tooltip[0].offsetWidth>0&&this.reposition(a)})),(f.adjust.resize||k.length)&&this._bind(d.event.special.resize?k:q,"resize",p),f.adjust.scroll&&this._bind(q.add(f.container),"scroll",p)},z._unassignEvents=function(){var c=this.options,e=c.show.target,f=c.hide.target,g=d.grep([this.elements.target[0],this.rendered&&this.tooltip[0],c.position.container[0],c.position.viewport[0],c.position.container.closest("html")[0],a,b],function(a){return"object"==typeof a});e&&e.toArray&&(g=g.concat(e.toArray())),f&&f.toArray&&(g=g.concat(f.toArray())),this._unbind(g)._unbind(g,"destroy")._unbind(g,"inactive")},d(function(){q(W,["mouseenter","mouseleave"],function(a){var b="mouseenter"===a.type,c=d(a.currentTarget),e=d(a.relatedTarget||a.target),f=this.options;b?(this.focus(a),c.hasClass(Y)&&!c.hasClass(ab)&&clearTimeout(this.timers.hide)):"mouse"===f.position.target&&f.position.adjust.mouse&&f.hide.event&&f.show.target&&!e.closest(f.show.target[0]).length&&this.hide(a),c.toggleClass(_,b)}),q("["+U+"]",X,o)}),y=d.fn.qtip=function(a,b,e){var f=(""+a).toLowerCase(),g=F,i=d.makeArray(arguments).slice(1),j=i[i.length-1],k=this[0]?d.data(this[0],S):F;return!arguments.length&&k||"api"===f?k:"string"==typeof a?(this.each(function(){var a=d.data(this,S);if(!a)return D;if(j&&j.timeStamp&&(a.cache.event=j),!b||"option"!==f&&"options"!==f)a[f]&&a[f].apply(a,i);else{if(e===c&&!d.isPlainObject(b))return g=a.get(b),E;a.set(b,e)}}),g!==F?g:this):"object"!=typeof a&&arguments.length?void 0:(k=h(d.extend(D,{},a)),this.each(function(a){var b,c;return c=d.isArray(k.id)?k.id[a]:k.id,c=!c||c===E||c.length<1||y.api[c]?y.nextid++:c,b=r(d(this),c,k),b===E?D:(y.api[c]=b,d.each(R,function(){"initialize"===this.initialize&&this(b)}),void b._assignInitialEvents(j))}))},d.qtip=e,y.api={},d.each({attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&"object"==typeof f&&f.options.suppress)return arguments.length<2?d.attr(c,cb):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(cb,b))}return d.fn["attr"+bb].apply(this,arguments)},clone:function(a){var b=(d([]),d.fn["clone"+bb].apply(this,arguments));return a||b.filter("["+cb+"]").attr("title",function(){return d.attr(this,cb)}).removeAttr(cb),b}},function(a,b){if(!b||d.fn[a+bb])return D;var c=d.fn[a+bb]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+bb]=d.cleanData,d.cleanData=function(a){for(var b,c=0;(b=d(a[c])).length;c++)if(b.attr(T))try{b.triggerHandler("removeqtip")}catch(e){}d["cleanData"+bb].apply(this,arguments)}),y.version="@@VERSION",y.nextid=0,y.inactiveEvents=X,y.zindex=15e3,y.defaults={prerender:E,id:E,overwrite:D,suppress:D,content:{text:D,attr:"title",title:E,button:E},position:{my:"top left",at:"bottom right",target:E,container:E,viewport:E,adjust:{x:0,y:0,mouse:D,scroll:D,resize:D,method:"flipinvert flipinvert"},effect:function(a,b){d(this).animate(b,{duration:200,queue:E})}},show:{target:E,event:"mouseenter",effect:D,delay:90,solo:E,ready:E,autofocus:E},hide:{target:E,event:"mouseleave",effect:D,delay:0,fixed:E,inactive:E,leave:"window",distance:E},style:{classes:"",widget:E,width:E,height:E,def:D},events:{render:F,move:F,show:F,hide:F,toggle:F,visible:F,hidden:F,focus:F,blur:F}};var hb,ib="margin",jb="border",kb="color",lb="background-color",mb="transparent",nb=" !important",ob=!!b.createElement("canvas").getContext,pb=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,qb={},rb=["Webkit","O","Moz","ms"];if(ob)var sb=a.devicePixelRatio||1,tb=function(){var a=b.createElement("canvas").getContext("2d");return a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||1}(),ub=sb/tb;else var vb=function(a,b,c){return"'};d.extend(v.prototype,{init:function(a){var b,c;c=this.element=a.elements.tip=d("
      ",{"class":S+"-tip"}).prependTo(a.tooltip),ob?(b=d("").appendTo(this.element)[0].getContext("2d"),b.lineJoin="miter",b.miterLimit=1e5,b.save()):(b=vb("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(b+b),a._bind(d("*",c).add(c),["click","mousedown"],function(a){a.stopPropagation()},this._ns)),a._bind(a.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(a){var b=this.qtip.elements.titlebar;return b&&(a.y===K||a.y===O&&this.element.position().top+this.size[1]/2+this.options.offsetl&&!pb.test(e[1])&&(e[0]=e[1]),this.border=l=p.border!==D?p.border:l):this.border=l=0,k=this.size=this._calculateSize(b),n.css({width:k[0],height:k[1],lineHeight:k[1]+"px"}),j=b.precedance===H?[s(r.x===L?l:r.x===N?k[0]-q[0]-l:(k[0]-q[0])/2),s(r.y===K?k[1]-q[1]:0)]:[s(r.x===L?k[0]-q[0]:0),s(r.y===K?l:r.y===M?k[1]-q[1]-l:(k[1]-q[1])/2)],ob?(g=o[0].getContext("2d"),g.restore(),g.save(),g.clearRect(0,0,6e3,6e3),h=this._calculateTip(r,q,ub),i=this._calculateTip(r,this.size,ub),o.attr(I,k[0]*ub).attr(J,k[1]*ub),o.css(I,k[0]).css(J,k[1]),this._drawCoords(g,i),g.fillStyle=e[1],g.fill(),g.translate(j[0]*ub,j[1]*ub),this._drawCoords(g,h),g.fillStyle=e[0],g.fill()):(h=this._calculateTip(r),h="m"+h[0]+","+h[1]+" l"+h[2]+","+h[3]+" "+h[4]+","+h[5]+" xe",j[2]=l&&/^(r|b)/i.test(b.string())?8===db.ie?2:1:0,o.css({coordsize:k[0]+l+" "+(k[1]+l),antialias:""+(r.string().indexOf(O)>-1),left:j[0]-j[2]*Number(f===G),top:j[1]-j[2]*Number(f===H),width:k[0]+l,height:k[1]+l}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k[0]+l+" "+(k[1]+l),path:h,fillcolor:e[0],filled:!!a,stroked:!a}).toggle(!(!l&&!a)),!a&&b.html(vb("stroke",'weight="'+2*l+'px" color="'+e[1]+'" miterlimit="1000" joinstyle="miter"'))})),a.opera&&setTimeout(function(){m.tip.css({display:"inline-block",visibility:"visible"})},1),c!==E&&this.calculate(b,k)},calculate:function(a,b){if(!this.enabled)return E;var c,e,f=this,g=this.qtip.elements,h=this.element,i=this.options.offset,j=(g.tooltip.hasClass("ui-widget"),{});return a=a||this.corner,c=a.precedance,b=b||this._calculateSize(a),e=[a.x,a.y],c===G&&e.reverse(),d.each(e,function(d,e){var h,k,l; +e===O?(h=c===H?L:K,j[h]="50%",j[ib+"-"+h]=-Math.round(b[c===H?0:1]/2)+i):(h=f._parseWidth(a,e,g.tooltip),k=f._parseWidth(a,e,g.content),l=f._parseRadius(a),j[e]=Math.max(-f.border,d?k:i+(l>h?l:-h)))}),j[a[c]]-=b[c===G?0:1],h.css({margin:"",top:"",bottom:"",left:"",right:""}).css(j),j},reposition:function(a,b,d){function e(a,b,c,d,e){a===Q&&j.precedance===b&&k[d]&&j[c]!==O?j.precedance=j.precedance===G?H:G:a!==Q&&k[d]&&(j[b]=j[b]===O?k[d]>0?d:e:j[b]===d?e:d)}function f(a,b,e){j[a]===O?p[ib+"-"+b]=o[a]=g[ib+"-"+b]-k[b]:(h=g[e]!==c?[k[b],-g[b]]:[-k[b],g[b]],(o[a]=Math.max(h[0],h[1]))>h[0]&&(d[b]-=k[b],o[b]=E),p[g[e]!==c?e:b]=o[a])}if(this.enabled){var g,h,i=b.cache,j=this.corner.clone(),k=d.adjusted,l=b.options.position.adjust.method.split(" "),m=l[0],n=l[1]||l[0],o={left:E,top:E,x:0,y:0},p={};this.corner.fixed!==D&&(e(m,G,H,L,N),e(n,H,G,K,M),(j.string()!==i.corner.string()||i.cornerTop!==k.top||i.cornerLeft!==k.left)&&this.update(j,E)),g=this.calculate(j),g.right!==c&&(g.left=-g.right),g.bottom!==c&&(g.top=-g.bottom),g.user=this.offset,(o.left=m===Q&&!!k.left)&&f(G,L,N),(o.top=n===Q&&!!k.top)&&f(H,K,M),this.element.css(p).toggle(!(o.x&&o.y||j.x===O&&o.y||j.y===O&&o.x)),d.left-=g.left.charAt?g.user:m!==Q||o.top||!o.left&&!o.top?g.left+this.border:0,d.top-=g.top.charAt?g.user:n!==Q||o.left||!o.left&&!o.top?g.top+this.border:0,i.cornerLeft=k.left,i.cornerTop=k.top,i.corner=j.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),hb=R.tip=function(a){return new v(a,a.options.style.tip)},hb.initialize="render",hb.sanitize=function(a){if(a.style&&"tip"in a.style){var b=a.style.tip;"object"!=typeof b&&(b=a.style.tip={corner:b}),/string|boolean/i.test(typeof b.corner)||(b.corner=D)}},B.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(a){this.size=[a.width,a.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},d.extend(D,y.defaults,{style:{tip:{corner:D,mimic:E,width:6,height:6,border:D,offset:0}}});var wb,xb,yb="qtip-modal",zb="."+yb;xb=function(){function a(a){if(d.expr[":"].focusable)return d.expr[":"].focusable;var b,c,e,f=!isNaN(d.attr(a,"tabindex")),g=a.nodeName&&a.nodeName.toLowerCase();return"area"===g?(b=a.parentNode,c=b.name,a.href&&c&&"map"===b.nodeName.toLowerCase()?(e=d("img[usemap=#"+c+"]")[0],!!e&&e.is(":visible")):!1):/input|select|textarea|button|object/.test(g)?!a.disabled:"a"===g?a.href||f:f}function c(a){k.length<1&&a.length?a.not("body").blur():k.first().focus()}function e(a){if(i.is(":visible")){var b,e=d(a.target),h=f.tooltip,j=e.closest(W);b=j.length<1?E:parseInt(j[0].style.zIndex,10)>parseInt(h[0].style.zIndex,10),b||e.closest(W)[0]===h[0]||c(e),g=a.target===k[k.length-1]}}var f,g,h,i,j=this,k={};d.extend(j,{init:function(){return i=j.elem=d("
      ",{id:"qtip-overlay",html:"
      ",mousedown:function(){return E}}).hide(),d(b.body).bind("focusin"+zb,e),d(b).bind("keydown"+zb,function(a){f&&f.options.show.modal.escape&&27===a.keyCode&&f.hide(a)}),i.bind("click"+zb,function(a){f&&f.options.show.modal.blur&&f.hide(a)}),j},update:function(b){f=b,k=b.options.show.modal.stealfocus!==E?b.tooltip.find("*").filter(function(){return a(this)}):[]},toggle:function(a,e,g){var k=(d(b.body),a.tooltip),l=a.options.show.modal,m=l.effect,n=e?"show":"hide",o=i.is(":visible"),p=d(zb).filter(":visible:not(:animated)").not(k);return j.update(a),e&&l.stealfocus!==E&&c(d(":focus")),i.toggleClass("blurs",l.blur),e&&i.appendTo(b.body),i.is(":animated")&&o===e&&h!==E||!e&&p.length?j:(i.stop(D,E),d.isFunction(m)?m.call(i,e):m===E?i[n]():i.fadeTo(parseInt(g,10)||90,e?1:0,function(){e||i.hide()}),e||i.queue(function(a){i.css({left:"",top:""}),d(zb).length||i.detach(),a()}),h=e,f.destroyed&&(f=F),j)}}),j.init()},xb=new xb,d.extend(w.prototype,{init:function(a){var b=a.tooltip;return this.options.on?(a.elements.overlay=xb.elem,b.addClass(yb).css("z-index",y.modal_zindex+d(zb).length),a._bind(b,["tooltipshow","tooltiphide"],function(a,c,e){var f=a.originalEvent;if(a.target===b[0])if(f&&"tooltiphide"===a.type&&/mouse(leave|enter)/.test(f.type)&&d(f.relatedTarget).closest(xb.elem[0]).length)try{a.preventDefault()}catch(g){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(a,"tooltipshow"===a.type,e)},this._ns,this),a._bind(b,"tooltipfocus",function(a,c){if(!a.isDefaultPrevented()&&a.target===b[0]){var e=d(zb),f=y.modal_zindex+e.length,g=parseInt(b[0].style.zIndex,10);xb.elem[0].style.zIndex=f-1,e.each(function(){this.style.zIndex>g&&(this.style.zIndex-=1)}),e.filter("."+$).qtip("blur",a.originalEvent),b.addClass($)[0].style.zIndex=f,xb.update(c);try{a.preventDefault()}catch(h){}}},this._ns,this),void a._bind(b,"tooltiphide",function(a){a.target===b[0]&&d(zb).filter(":visible").not(b).last().qtip("focus",a)},this._ns,this)):this},toggle:function(a,b,c){return a&&a.isDefaultPrevented()?this:void xb.toggle(this.qtip,!!b,c)},destroy:function(){this.qtip.tooltip.removeClass(yb),this.qtip._unbind(this.qtip.tooltip,this._ns),xb.toggle(this.qtip,E),delete this.qtip.elements.overlay}}),wb=R.modal=function(a){return new w(a,a.options.show.modal)},wb.sanitize=function(a){a.show&&("object"!=typeof a.show.modal?a.show.modal={on:!!a.show.modal}:"undefined"==typeof a.show.modal.on&&(a.show.modal.on=D))},y.modal_zindex=y.zindex-200,wb.initialize="render",B.modal={"^show.modal.(on|blur)$":function(){this.destroy(),this.init(),this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}},d.extend(D,y.defaults,{show:{modal:{on:E,effect:D,blur:D,stealfocus:D,escape:D}}}),R.viewport=function(c,d,e,f,g,h,i){function j(a,b,c,e,f,g,h,i,j){var k=d[f],s=u[a],t=v[a],w=c===Q,x=s===f?j:s===g?-j:-j/2,y=t===f?i:t===g?-i:-i/2,z=q[f]+r[f]-(n?0:m[f]),A=z-k,B=k+j-(h===I?o:p)-z,C=x-(u.precedance===a||s===u[b]?y:0)-(t===O?i/2:0);return w?(C=(s===f?1:-1)*x,d[f]+=A>0?A:B>0?-B:0,d[f]=Math.max(-m[f]+r[f],k-C,Math.min(Math.max(-m[f]+r[f]+(h===I?o:p),k+C),d[f],"center"===s?k-x:1e9))):(e*=c===P?2:0,A>0&&(s!==f||B>0)?(d[f]-=C+e,l.invert(a,f)):B>0&&(s!==g||A>0)&&(d[f]-=(s===O?-C:C)+e,l.invert(a,g)),d[f]B&&(d[f]=k,l=u.clone())),d[f]-k}var k,l,m,n,o,p,q,r,s=e.target,t=c.elements.tooltip,u=e.my,v=e.at,w=e.adjust,x=w.method.split(" "),y=x[0],z=x[1]||x[0],A=e.viewport,B=e.container,C=(c.cache,{left:0,top:0});return A.jquery&&s[0]!==a&&s[0]!==b.body&&"none"!==w.method?(m=B.offset()||C,n="static"===B.css("position"),k="fixed"===t.css("position"),o=A[0]===a?A.width():A.outerWidth(E),p=A[0]===a?A.height():A.outerHeight(E),q={left:k?0:A.scrollLeft(),top:k?0:A.scrollTop()},r=A.offset()||C,("shift"!==y||"shift"!==z)&&(l=u.clone()),C={left:"none"!==y?j(G,H,y,w.x,L,N,I,f,h):0,top:"none"!==z?j(H,G,z,w.y,K,M,J,g,i):0,my:l}):C},R.polys={polygon:function(a,b){var c,d,e,f={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:E},g=0,h=[],i=1,j=1,k=0,l=0;for(g=a.length;g--;)c=[parseInt(a[--g],10),parseInt(a[g+1],10)],c[0]>f.position.right&&(f.position.right=c[0]),c[0]f.position.bottom&&(f.position.bottom=c[1]),c[1]0&&e>0&&i>0&&j>0;)for(d=Math.floor(d/2),e=Math.floor(e/2),b.x===L?i=d:b.x===N?i=f.width-d:i+=Math.floor(d/2),b.y===K?j=e:b.y===M?j=f.height-e:j+=Math.floor(e/2),g=h.length;g--&&!(h.length<2);)k=h[g][0]-f.position.left,l=h[g][1]-f.position.top,(b.x===L&&k>=i||b.x===N&&i>=k||b.x===O&&(i>k||k>f.width-i)||b.y===K&&l>=j||b.y===M&&j>=l||b.y===O&&(j>l||l>f.height-j))&&h.splice(g,1);f.position={left:h[0][0],top:h[0][1]}}return f},rect:function(a,b,c,d){return{width:Math.abs(c-a),height:Math.abs(d-b),position:{left:Math.min(a,c),top:Math.min(b,d)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(a,b,c,d,e){var f=R.polys._angles[e.abbrev()],g=0===f?0:c*Math.cos(f*Math.PI),h=d*Math.sin(f*Math.PI);return{width:2*c-Math.abs(g),height:2*d-Math.abs(h),position:{left:a+g,top:b+h},adjustable:E}},circle:function(a,b,c,d){return R.polys.ellipse(a,b,c,c,d)}},R.svg=function(a,c,e){for(var f,g,h,i,j,k,l,m,n,o=(d(b),c[0]),p=d(o.ownerSVGElement),q=o.ownerDocument,r=(parseInt(c.css("stroke-width"),10)||0)/2;!o.getBBox;)o=o.parentNode;if(!o.getBBox||!o.parentNode)return E;switch(o.nodeName){case"ellipse":case"circle":m=R.polys.ellipse(o.cx.baseVal.value,o.cy.baseVal.value,(o.rx||o.r).baseVal.value+r,(o.ry||o.r).baseVal.value+r,e);break;case"line":case"polygon":case"polyline":for(l=o.points||[{x:o.x1.baseVal.value,y:o.y1.baseVal.value},{x:o.x2.baseVal.value,y:o.y2.baseVal.value}],m=[],k=-1,i=l.numberOfItems||l.length;++k';d.extend(x.prototype,{_scroll:function(){var b=this.qtip.elements.overlay;b&&(b[0].style.top=d(a).scrollTop()+"px")},init:function(c){var e=c.tooltip;d("select, object").length<1&&(this.bgiframe=c.elements.bgiframe=d(Bb).appendTo(e),c._bind(e,"tooltipmove",this.adjustBGIFrame,this._ns,this)),this.redrawContainer=d("
      ",{id:S+"-rcontainer"}).appendTo(b.body),c.elements.overlay&&c.elements.overlay.addClass("qtipmodal-ie6fix")&&(c._bind(a,["scroll","resize"],this._scroll,this._ns,this),c._bind(e,["tooltipshow"],this._scroll,this._ns,this)),this.redraw()},adjustBGIFrame:function(){var a,b,c=this.qtip.tooltip,d={height:c.outerHeight(E),width:c.outerWidth(E)},e=this.qtip.plugins.tip,f=this.qtip.elements.tip;b=parseInt(c.css("borderLeftWidth"),10)||0,b={left:-b,top:-b},e&&f&&(a="x"===e.corner.precedance?[I,L]:[J,K],b[a[1]]-=f[a[0]]()),this.bgiframe.css(b).css(d)},redraw:function(){if(this.qtip.rendered<1||this.drawing)return this;var a,b,c,d,e=this.qtip.tooltip,f=this.qtip.options.style,g=this.qtip.options.position.container;return this.qtip.drawing=1,f.height&&e.css(J,f.height),f.width?e.css(I,f.width):(e.css(I,"").appendTo(this.redrawContainer),b=e.width(),1>b%2&&(b+=1),c=e.css("maxWidth")||"",d=e.css("minWidth")||"",a=(c+d).indexOf("%")>-1?g.width()/100:0,c=(c.indexOf("%")>-1?a:1)*parseInt(c,10)||b,d=(d.indexOf("%")>-1?a:1)*parseInt(d,10)||0,b=c+d?Math.min(Math.max(b,d),c):b,e.css(I,Math.round(b)).appendTo(g)),this.drawing=0,this},destroy:function(){this.bgiframe&&this.bgiframe.remove(),this.qtip._unbind([a,this.qtip.tooltip],this._ns)}}),Ab=R.ie6=function(a){return 6===db.ie?new x(a):E},Ab.initialize="render",B.ie6={"^content|style$":function(){this.redraw()}}})}(window,document); +//# sourceMappingURL=jquery.qtip.min.js.map +(function(){var a={VERSION:"2.3.3",Result:{SUCCEEDED:1,NOTRANSITION:2,CANCELLED:3,PENDING:4},Error:{INVALID_TRANSITION:100,PENDING_TRANSITION:200,INVALID_CALLBACK:300},WILDCARD:"*",ASYNC:"async",create:function(g,h){var j=(typeof g.initial=="string")?{state:g.initial}:g.initial;var f=g.terminal||g["final"];var e=h||g.target||{};var l=g.events||[];var i=g.callbacks||{};var c={};var k=function(m){var p=(m.from instanceof Array)?m.from:(m.from?[m.from]:[a.WILDCARD]);c[m.name]=c[m.name]||{};for(var o=0;o=0):(this.current===m)};e.can=function(m){return !this.transition&&(c[m].hasOwnProperty(this.current)||c[m].hasOwnProperty(a.WILDCARD))};e.cannot=function(m){return !this.can(m)};e.error=g.error||function(o,s,r,n,m,q,p){throw p||q};e.isFinished=function(){return this.is(f)};if(j&&!j.defer){e[j.event]()}return e},doCallback:function(g,d,c,i,h,b){if(d){try{return d.apply(g,[c,i,h].concat(b))}catch(f){return g.error(c,i,h,b,a.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",f)}}},beforeAnyEvent:function(d,c,f,e,b){return a.doCallback(d,d.onbeforeevent,c,f,e,b)},afterAnyEvent:function(d,c,f,e,b){return a.doCallback(d,d.onafterevent||d.onevent,c,f,e,b)},leaveAnyState:function(d,c,f,e,b){return a.doCallback(d,d.onleavestate,c,f,e,b)},enterAnyState:function(d,c,f,e,b){return a.doCallback(d,d.onenterstate||d.onstate,c,f,e,b)},changeState:function(d,c,f,e,b){return a.doCallback(d,d.onchangestate,c,f,e,b)},beforeThisEvent:function(d,c,f,e,b){return a.doCallback(d,d["onbefore"+c],c,f,e,b)},afterThisEvent:function(d,c,f,e,b){return a.doCallback(d,d["onafter"+c]||d["on"+c],c,f,e,b)},leaveThisState:function(d,c,f,e,b){return a.doCallback(d,d["onleave"+f],c,f,e,b)},enterThisState:function(d,c,f,e,b){return a.doCallback(d,d["onenter"+e]||d["on"+e],c,f,e,b)},beforeEvent:function(d,c,f,e,b){if((false===a.beforeThisEvent(d,c,f,e,b))||(false===a.beforeAnyEvent(d,c,f,e,b))){return false}},afterEvent:function(d,c,f,e,b){a.afterThisEvent(d,c,f,e,b);a.afterAnyEvent(d,c,f,e,b)},leaveState:function(f,e,h,g,d){var c=a.leaveThisState(f,e,h,g,d),b=a.leaveAnyState(f,e,h,g,d);if((false===c)||(false===b)){return false}else{if((a.ASYNC===c)||(a.ASYNC===b)){return a.ASYNC}}},enterState:function(d,c,f,e,b){a.enterThisState(d,c,f,e,b);a.enterAnyState(d,c,f,e,b)},buildEvent:function(b,c){return function(){var h=this.current;var g=c[h]||c[a.WILDCARD]||h;var e=Array.prototype.slice.call(arguments);if(this.transition){return this.error(b,h,g,e,a.Error.PENDING_TRANSITION,"event "+b+" inappropriate because previous transition did not complete")}if(this.cannot(b)){return this.error(b,h,g,e,a.Error.INVALID_TRANSITION,"event "+b+" inappropriate in current state "+this.current)}if(false===a.beforeEvent(this,b,h,g,e)){return a.Result.CANCELLED}if(h===g){a.afterEvent(this,b,h,g,e);return a.Result.NOTRANSITION}var f=this;this.transition=function(){f.transition=null;f.current=g;a.enterState(f,b,h,g,e);a.changeState(f,b,h,g,e);a.afterEvent(f,b,h,g,e);return a.Result.SUCCEEDED};this.transition.cancel=function(){f.transition=null;a.afterEvent(f,b,h,g,e)};var d=a.leaveState(this,b,h,g,e);if(false===d){this.transition=null;return a.Result.CANCELLED}else{if(a.ASYNC===d){return a.Result.PENDING}else{if(this.transition){return this.transition()}}}}}};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=a}exports.StateMachine=a}else{if(typeof define==="function"&&define.amd){define(function(b){return a})}else{if(typeof window!=="undefined"){window.StateMachine=a}else{if(typeof self!=="undefined"){self.StateMachine=a}}}}}()); +// 4.1.7 (2014-11-27) +!function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;ir;r++)if(o=n[r],o&&o.func.call(o.scope,e)===!1&&e.preventDefault(),e.isImmediatePropagationStopped())return}var a=this,s={},l,c,u,d,f;c=o+(+new Date).toString(32),d="onmouseenter"in document.documentElement,u="onfocusin"in document.documentElement,f={mouseenter:"mouseover",mouseleave:"mouseout"},l=1,a.domLoaded=!1,a.events=s,a.bind=function(t,o,p,h){function m(e){i(n(e||_.event),g)}var g,v,y,b,C,x,w,_=window;if(t&&3!==t.nodeType&&8!==t.nodeType){for(t[c]?g=t[c]:(g=l++,t[c]=g,s[g]={}),h=h||t,o=o.split(" "),y=o.length;y--;)b=o[y],x=m,C=w=!1,"DOMContentLoaded"===b&&(b="ready"),a.domLoaded&&"ready"===b&&"complete"==t.readyState?p.call(h,n({type:b})):(d||(C=f[b],C&&(x=function(e){var t,r;if(t=e.currentTarget,r=e.relatedTarget,r&&t.contains)r=t.contains(r);else for(;r&&r!==t;)r=r.parentNode;r||(e=n(e||_.event),e.type="mouseout"===e.type?"mouseleave":"mouseenter",e.target=t,i(e,g))})),u||"focusin"!==b&&"focusout"!==b||(w=!0,C="focusin"===b?"focus":"blur",x=function(e){e=n(e||_.event),e.type="focus"===e.type?"focusin":"focusout",i(e,g)}),v=s[g][b],v?"ready"===b&&a.domLoaded?p({type:b}):v.push({func:p,scope:h}):(s[g][b]=v=[{func:p,scope:h}],v.fakeName=C,v.capture=w,v.nativeHandler=x,"ready"===b?r(t,x,a):e(t,C||b,x,w)));return t=v=0,p}},a.unbind=function(e,n,r){var i,o,l,u,d,f;if(!e||3===e.nodeType||8===e.nodeType)return a;if(i=e[c]){if(f=s[i],n){for(n=n.split(" "),l=n.length;l--;)if(d=n[l],o=f[d]){if(r)for(u=o.length;u--;)if(o[u].func===r){var p=o.nativeHandler,h=o.fakeName,m=o.capture;o=o.slice(0,u).concat(o.slice(u+1)),o.nativeHandler=p,o.fakeName=h,o.capture=m,f[d]=o}r&&0!==o.length||(delete f[d],t(e,o.fakeName||d,o.nativeHandler,o.capture))}}else{for(d in f)o=f[d],t(e,o.fakeName||d,o.nativeHandler,o.capture);f={}}for(d in f)return a;delete s[i];try{delete e[c]}catch(g){e[c]=null}}return a},a.fire=function(e,t,r){var o;if(!e||3===e.nodeType||8===e.nodeType)return a;r=n(null,r),r.type=t,r.target=e;do o=e[c],o&&i(r,o),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow;while(e&&!r.isPropagationStopped());return a},a.clean=function(e){var t,n,r=a.unbind;if(!e||3===e.nodeType||8===e.nodeType)return a;if(e[c]&&r(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName)for(r(e),n=e.getElementsByTagName("*"),t=n.length;t--;)e=n[t],e[c]&&r(e);return a},a.destroy=function(){s={}},a.cancel=function(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}}var o="mce-data-",a=/^(?:mouse|contextmenu)|click/,s={keyLocation:1,layerX:1,layerY:1,returnValue:1};return i.Event=new i,i.Event.bind(window,"ready",function(){}),i}),r(c,[],function(){function e(e,t,n,r){var i,o,a,s,l,c,d,p,h,m;if((t?t.ownerDocument||t:z)!==D&&B(t),t=t||D,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(H&&!r){if(i=vt.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&I(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return Z.apply(n,t.getElementsByTagName(e)),n;if((a=i[3])&&x.getElementsByClassName)return Z.apply(n,t.getElementsByClassName(a)),n}if(x.qsa&&(!M||!M.test(e))){if(p=d=F,h=t,m=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){for(c=N(e),(d=t.getAttribute("id"))?p=d.replace(bt,"\\$&"):t.setAttribute("id",p),p="[id='"+p+"'] ",l=c.length;l--;)c[l]=p+f(c[l]);h=yt.test(e)&&u(t.parentNode)||t,m=c.join(",")}if(m)try{return Z.apply(n,h.querySelectorAll(m)),n}catch(g){}finally{d||t.removeAttribute("id")}}}return S(e.replace(st,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[F]=!0,e}function i(e){var t=D.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=e.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||K)-(~e.sourceIndex||K);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function l(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function c(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function u(e){return e&&typeof e.getElementsByTagName!==Y&&e}function d(){}function f(e){for(var t=0,n=e.length,r="";n>t;t++)r+=e[t].value;return r}function p(e,t,n){var r=t.dir,i=n&&"parentNode"===r,o=V++;return t.first?function(t,n,o){for(;t=t[r];)if(1===t.nodeType||i)return e(t,n,o)}:function(t,n,a){var s,l,c=[W,o];if(a){for(;t=t[r];)if((1===t.nodeType||i)&&e(t,n,a))return!0}else for(;t=t[r];)if(1===t.nodeType||i){if(l=t[F]||(t[F]={}),(s=l[r])&&s[0]===W&&s[1]===o)return c[2]=s[2];if(l[r]=c,c[2]=e(t,n,a))return!0}}}function h(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function m(t,n,r){for(var i=0,o=n.length;o>i;i++)e(t,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,l=e.length,c=null!=t;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),c&&t.push(s));return a}function v(e,t,n,i,o,a){return i&&!i[F]&&(i=v(i)),o&&!o[F]&&(o=v(o,a)),r(function(r,a,s,l){var c,u,d,f=[],p=[],h=a.length,v=r||m(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?v:g(v,f,e,s,l),b=n?o||(r?e:h||i)?[]:a:y;if(n&&n(y,b,s,l),i)for(c=g(b,p),i(c,[],s,l),u=c.length;u--;)(d=c[u])&&(b[p[u]]=!(y[p[u]]=d));if(r){if(o||e){if(o){for(c=[],u=b.length;u--;)(d=b[u])&&c.push(y[u]=d);o(null,b=[],c,l)}for(u=b.length;u--;)(d=b[u])&&(c=o?tt.call(r,d):f[u])>-1&&(r[c]=!(a[c]=d))}}else b=g(b===a?b.splice(h,b.length):b),o?o(null,a,b,l):Z.apply(a,b)})}function y(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,l=p(function(e){return e===t},a,!0),c=p(function(e){return tt.call(t,e)>-1},a,!0),u=[function(e,n,r){return!o&&(r||n!==T)||((t=n).nodeType?l(e,n,r):c(e,n,r))}];i>s;s++)if(n=w.relative[e[s].type])u=[p(h(u),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[F]){for(r=++s;i>r&&!w.relative[e[r].type];r++);return v(s>1&&h(u),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(st,"$1"),n,r>s&&y(e.slice(s,r)),i>r&&y(e=e.slice(r)),i>r&&f(e))}u.push(n)}return h(u)}function b(t,n){var i=n.length>0,o=t.length>0,a=function(r,a,s,l,c){var u,d,f,p=0,h="0",m=r&&[],v=[],y=T,b=r||o&&w.find.TAG("*",c),C=W+=null==y?1:Math.random()||.1,x=b.length;for(c&&(T=a!==D&&a);h!==x&&null!=(u=b[h]);h++){if(o&&u){for(d=0;f=t[d++];)if(f(u,a,s)){l.push(u);break}c&&(W=C)}i&&((u=!f&&u)&&p--,r&&m.push(u))}if(p+=h,i&&h!==p){for(d=0;f=n[d++];)f(m,v,a,s);if(r){if(p>0)for(;h--;)m[h]||v[h]||(v[h]=J.call(l));v=g(v)}Z.apply(l,v),c&&!r&&v.length>0&&p+n.length>1&&e.uniqueSort(l)}return c&&(W=C,T=y),m};return i?r(a):a}var C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F="sizzle"+-new Date,z=window.document,W=0,V=0,U=n(),$=n(),q=n(),j=function(e,t){return e===t&&(A=!0),0},Y=typeof t,K=1<<31,G={}.hasOwnProperty,X=[],J=X.pop,Q=X.push,Z=X.push,et=X.slice,tt=X.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},nt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",rt="[\\x20\\t\\r\\n\\f]",it="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",ot="\\["+rt+"*("+it+")(?:"+rt+"*([*^$|!~]?=)"+rt+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+it+"))|)"+rt+"*\\]",at=":("+it+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ot+")*)|.*)\\)|)",st=new RegExp("^"+rt+"+|((?:^|[^\\\\])(?:\\\\.)*)"+rt+"+$","g"),lt=new RegExp("^"+rt+"*,"+rt+"*"),ct=new RegExp("^"+rt+"*([>+~]|"+rt+")"+rt+"*"),ut=new RegExp("="+rt+"*([^\\]'\"]*?)"+rt+"*\\]","g"),dt=new RegExp(at),ft=new RegExp("^"+it+"$"),pt={ID:new RegExp("^#("+it+")"),CLASS:new RegExp("^\\.("+it+")"),TAG:new RegExp("^("+it+"|[*])"),ATTR:new RegExp("^"+ot),PSEUDO:new RegExp("^"+at),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+rt+"*(even|odd|(([+-]|)(\\d*)n|)"+rt+"*(?:([+-]|)"+rt+"*(\\d+)|))"+rt+"*\\)|)","i"),bool:new RegExp("^(?:"+nt+")$","i"),needsContext:new RegExp("^"+rt+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+rt+"*((?:-\\d)?\\d*)"+rt+"*\\)|)(?=[^-]|$)","i")},ht=/^(?:input|select|textarea|button)$/i,mt=/^h\d$/i,gt=/^[^{]+\{\s*\[native \w/,vt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,yt=/[+~]/,bt=/'|\\/g,Ct=new RegExp("\\\\([\\da-f]{1,6}"+rt+"?|("+rt+")|.)","ig"),xt=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)};try{Z.apply(X=et.call(z.childNodes),z.childNodes),X[z.childNodes.length].nodeType}catch(wt){Z={apply:X.length?function(e,t){Q.apply(e,et.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}x=e.support={},E=e.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},B=e.setDocument=function(e){var t,n=e?e.ownerDocument||e:z,r=n.defaultView;return n!==D&&9===n.nodeType&&n.documentElement?(D=n,L=n.documentElement,H=!E(n),r&&r!==r.top&&(r.addEventListener?r.addEventListener("unload",function(){B()},!1):r.attachEvent&&r.attachEvent("onunload",function(){B()})),x.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),x.getElementsByTagName=i(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),x.getElementsByClassName=gt.test(n.getElementsByClassName),x.getById=i(function(e){return L.appendChild(e).id=F,!n.getElementsByName||!n.getElementsByName(F).length}),x.getById?(w.find.ID=function(e,t){if(typeof t.getElementById!==Y&&H){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},w.filter.ID=function(e){var t=e.replace(Ct,xt);return function(e){return e.getAttribute("id")===t}}):(delete w.find.ID,w.filter.ID=function(e){var t=e.replace(Ct,xt);return function(e){var n=typeof e.getAttributeNode!==Y&&e.getAttributeNode("id");return n&&n.value===t}}),w.find.TAG=x.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==Y?t.getElementsByTagName(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=x.getElementsByClassName&&function(e,t){return H?t.getElementsByClassName(e):void 0},P=[],M=[],(x.qsa=gt.test(n.querySelectorAll))&&(i(function(e){e.innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&M.push("[*^$]="+rt+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||M.push("\\["+rt+"*(?:value|"+nt+")"),e.querySelectorAll(":checked").length||M.push(":checked")}),i(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&M.push("name"+rt+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||M.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),M.push(",.*:")})),(x.matchesSelector=gt.test(O=L.matches||L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&i(function(e){x.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),P.push("!=",at)}),M=M.length&&new RegExp(M.join("|")),P=P.length&&new RegExp(P.join("|")),t=gt.test(L.compareDocumentPosition),I=t||gt.test(L.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return A=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r?r:(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&r||!x.sortDetached&&t.compareDocumentPosition(e)===r?e===n||e.ownerDocument===z&&I(z,e)?-1:t===n||t.ownerDocument===z&&I(z,t)?1:R?tt.call(R,e)-tt.call(R,t):0:4&r?-1:1)}:function(e,t){if(e===t)return A=!0,0;var r,i=0,o=e.parentNode,s=t.parentNode,l=[e],c=[t];if(!o||!s)return e===n?-1:t===n?1:o?-1:s?1:R?tt.call(R,e)-tt.call(R,t):0;if(o===s)return a(e,t);for(r=e;r=r.parentNode;)l.unshift(r);for(r=t;r=r.parentNode;)c.unshift(r);for(;l[i]===c[i];)i++;return i?a(l[i],c[i]):l[i]===z?-1:c[i]===z?1:0},n):D},e.matches=function(t,n){return e(t,null,null,n)},e.matchesSelector=function(t,n){if((t.ownerDocument||t)!==D&&B(t),n=n.replace(ut,"='$1']"),!(!x.matchesSelector||!H||P&&P.test(n)||M&&M.test(n)))try{var r=O.call(t,n);if(r||x.disconnectedMatch||t.document&&11!==t.document.nodeType)return r}catch(i){}return e(n,D,null,[t]).length>0},e.contains=function(e,t){return(e.ownerDocument||e)!==D&&B(e),I(e,t)},e.attr=function(e,n){(e.ownerDocument||e)!==D&&B(e);var r=w.attrHandle[n.toLowerCase()],i=r&&G.call(w.attrHandle,n.toLowerCase())?r(e,n,!H):t;return i!==t?i:x.attributes||!H?e.getAttribute(n):(i=e.getAttributeNode(n))&&i.specified?i.value:null},e.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},e.uniqueSort=function(e){var t,n=[],r=0,i=0;if(A=!x.detectDuplicates,R=!x.sortStable&&e.slice(0),e.sort(j),A){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return R=null,e},_=e.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=_(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=_(t);return n},w=e.selectors={cacheLength:50,createPseudo:r,match:pt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Ct,xt),e[3]=(e[3]||e[4]||e[5]||"").replace(Ct,xt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pt.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&dt.test(n)&&(t=N(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Ct,xt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=U[e+" "];return t||(t=new RegExp("(^|"+rt+")"+e+"("+rt+"|$)"))&&U(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==Y&&e.getAttribute("class")||"")})},ATTR:function(t,n,r){return function(i){var o=e.attr(i,t);return null==o?"!="===n:n?(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o+" ").indexOf(r)>-1:"|="===n?o===r||o.slice(0,r.length+1)===r+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var c,u,d,f,p,h,m=o!==a?"nextSibling":"previousSibling",g=t.parentNode,v=s&&t.nodeName.toLowerCase(),y=!l&&!s;if(g){if(o){for(;m;){for(d=t;d=d[m];)if(s?d.nodeName.toLowerCase()===v:1===d.nodeType)return!1;h=m="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?g.firstChild:g.lastChild],a&&y){for(u=g[F]||(g[F]={}),c=u[e]||[],p=c[0]===W&&c[1],f=c[0]===W&&c[2],d=p&&g.childNodes[p];d=++p&&d&&d[m]||(f=p=0)||h.pop();)if(1===d.nodeType&&++f&&d===t){u[e]=[W,p,f];break}}else if(y&&(c=(t[F]||(t[F]={}))[e])&&c[0]===W)f=c[1];else for(;(d=++p&&d&&d[m]||(f=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==v:1!==d.nodeType)||!++f||(y&&((d[F]||(d[F]={}))[e]=[W,f]),d!==t)););return f-=i,f===r||f%r===0&&f/r>=0}}},PSEUDO:function(t,n){var i,o=w.pseudos[t]||w.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return o[F]?o(n):o.length>1?(i=[t,t,"",n],w.setFilters.hasOwnProperty(t.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=tt.call(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(st,"$1"));return i[F]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),!n.pop()}}),has:r(function(t){return function(n){return e(t,n).length>0}}),contains:r(function(e){return e=e.replace(Ct,xt),function(t){return(t.textContent||t.innerText||_(t)).indexOf(e)>-1}}),lang:r(function(t){return ft.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(Ct,xt).toLowerCase(),function(e){var n;do if(n=H?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return n=n.toLowerCase(),n===t||0===n.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=window.location&&window.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===L},focus:function(e){return e===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return mt.test(e.nodeName)},input:function(e){return ht.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:c(function(){return[0]}),last:c(function(e,t){return[t-1]}),eq:c(function(e,t,n){return[0>n?n+t:n]}),even:c(function(e,t){for(var n=0;t>n;n+=2)e.push(n);return e}),odd:c(function(e,t){for(var n=1;t>n;n+=2)e.push(n);return e}),lt:c(function(e,t,n){for(var r=0>n?n+t:n;--r>=0;)e.push(r);return e}),gt:c(function(e,t,n){for(var r=0>n?n+t:n;++r2&&"ID"===(a=o[0]).type&&x.getById&&9===t.nodeType&&H&&w.relative[o[1].type]){if(t=(w.find.ID(a.matches[0].replace(Ct,xt),t)||[])[0],!t)return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=pt.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((l=w.find[s])&&(r=l(a.matches[0].replace(Ct,xt),yt.test(o[0].type)&&u(t.parentNode)||t))){if(o.splice(i,1),e=r.length&&f(o),!e)return Z.apply(n,r),n;break}}return(c||k(e,d))(r,t,!H,n,yt.test(e)&&u(t.parentNode)||t),n},x.sortStable=F.split("").sort(j).join("")===F,x.detectDuplicates=!!A,B(),x.sortDetached=i(function(e){return 1&e.compareDocumentPosition(D.createElement("div"))}),i(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){return n?void 0:e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),x.attributes&&i(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){return n||"input"!==e.nodeName.toLowerCase()?void 0:e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(nt,function(e,t,n){var r;return n?void 0:e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),e}),r(u,[],function(){var e=navigator,t=e.userAgent,n,r,i,o,a,s,l;n=window.opera&&window.opera.buildNumber,r=/WebKit/.test(t),i=!r&&!n&&/MSIE/gi.test(t)&&/Explorer/gi.test(e.appName),i=i&&/MSIE (\w+)\./.exec(t)[1],o=-1==t.indexOf("Trident/")||-1==t.indexOf("rv:")&&-1==e.appName.indexOf("Netscape")?!1:11,i=i||o,a=!r&&!o&&/Gecko/.test(t),s=-1!=t.indexOf("Mac"),l=/(iPad|iPhone)/.test(t);var c=!l||t.match(/AppleWebKit\/(\d*)/)[1]>=534;return{opera:n,webkit:r,ie:i,gecko:a,mac:s,iOS:l,contentEditable:c,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:8!=i,range:window.getSelection&&"Range"in window,documentMode:i?document.documentMode||7:10}}),r(d,[u],function(e){function n(e){return null===e||e===t?"":(""+e).replace(v,"")}function r(e,n){return n?"array"==n&&y(e)?!0:typeof e==n:e!==t}function i(e){var t=e,n,r;if(!y(e))for(t=[],n=0,r=e.length;r>n;n++)t[n]=e[n];return t}function o(e,t,n){var r;for(e=e||[],t=t||",","string"==typeof e&&(e=e.split(t)),n=n||{},r=e.length;r--;)n[e[r]]={};return n}function a(e,n,r){var i,o;if(!e)return 0;if(r=r||e,e.length!==t){for(i=0,o=e.length;o>i;i++)if(n.call(r,e[i],i,e)===!1)return 0}else for(i in e)if(e.hasOwnProperty(i)&&n.call(r,e[i],i,e)===!1)return 0;return 1}function s(e,t){var n=[];return a(e,function(e){n.push(t(e))}),n}function l(e,t){var n=[];return a(e,function(e){(!t||t(e))&&n.push(e)}),n}function c(e,t,n){var r=this,i,o,a,s,l,c=0;if(e=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(e),a=e[3].match(/(^|\.)(\w+)$/i)[2],o=r.createNS(e[3].replace(/\.\w+$/,""),n),!o[a]){if("static"==e[2])return o[a]=t,void(this.onCreate&&this.onCreate(e[2],e[3],o[a]));t[a]||(t[a]=function(){},c=1),o[a]=t[a],r.extend(o[a].prototype,t),e[5]&&(i=r.resolve(e[5]).prototype,s=e[5].match(/\.(\w+)$/i)[1],l=o[a],o[a]=c?function(){return i[s].apply(this,arguments)}:function(){return this.parent=i[s],l.apply(this,arguments)},o[a].prototype[a]=o[a],r.each(i,function(e,t){o[a].prototype[t]=i[t]}),r.each(t,function(e,t){i[t]?o[a].prototype[t]=function(){return this.parent=i[t],e.apply(this,arguments)}:t!=a&&(o[a].prototype[t]=e)})),r.each(t["static"],function(e,t){o[a][t]=e})}}function u(e,t){var n,r;if(e)for(n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}function d(e,n){var r,i,o,a=arguments,s;for(r=1,i=a.length;i>r;r++){n=a[r];for(o in n)n.hasOwnProperty(o)&&(s=n[o],s!==t&&(e[o]=s))}return e}function f(e,t,n,r){r=r||this,e&&(n&&(e=e[n]),a(e,function(e,i){return t.call(r,e,i,n)===!1?!1:void f(e,t,n,r)}))}function p(e,t){var n,r;for(t=t||window,e=e.split("."),n=0;nn&&(t=t[e[n]],t);n++);return t}function m(e,t){return!e||r(e,"array")?e:s(e.split(t||","),n)}function g(t){var n=e.cacheSuffix;return n&&(t+=(-1===t.indexOf("?")?"?":"&")+n),t}var v=/^\s*|\s*$/g,y=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};return{trim:n,isArray:y,is:r,toArray:i,makeMap:o,each:a,map:s,grep:l,inArray:u,extend:d,create:c,walk:f,createNS:p,resolve:h,explode:m,_addCacheSuffix:g}}),r(f,[l,c,d,u],function(e,n,r,i){function o(e){return"undefined"!=typeof e}function a(e){return"string"==typeof e}function s(e){return e&&e==e.window}function l(e,t){var n,r,i;for(t=t||w,i=t.createElement("div"),n=t.createDocumentFragment(),i.innerHTML=e;r=i.firstChild;)n.appendChild(r);return n}function c(e,t,n,r){var i;if(a(t))t=l(t,v(e[0]));else if(t.length&&!t.nodeType){if(t=f.makeArray(t),r)for(i=t.length-1;i>=0;i--)c(e,t[i],n,r);else for(i=0;ii&&(a=e[i],t.call(a,i,a)!==!1);i++);return e}function g(e,t){var n=[];return m(e,function(e,r){t(r,e)&&n.push(r)}),n}function v(e){return e?9==e.nodeType?e:e.ownerDocument:w}function y(e,n,r){var i=[],o=e[n];for("string"!=typeof r&&r instanceof f&&(r=r[0]);o&&9!==o.nodeType;){if(r!==t){if(o===r)break;if("string"==typeof r&&f(o).is(r))break}1===o.nodeType&&i.push(o),o=o[n]}return i}function b(e,n,r,i){var o=[];for(i instanceof f&&(i=i[0]);e;e=e[n])if(!r||e.nodeType===r){if(i!==t){if(e===i)break;if("string"==typeof i&&f(e).is(i))break}o.push(e)}return o}function C(e,t,n){for(e=e[t];e;e=e[t])if(e.nodeType==n)return e;return null}function x(e,t,n){m(n,function(n,r){e[n]=e[n]||{},e[n][t]=r})}var w=document,_=Array.prototype.push,E=Array.prototype.slice,N=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,k=e.Event,S,T=r.makeMap("fillOpacity fontWeight lineHeight opacity orphans widows zIndex zoom"," "),R=r.makeMap("checked compact declare defer disabled ismap multiple nohref noshade nowrap readonly selected"," "),A={"for":"htmlFor","class":"className",readonly:"readOnly"},B={"float":"cssFloat"},D={},L={},H=/^\s*|\s*$/g;return f.fn=f.prototype={constructor:f,selector:"",context:null,length:0,init:function(e,t){var n=this,r,i;if(!e)return n;if(e.nodeType)return n.context=n[0]=e,n.length=1,n;if(t&&t.nodeType)n.context=t;else{if(t)return f(e).attr(t);n.context=t=document}if(a(e)){if(n.selector=e,r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!r)return f(t).find(e);if(r[1])for(i=l(e,v(t)).firstChild;i;)_.call(n,i),i=i.nextSibling;else{if(i=v(t).getElementById(r[2]),!i)return n;if(i.id!==r[2])return n.find(e);n.length=1,n[0]=i}}else this.add(e,!1);return n},toArray:function(){return r.toArray(this)},add:function(e,t){var n=this,r,i;if(a(e))return n.add(f(e));if(t!==!1)for(r=f.unique(n.toArray().concat(f.makeArray(e))),n.length=r.length,i=0;it;t++)f.find(e,this[t],r);return f(r)},filter:function(e){return f("function"==typeof e?g(this.toArray(),function(t,n){return e(n,t)}):f.filter(e,this.toArray()))},closest:function(e){var t=[];return e instanceof f&&(e=e[0]),this.each(function(n,r){for(;r;){if("string"==typeof e&&f(r).is(e)){t.push(r);break}if(r==e){t.push(r);break}r=r.parentNode}}),f(t)},offset:function(e){var t,n,r,i=0,o=0,a;return e?this.css(e):(t=this[0],t&&(n=t.ownerDocument,r=n.documentElement,t.getBoundingClientRect&&(a=t.getBoundingClientRect(),i=a.left+(r.scrollLeft||n.body.scrollLeft)-r.clientLeft,o=a.top+(r.scrollTop||n.body.scrollTop)-r.clientTop)),{left:i,top:o})},push:_,sort:[].sort,splice:[].splice},r.extend(f,{extend:r.extend,makeArray:function(e){return s(e)||e.nodeType?[e]:r.toArray(e)},inArray:p,isArray:r.isArray,each:m,trim:h,grep:g,find:n,expr:n.selectors,unique:n.uniqueSort,text:n.getText,contains:n.contains,filter:function(e,t,n){var r=t.length;for(n&&(e=":not("+e+")");r--;)1!=t[r].nodeType&&t.splice(r,1);return t=1===t.length?f.find.matchesSelector(t[0],e)?[t[0]]:[]:f.find.matches(e,t)}}),m({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return y(e,"parentNode")},next:function(e){return C(e,"nextSibling",1)},prev:function(e){return C(e,"previousSibling",1)},children:function(e){return b(e.firstChild,"nextSibling",1)},contents:function(e){return r.toArray(("iframe"===e.nodeName?e.contentDocument||e.contentWindow.document:e).childNodes)}},function(e,t){f.fn[e]=function(n){var r=this,i=[];return r.each(function(){var e=t.call(i,this,n,i);e&&(f.isArray(e)?i.push.apply(i,e):i.push(e))}),this.length>1&&(i=f.unique(i),0===e.indexOf("parents")&&(i=i.reverse())),i=f(i),n?i.filter(n):i}}),m({parentsUntil:function(e,t){return y(e,"parentNode",t)},nextUntil:function(e,t){return b(e,"nextSibling",1,t).slice(1)},prevUntil:function(e,t){return b(e,"previousSibling",1,t).slice(1)}},function(e,t){f.fn[e]=function(n,r){var i=this,o=[];return i.each(function(){var e=t.call(o,this,n,o);e&&(f.isArray(e)?o.push.apply(o,e):o.push(e))}),this.length>1&&(o=f.unique(o),(0===e.indexOf("parents")||"prevUntil"===e)&&(o=o.reverse())),o=f(o),r?o.filter(r):o}}),f.fn.is=function(e){return!!e&&this.filter(e).length>0},f.fn.init.prototype=f.fn,f.overrideDefaults=function(e){function t(r,i){return n=n||e(),0===arguments.length&&(r=n.element),i||(i=n.context),new t.fn.init(r,i)}var n;return f.extend(t,this),t},i.ie&&i.ie<8&&(x(D,"get",{maxlength:function(e){var t=e.maxLength;return 2147483647===t?S:t},size:function(e){var t=e.size;return 20===t?S:t},"class":function(e){return e.className},style:function(e){var t=e.style.cssText;return 0===t.length?S:t}}),x(D,"set",{"class":function(e,t){e.className=t},style:function(e,t){e.style.cssText=t}})),i.ie&&i.ie<9&&(B["float"]="styleFloat",x(L,"set",{opacity:function(e,t){var n=e.style;null===t||""===t?n.removeAttribute("filter"):(n.zoom=1,n.filter="alpha(opacity="+100*t+")")}})),f.attrHooks=D,f.cssHooks=L,f}),r(p,[],function(){return function(e,t){function n(e,t,n,r){function i(e){return e=parseInt(e,10).toString(16),e.length>1?e:"0"+e}return"#"+i(t)+i(n)+i(r)}var r=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,i=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,o=/\s*([^:]+):\s*([^;]+);?/g,a=/\s+$/,s,l,c={},u,d,f,p="\ufeff";for(e=e||{},t&&(d=t.getValidStyles(),f=t.getInvalidStyles()),u=("\\\" \\' \\; \\: ; : "+p).split(" "),l=0;l-1&&n||(m[e+t]=-1==l?s[0]:s.join(" "),delete m[e+"-top"+t],delete m[e+"-right"+t],delete m[e+"-bottom"+t],delete m[e+"-left"+t])}}function u(e){var t=m[e],n;if(t){for(t=t.split(" "),n=t.length;n--;)if(t[n]!==t[0])return!1;return m[e]=t[0],!0}}function d(e,t,n,r){u(t)&&u(n)&&u(r)&&(m[e]=m[t]+" "+m[n]+" "+m[r],delete m[t],delete m[n],delete m[r])}function f(e){return b=!0,c[e]}function p(e,t){return b&&(e=e.replace(/\uFEFF[0-9]/g,function(e){return c[e]})),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e}function h(t,n,r,i,o,a){if(o=o||a)return o=p(o),"'"+o.replace(/\'/g,"\\'")+"'";if(n=p(n||r||i),!e.allow_script_urls){var s=n.replace(/[\s\r\n]+/,"");if(/(java|vb)script:/i.test(s))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(s))return""}return C&&(n=C.call(x,n,"style")),"url('"+n.replace(/\'/g,"\\'")+"')"}var m={},g,v,y,b,C=e.url_converter,x=e.url_converter_scope||this;if(t){for(t=t.replace(/[\u0000-\u001F]/g,""),t=t.replace(/\\[\"\';:\uFEFF]/g,f).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(e){return e.replace(/[;:]/g,f)});g=o.exec(t);){if(v=g[1].replace(a,"").toLowerCase(),y=g[2].replace(a,""),y=y.replace(/\\[0-9a-f]+/g,function(e){return String.fromCharCode(parseInt(e.substr(1),16))}),v&&y.length>0){if(!e.allow_script_urls&&("behavior"==v||/expression\s*\(|\/\*|\*\//.test(y)))continue;"font-weight"===v&&"700"===y?y="bold":("color"===v||"background-color"===v)&&(y=y.toLowerCase()),y=y.replace(r,n),y=y.replace(i,h),m[v]=b?p(y,!0):y}o.lastIndex=g.index+g[0].length}s("border","",!0),s("border","-width"),s("border","-color"),s("border","-style"),s("padding",""),s("margin",""),d("border","border-width","border-style","border-color"),"medium none"===m.border&&delete m.border,"none"===m["border-image"]&&delete m["border-image"]}return m},serialize:function(e,t){function n(t){var n,r,o,a;if(n=d[t])for(r=0,o=n.length;o>r;r++)t=n[r],a=e[t],a!==s&&a.length>0&&(i+=(i.length>0?" ":"")+t+": "+a+";")}function r(e,t){var n;return n=f["*"],n&&n[e]?!1:(n=f[t],n&&n[e]?!1:!0)}var i="",o,a;if(t&&d)n("*"),n(t);else for(o in e)a=e[o],a!==s&&a.length>0&&(!f||r(o,t))&&(i+=(i.length>0?" ":"")+o+": "+a+";");return i}}}}),r(h,[],function(){return function(e,t){function n(e,n,r,i){var o,a;if(e){if(!i&&e[n])return e[n];if(e!=t){if(o=e[r])return o;for(a=e.parentNode;a&&a!=t;a=a.parentNode)if(o=a[r])return o}}}var r=e;this.current=function(){return r},this.next=function(e){return r=n(r,"firstChild","nextSibling",e)},this.prev=function(e){return r=n(r,"lastChild","previousSibling",e)}}}),r(m,[d],function(e){function t(n){function r(){return M.createDocumentFragment()}function i(e,t){_(F,e,t)}function o(e,t){_(z,e,t)}function a(e){i(e.parentNode,j(e))}function s(e){i(e.parentNode,j(e)+1)}function l(e){o(e.parentNode,j(e))}function c(e){o(e.parentNode,j(e)+1)}function u(e){e?(H[U]=H[V],H[$]=H[W]):(H[V]=H[U],H[W]=H[$]),H.collapsed=F}function d(e){a(e),c(e)}function f(e){i(e,0),o(e,1===e.nodeType?e.childNodes.length:e.nodeValue.length)}function p(e,t){var n=H[V],r=H[W],i=H[U],o=H[$],a=t.startContainer,s=t.startOffset,l=t.endContainer,c=t.endOffset;return 0===e?w(n,r,a,s):1===e?w(i,o,a,s):2===e?w(i,o,l,c):3===e?w(n,r,l,c):void 0}function h(){E(I)}function m(){return E(P)}function g(){return E(O)}function v(e){var t=this[V],r=this[W],i,o;3!==t.nodeType&&4!==t.nodeType||!t.nodeValue?(t.childNodes.length>0&&(o=t.childNodes[r]),o?t.insertBefore(e,o):3==t.nodeType?n.insertAfter(e,t):t.appendChild(e)):r?r>=t.nodeValue.length?n.insertAfter(e,t):(i=t.splitText(r),t.parentNode.insertBefore(e,i)):t.parentNode.insertBefore(e,t)}function y(e){var t=H.extractContents();H.insertNode(e),e.appendChild(t),H.selectNode(e)}function b(){return q(new t(n),{startContainer:H[V],startOffset:H[W],endContainer:H[U],endOffset:H[$],collapsed:H.collapsed,commonAncestorContainer:H.commonAncestorContainer})}function C(e,t){var n;if(3==e.nodeType)return e;if(0>t)return e;for(n=e.firstChild;n&&t>0;)--t,n=n.nextSibling;return n?n:e}function x(){return H[V]==H[U]&&H[W]==H[$]}function w(e,t,r,i){var o,a,s,l,c,u;if(e==r)return t==i?0:i>t?-1:1;for(o=r;o&&o.parentNode!=e;)o=o.parentNode;if(o){for(a=0,s=e.firstChild;s!=o&&t>a;)a++,s=s.nextSibling;return a>=t?-1:1}for(o=e;o&&o.parentNode!=r;)o=o.parentNode;if(o){for(a=0,s=r.firstChild;s!=o&&i>a;)a++,s=s.nextSibling;return i>a?-1:1}for(l=n.findCommonAncestor(e,r),c=e;c&&c.parentNode!=l;)c=c.parentNode;for(c||(c=l),u=r;u&&u.parentNode!=l;)u=u.parentNode;if(u||(u=l),c==u)return 0;for(s=l.firstChild;s;){if(s==c)return-1;if(s==u)return 1;s=s.nextSibling}}function _(e,t,r){var i,o;for(e?(H[V]=t,H[W]=r):(H[U]=t,H[$]=r),i=H[U];i.parentNode;)i=i.parentNode;for(o=H[V];o.parentNode;)o=o.parentNode;o==i?w(H[V],H[W],H[U],H[$])>0&&H.collapse(e):H.collapse(e),H.collapsed=x(),H.commonAncestorContainer=n.findCommonAncestor(H[V],H[U])}function E(e){var t,n=0,r=0,i,o,a,s,l,c;if(H[V]==H[U])return N(e);for(t=H[U],i=t.parentNode;i;t=i,i=i.parentNode){if(i==H[V])return k(t,e);++n}for(t=H[V],i=t.parentNode;i;t=i,i=i.parentNode){if(i==H[U])return S(t,e);++r}for(o=r-n,a=H[V];o>0;)a=a.parentNode,o--;for(s=H[U];0>o;)s=s.parentNode,o++;for(l=a.parentNode,c=s.parentNode;l!=c;l=l.parentNode,c=c.parentNode)a=l,s=c;return T(a,s,e)}function N(e){var t,n,i,o,a,s,l,c,u;if(e!=I&&(t=r()),H[W]==H[$])return t;if(3==H[V].nodeType){if(n=H[V].nodeValue,i=n.substring(H[W],H[$]),e!=O&&(o=H[V],c=H[W],u=H[$]-H[W],0===c&&u>=o.nodeValue.length-1?o.parentNode.removeChild(o):o.deleteData(c,u),H.collapse(F)),e==I)return;return i.length>0&&t.appendChild(M.createTextNode(i)),t}for(o=C(H[V],H[W]),a=H[$]-H[W];o&&a>0;)s=o.nextSibling,l=D(o,e),t&&t.appendChild(l),--a,o=s;return e!=O&&H.collapse(F),t}function k(e,t){var n,i,o,a,s,l;if(t!=I&&(n=r()),i=R(e,t),n&&n.appendChild(i),o=j(e),a=o-H[W],0>=a)return t!=O&&(H.setEndBefore(e),H.collapse(z)),n;for(i=e.previousSibling;a>0;)s=i.previousSibling,l=D(i,t),n&&n.insertBefore(l,n.firstChild),--a,i=s;return t!=O&&(H.setEndBefore(e),H.collapse(z)),n}function S(e,t){var n,i,o,a,s,l;for(t!=I&&(n=r()),o=A(e,t),n&&n.appendChild(o),i=j(e),++i,a=H[$]-i,o=e.nextSibling;o&&a>0;)s=o.nextSibling,l=D(o,t),n&&n.appendChild(l),--a,o=s;return t!=O&&(H.setStartAfter(e),H.collapse(F)),n}function T(e,t,n){var i,o,a,s,l,c,u;for(n!=I&&(o=r()),i=A(e,n),o&&o.appendChild(i),a=j(e),s=j(t),++a,l=s-a,c=e.nextSibling;l>0;)u=c.nextSibling,i=D(c,n),o&&o.appendChild(i),c=u,--l;return i=R(t,n),o&&o.appendChild(i),n!=O&&(H.setStartAfter(e),H.collapse(F)),o}function R(e,t){var n=C(H[U],H[$]-1),r,i,o,a,s,l=n!=H[U];if(n==e)return B(n,l,z,t);for(r=n.parentNode,i=B(r,z,z,t);r;){for(;n;)o=n.previousSibling,a=B(n,l,z,t),t!=I&&i.insertBefore(a,i.firstChild),l=F,n=o;if(r==e)return i;n=r.previousSibling,r=r.parentNode,s=B(r,z,z,t),t!=I&&s.appendChild(i),i=s}}function A(e,t){var n=C(H[V],H[W]),r=n!=H[V],i,o,a,s,l;if(n==e)return B(n,r,F,t);for(i=n.parentNode,o=B(i,z,F,t);i;){for(;n;)a=n.nextSibling,s=B(n,r,F,t),t!=I&&o.appendChild(s),r=F,n=a;if(i==e)return o;n=i.nextSibling,i=i.parentNode,l=B(i,z,F,t),t!=I&&l.appendChild(o),o=l}}function B(e,t,r,i){var o,a,s,l,c;if(t)return D(e,i);if(3==e.nodeType){if(o=e.nodeValue,r?(l=H[W],a=o.substring(l),s=o.substring(0,l)):(l=H[$],a=o.substring(0,l),s=o.substring(l)),i!=O&&(e.nodeValue=s),i==I)return;return c=n.clone(e,z),c.nodeValue=a,c}if(i!=I)return n.clone(e,z)}function D(e,t){return t!=I?t==O?n.clone(e,F):e:void e.parentNode.removeChild(e)}function L(){return n.create("body",null,g()).outerText}var H=this,M=n.doc,P=0,O=1,I=2,F=!0,z=!1,W="startOffset",V="startContainer",U="endContainer",$="endOffset",q=e.extend,j=n.nodeIndex;return q(H,{startContainer:M,startOffset:0,endContainer:M,endOffset:0,collapsed:F,commonAncestorContainer:M,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:i,setEnd:o,setStartBefore:a,setStartAfter:s,setEndBefore:l,setEndAfter:c,collapse:u,selectNode:d,selectNodeContents:f,compareBoundaryPoints:p,deleteContents:h,extractContents:m,cloneContents:g,insertNode:v,surroundContents:y,cloneRange:b,toStringIE:L}),H}return t.prototype.toString=function(){return this.toStringIE()},t}),r(g,[d],function(e){function t(e){var t;return t=document.createElement("div"),t.innerHTML=e,t.textContent||t.innerText||e}function n(e,t){var n,r,i,a={};if(e){for(e=e.split(","),t=t||10,n=0;n\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,l=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,c=/[<>&\"\']/g,u=/&(#x|#)?([\w]+);/g,d={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"};o={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},a={"<":"<",">":">","&":"&",""":'"',"'":"'"},i=n("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32);var f={encodeRaw:function(e,t){return e.replace(t?s:l,function(e){return o[e]||e})},encodeAllRaw:function(e){return(""+e).replace(c,function(e){return o[e]||e})},encodeNumeric:function(e,t){return e.replace(t?s:l,function(e){return e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":o[e]||"&#"+e.charCodeAt(0)+";"})},encodeNamed:function(e,t,n){return n=n||i,e.replace(t?s:l,function(e){return o[e]||n[e]||e})},getEncodeFunc:function(e,t){function a(e,n){return e.replace(n?s:l,function(e){return o[e]||t[e]||"&#"+e.charCodeAt(0)+";"||e})}function c(e,n){return f.encodeNamed(e,n,t)}return t=n(t)||i,e=r(e.replace(/\+/g,",")),e.named&&e.numeric?a:e.named?t?c:f.encodeNamed:e.numeric?f.encodeNumeric:f.encodeRaw},decode:function(e){return e.replace(u,function(e,n,r){return n?(r=parseInt(r,2===n.length?16:10),r>65535?(r-=65536,String.fromCharCode(55296+(r>>10),56320+(1023&r))):d[r]||String.fromCharCode(r)):a[e]||i[e]||t(e)})}};return f}),r(v,[d],function(e){return function(t,n){function r(e){t.getElementsByTagName("head")[0].appendChild(e)}function i(n,i,l){function c(){for(var e=y.passed,t=e.length;t--;)e[t]();y.status=2,y.passed=[],y.failed=[]}function u(){for(var e=y.failed,t=e.length;t--;)e[t]();y.status=3,y.passed=[],y.failed=[]}function d(){var e=navigator.userAgent.match(/WebKit\/(\d*)/);return!!(e&&e[1]<536)}function f(e,t){e()||((new Date).getTime()-v0)return g=t.createElement("style"),g.textContent='@import "'+n+'"',h(),void r(g);p()}r(m),m.href=n}}var o=0,a={},s;n=n||{},s=n.maxLoadTime||5e3,this.load=i}}),r(y,[c,f,p,l,h,m,g,u,d,v],function(e,n,r,i,o,a,s,l,c,u){function d(e,t){var n={},r=t.keep_values,i;return i={set:function(n,r,i){t.url_converter&&(r=t.url_converter.call(t.url_converter_scope||e,r,i,n[0])),n.attr("data-mce-"+i,r).attr(i,r)},get:function(e,t){return e.attr("data-mce-"+t)||e.attr(t)}},n={style:{set:function(e,t){return null!==t&&"object"==typeof t?void e.css(t):(r&&e.attr("data-mce-style",t),void e.attr("style",t))},get:function(t){var n=t.attr("data-mce-style")||t.attr("style");return n=e.serializeStyle(e.parseStyle(n),t[0].nodeName)}}},r&&(n.href=n.src=i),n}function f(e,t){var o=this,a;o.doc=e,o.win=window,o.files={},o.counter=0,o.stdMode=!v||e.documentMode>=8,o.boxModel=!v||"CSS1Compat"==e.compatMode||o.stdMode,o.styleSheetLoader=new u(e),o.boundEvents=[],o.settings=t=t||{},o.schema=t.schema,o.styles=new r({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema),o.fixDoc(e),o.events=t.ownEvents?new i(t.proxy):i.Event,o.attrHooks=d(o,t),a=t.schema?t.schema.getBlockElements():{},o.$=n.overrideDefaults(function(){return{context:e,element:o.getRoot()}}),o.isBlock=function(e){if(!e)return!1;var t=e.nodeType;return t?!(1!==t||!a[e.nodeName]):!!a[e]}}var p=c.each,h=c.is,m=c.grep,g=c.trim,v=l.ie,y=/^([a-z0-9],?)+$/i,b=/^[ \t\r\n]*$/;return f.prototype={$$:function(e){return"string"==typeof e&&(e=this.get(e)),this.$(e)},root:null,fixDoc:function(e){var t=this.settings,n;if(v&&t.schema){"abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video".replace(/\w+/g,function(t){e.createElement(t)});for(n in t.schema.getCustomElements())e.createElement(n)}},clone:function(e,t){var n=this,r,i;return!v||1!==e.nodeType||t?e.cloneNode(t):(i=n.doc,t?r.firstChild:(r=i.createElement(e.nodeName),p(n.getAttribs(e),function(t){n.setAttrib(r,t.nodeName,n.getAttrib(e,t.nodeName))}),r))},getRoot:function(){var e=this;return e.settings.root_element||e.doc.body},getViewPort:function(e){var t,n;return e=e?e:this.win,t=e.document,n=this.boxModel?t.documentElement:t.body,{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop,w:e.innerWidth||n.clientWidth,h:e.innerHeight||n.clientHeight}},getRect:function(e){var t=this,n,r;return e=t.get(e),n=t.getPos(e),r=t.getSize(e),{x:n.x,y:n.y,w:r.w,h:r.h}},getSize:function(e){var t=this,n,r;return e=t.get(e),n=t.getStyle(e,"width"),r=t.getStyle(e,"height"),-1===n.indexOf("px")&&(n=0),-1===r.indexOf("px")&&(r=0),{w:parseInt(n,10)||e.offsetWidth||e.clientWidth,h:parseInt(r,10)||e.offsetHeight||e.clientHeight}},getParent:function(e,t,n){return this.getParents(e,t,n,!1)},getParents:function(e,n,r,i){var o=this,a,s=[];for(e=o.get(e),i=i===t,r=r||("BODY"!=o.getRoot().nodeName?o.getRoot().parentNode:null),h(n,"string")&&(a=n,n="*"===n?function(e){return 1==e.nodeType}:function(e){return o.is(e,a)});e&&e!=r&&e.nodeType&&9!==e.nodeType;){if(!n||n(e)){if(!i)return e;s.push(e)}e=e.parentNode}return i?s:null},get:function(e){var t;return e&&this.doc&&"string"==typeof e&&(t=e,e=this.doc.getElementById(e),e&&e.id!==t)?this.doc.getElementsByName(t)[1]:e},getNext:function(e,t){return this._findSib(e,t,"nextSibling")},getPrev:function(e,t){return this._findSib(e,t,"previousSibling")},select:function(t,n){var r=this;return e(t,r.get(n)||r.settings.root_element||r.doc,[])},is:function(n,r){var i;if(n.length===t){if("*"===r)return 1==n.nodeType;if(y.test(r)){for(r=r.toLowerCase().split(/,/),n=n.nodeName.toLowerCase(),i=r.length-1;i>=0;i--)if(r[i]==n)return!0;return!1}}if(n.nodeType&&1!=n.nodeType)return!1;var o=n.nodeType?[n]:n;return e(r,o[0].ownerDocument||o[0],null,o).length>0},add:function(e,t,n,r,i){var o=this;return this.run(e,function(e){var a;return a=h(t,"string")?o.doc.createElement(t):t,o.setAttribs(a,n),r&&(r.nodeType?a.appendChild(r):o.setHTML(a,r)),i?a:e.appendChild(a)})},create:function(e,t,n){return this.add(this.doc.createElement(e),e,t,n,1)},createHTML:function(e,t,n){var r="",i;r+="<"+e;for(i in t)t.hasOwnProperty(i)&&null!==t[i]&&"undefined"!=typeof t[i]&&(r+=" "+i+'="'+this.encode(t[i])+'"');return"undefined"!=typeof n?r+">"+n+"":r+" />"},createFragment:function(e){var t,n,r=this.doc,i;for(i=r.createElement("div"),t=r.createDocumentFragment(),e&&(i.innerHTML=e);n=i.firstChild;)t.appendChild(n);return t},remove:function(e,t){return e=this.$$(e),t?e.each(function(){for(var e;e=this.firstChild;)3==e.nodeType&&0===e.data.length?this.removeChild(e):this.parentNode.insertBefore(e,this)}).remove():e.remove(),e.length>1?e.toArray():e[0]},setStyle:function(e,t,n){e=this.$$(e).css(t,n),this.settings.update_styles&&e.attr("data-mce-style",null)},getStyle:function(e,n,r){return e=this.$$(e),r?e.css(n):(n=n.replace(/-(\D)/g,function(e,t){return t.toUpperCase()}),"float"==n&&(n=v?"styleFloat":"cssFloat"),e[0]&&e[0].style?e[0].style[n]:t)},setStyles:function(e,t){e=this.$$(e).css(t),this.settings.update_styles&&e.attr("data-mce-style",null)},removeAllAttribs:function(e){return this.run(e,function(e){var t,n=e.attributes;for(t=n.length-1;t>=0;t--)e.removeAttributeNode(n.item(t))})},setAttrib:function(e,t,n){var r=this,i,o,a=r.settings;""===n&&(n=null),e=r.$$(e),i=e.attr(t),e.length&&(o=r.attrHooks[t],o&&o.set?o.set(e,n,t):e.attr(t,n),i!=n&&a.onSetAttrib&&a.onSetAttrib({attrElm:e,attrName:t,attrValue:n}))},setAttribs:function(e,t){var n=this;n.$$(e).each(function(e,r){p(t,function(e,t){n.setAttrib(r,t,e)})})},getAttrib:function(e,t,n){var r=this,i,o;return e=r.$$(e),e.length&&(i=r.attrHooks[t],o=i&&i.get?i.get(e,t):e.attr(t)),"undefined"==typeof o&&(o=n||""),o},getPos:function(e,t){var r=this,i=0,o=0,a,s=r.doc,l=s.body,c;if(e=r.get(e),t=t||l,e){if(t===l&&e.getBoundingClientRect&&"static"===n(l).css("position"))return c=e.getBoundingClientRect(),t=r.boxModel?s.documentElement:l,i=c.left+(s.documentElement.scrollLeft||l.scrollLeft)-t.clientLeft,o=c.top+(s.documentElement.scrollTop||l.scrollTop)-t.clientTop,{x:i,y:o};for(a=e;a&&a!=t&&a.nodeType;)i+=a.offsetLeft||0,o+=a.offsetTop||0,a=a.offsetParent;for(a=e.parentNode;a&&a!=t&&a.nodeType;)i-=a.scrollLeft||0,o-=a.scrollTop||0,a=a.parentNode}return{x:i,y:o}},parseStyle:function(e){return this.styles.parse(e)},serializeStyle:function(e,t){return this.styles.serialize(e,t)},addStyle:function(e){var t=this,n=t.doc,r,i;if(t!==f.DOM&&n===document){var o=f.DOM.addedStyles;if(o=o||[],o[e])return;o[e]=!0,f.DOM.addedStyles=o}i=n.getElementById("mceDefaultStyles"),i||(i=n.createElement("style"),i.id="mceDefaultStyles",i.type="text/css",r=n.getElementsByTagName("head")[0],r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i)),i.styleSheet?i.styleSheet.cssText+=e:i.appendChild(n.createTextNode(e))},loadCSS:function(e){var t=this,n=t.doc,r;return t!==f.DOM&&n===document?void f.DOM.loadCSS(e):(e||(e=""),r=n.getElementsByTagName("head")[0],void p(e.split(","),function(e){var i;e=c._addCacheSuffix(e),t.files[e]||(t.files[e]=!0,i=t.create("link",{rel:"stylesheet",href:e}),v&&n.documentMode&&n.recalc&&(i.onload=function(){n.recalc&&n.recalc(),i.onload=null}),r.appendChild(i))}))},addClass:function(e,t){this.$$(e).addClass(t)},removeClass:function(e,t){this.toggleClass(e,t,!1)},hasClass:function(e,t){return this.$$(e).hasClass(t)},toggleClass:function(e,t,r){this.$$(e).toggleClass(t,r).each(function(){""===this.className&&n(this).attr("class",null)})},show:function(e){this.$$(e).show()},hide:function(e){this.$$(e).hide()},isHidden:function(e){return"none"==this.$$(e).css("display")},uniqueId:function(e){return(e?e:"mce_")+this.counter++},setHTML:function(e,t){e=this.$$(e),v?e.each(function(e,r){if(r.canHaveHTML!==!1){for(;r.firstChild;)r.removeChild(r.firstChild);try{r.innerHTML="
      "+t,r.removeChild(r.firstChild)}catch(i){n("
      ").html("
      "+t).contents().slice(1).appendTo(r)}return t}}):e.html(t)},getOuterHTML:function(e){return e=this.get(e),1==e.nodeType?e.outerHTML:n("
      ").append(n(e).clone()).html()},setOuterHTML:function(e,t){var r=this;r.$$(e).each(function(){try{this.outerHTML=t}catch(e){r.remove(n(this).html(t),!0)}})},decode:s.decode,encode:s.encodeAllRaw,insertAfter:function(e,t){return t=this.get(t),this.run(e,function(e){var n,r;return n=t.parentNode,r=t.nextSibling,r?n.insertBefore(e,r):n.appendChild(e),e})},replace:function(e,t,n){var r=this;return r.run(t,function(t){return h(t,"array")&&(e=e.cloneNode(!0)),n&&p(m(t.childNodes),function(t){e.appendChild(t)}),t.parentNode.replaceChild(e,t)})},rename:function(e,t){var n=this,r;return e.nodeName!=t.toUpperCase()&&(r=n.create(t),p(n.getAttribs(e),function(t){n.setAttrib(r,t.nodeName,n.getAttrib(e,t.nodeName))}),n.replace(r,e,1)),r||e},findCommonAncestor:function(e,t){for(var n=e,r;n;){for(r=t;r&&n!=r;)r=r.parentNode;if(n==r)break;n=n.parentNode}return!n&&e.ownerDocument?e.ownerDocument.documentElement:n},toHex:function(e){return this.styles.toHex(c.trim(e))},run:function(e,t,n){var r=this,i;return"string"==typeof e&&(e=r.get(e)),e?(n=n||this,e.nodeType||!e.length&&0!==e.length?t.call(n,e):(i=[],p(e,function(e,o){e&&("string"==typeof e&&(e=r.get(e)),i.push(t.call(n,e,o)))}),i)):!1},getAttribs:function(e){var t;if(e=this.get(e),!e)return[];if(v){if(t=[],"OBJECT"==e.nodeName)return e.attributes;"OPTION"===e.nodeName&&this.getAttrib(e,"selected")&&t.push({specified:1,nodeName:"selected"});var n=/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi;return e.cloneNode(!1).outerHTML.replace(n,"").replace(/[\w:\-]+/gi,function(e){t.push({specified:1,nodeName:e})}),t}return e.attributes},isEmpty:function(e,t){var n=this,r,i,a,s,l,c=0;if(e=e.firstChild){s=new o(e,e.parentNode),t=t||(n.schema?n.schema.getNonEmptyElements():null);do{if(a=e.nodeType,1===a){if(e.getAttribute("data-mce-bogus"))continue;if(l=e.nodeName.toLowerCase(),t&&t[l]){if("br"===l){c++;continue}return!1}for(i=n.getAttribs(e),r=i.length;r--;)if(l=i[r].nodeName,"name"===l||"data-mce-bookmark"===l)return!1}if(8==a)return!1;if(3===a&&!b.test(e.nodeValue))return!1}while(e=s.next())}return 1>=c},createRng:function(){var e=this.doc;return e.createRange?e.createRange():new a(this)},nodeIndex:function(e,t){var n=0,r,i;if(e)for(r=e.nodeType,e=e.previousSibling;e;e=e.previousSibling)i=e.nodeType,(!t||3!=i||i!=r&&e.nodeValue.length)&&(n++,r=i);return n},split:function(e,t,n){function r(e){function t(e){var t=e.previousSibling&&"SPAN"==e.previousSibling.nodeName,n=e.nextSibling&&"SPAN"==e.nextSibling.nodeName;return t&&n}var n,o=e.childNodes,a=e.nodeType;if(1!=a||"bookmark"!=e.getAttribute("data-mce-type")){for(n=o.length-1;n>=0;n--)r(o[n]);if(9!=a){if(3==a&&e.nodeValue.length>0){var s=g(e.nodeValue).length;if(!i.isBlock(e.parentNode)||s>0||0===s&&t(e))return +}else if(1==a&&(o=e.childNodes,1==o.length&&o[0]&&1==o[0].nodeType&&"bookmark"==o[0].getAttribute("data-mce-type")&&e.parentNode.insertBefore(o[0],e),o.length||/^(br|hr|input|img)$/i.test(e.nodeName)))return;i.remove(e)}return e}}var i=this,o=i.createRng(),a,s,l;return e&&t?(o.setStart(e.parentNode,i.nodeIndex(e)),o.setEnd(t.parentNode,i.nodeIndex(t)),a=o.extractContents(),o=i.createRng(),o.setStart(t.parentNode,i.nodeIndex(t)+1),o.setEnd(e.parentNode,i.nodeIndex(e)+1),s=o.extractContents(),l=e.parentNode,l.insertBefore(r(a),e),n?l.replaceChild(n,t):l.insertBefore(t,e),l.insertBefore(r(s),e),i.remove(e),n||t):void 0},bind:function(e,t,n,r){var i=this;if(c.isArray(e)){for(var o=e.length;o--;)e[o]=i.bind(e[o],t,n,r);return e}return!i.settings.collect||e!==i.doc&&e!==i.win||i.boundEvents.push([e,t,n,r]),i.events.bind(e,t,n,r||i)},unbind:function(e,t,n){var r=this,i;if(c.isArray(e)){for(i=e.length;i--;)e[i]=r.unbind(e[i],t,n);return e}if(r.boundEvents&&(e===r.doc||e===r.win))for(i=r.boundEvents.length;i--;){var o=r.boundEvents[i];e!=o[0]||t&&t!=o[1]||n&&n!=o[2]||this.events.unbind(o[0],o[1],o[2])}return this.events.unbind(e,t,n)},fire:function(e,t,n){return this.events.fire(e,t,n)},getContentEditable:function(e){var t;return e&&1==e.nodeType?(t=e.getAttribute("data-mce-contenteditable"),t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null):null},getContentEditableParent:function(e){for(var t=this.getRoot(),n=null;e&&e!==t&&(n=this.getContentEditable(e),null===n);e=e.parentNode);return n},destroy:function(){var t=this;if(t.boundEvents){for(var n=t.boundEvents.length;n--;){var r=t.boundEvents[n];this.events.unbind(r[0],r[1],r[2])}t.boundEvents=null}e.setDocument&&e.setDocument(),t.win=t.doc=t.root=t.events=t.frag=null},isChildOf:function(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1},dumpRng:function(e){return"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},_findSib:function(e,t,n){var r=this,i=t;if(e)for("string"==typeof i&&(i=function(e){return r.is(e,t)}),e=e[n];e;e=e[n])if(i(e))return e;return null}},f.DOM=new f(document),f}),r(b,[y,d],function(e,t){function n(){function e(e,n){function i(){a.remove(l),s&&(s.onreadystatechange=s.onload=s=null),n()}function o(){"undefined"!=typeof console&&console.log&&console.log("Failed to load: "+e)}var a=r,s,l;l=a.uniqueId(),s=document.createElement("script"),s.id=l,s.type="text/javascript",s.src=t._addCacheSuffix(e),"onreadystatechange"in s?s.onreadystatechange=function(){/loaded|complete/.test(s.readyState)&&i()}:s.onload=i,s.onerror=o,(document.getElementsByTagName("head")[0]||document.body).appendChild(s)}var n=0,a=1,s=2,l={},c=[],u={},d=[],f=0,p;this.isDone=function(e){return l[e]==s},this.markDone=function(e){l[e]=s},this.add=this.load=function(e,t,r){var i=l[e];i==p&&(c.push(e),l[e]=n),t&&(u[e]||(u[e]=[]),u[e].push({func:t,scope:r||this}))},this.loadQueue=function(e,t){this.loadScripts(c,e,t)},this.loadScripts=function(t,n,r){function c(e){i(u[e],function(e){e.func.call(e.scope)}),u[e]=p}var h;d.push({func:n,scope:r||this}),(h=function(){var n=o(t);t.length=0,i(n,function(t){return l[t]==s?void c(t):void(l[t]!=a&&(l[t]=a,f++,e(t,function(){l[t]=s,f--,c(t),h()})))}),f||(i(d,function(e){e.func.call(e.scope)}),d.length=0)})()}}var r=e.DOM,i=t.each,o=t.grep;return n.ScriptLoader=new n,n}),r(C,[b,d],function(e,n){function r(){var e=this;e.items=[],e.urls={},e.lookup={}}var i=n.each;return r.prototype={get:function(e){return this.lookup[e]?this.lookup[e].instance:t},dependencies:function(e){var t;return this.lookup[e]&&(t=this.lookup[e].dependencies),t||[]},requireLangPack:function(t,n){var i=r.language;if(i&&r.languageLoad!==!1){if(n)if(n=","+n+",",-1!=n.indexOf(","+i.substr(0,2)+","))i=i.substr(0,2);else if(-1==n.indexOf(","+i+","))return;e.ScriptLoader.add(this.urls[t]+"/langs/"+i+".js")}},add:function(e,t,n){return this.items.push(t),this.lookup[e]={instance:t,dependencies:n},t},createUrl:function(e,t){return"object"==typeof t?t:{prefix:e.prefix,resource:t,suffix:e.suffix}},addComponents:function(t,n){var r=this.urls[t];i(n,function(t){e.ScriptLoader.add(r+"/"+t)})},load:function(n,o,a,s){function l(){var r=c.dependencies(n);i(r,function(e){var n=c.createUrl(o,e);c.load(n.resource,n,t,t)}),a&&a.call(s?s:e)}var c=this,u=o;c.urls[n]||("object"==typeof o&&(u=o.prefix+o.resource+o.suffix),0!==u.indexOf("/")&&-1==u.indexOf("://")&&(u=r.baseURL+"/"+u),c.urls[n]=u.substring(0,u.lastIndexOf("/")),c.lookup[n]?l():e.ScriptLoader.add(u,l,s))}},r.PluginManager=new r,r.ThemeManager=new r,r}),r(x,[d,h],function(e,t){function n(e,t){var n=e.childNodes;return t--,t>n.length-1?t=n.length-1:0>t&&(t=0),n[t]||e}function r(e){this.walk=function(t,r){function o(e){var t;return t=e[0],3===t.nodeType&&t===c&&u>=t.nodeValue.length&&e.splice(0,1),t=e[e.length-1],0===f&&e.length>0&&t===d&&3===t.nodeType&&e.splice(e.length-1,1),e}function a(e,t,n){for(var r=[];e&&e!=n;e=e[t])r.push(e);return r}function s(e,t){do{if(e.parentNode==t)return e;e=e.parentNode}while(e)}function l(e,t,n){var i=n?"nextSibling":"previousSibling";for(g=e,v=g.parentNode;g&&g!=t;g=v)v=g.parentNode,y=a(g==e?g:g[i],i),y.length&&(n||y.reverse(),r(o(y)))}var c=t.startContainer,u=t.startOffset,d=t.endContainer,f=t.endOffset,p,h,m,g,v,y,b;if(b=e.select("td.mce-item-selected,th.mce-item-selected"),b.length>0)return void i(b,function(e){r([e])});if(1==c.nodeType&&c.hasChildNodes()&&(c=c.childNodes[u]),1==d.nodeType&&d.hasChildNodes()&&(d=n(d,f)),c==d)return r(o([c]));for(p=e.findCommonAncestor(c,d),g=c;g;g=g.parentNode){if(g===d)return l(c,p,!0);if(g===p)break}for(g=d;g;g=g.parentNode){if(g===c)return l(d,p);if(g===p)break}h=s(c,p)||c,m=s(d,p)||d,l(c,h,!0),y=a(h==c?h:h.nextSibling,"nextSibling",m==d?m.nextSibling:m),y.length&&r(o(y)),l(d,m)},this.split=function(e){function t(e,t){return e.splitText(t)}var n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset;return n==i&&3==n.nodeType?r>0&&rr?(o-=r,n=i=t(i,o).previousSibling,o=i.nodeValue.length,r=0):o=0):(3==n.nodeType&&r>0&&r0&&o0)return c=p,u=n?p.nodeValue.length:0,void(i=!0);if(e.isBlock(p)||h[p.nodeName.toLowerCase()])return;s=p}o&&s&&(c=s,i=!0,u=0)}var c,u,d,f=e.getRoot(),p,h,m,g;if(c=n[(r?"start":"end")+"Container"],u=n[(r?"start":"end")+"Offset"],g=1==c.nodeType&&u===c.childNodes.length,h=e.schema.getNonEmptyElements(),m=r,1==c.nodeType&&u>c.childNodes.length-1&&(m=!1),9===c.nodeType&&(c=e.getRoot(),u=0),c===f){if(m&&(p=c.childNodes[u>0?u-1:0],p&&(h[p.nodeName]||"TABLE"==p.nodeName)))return;if(c.hasChildNodes()&&(u=Math.min(!m&&u>0?u-1:u,c.childNodes.length-1),c=c.childNodes[u],u=0,c.hasChildNodes()&&!/TABLE/.test(c.nodeName))){p=c,d=new t(c,f);do{if(3===p.nodeType&&p.nodeValue.length>0){u=m?0:p.nodeValue.length,c=p,i=!0;break}if(h[p.nodeName.toLowerCase()]){u=e.nodeIndex(p),c=p.parentNode,"IMG"!=p.nodeName||m||u++,i=!0;break}}while(p=m?d.next():d.prev())}}o&&(3===c.nodeType&&0===u&&l(!0),1===c.nodeType&&(p=c.childNodes[u],p||(p=c.childNodes[u-1]),!p||"BR"!==p.nodeName||s(p,"A")||a(p)||a(p,!0)||l(!0,p))),m&&!o&&3===c.nodeType&&u===c.nodeValue.length&&l(!1),i&&n["set"+(r?"Start":"End")](c,u)}var i,o;return o=n.collapsed,r(!0),o||r(),i&&o&&n.collapse(!0),i}}var i=e.each;return r.compareRanges=function(e,t){if(e&&t){if(!e.item&&!e.duplicate)return e.startContainer==t.startContainer&&e.startOffset==t.startOffset;if(e.item&&t.item&&e.item(0)===t.item(0))return!0;if(e.isEqual&&t.isEqual&&t.isEqual(e))return!0}return!1},r}),r(w,[x],function(e){return function(t){function n(e){var n,r;if(r=t.$(e).parentsUntil(t.getBody()).add(e),r.length===i.length){for(n=r.length;n>=0&&r[n]===i[n];n--);if(-1===n)return i=r,!0}return i=r,!1}var r,i=[];"onselectionchange"in t.getDoc()||t.on("NodeChange Click MouseUp KeyUp Focus",function(n){var i,o;i=t.selection.getRng(),o={startContainer:i.startContainer,startOffset:i.startOffset,endContainer:i.endContainer,endOffset:i.endOffset},"nodechange"!=n.type&&e.compareRanges(o,r)||t.fire("SelectionChange"),r=o}),t.on("contextmenu",function(){t.fire("SelectionChange")}),t.on("SelectionChange",function(){var e=t.selection.getStart(!0);t.selection.isCollapsed()||n(e)||!t.dom.isChildOf(e,t.getBody())||t.nodeChanged({selectionChange:!0})}),t.on("MouseUp",function(e){e.isDefaultPrevented()||setTimeout(function(){t.nodeChanged()},0)}),this.nodeChanged=function(e){var n=t.selection,r,i,o;t.initialized&&n&&!t.settings.disable_nodechange&&!t.settings.readonly&&(o=t.getBody(),r=n.getStart()||o,r=r.ownerDocument!=t.getDoc()?t.getBody():r,"IMG"==r.nodeName&&n.isCollapsed()&&(r=r.parentNode),i=[],t.dom.getParent(r,function(e){return e===o?!0:void i.push(e)}),e=e||{},e.element=r,e.parents=i,t.fire("NodeChange",e))}}}),r(_,[],function(){function e(e,t,n){var r,i,o=n?"lastChild":"firstChild",a=n?"prev":"next";if(e[o])return e[o];if(e!==t){if(r=e[a])return r;for(i=e.parent;i&&i!==t;i=i.parent)if(r=i[a])return r}}function t(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}var n=/^[ \t\r\n]*$/,r={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11};return t.prototype={replace:function(e){var t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t},attr:function(e,t){var n=this,r,i,o;if("string"!=typeof e){for(i in e)n.attr(i,e[i]);return n}if(r=n.attributes){if(t!==o){if(null===t){if(e in r.map)for(delete r.map[e],i=r.length;i--;)if(r[i].name===e)return r=r.splice(i,1),n;return n}if(e in r.map){for(i=r.length;i--;)if(r[i].name===e){r[i].value=t;break}}else r.push({name:e,value:t});return r.map[e]=t,n}return r.map[e]}},clone:function(){var e=this,n=new t(e.name,e.type),r,i,o,a,s;if(o=e.attributes){for(s=[],s.map={},r=0,i=o.length;i>r;r++)a=o[r],"id"!==a.name&&(s[s.length]={name:a.name,value:a.value},s.map[a.name]=a.value);n.attributes=s}return n.value=e.value,n.shortEnded=e.shortEnded,n},wrap:function(e){var t=this;return t.parent.insert(e,t),e.append(t),t},unwrap:function(){var e=this,t,n;for(t=e.firstChild;t;)n=t.next,e.insert(t,e,!0),t=n;e.remove()},remove:function(){var e=this,t=e.parent,n=e.next,r=e.prev;return t&&(t.firstChild===e?(t.firstChild=n,n&&(n.prev=null)):r.next=n,t.lastChild===e?(t.lastChild=r,r&&(r.next=null)):n.prev=r,e.parent=e.next=e.prev=null),e},append:function(e){var t=this,n;return e.parent&&e.remove(),n=t.lastChild,n?(n.next=e,e.prev=n,t.lastChild=e):t.lastChild=t.firstChild=e,e.parent=t,e},insert:function(e,t,n){var r;return e.parent&&e.remove(),r=t.parent||this,n?(t===r.firstChild?r.firstChild=e:t.prev.next=e,e.prev=t.prev,e.next=t,t.prev=e):(t===r.lastChild?r.lastChild=e:t.next.prev=e,e.next=t.next,e.prev=t,t.next=e),e.parent=r,e},getAll:function(t){var n=this,r,i=[];for(r=n.firstChild;r;r=e(r,n))r.name===t&&i.push(r);return i},empty:function(){var t=this,n,r,i;if(t.firstChild){for(n=[],i=t.firstChild;i;i=e(i,t))n.push(i);for(r=n.length;r--;)i=n[r],i.parent=i.firstChild=i.lastChild=i.next=i.prev=null}return t.firstChild=t.lastChild=null,t},isEmpty:function(t){var r=this,i=r.firstChild,o,a;if(i)do{if(1===i.type){if(i.attributes.map["data-mce-bogus"])continue;if(t[i.name])return!1;for(o=i.attributes.length;o--;)if(a=i.attributes[o].name,"name"===a||0===a.indexOf("data-mce-bookmark"))return!1}if(8===i.type)return!1;if(3===i.type&&!n.test(i.value))return!1}while(i=e(i,r));return!0},walk:function(t){return e(this,null,t)}},t.create=function(e,n){var i,o;if(i=new t(e,r[e]||1),n)for(o in n)i.attr(o,n[o]);return i},t}),r(E,[d],function(e){function t(e,t){return e?e.split(t||" "):[]}function n(e){function n(e,n,r){function i(e,t){var n={},r,i;for(r=0,i=e.length;i>r;r++)n[e[r]]=t||{};return n}var s,c,u,d=arguments;for(r=r||[],n=n||"","string"==typeof r&&(r=t(r)),c=3;co;o++)i.attributes[n[o]]={},i.attributesOrder.push(n[o])}var a={},l,c,u,d,f,p;return i[e]?i[e]:(l=t("id accesskey class dir lang style tabindex title"),c=t("address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul"),u=t("a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment"),"html4"!=e&&(l.push.apply(l,t("contenteditable contextmenu draggable dropzone hidden spellcheck translate")),c.push.apply(c,t("article aside details dialog figure header footer hgroup section nav")),u.push.apply(u,t("audio canvas command datalist mark meter output progress time wbr video ruby bdi keygen"))),"html5-strict"!=e&&(l.push("xml:lang"),p=t("acronym applet basefont big font strike tt"),u.push.apply(u,p),s(p,function(e){n(e,"",u)}),f=t("center dir isindex noframes"),c.push.apply(c,f),d=[].concat(c,u),s(f,function(e){n(e,"",d)})),d=d||[].concat(c,u),n("html","manifest","head body"),n("head","","base command link meta noscript script style title"),n("title hr noscript br"),n("base","href target"),n("link","href rel media hreflang type sizes hreflang"),n("meta","name http-equiv content charset"),n("style","media type scoped"),n("script","src async defer type charset"),n("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",d),n("address dt dd div caption","",d),n("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",u),n("blockquote","cite",d),n("ol","reversed start type","li"),n("ul","","li"),n("li","value",d),n("dl","","dt dd"),n("a","href target rel media hreflang type",u),n("q","cite",u),n("ins del","cite datetime",d),n("img","src srcset alt usemap ismap width height"),n("iframe","src name width height",d),n("embed","src type width height"),n("object","data type typemustmatch name usemap form width height",d,"param"),n("param","name value"),n("map","name",d,"area"),n("area","alt coords shape href target rel media hreflang type"),n("table","border","caption colgroup thead tfoot tbody tr"+("html4"==e?" col":"")),n("colgroup","span","col"),n("col","span"),n("tbody thead tfoot","","tr"),n("tr","","td th"),n("td","colspan rowspan headers",d),n("th","colspan rowspan headers scope abbr",d),n("form","accept-charset action autocomplete enctype method name novalidate target",d),n("fieldset","disabled form name",d,"legend"),n("label","form for",u),n("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),n("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"==e?d:u),n("select","disabled form multiple name required size","option optgroup"),n("optgroup","disabled label","option"),n("option","disabled label selected value"),n("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),n("menu","type label",d,"li"),n("noscript","",d),"html4"!=e&&(n("wbr"),n("ruby","",u,"rt rp"),n("figcaption","",d),n("mark rt rp summary bdi","",u),n("canvas","width height",d),n("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",d,"track source"),n("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",d,"track source"),n("picture","","img source"),n("source","src srcset type media sizes"),n("track","kind src srclang label default"),n("datalist","",u,"option"),n("article section nav aside header footer","",d),n("hgroup","","h1 h2 h3 h4 h5 h6"),n("figure","",d,"figcaption"),n("time","datetime",u),n("dialog","open",d),n("command","type label icon disabled checked radiogroup command"),n("output","for form name",u),n("progress","value max",u),n("meter","value min max low high optimum",u),n("details","open",d,"summary"),n("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!=e&&(r("script","language xml:space"),r("style","xml:space"),r("object","declare classid code codebase codetype archive standby align border hspace vspace"),r("embed","align name hspace vspace"),r("param","valuetype type"),r("a","charset name rev shape coords"),r("br","clear"),r("applet","codebase archive code object alt name width height align hspace vspace"),r("img","name longdesc align border hspace vspace"),r("iframe","longdesc frameborder marginwidth marginheight scrolling align"),r("font basefont","size color face"),r("input","usemap align"),r("select","onchange"),r("textarea"),r("h1 h2 h3 h4 h5 h6 div p legend caption","align"),r("ul","type compact"),r("li","type"),r("ol dl menu dir","compact"),r("pre","width xml:space"),r("hr","align noshade size width"),r("isindex","prompt"),r("table","summary width frame rules cellspacing cellpadding align bgcolor"),r("col","width align char charoff valign"),r("colgroup","width align char charoff valign"),r("thead","align char charoff valign"),r("tr","align char charoff valign bgcolor"),r("th","axis align char charoff valign nowrap bgcolor width height"),r("form","accept"),r("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),r("tfoot","align char charoff valign"),r("tbody","align char charoff valign"),r("area","nohref"),r("body","background bgcolor text link vlink alink")),"html4"!=e&&(r("input button select textarea","autofocus"),r("input textarea","placeholder"),r("a","download"),r("link script img","crossorigin"),r("iframe","sandbox seamless allowfullscreen")),s(t("a form meter progress dfn"),function(e){a[e]&&delete a[e].children[e]}),delete a.caption.children.table,i[e]=a,a)}function r(e,t){var n;return e&&(n={},"string"==typeof e&&(e={"*":e}),s(e,function(e,r){n[r]="map"==t?a(e,/[, ]/):c(e,/[, ]/)})),n}var i={},o={},a=e.makeMap,s=e.each,l=e.extend,c=e.explode,u=e.inArray;return function(e){function o(t,n,r){var o=e[t];return o?o=a(o,/[, ]/,a(o.toUpperCase(),/[, ]/)):(o=i[t],o||(o=a(n," ",a(n.toUpperCase()," ")),o=l(o,r),i[t]=o)),o}function d(e){return new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$")}function f(e){var n,r,i,o,s,l,c,f,p,h,m,g,v,b,x,w,_,E,N,k=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,S=/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,T=/[*?+]/;if(e)for(e=t(e,","),y["@"]&&(w=y["@"].attributes,_=y["@"].attributesOrder),n=0,r=e.length;r>n;n++)if(s=k.exec(e[n])){if(b=s[1],p=s[2],x=s[3],f=s[5],g={},v=[],l={attributes:g,attributesOrder:v},"#"===b&&(l.paddEmpty=!0),"-"===b&&(l.removeEmpty=!0),"!"===s[4]&&(l.removeEmptyAttrs=!0),w){for(E in w)g[E]=w[E];v.push.apply(v,_)}if(f)for(f=t(f,"|"),i=0,o=f.length;o>i;i++)if(s=S.exec(f[i])){if(c={},m=s[1],h=s[2].replace(/::/g,":"),b=s[3],N=s[4],"!"===m&&(l.attributesRequired=l.attributesRequired||[],l.attributesRequired.push(h),c.required=!0),"-"===m){delete g[h],v.splice(u(v,h),1);continue}b&&("="===b&&(l.attributesDefault=l.attributesDefault||[],l.attributesDefault.push({name:h,value:N}),c.defaultValue=N),":"===b&&(l.attributesForced=l.attributesForced||[],l.attributesForced.push({name:h,value:N}),c.forcedValue=N),"<"===b&&(c.validValues=a(N,"?"))),T.test(h)?(l.attributePatterns=l.attributePatterns||[],c.pattern=d(h),l.attributePatterns.push(c)):(g[h]||v.push(h),g[h]=c)}w||"@"!=p||(w=g,_=v),x&&(l.outputName=p,y[x]=l),T.test(p)?(l.pattern=d(p),C.push(l)):y[p]=l}}function p(e){y={},C=[],f(e),s(_,function(e,t){b[t]=e.children})}function h(e){var n=/^(~)?(.+)$/;e&&(i.text_block_elements=i.block_elements=null,s(t(e,","),function(e){var t=n.exec(e),r="~"===t[1],i=r?"span":"div",o=t[2];if(b[o]=b[i],L[o]=i,r||(R[o.toUpperCase()]={},R[o]={}),!y[o]){var a=y[i];a=l({},a),delete a.removeEmptyAttrs,delete a.removeEmpty,y[o]=a}s(b,function(e,t){e[i]&&(b[t]=e=l({},b[t]),e[o]=e[i])})}))}function m(e){var n=/^([+\-]?)(\w+)\[([^\]]+)\]$/;e&&s(t(e,","),function(e){var r=n.exec(e),i,o;r&&(o=r[1],i=o?b[r[2]]:b[r[2]]={"#comment":{}},i=b[r[2]],s(t(r[3],"|"),function(e){"-"===o?(b[r[2]]=i=l({},b[r[2]]),delete i[e]):i[e]={}}))})}function g(e){var t=y[e],n;if(t)return t;for(n=C.length;n--;)if(t=C[n],t.pattern.test(e))return t}var v=this,y={},b={},C=[],x,w,_,E,N,k,S,T,R,A,B,D,L={},H={};e=e||{},_=n(e.schema),e.verify_html===!1&&(e.valid_elements="*[*]"),x=r(e.valid_styles),w=r(e.invalid_styles,"map"),T=r(e.valid_classes,"map"),E=o("whitespace_elements","pre script noscript style textarea video audio iframe object"),N=o("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),k=o("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),S=o("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls"),A=o("non_empty_elements","td th iframe video audio object script",k),B=o("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside nav figure"),R=o("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup",B),D=o("text_inline_elements","span strong b em i font strike u var cite dfn code mark q sup sub samp"),s((e.special||"script noscript style textarea").split(" "),function(e){H[e]=new RegExp("]*>","gi")}),e.valid_elements?p(e.valid_elements):(s(_,function(e,t){y[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},b[t]=e.children}),"html5"!=e.schema&&s(t("strong/b em/i"),function(e){e=t(e,"/"),y[e[1]].outputName=e[0]}),y.img.attributesDefault=[{name:"alt",value:""}],s(t("ol ul sub sup blockquote span font a table tbody tr strong em b i"),function(e){y[e]&&(y[e].removeEmpty=!0)}),s(t("p h1 h2 h3 h4 h5 h6 th td pre div address caption"),function(e){y[e].paddEmpty=!0}),s(t("span"),function(e){y[e].removeEmptyAttrs=!0})),h(e.custom_elements),m(e.valid_children),f(e.extended_valid_elements),m("+ol[ul|ol],+ul[ul|ol]"),e.invalid_elements&&s(c(e.invalid_elements),function(e){y[e]&&delete y[e]}),g("span")||f("span[!data-mce-type|*]"),v.children=b,v.getValidStyles=function(){return x},v.getInvalidStyles=function(){return w},v.getValidClasses=function(){return T},v.getBoolAttrs=function(){return S},v.getBlockElements=function(){return R},v.getTextBlockElements=function(){return B},v.getTextInlineElements=function(){return D},v.getShortEndedElements=function(){return k},v.getSelfClosingElements=function(){return N},v.getNonEmptyElements=function(){return A},v.getWhiteSpaceElements=function(){return E},v.getSpecialElements=function(){return H},v.isValidChild=function(e,t){var n=b[e];return!(!n||!n[t])},v.isValid=function(e,t){var n,r,i=g(e);if(i){if(!t)return!0;if(i.attributes[t])return!0;if(n=i.attributePatterns)for(r=n.length;r--;)if(n[r].pattern.test(e))return!0}return!1},v.getElementRule=g,v.getCustomElements=function(){return L},v.addValidElements=f,v.setValidElements=p,v.addCustomElements=h,v.addValidChildren=m,v.elements=y}}),r(N,[E,g,d],function(e,t,n){function r(e,t,n){var r=1,i,o,a,s;for(s=e.getShortEndedElements(),a=/<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g,a.lastIndex=i=n;o=a.exec(t);){if(i=a.lastIndex,"/"===o[1])r--;else if(!o[1]){if(o[2]in s)continue;r++}if(0===r)break}return i}function i(i,a){function s(){}var l=this;i=i||{},l.schema=a=a||new e,i.fix_self_closing!==!1&&(i.fix_self_closing=!0),o("comment cdata text start end pi doctype".split(" "),function(e){e&&(l[e]=i[e]||s)}),l.parse=function(e){function o(e){var t,n;for(t=p.length;t--&&p[t].name!==e;);if(t>=0){for(n=p.length-1;n>=t;n--)e=p[n],e.valid&&l.end(e.name);p.length=t}}function s(e,t,n,r,o){var a,s,l=/[\s\u0000-\u001F]+/g;if(t=t.toLowerCase(),n=t in x?t:z(n||r||o||""),_&&!y&&0!==t.indexOf("data-")){if(a=T[t],!a&&R){for(s=R.length;s--&&(a=R[s],!a.pattern.test(t)););-1===s&&(a=null)}if(!a)return;if(a.validValues&&!(n in a.validValues))return}if(V[t]&&!i.allow_script_urls){var c=n.replace(l,"");try{c=decodeURIComponent(c)}catch(u){c=unescape(c)}if(U.test(c))return;if(!i.allow_html_data_urls&&$.test(c)&&!/^data:image\//i.test(c))return}h.map[t]=n,h.push({name:t,value:n})}var l=this,c,u=0,d,f,p=[],h,m,g,v,y,b,C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F=0,z=t.decode,W,V=n.makeMap("src,href,data,background,formaction,poster"),U=/((java|vb)script|mhtml):/i,$=/^data:/i;for(M=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([^>]+)>)|(?:([A-Za-z0-9\\-_\\:\\.]+)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g"),P=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g,C=a.getShortEndedElements(),H=i.self_closing_elements||a.getSelfClosingElements(),x=a.getBoolAttrs(),_=i.validate,b=i.remove_internals,W=i.fix_self_closing,O=a.getSpecialElements();c=M.exec(e);){if(u0&&p[p.length-1].name===d&&o(d),!_||(E=a.getElementRule(d))){if(N=!0,_&&(T=E.attributes,R=E.attributePatterns),(S=c[8])?(y=-1!==S.indexOf("data-mce-type"),y&&b&&(N=!1),h=[],h.map={},S.replace(P,s)):(h=[],h.map={}),_&&!y){if(A=E.attributesRequired,B=E.attributesDefault,D=E.attributesForced,L=E.removeEmptyAttrs,L&&!h.length&&(N=!1),D)for(m=D.length;m--;)k=D[m],v=k.name,I=k.value,"{$uid}"===I&&(I="mce_"+F++),h.map[v]=I,h.push({name:v,value:I});if(B)for(m=B.length;m--;)k=B[m],v=k.name,v in h.map||(I=k.value,"{$uid}"===I&&(I="mce_"+F++),h.map[v]=I,h.push({name:v,value:I}));if(A){for(m=A.length;m--&&!(A[m]in h.map););-1===m&&(N=!1)}if(k=h.map["data-mce-bogus"]){if("all"===k){u=r(a,e,M.lastIndex),M.lastIndex=u;continue}N=!1}}N&&l.start(d,h,w)}else N=!1;if(f=O[d]){f.lastIndex=u=c.index+c[0].length,(c=f.exec(e))?(N&&(g=e.substr(u,c.index-u)),u=c.index+c[0].length):(g=e.substr(u),u=e.length),N&&(g.length>0&&l.text(g,!0),l.end(d)),M.lastIndex=u;continue}w||(S&&S.indexOf("/")==S.length-1?N&&l.end(d):p.push({name:d,valid:N}))}else(d=c[1])?(">"===d.charAt(0)&&(d=" "+d),i.allow_conditional_comments||"[if"!==d.substr(0,3)||(d=" "+d),l.comment(d)):(d=c[2])?l.cdata(d):(d=c[3])?l.doctype(d):(d=c[4])&&l.pi(d,c[5]);u=c.index+c[0].length}for(u=0;m--)d=p[m],d.valid&&l.end(d.name)}}var o=n.each;return i.findEndTag=r,i}),r(k,[_,E,N,d],function(e,t,n,r){var i=r.makeMap,o=r.each,a=r.explode,s=r.extend;return function(r,l){function c(t){var n,r,o,a,s,c,d,f,p,h,m,g,v,y;for(m=i("tr,td,th,tbody,thead,tfoot,table"),h=l.getNonEmptyElements(),g=l.getTextBlockElements(),n=0;n1){for(a.reverse(),s=c=u.filterNode(a[0].clone()),p=0;p0?(t.value=n,t=t.prev):(r=t.prev,t.remove(),t=r)}function g(e){var t,n={};for(t in e)"li"!==t&&"p"!=t&&(n[t]=e[t]);return n}var v,y,b,C,x,w,_,E,N,k,S,T,R,A=[],B,D,L,H,M,P,O,I;if(o=o||{},p={},h={},T=s(i("script,style,head,html,body,title,meta,param"),l.getBlockElements()),O=l.getNonEmptyElements(),P=l.children,S=r.validate,I="forced_root_block"in o?o.forced_root_block:r.forced_root_block,M=l.getWhiteSpaceElements(),R=/^[ \t\r\n]+/,D=/[ \t\r\n]+$/,L=/[ \t\r\n]+/g,H=/^[ \t\r\n]+$/,v=new n({validate:S,allow_script_urls:r.allow_script_urls,allow_conditional_comments:r.allow_conditional_comments,self_closing_elements:g(l.getSelfClosingElements()),cdata:function(e){b.append(u("#cdata",4)).value=e},text:function(e,t){var n;B||(e=e.replace(L," "),b.lastChild&&T[b.lastChild.name]&&(e=e.replace(R,""))),0!==e.length&&(n=u("#text",3),n.raw=!!t,b.append(n).value=e)},comment:function(e){b.append(u("#comment",8)).value=e},pi:function(e,t){b.append(u(e,7)).value=t,m(b)},doctype:function(e){var t;t=b.append(u("#doctype",10)),t.value=e,m(b)},start:function(e,t,n){var r,i,o,a,s;if(o=S?l.getElementRule(e):{}){for(r=u(o.outputName||e,1),r.attributes=t,r.shortEnded=n,b.append(r),s=P[b.name],s&&P[r.name]&&!s[r.name]&&A.push(r),i=f.length;i--;)a=f[i].name,a in t.map&&(N=h[a],N?N.push(r):h[a]=[r]);T[e]&&m(r),n||(b=r),!B&&M[e]&&(B=!0)}},end:function(t){var n,r,i,o,a;if(r=S?l.getElementRule(t):{}){if(T[t]&&!B){if(n=b.firstChild,n&&3===n.type)if(i=n.value.replace(R,""),i.length>0)n.value=i,n=n.next;else for(o=n.next,n.remove(),n=o;n&&3===n.type;)i=n.value,o=n.next,(0===i.length||H.test(i))&&(n.remove(),n=o),n=o;if(n=b.lastChild,n&&3===n.type)if(i=n.value.replace(D,""),i.length>0)n.value=i,n=n.prev;else for(o=n.prev,n.remove(),n=o;n&&3===n.type;)i=n.value,o=n.prev,(0===i.length||H.test(i))&&(n.remove(),n=o),n=o}if(B&&M[t]&&(B=!1),(r.removeEmpty||r.paddEmpty)&&b.isEmpty(O))if(r.paddEmpty)b.empty().append(new e("#text","3")).value="\xa0";else if(!b.attributes.map.name&&!b.attributes.map.id)return a=b.parent,T[b.name]?b.empty().remove():b.unwrap(),void(b=a); +b=b.parent}}},l),y=b=new e(o.context||r.root_name,11),v.parse(t),S&&A.length&&(o.context?o.invalid=!0:c(A)),I&&("body"==y.name||o.isRootContent)&&a(),!o.invalid){for(k in p){for(N=d[k],C=p[k],_=C.length;_--;)C[_].parent||C.splice(_,1);for(x=0,w=N.length;w>x;x++)N[x](C,k,o)}for(x=0,w=f.length;w>x;x++)if(N=f[x],N.name in h){for(C=h[N.name],_=C.length;_--;)C[_].parent||C.splice(_,1);for(_=0,E=N.callbacks.length;E>_;_++)N.callbacks[_](C,N.name,o)}}return y},r.remove_trailing_brs&&u.addNodeFilter("br",function(t){var n,r=t.length,i,o=s({},l.getBlockElements()),a=l.getNonEmptyElements(),c,u,d,f,p,h;for(o.body=1,n=0;r>n;n++)if(i=t[n],c=i.parent,o[i.parent.name]&&i===c.lastChild){for(d=i.prev;d;){if(f=d.name,"span"!==f||"bookmark"!==d.attr("data-mce-type")){if("br"!==f)break;if("br"===f){i=null;break}}d=d.prev}i&&(i.remove(),c.isEmpty(a)&&(p=l.getElementRule(c.name),p&&(p.removeEmpty?c.remove():p.paddEmpty&&(c.empty().append(new e("#text",3)).value="\xa0"))))}else{for(u=i;c&&c.firstChild===u&&c.lastChild===u&&(u=c,!o[c.name]);)c=c.parent;u===c&&(h=new e("#text",3),h.value="\xa0",i.replace(h))}}),r.allow_html_in_named_anchor||u.addAttributeFilter("id,name",function(e){for(var t=e.length,n,r,i,o;t--;)if(o=e[t],"a"===o.name&&o.firstChild&&!o.attr("href")){i=o.parent,n=o.lastChild;do r=n.prev,i.insert(n,o),n=r;while(n)}}),r.validate&&l.getValidClasses()&&u.addAttributeFilter("class",function(e){for(var t=e.length,n,r,i,o,a,s=l.getValidClasses(),c,u;t--;){for(n=e[t],r=n.attr("class").split(" "),a="",i=0;i0&&(f=r[r.length-1],f.length>0&&"\n"!==f&&r.push("\n")),r.push("<",e),t)for(c=0,u=t.length;u>c;c++)d=t[c],r.push(" ",d.name,'="',s(d.value,!0),'"');r[r.length]=!n||l?">":" />",n&&i&&a[e]&&r.length>0&&(f=r[r.length-1],f.length>0&&"\n"!==f&&r.push("\n"))},end:function(e){var t;r.push(""),i&&a[e]&&r.length>0&&(t=r[r.length-1],t.length>0&&"\n"!==t&&r.push("\n"))},text:function(e,t){e.length>0&&(r[r.length]=t?e:s(e))},cdata:function(e){r.push("")},comment:function(e){r.push("")},pi:function(e,t){t?r.push(""):r.push(""),i&&r.push("\n")},doctype:function(e){r.push("",i?"\n":"")},reset:function(){r.length=0},getContent:function(){return r.join("").replace(/\n$/,"")}}}}),r(T,[S,E],function(e,t){return function(n,r){var i=this,o=new e(n);n=n||{},n.validate="validate"in n?n.validate:!0,i.schema=r=r||new t,i.writer=o,i.serialize=function(e){function t(e){var n=i[e.type],s,l,c,u,d,f,p,h,m;if(n)n(e);else{if(s=e.name,l=e.shortEnded,c=e.attributes,a&&c&&c.length>1){for(f=[],f.map={},m=r.getElementRule(e.name),p=0,h=m.attributesOrder.length;h>p;p++)u=m.attributesOrder[p],u in c.map&&(d=c.map[u],f.map[u]=d,f.push({name:u,value:d}));for(p=0,h=c.length;h>p;p++)u=c[p].name,u in f.map||(d=c.map[u],f.map[u]=d,f.push({name:u,value:d}));c=f}if(o.start(e.name,c,l),!l){if(e=e.firstChild)do t(e);while(e=e.next);o.end(s)}}}var i,a;return a=n.validate,i={3:function(e){o.text(e.value,e.raw)},8:function(e){o.comment(e.value)},7:function(e){o.pi(e.name,e.value)},10:function(e){o.doctype(e.value)},4:function(e){o.cdata(e.value)},11:function(e){if(e=e.firstChild)do t(e);while(e=e.next)}},o.reset(),1!=e.type||n.inner?i[11](e):t(e),o.getContent()}}}),r(R,[y,k,g,T,_,E,u,d],function(e,t,n,r,i,o,a,s){var l=s.each,c=s.trim,u=e.DOM;return function(e,i){var s,d,f;return i&&(s=i.dom,d=i.schema),s=s||u,d=d||new o(e),e.entity_encoding=e.entity_encoding||"named",e.remove_trailing_brs="remove_trailing_brs"in e?e.remove_trailing_brs:!0,f=new t(e,d),f.addAttributeFilter("data-mce-tabindex",function(e,t){for(var n=e.length,r;n--;)r=e[n],r.attr("tabindex",r.attributes.map["data-mce-tabindex"]),r.attr(t,null)}),f.addAttributeFilter("src,href,style",function(t,n){for(var r=t.length,i,o,a="data-mce-"+n,l=e.url_converter,c=e.url_converter_scope,u;r--;)i=t[r],o=i.attributes.map[a],o!==u?(i.attr(n,o.length>0?o:null),i.attr(a,null)):(o=i.attributes.map[n],"style"===n?o=s.serializeStyle(s.parseStyle(o),i.name):l&&(o=l.call(c,o,n,i.name)),i.attr(n,o.length>0?o:null))}),f.addAttributeFilter("class",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.attr("class"),r&&(r=n.attr("class").replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),n.attr("class",r.length>0?r:null))}),f.addAttributeFilter("data-mce-type",function(e,t,n){for(var r=e.length,i;r--;)i=e[r],"bookmark"!==i.attributes.map["data-mce-type"]||n.cleanup||i.remove()}),f.addNodeFilter("noscript",function(e){for(var t=e.length,r;t--;)r=e[t].firstChild,r&&(r.value=n.decode(r.value))}),f.addNodeFilter("script,style",function(e,t){function n(e){return e.replace(/()/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")}for(var r=e.length,i,o,a;r--;)i=e[r],o=i.firstChild?i.firstChild.value:"","script"===t?(a=i.attr("type"),a&&i.attr("type","mce-no/type"==a?null:a.replace(/^mce\-/,"")),o.length>0&&(i.firstChild.value="// ")):o.length>0&&(i.firstChild.value="")}),f.addNodeFilter("#comment",function(e){for(var t=e.length,n;t--;)n=e[t],0===n.value.indexOf("[CDATA[")?(n.name="#cdata",n.type=4,n.value=n.value.replace(/^\[CDATA\[|\]\]$/g,"")):0===n.value.indexOf("mce:protected ")&&(n.name="#text",n.type=3,n.raw=!0,n.value=unescape(n.value).substr(14))}),f.addNodeFilter("xml:namespace,input",function(e,t){for(var n=e.length,r;n--;)r=e[n],7===r.type?r.remove():1===r.type&&("input"!==t||"type"in r.attributes.map||r.attr("type","text"))}),e.fix_list_elements&&f.addNodeFilter("ul,ol",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.parent,("ul"===r.name||"ol"===r.name)&&n.prev&&"li"===n.prev.name&&n.prev.append(n)}),f.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-type,data-mce-resize",function(e,t){for(var n=e.length;n--;)e[n].attr(t,null)}),{schema:d,addNodeFilter:f.addNodeFilter,addAttributeFilter:f.addAttributeFilter,serialize:function(t,n){var i=this,o,u,p,h,m;return a.ie&&s.select("script,style,select,map").length>0?(m=t.innerHTML,t=t.cloneNode(!1),s.setHTML(t,m)):t=t.cloneNode(!0),o=t.ownerDocument.implementation,o.createHTMLDocument&&(u=o.createHTMLDocument(""),l("BODY"==t.nodeName?t.childNodes:[t],function(e){u.body.appendChild(u.importNode(e,!0))}),t="BODY"!=t.nodeName?u.body.firstChild:u.body,p=s.doc,s.doc=u),n=n||{},n.format=n.format||"html",n.selection&&(n.forced_root_block=""),n.no_events||(n.node=t,i.onPreProcess(n)),h=new r(e,d),n.content=h.serialize(f.parse(c(n.getInner?t.innerHTML:s.getOuterHTML(t)),n)),n.cleanup||(n.content=n.content.replace(/\uFEFF/g,"")),n.no_events||i.onPostProcess(n),p&&(s.doc=p),n.node=null,n.content},addRules:function(e){d.addValidElements(e)},setRules:function(e){d.setValidElements(e)},onPreProcess:function(e){i&&i.fire("PreProcess",e)},onPostProcess:function(e){i&&i.fire("PostProcess",e)}}}}),r(A,[],function(){function e(e){function t(t,n){var r,i=0,o,a,s,l,c,u,d=-1,f;if(r=t.duplicate(),r.collapse(n),f=r.parentElement(),f.ownerDocument===e.dom.doc){for(;"false"===f.contentEditable;)f=f.parentNode;if(!f.hasChildNodes())return{node:f,inside:1};for(s=f.children,o=s.length-1;o>=i;)if(u=Math.floor((i+o)/2),l=s[u],r.moveToElementText(l),d=r.compareEndPoints(n?"StartToStart":"EndToEnd",t),d>0)o=u-1;else{if(!(0>d))return{node:l};i=u+1}if(0>d)for(l?r.collapse(!1):(r.moveToElementText(f),r.collapse(!0),l=f,a=!0),c=0;0!==r.compareEndPoints(n?"StartToStart":"StartToEnd",t)&&0!==r.move("character",1)&&f==r.parentElement();)c++;else for(r.collapse(!0),c=0;0!==r.compareEndPoints(n?"StartToStart":"StartToEnd",t)&&0!==r.move("character",-1)&&f==r.parentElement();)c++;return{node:l,position:d,offset:c,inside:a}}}function n(){function n(e){var n=t(o,e),r,i,s=0,l,c,u;if(r=n.node,i=n.offset,n.inside&&!r.hasChildNodes())return void a[e?"setStart":"setEnd"](r,0);if(i===c)return void a[e?"setStartBefore":"setEndAfter"](r);if(n.position<0){if(l=n.inside?r.firstChild:r.nextSibling,!l)return void a[e?"setStartAfter":"setEndAfter"](r);if(!i)return void(3==l.nodeType?a[e?"setStart":"setEnd"](l,0):a[e?"setStartBefore":"setEndBefore"](l));for(;l;){if(3==l.nodeType&&(u=l.nodeValue,s+=u.length,s>=i)){r=l,s-=i,s=u.length-s;break}l=l.nextSibling}}else{if(l=r.previousSibling,!l)return a[e?"setStartBefore":"setEndBefore"](r);if(!i)return void(3==r.nodeType?a[e?"setStart":"setEnd"](l,r.nodeValue.length):a[e?"setStartAfter":"setEndAfter"](l));for(;l;){if(3==l.nodeType&&(s+=l.nodeValue.length,s>=i)){r=l,s-=i;break}l=l.previousSibling}}a[e?"setStart":"setEnd"](r,s)}var o=e.getRng(),a=i.createRng(),s,l,c,u,d;if(s=o.item?o.item(0):o.parentElement(),s.ownerDocument!=i.doc)return a;if(l=e.isCollapsed(),o.item)return a.setStart(s.parentNode,i.nodeIndex(s)),a.setEnd(a.startContainer,a.startOffset+1),a;try{n(!0),l||n()}catch(f){if(-2147024809!=f.number)throw f;d=r.getBookmark(2),c=o.duplicate(),c.collapse(!0),s=c.parentElement(),l||(c=o.duplicate(),c.collapse(!1),u=c.parentElement(),u.innerHTML=u.innerHTML),s.innerHTML=s.innerHTML,r.moveToBookmark(d),o=e.getRng(),n(!0),l||n()}return a}var r=this,i=e.dom,o=!1;this.getBookmark=function(n){function r(e){var t,n,r,o,a=[];for(t=e.parentNode,n=i.getRoot().parentNode;t!=n&&9!==t.nodeType;){for(r=t.children,o=r.length;o--;)if(e===r[o]){a.push(o);break}e=t,t=t.parentNode}return a}function o(e){var n;return n=t(a,e),n?{position:n.position,offset:n.offset,indexes:r(n.node),inside:n.inside}:void 0}var a=e.getRng(),s={};return 2===n&&(a.item?s.start={ctrl:!0,indexes:r(a.item(0))}:(s.start=o(!0),e.isCollapsed()||(s.end=o()))),s},this.moveToBookmark=function(e){function t(e){var t,n,r,o;for(t=i.getRoot(),n=e.length-1;n>=0;n--)o=t.children,r=e[n],r<=o.length-1&&(t=o[r]);return t}function n(n){var i=e[n?"start":"end"],a,s,l,c;i&&(a=i.position>0,s=o.createTextRange(),s.moveToElementText(t(i.indexes)),c=i.offset,c!==l?(s.collapse(i.inside||a),s.moveStart("character",a?-c:c)):s.collapse(n),r.setEndPoint(n?"StartToStart":"EndToStart",s),n&&r.collapse(!0))}var r,o=i.doc.body;e.start&&(e.start.ctrl?(r=o.createControlRange(),r.addElement(t(e.start.indexes)),r.select()):(r=o.createTextRange(),n(!0),n(),r.select()))},this.addRange=function(t){function n(e){var t,n,a,d,h;a=i.create("a"),t=e?s:c,n=e?l:u,d=r.duplicate(),(t==f||t==f.documentElement)&&(t=p,n=0),3==t.nodeType?(t.parentNode.insertBefore(a,t),d.moveToElementText(a),d.moveStart("character",n),i.remove(a),r.setEndPoint(e?"StartToStart":"EndToEnd",d)):(h=t.childNodes,h.length?(n>=h.length?i.insertAfter(a,h[h.length-1]):t.insertBefore(a,h[n]),d.moveToElementText(a)):t.canHaveHTML&&(t.innerHTML="",a=t.firstChild,d.moveToElementText(a),d.collapse(o)),r.setEndPoint(e?"StartToStart":"EndToEnd",d),i.remove(a))}var r,a,s,l,c,u,d,f=e.dom.doc,p=f.body,h,m;if(s=t.startContainer,l=t.startOffset,c=t.endContainer,u=t.endOffset,r=p.createTextRange(),s==c&&1==s.nodeType){if(l==u&&!s.hasChildNodes()){if(s.canHaveHTML)return d=s.previousSibling,d&&!d.hasChildNodes()&&i.isBlock(d)?d.innerHTML="":d=null,s.innerHTML="",r.moveToElementText(s.lastChild),r.select(),i.doc.selection.clear(),s.innerHTML="",void(d&&(d.innerHTML=""));l=i.nodeIndex(s),s=s.parentNode}if(l==u-1)try{if(m=s.childNodes[l],a=p.createControlRange(),a.addElement(m),a.select(),h=e.getRng(),h.item&&m===h.item(0))return}catch(g){}}n(!0),n(),r.select()},this.getRangeAt=n}return e}),r(B,[u],function(e){return{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(e){return e.shiftKey||e.ctrlKey||e.altKey||this.metaKeyPressed(e)},metaKeyPressed:function(t){return e.mac?t.metaKey:t.ctrlKey&&!t.altKey}}}),r(D,[B,d,u],function(e,t,n){return function(r,i){function o(e){var t=i.settings.object_resizing;return t===!1||n.iOS?!1:("string"!=typeof t&&(t="table,img,div"),"false"===e.getAttribute("data-mce-resize")?!1:i.dom.is(e,t))}function a(t){var n,r,o,a,s;n=t.screenX-T,r=t.screenY-R,P=n*k[2]+D,O=r*k[3]+L,P=5>P?5:P,O=5>O?5:O,o="IMG"==w.nodeName&&i.settings.resize_img_proportional!==!1?!e.modifierPressed(t):e.modifierPressed(t)||"IMG"==w.nodeName&&k[2]*k[3]!==0,o&&(W(n)>W(r)?(O=V(P*H),P=V(O/H)):(P=V(O/H),O=V(P*H))),C.setStyles(_,{width:P,height:O}),a=k.startPos.x+n,s=k.startPos.y+r,a=a>0?a:0,s=s>0?s:0,C.setStyles(E,{left:a,top:s,display:"block"}),E.innerHTML=P+" × "+O,k[2]<0&&_.clientWidth<=P&&C.setStyle(_,"left",A+(D-P)),k[3]<0&&_.clientHeight<=O&&C.setStyle(_,"top",B+(L-O)),n=U.scrollWidth-$,r=U.scrollHeight-q,n+r!==0&&C.setStyles(E,{left:a-n,top:s-r}),M||(i.fire("ObjectResizeStart",{target:w,width:D,height:L}),M=!0)}function s(){function e(e,t){t&&(w.style[e]||!i.schema.isValid(w.nodeName.toLowerCase(),e)?C.setStyle(w,e,t):C.setAttrib(w,e,t))}M=!1,e("width",P),e("height",O),C.unbind(I,"mousemove",a),C.unbind(I,"mouseup",s),F!=I&&(C.unbind(F,"mousemove",a),C.unbind(F,"mouseup",s)),C.remove(_),C.remove(E),z&&"TABLE"!=w.nodeName||l(w),i.fire("ObjectResized",{target:w,width:P,height:O}),C.setAttrib(w,"style",C.getAttrib(w,"style")),i.nodeChanged()}function l(e,t,r){var l,u,d,f,p;g(),l=C.getPos(e,U),A=l.x,B=l.y,p=e.getBoundingClientRect(),u=p.width||p.right-p.left,d=p.height||p.bottom-p.top,w!=e&&(m(),w=e,P=O=0),f=i.fire("ObjectSelected",{target:e}),o(e)&&!f.isDefaultPrevented()?x(N,function(e,i){function o(t){T=t.screenX,R=t.screenY,D=w.clientWidth,L=w.clientHeight,H=L/D,k=e,e.startPos={x:u*e[0]+A,y:d*e[1]+B},$=U.scrollWidth,q=U.scrollHeight,_=w.cloneNode(!0),C.addClass(_,"mce-clonedresizable"),C.setAttrib(_,"data-mce-bogus","all"),_.contentEditable=!1,_.unSelectabe=!0,C.setStyles(_,{left:A,top:B,margin:0}),_.removeAttribute("data-mce-selected"),U.appendChild(_),C.bind(I,"mousemove",a),C.bind(I,"mouseup",s),F!=I&&(C.bind(F,"mousemove",a),C.bind(F,"mouseup",s)),E=C.add(U,"div",{"class":"mce-resize-helper","data-mce-bogus":"all"},D+" × "+L)}var l,c;return t?void(i==t&&o(r)):(l=C.get("mceResizeHandle"+i),l?C.show(l):(c=U,l=C.add(c,"div",{id:"mceResizeHandle"+i,"data-mce-bogus":"all","class":"mce-resizehandle",unselectable:!0,style:"cursor:"+i+"-resize; margin:0; padding:0"}),n.ie&&(l.contentEditable=!1)),e.elm||(C.bind(l,"mousedown",function(e){e.stopImmediatePropagation(),e.preventDefault(),o(e)}),e.elm=l),void C.setStyles(l,{left:u*e[0]+A-l.offsetWidth/2,top:d*e[1]+B-l.offsetHeight/2}))}):c(),w.setAttribute("data-mce-selected","1")}function c(){var e,t;g(),w&&w.removeAttribute("data-mce-selected");for(e in N)t=C.get("mceResizeHandle"+e),t&&(C.unbind(t),C.remove(t))}function u(e){function t(e,t){if(e)do if(e===t)return!0;while(e=e.parentNode)}var n,i;if(!M)return x(C.select("img[data-mce-selected],hr[data-mce-selected]"),function(e){e.removeAttribute("data-mce-selected")}),i="mousedown"==e.type?e.target:r.getNode(),i=C.$(i).closest(z?"table":"table,img,hr")[0],t(i,U)&&(v(),n=r.getStart(!0),t(n,i)&&t(r.getEnd(!0),i)&&(!z||i!=n&&"IMG"!==n.nodeName))?void l(i):void c()}function d(e,t,n){e&&e.attachEvent&&e.attachEvent("on"+t,n)}function f(e,t,n){e&&e.detachEvent&&e.detachEvent("on"+t,n)}function p(e){var t=e.srcElement,n,r,o,a,s,c,u;n=t.getBoundingClientRect(),c=S.clientX-n.left,u=S.clientY-n.top;for(r in N)if(o=N[r],a=t.offsetWidth*o[0],s=t.offsetHeight*o[1],W(a-c)<8&&W(s-u)<8){k=o;break}M=!0,i.fire("ObjectResizeStart",{target:w,width:w.clientWidth,height:w.clientHeight}),i.getDoc().selection.empty(),l(t,r,S)}function h(e){var t=e.srcElement;if(t!=w){if(i.fire("ObjectSelected",{target:t}),m(),0===t.id.indexOf("mceResizeHandle"))return void(e.returnValue=!1);("IMG"==t.nodeName||"TABLE"==t.nodeName)&&(c(),w=t,d(t,"resizestart",p))}}function m(){f(w,"resizestart",p)}function g(){for(var e in N){var t=N[e];t.elm&&(C.unbind(t.elm),delete t.elm)}}function v(){try{i.getDoc().execCommand("enableObjectResizing",!1,!1)}catch(e){}}function y(e){var t;if(z){t=I.body.createControlRange();try{return t.addElement(e),t.select(),!0}catch(n){}}}function b(){w=_=null,z&&(m(),f(U,"controlselect",h))}var C=i.dom,x=t.each,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I=i.getDoc(),F=document,z=n.ie&&n.ie<11,W=Math.abs,V=Math.round,U=i.getBody(),$,q;N={n:[.5,0,0,-1],e:[1,.5,1,0],s:[.5,1,0,1],w:[0,.5,-1,0],nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]};var j=".mce-content-body";return i.contentStyles.push(j+" div.mce-resizehandle {position: absolute;border: 1px solid black;background: #FFF;width: 5px;height: 5px;z-index: 10000}"+j+" .mce-resizehandle:hover {background: #000}"+j+" img[data-mce-selected], hr[data-mce-selected] {outline: 1px solid black;resize: none}"+j+" .mce-clonedresizable {position: absolute;"+(n.gecko?"":"outline: 1px dashed black;")+"opacity: .5;filter: alpha(opacity=50);z-index: 10000}"+j+" .mce-resize-helper {background: #555;background: rgba(0,0,0,0.75);border-radius: 3px;border: 1px;color: white;display: none;font-family: sans-serif;font-size: 12px;white-space: nowrap;line-height: 14px;margin: 5px 10px;padding: 5px;position: absolute;z-index: 10001}"),i.on("init",function(){z?(i.on("ObjectResized",function(e){"TABLE"!=e.target.nodeName&&(c(),y(e.target))}),d(U,"controlselect",h),i.on("mousedown",function(e){S=e})):(v(),n.ie>=11&&(i.on("mouseup",function(e){var t=e.target.nodeName;!M&&/^(TABLE|IMG|HR)$/.test(t)&&(i.selection.select(e.target,"TABLE"==t),i.nodeChanged())}),i.dom.bind(U,"mscontrolselect",function(e){/^(TABLE|IMG|HR)$/.test(e.target.nodeName)&&(e.preventDefault(),"IMG"==e.target.tagName&&window.setTimeout(function(){i.selection.select(e.target)},0))}))),i.on("nodechange ResizeEditor",u),i.on("keydown keyup",function(e){w&&"TABLE"==w.nodeName&&u(e)}),i.on("hide",c)}),i.on("remove",g),{isResizable:o,showResizeRect:l,hideResizeRect:c,updateResizeRect:u,controlSelect:y,destroy:b}}}),r(L,[u,d],function(e,t){function n(n){var r=n.dom;this.getBookmark=function(e,i){function o(e,n){var i=0;return t.each(r.select(e),function(e,t){e==n&&(i=t)}),i}function a(e){function t(t){var n,r,i,o=t?"start":"end";n=e[o+"Container"],r=e[o+"Offset"],1==n.nodeType&&"TR"==n.nodeName&&(i=n.childNodes,n=i[Math.min(t?r:r-1,i.length-1)],n&&(r=t?0:n.childNodes.length,e["set"+(t?"Start":"End")](n,r)))}return t(!0),t(),e}function s(){function e(e,t){var n=e[t?"startContainer":"endContainer"],a=e[t?"startOffset":"endOffset"],s=[],l,c,u=0;if(3==n.nodeType){if(i)for(l=n.previousSibling;l&&3==l.nodeType;l=l.previousSibling)a+=l.nodeValue.length;s.push(a)}else c=n.childNodes,a>=c.length&&c.length&&(u=1,a=Math.max(0,c.length-1)),s.push(r.nodeIndex(c[a],i)+u);for(;n&&n!=o;n=n.parentNode)s.push(r.nodeIndex(n,i));return s}var t=n.getRng(!0),o=r.getRoot(),a={};return a.start=e(t,!0),n.isCollapsed()||(a.end=e(t)),a}var l,c,u,d,f,p,h="",m;if(2==e)return p=n.getNode(),f=p?p.nodeName:null,"IMG"==f?{name:f,index:o(f,p)}:n.tridentSel?n.tridentSel.getBookmark(e):s();if(e)return{rng:n.getRng()};if(l=n.getRng(),u=r.uniqueId(),d=n.isCollapsed(),m="overflow:hidden;line-height:0px",l.duplicate||l.item){if(l.item)return p=l.item(0),f=p.nodeName,{name:f,index:o(f,p)};c=l.duplicate();try{l.collapse(),l.pasteHTML(''+h+""),d||(c.collapse(!1),l.moveToElementText(c.parentElement()),0===l.compareEndPoints("StartToEnd",c)&&c.move("character",-1),c.pasteHTML(''+h+""))}catch(g){return null}}else{if(p=n.getNode(),f=p.nodeName,"IMG"==f)return{name:f,index:o(f,p)};c=a(l.cloneRange()),d||(c.collapse(!1),c.insertNode(r.create("span",{"data-mce-type":"bookmark",id:u+"_end",style:m},h))),l=a(l),l.collapse(!0),l.insertNode(r.create("span",{"data-mce-type":"bookmark",id:u+"_start",style:m},h))}return n.moveToBookmark({id:u,keep:1}),{id:u}},this.moveToBookmark=function(i){function o(e){var t=i[e?"start":"end"],n,r,o,a;if(t){for(o=t[0],r=c,n=t.length-1;n>=1;n--){if(a=r.childNodes,t[n]>a.length-1)return;r=a[t[n]]}3===r.nodeType&&(o=Math.min(t[0],r.nodeValue.length)),1===r.nodeType&&(o=Math.min(t[0],r.childNodes.length)),e?l.setStart(r,o):l.setEnd(r,o)}return!0}function a(n){var o=r.get(i.id+"_"+n),a,s,l,c,h=i.keep;if(o&&(a=o.parentNode,"start"==n?(h?(a=o.firstChild,s=1):s=r.nodeIndex(o),u=d=a,f=p=s):(h?(a=o.firstChild,s=1):s=r.nodeIndex(o),d=a,p=s),!h)){for(c=o.previousSibling,l=o.nextSibling,t.each(t.grep(o.childNodes),function(e){3==e.nodeType&&(e.nodeValue=e.nodeValue.replace(/\uFEFF/g,""))});o=r.get(i.id+"_"+n);)r.remove(o,1);c&&l&&c.nodeType==l.nodeType&&3==c.nodeType&&!e.opera&&(s=c.nodeValue.length,c.appendData(l.nodeValue),r.remove(l),"start"==n?(u=d=c,f=p=s):(d=c,p=s))}}function s(t){return!r.isBlock(t)||t.innerHTML||e.ie||(t.innerHTML='
      '),t}var l,c,u,d,f,p;if(i)if(i.start){if(l=r.createRng(),c=r.getRoot(),n.tridentSel)return n.tridentSel.moveToBookmark(i);o(!0)&&o()&&n.setRng(l)}else i.id?(a("start"),a("end"),u&&(l=r.createRng(),l.setStart(s(u),f),l.setEnd(s(d),p),n.setRng(l))):i.name?n.select(r.select(i.name)[i.index]):i.rng&&n.setRng(i.rng)}}return n.isBookmarkNode=function(e){return e&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type")},n}),r(H,[h,A,D,x,L,u,d],function(e,n,r,i,o,a,s){function l(e,t,i,a){var s=this;s.dom=e,s.win=t,s.serializer=i,s.editor=a,s.bookmarkManager=new o(s),s.controlSelection=new r(s,a),s.win.getSelection||(s.tridentSel=new n(s))}var c=s.each,u=s.trim,d=a.ie;return l.prototype={setCursorLocation:function(e,t){var n=this,r=n.dom.createRng();e?(r.setStart(e,t),r.setEnd(e,t),n.setRng(r),n.collapse(!1)):(n._moveEndPoint(r,n.editor.getBody(),!0),n.setRng(r))},getContent:function(e){var n=this,r=n.getRng(),i=n.dom.create("body"),o=n.getSel(),a,s,l;return e=e||{},a=s="",e.get=!0,e.format=e.format||"html",e.selection=!0,n.editor.fire("BeforeGetContent",e),"text"==e.format?n.isCollapsed()?"":r.text||(o.toString?o.toString():""):(r.cloneContents?(l=r.cloneContents(),l&&i.appendChild(l)):r.item!==t||r.htmlText!==t?(i.innerHTML="
      "+(r.item?r.item(0).outerHTML:r.htmlText),i.removeChild(i.firstChild)):i.innerHTML=r.toString(),/^\s/.test(i.innerHTML)&&(a=" "),/\s+$/.test(i.innerHTML)&&(s=" "),e.getInner=!0,e.content=n.isCollapsed()?"":a+n.serializer.serialize(i,e)+s,n.editor.fire("GetContent",e),e.content)},setContent:function(e,t){var n=this,r=n.getRng(),i,o=n.win.document,a,s;if(t=t||{format:"html"},t.set=!0,t.selection=!0,e=t.content=e,t.no_events||n.editor.fire("BeforeSetContent",t),e=t.content,r.insertNode){e+='_',r.startContainer==o&&r.endContainer==o?o.body.innerHTML=e:(r.deleteContents(),0===o.body.childNodes.length?o.body.innerHTML=e:r.createContextualFragment?r.insertNode(r.createContextualFragment(e)):(a=o.createDocumentFragment(),s=o.createElement("div"),a.appendChild(s),s.outerHTML=e,r.insertNode(a))),i=n.dom.get("__caret"),r=o.createRange(),r.setStartBefore(i),r.setEndBefore(i),n.setRng(r),n.dom.remove("__caret");try{n.setRng(r)}catch(l){}}else r.item&&(o.execCommand("Delete",!1,null),r=n.getRng()),/^\s+/.test(e)?(r.pasteHTML('_'+e),n.dom.remove("__mce_tmp")):r.pasteHTML(e);t.no_events||n.editor.fire("SetContent",t)},getStart:function(e){var t=this,n=t.getRng(),r,i,o,a;if(n.duplicate||n.item){if(n.item)return n.item(0);for(o=n.duplicate(),o.collapse(1),r=o.parentElement(),r.ownerDocument!==t.dom.doc&&(r=t.dom.getRoot()),i=a=n.parentElement();a=a.parentNode;)if(a==r){r=i;break}return r}return r=n.startContainer,1==r.nodeType&&r.hasChildNodes()&&(e&&n.collapsed||(r=r.childNodes[Math.min(r.childNodes.length-1,n.startOffset)])),r&&3==r.nodeType?r.parentNode:r},getEnd:function(e){var t=this,n=t.getRng(),r,i;return n.duplicate||n.item?n.item?n.item(0):(n=n.duplicate(),n.collapse(0),r=n.parentElement(),r.ownerDocument!==t.dom.doc&&(r=t.dom.getRoot()),r&&"BODY"==r.nodeName?r.lastChild||r:r):(r=n.endContainer,i=n.endOffset,1==r.nodeType&&r.hasChildNodes()&&(e&&n.collapsed||(r=r.childNodes[i>0?i-1:i])),r&&3==r.nodeType?r.parentNode:r)},getBookmark:function(e,t){return this.bookmarkManager.getBookmark(e,t)},moveToBookmark:function(e){return this.bookmarkManager.moveToBookmark(e)},select:function(e,t){var n=this,r=n.dom,i=r.createRng(),o;if(n.lastFocusBookmark=null,e){if(!t&&n.controlSelection.controlSelect(e))return;o=r.nodeIndex(e),i.setStart(e.parentNode,o),i.setEnd(e.parentNode,o+1),t&&(n._moveEndPoint(i,e,!0),n._moveEndPoint(i,e)),n.setRng(i)}return e},isCollapsed:function(){var e=this,t=e.getRng(),n=e.getSel();return!t||t.item?!1:t.compareEndPoints?0===t.compareEndPoints("StartToEnd",t):!n||t.collapsed},collapse:function(e){var t=this,n=t.getRng(),r;n.item&&(r=n.item(0),n=t.win.document.body.createTextRange(),n.moveToElementText(r)),n.collapse(!!e),t.setRng(n)},getSel:function(){var e=this.win;return e.getSelection?e.getSelection():e.document.selection},getRng:function(e){function t(e,t,n){try{return t.compareBoundaryPoints(e,n)}catch(r){return-1}}var n=this,r,i,o,a=n.win.document,s;if(!e&&n.lastFocusBookmark){var l=n.lastFocusBookmark;return l.startContainer?(i=a.createRange(),i.setStart(l.startContainer,l.startOffset),i.setEnd(l.endContainer,l.endOffset)):i=l,i}if(e&&n.tridentSel)return n.tridentSel.getRangeAt(0);try{(r=n.getSel())&&(i=r.rangeCount>0?r.getRangeAt(0):r.createRange?r.createRange():a.createRange())}catch(c){}if(d&&i&&i.setStart&&a.selection){try{s=a.selection.createRange()}catch(c){}s&&s.item&&(o=s.item(0),i=a.createRange(),i.setStartBefore(o),i.setEndAfter(o))}return i||(i=a.createRange?a.createRange():a.body.createTextRange()),i.setStart&&9===i.startContainer.nodeType&&i.collapsed&&(o=n.dom.getRoot(),i.setStart(o,0),i.setEnd(o,0)),n.selectedRange&&n.explicitRange&&(0===t(i.START_TO_START,i,n.selectedRange)&&0===t(i.END_TO_END,i,n.selectedRange)?i=n.explicitRange:(n.selectedRange=null,n.explicitRange=null)),i},setRng:function(e,t){var n=this,r;if(e)if(e.select)try{e.select()}catch(i){}else if(n.tridentSel){if(e.cloneRange)try{return void n.tridentSel.addRange(e)}catch(i){}}else if(r=n.getSel()){n.explicitRange=e;try{r.removeAllRanges(),r.addRange(e)}catch(i){}t===!1&&r.extend&&(r.collapse(e.endContainer,e.endOffset),r.extend(e.startContainer,e.startOffset)),n.selectedRange=r.rangeCount>0?r.getRangeAt(0):null}},setNode:function(e){var t=this;return t.setContent(t.dom.getOuterHTML(e)),e},getNode:function(){function e(e,t){for(var n=e;e&&3===e.nodeType&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||n}var t=this,n=t.getRng(),r,i=n.startContainer,o=n.endContainer,a=n.startOffset,s=n.endOffset,l=t.dom.getRoot();return n?n.setStart?(r=n.commonAncestorContainer,!n.collapsed&&(i==o&&2>s-a&&i.hasChildNodes()&&(r=i.childNodes[a]),3===i.nodeType&&3===o.nodeType&&(i=i.length===a?e(i.nextSibling,!0):i.parentNode,o=0===s?e(o.previousSibling,!1):o.parentNode,i&&i===o))?i:r&&3==r.nodeType?r.parentNode:r):(r=n.item?n.item(0):n.parentElement(),r.ownerDocument!==t.win.document&&(r=l),r):l},getSelectedBlocks:function(t,n){var r=this,i=r.dom,o,a,s=[];if(a=i.getRoot(),t=i.getParent(t||r.getStart(),i.isBlock),n=i.getParent(n||r.getEnd(),i.isBlock),t&&t!=a&&s.push(t),t&&n&&t!=n){o=t;for(var l=new e(t,a);(o=l.next())&&o!=n;)i.isBlock(o)&&s.push(o)}return n&&t!=n&&n!=a&&s.push(n),s},isForward:function(){var e=this.dom,t=this.getSel(),n,r;return t&&t.anchorNode&&t.focusNode?(n=e.createRng(),n.setStart(t.anchorNode,t.anchorOffset),n.collapse(!0),r=e.createRng(),r.setStart(t.focusNode,t.focusOffset),r.collapse(!0),n.compareBoundaryPoints(n.START_TO_START,r)<=0):!0},normalize:function(){var e=this,t=e.getRng();return!d&&new i(e.dom).normalize(t)&&e.setRng(t,e.isForward()),t},selectorChanged:function(e,t){var n=this,r;return n.selectorChangedData||(n.selectorChangedData={},r={},n.editor.on("NodeChange",function(e){var t=e.element,i=n.dom,o=i.getParents(t,null,i.getRoot()),a={};c(n.selectorChangedData,function(e,t){c(o,function(n){return i.is(n,t)?(r[t]||(c(e,function(e){e(!0,{node:n,selector:t,parents:o})}),r[t]=e),a[t]=e,!1):void 0})}),c(r,function(e,n){a[n]||(delete r[n],c(e,function(e){e(!1,{node:t,selector:n,parents:o})}))})})),n.selectorChangedData[e]||(n.selectorChangedData[e]=[]),n.selectorChangedData[e].push(t),n},getScrollContainer:function(){for(var e,t=this.dom.getRoot();t&&"BODY"!=t.nodeName;){if(t.scrollHeight>t.clientHeight){e=t;break}t=t.parentNode}return e},scrollIntoView:function(e){function t(e){for(var t=0,n=0,r=e;r&&r.nodeType;)t+=r.offsetLeft||0,n+=r.offsetTop||0,r=r.offsetParent;return{x:t,y:n}}var n,r,i=this,o=i.dom,a=o.getRoot(),s,l;if("BODY"!=a.nodeName){var c=i.getScrollContainer();if(c)return n=t(e).y-t(c).y,l=c.clientHeight,s=c.scrollTop,void((s>n||n+25>s+l)&&(c.scrollTop=s>n?n:n-l+25))}r=o.getViewPort(i.editor.getWin()),n=o.getPos(e).y,s=r.y,l=r.h,(ns+l)&&i.editor.getWin().scrollTo(0,s>n?n:n-l+25)},placeCaretAt:function(e,t){var n=this.editor.getDoc(),r,i;if(n.caretPositionFromPoint)i=n.caretPositionFromPoint(e,t),r=n.createRange(),r.setStart(i.offsetNode,i.offset),r.collapse(!0);else if(n.caretRangeFromPoint)r=n.caretRangeFromPoint(e,t);else if(n.body.createTextRange){r=n.body.createTextRange();try{r.moveToPoint(e,t),r.collapse(!0)}catch(o){r.collapse(t=e;e++)a.addShortcut("ctrl+"+e,"",["FormatBlock",!1,"h"+e]);a.addShortcut("ctrl+7","",["FormatBlock",!1,"p"]),a.addShortcut("ctrl+8","",["FormatBlock",!1,"div"]),a.addShortcut("ctrl+9","",["FormatBlock",!1,"address"])}function f(e){return e?V[e]:V}function p(e,t){e&&("string"!=typeof e?at(e,function(e,t){p(t,e)}):(t=t.length?t:[t],at(t,function(e){e.deep===tt&&(e.deep=!e.selector),e.split===tt&&(e.split=!e.selector||e.inline),e.remove===tt&&e.selector&&!e.inline&&(e.remove="none"),e.selector&&e.inline&&(e.mixed=!0,e.block_expand=!0),"string"==typeof e.classes&&(e.classes=e.classes.split(/\s+/))}),V[e]=t))}function h(e){return e&&V[e]&&delete V[e],V}function m(e){var t;return a.dom.getParent(e,function(e){return t=a.dom.getStyle(e,"text-decoration"),t&&"none"!==t}),t}function g(e){var t;1===e.nodeType&&e.parentNode&&1===e.parentNode.nodeType&&(t=m(e.parentNode),a.dom.getStyle(e,"color")&&t?a.dom.setStyle(e,"text-decoration",t):a.dom.getStyle(e,"textdecoration")===t&&a.dom.setStyle(e,"text-decoration",null))}function v(t,n,r){function i(e,t){if(t=t||d,e){if(t.onformat&&t.onformat(e,t,n,r),at(t.styles,function(t,r){U.setStyle(e,r,A(t,n))}),t.styles){var i=U.getAttrib(e,"style");i&&e.setAttribute("data-mce-style",i)}at(t.attributes,function(t,r){U.setAttrib(e,r,A(t,n))}),at(t.classes,function(t){t=A(t,n),U.hasClass(e,t)||U.addClass(e,t)})}}function o(){function t(t,n){var i=new e(n);for(r=i.current();r;r=i.prev())if(r.childNodes.length>1||r==t||"BR"==r.tagName)return r}var n=a.selection.getRng(),i=n.startContainer,o=n.endContainer;if(i!=o&&0===n.endOffset){var s=t(i,o),l=3==s.nodeType?s.length:s.childNodes.length;n.setEnd(s,l)}return n}function l(e,r,o){var a=[],l,f,p=!0;l=d.inline||d.block,f=U.create(l),i(f),q.walk(e,function(e){function r(e){var g,v,y,b,x;return x=p,g=e.nodeName.toLowerCase(),v=e.parentNode.nodeName.toLowerCase(),1===e.nodeType&&nt(e)&&(x=p,p="true"===nt(e),b=!0),S(g,"br")?(h=0,void(d.block&&U.remove(e))):d.wrapper&&C(e,t,n)?void(h=0):p&&!b&&d.block&&!d.wrapper&&s(g)&&j(v,l)?(e=U.rename(e,l),i(e),a.push(e),void(h=0)):d.selector&&(at(u,function(t){"collapsed"in t&&t.collapsed!==m||U.is(e,t.selector)&&!c(e)&&(i(e,t),y=!0)}),!d.inline||y)?void(h=0):void(!p||b||!j(l,g)||!j(v,l)||!o&&3===e.nodeType&&1===e.nodeValue.length&&65279===e.nodeValue.charCodeAt(0)||c(e)||d.inline&&Y(e)?(h=0,at(st(e.childNodes),r),b&&(p=x),h=0):(h||(h=U.clone(f,Q),e.parentNode.insertBefore(h,e),a.push(h)),h.appendChild(e)))}var h;at(e,r)}),d.links===!0&&at(a,function(e){function t(e){"A"===e.nodeName&&i(e,d),at(st(e.childNodes),t)}t(e)}),at(a,function(e){function r(e){var t=0;return at(e.childNodes,function(e){B(e)||ot(e)||t++}),t}function o(e){var t,n;return at(e.childNodes,function(e){return 1!=e.nodeType||ot(e)||c(e)?void 0:(t=e,Q)}),t&&!ot(t)&&k(t,d)&&(n=U.clone(t,Q),i(n),U.replace(n,e,Z),U.remove(t,1)),n||e}var s;if(s=r(e),(a.length>1||!Y(e))&&0===s)return void U.remove(e,1);if(d.inline||d.wrapper){if(d.exact||1!==s||(e=o(e)),at(u,function(t){at(U.select(t.inline,e),function(e){ot(e)||M(t,n,e,t.exact?e:null)})}),C(e.parentNode,t,n))return U.remove(e,1),e=0,Z;d.merge_with_parents&&U.getParent(e.parentNode,function(r){return C(r,t,n)?(U.remove(e,1),e=0,Z):void 0}),e&&d.merge_siblings!==!1&&(e=I(O(e),e),e=I(e,O(e,Z)))}})}var u=f(t),d=u[0],p,h,m=!r&&$.isCollapsed();if(d)if(r)r.nodeType?(h=U.createRng(),h.setStartBefore(r),h.setEndAfter(r),l(L(h,u),null,!0)):l(r,null,!0);else if(m&&d.inline&&!U.select("td.mce-item-selected,th.mce-item-selected").length)z("apply",t,n);else{var y=a.selection.getNode();K||!u[0].defaultBlock||U.getParent(y,U.isBlock)||v(u[0].defaultBlock),a.selection.setRng(o()),p=$.getBookmark(),l(L($.getRng(Z),u),p),d.styles&&(d.styles.color||d.styles.textDecoration)&&(lt(y,g,"childNodes"),g(y)),$.moveToBookmark(p),W($.getRng(Z)),a.nodeChanged()}}function y(e,t,n,r){function i(e){var n,r,o,a,s;if(1===e.nodeType&&nt(e)&&(a=y,y="true"===nt(e),s=!0),n=st(e.childNodes),y&&!s)for(r=0,o=p.length;o>r&&!M(p[r],t,e,e);r++);if(h.deep&&n.length){for(r=0,o=n.length;o>r;r++)i(n[r]);s&&(y=a)}}function o(n){var i;return at(l(n.parentNode).reverse(),function(n){var o;i||"_start"==n.id||"_end"==n.id||(o=C(n,e,t,r),o&&o.split!==!1&&(i=n))}),i}function s(e,n,r,i){var o,a,s,l,c,u;if(e){for(u=e.parentNode,o=n.parentNode;o&&o!=u;o=o.parentNode){for(a=U.clone(o,Q),c=0;c=0;o--){if(a=t[o].selector,!a||t[o].defaultBlock)return Z;for(i=r.length-1;i>=0;i--)if(U.is(r[i],a))return Z}return Q}function E(e,t,n){var r;return et||(et={},r={},a.on("NodeChange",function(e){var t=l(e.element),n={};t=i.grep(t,function(e){return 1==e.nodeType&&!e.getAttribute("data-mce-bogus")}),at(et,function(e,i){at(t,function(o){return C(o,i,{},e.similar)?(r[i]||(at(e,function(e){e(!0,{node:o,format:i,parents:t})}),r[i]=e),n[i]=e,!1):void 0})}),at(r,function(i,o){n[o]||(delete r[o],at(i,function(n){n(!1,{node:e.element,format:o,parents:t})}))})})),at(e.split(","),function(e){et[e]||(et[e]=[],et[e].similar=n),et[e].push(t)}),this}function N(e){return o.getCssText(a,e)}function k(e,t){return S(e,t.inline)?Z:S(e,t.block)?Z:t.selector?1==e.nodeType&&U.is(e,t.selector):void 0}function S(e,t){return e=e||"",t=t||"",e=""+(e.nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()==t.toLowerCase()}function T(e,t){return R(U.getStyle(e,t),t)}function R(e,t){return("color"==t||"backgroundColor"==t)&&(e=U.toHex(e)),"fontWeight"==t&&700==e&&(e="bold"),"fontFamily"==t&&(e=e.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),""+e}function A(e,t){return"string"!=typeof e?e=e(t):t&&(e=e.replace(/%(\w+)/g,function(e,n){return t[n]||e})),e}function B(e){return e&&3===e.nodeType&&/^([\t \r\n]+|)$/.test(e.nodeValue)}function D(e,t,n){var r=U.create(t,n);return e.parentNode.insertBefore(r,e),r.appendChild(e),r}function L(t,n,r){function i(e){function t(e){return"BR"==e.nodeName&&e.getAttribute("data-mce-bogus")&&!e.nextSibling}var r,i,o,a,s;if(r=i=e?g:y,a=e?"previousSibling":"nextSibling",s=U.getRoot(),3==r.nodeType&&!B(r)&&(e?v>0:bo?n:o,-1===n||r||n++):(n=a.indexOf(" ",t),o=a.indexOf("\xa0",t),n=-1!==n&&(-1===o||o>n)?n:o),n}var s,l,c,u;if(3===t.nodeType){if(c=o(t,n),-1!==c)return{container:t,offset:c};u=t}for(s=new e(t,U.getParent(t,Y)||a.getBody());l=s[i?"prev":"next"]();)if(3===l.nodeType){if(u=l,c=o(l),-1!==c)return{container:l,offset:c}}else if(Y(l))break;return u?(n=i?0:u.length,{container:u,offset:n}):void 0}function d(e,r){var i,o,a,s;for(3==e.nodeType&&0===e.nodeValue.length&&e[r]&&(e=e[r]),i=l(e),o=0;op?p:v],3==g.nodeType&&(v=0)),1==y.nodeType&&y.hasChildNodes()&&(p=y.childNodes.length-1,y=y.childNodes[b>p?p:b-1],3==y.nodeType&&(b=y.nodeValue.length)),g=c(g),y=c(y),(ot(g.parentNode)||ot(g))&&(g=ot(g)?g:g.parentNode,g=g.nextSibling||g,3==g.nodeType&&(v=0)),(ot(y.parentNode)||ot(y))&&(y=ot(y)?y:y.parentNode,y=y.previousSibling||y,3==y.nodeType&&(b=y.length)),n[0].inline&&(t.collapsed&&(m=u(g,v,!0),m&&(g=m.container,v=m.offset),m=u(y,b),m&&(y=m.container,b=m.offset)),h=o(y,b),h.node)){for(;h.node&&0===h.offset&&h.node.previousSibling;)h=o(h.node.previousSibling);h.node&&h.offset>0&&3===h.node.nodeType&&" "===h.node.nodeValue.charAt(h.offset-1)&&h.offset>1&&(y=h.node,y.splitText(h.offset-1))}return(n[0].inline||n[0].block_expand)&&(n[0].inline&&3==g.nodeType&&0!==v||(g=i(!0)),n[0].inline&&3==y.nodeType&&b!==y.nodeValue.length||(y=i())),n[0].selector&&n[0].expand!==Q&&!n[0].inline&&(g=d(g,"previousSibling"),y=d(y,"nextSibling")),(n[0].block||n[0].selector)&&(g=f(g,"previousSibling"),y=f(y,"nextSibling"),n[0].block&&(Y(g)||(g=i(!0)),Y(y)||(y=i()))),1==g.nodeType&&(v=G(g),g=g.parentNode),1==y.nodeType&&(b=G(y)+1,y=y.parentNode),{startContainer:g,startOffset:v,endContainer:y,endOffset:b}}function H(e,t){return t.links&&"A"==e.tagName}function M(e,t,n,r){var i,o,a;if(!k(n,e)&&!H(n,e))return Q;if("all"!=e.remove)for(at(e.styles,function(i,o){i=R(A(i,t),o),"number"==typeof o&&(o=i,r=0),(e.remove_similar||!r||S(T(r,o),i))&&U.setStyle(n,o,""),a=1}),a&&""===U.getAttrib(n,"style")&&(n.removeAttribute("style"),n.removeAttribute("data-mce-style")),at(e.attributes,function(e,i){var o;if(e=A(e,t),"number"==typeof i&&(i=e,r=0),!r||S(U.getAttrib(r,i),e)){if("class"==i&&(e=U.getAttrib(n,i),e&&(o="",at(e.split(/\s+/),function(e){/mce\w+/.test(e)&&(o+=(o?" ":"")+e)}),o)))return void U.setAttrib(n,i,o);"class"==i&&n.removeAttribute("className"),J.test(i)&&n.removeAttribute("data-mce-"+i),n.removeAttribute(i)}}),at(e.classes,function(e){e=A(e,t),(!r||U.hasClass(r,e))&&U.removeClass(n,e)}),o=U.getAttribs(n),i=0;io?o:i]),3===r.nodeType&&n&&i>=r.nodeValue.length&&(r=new e(r,a.getBody()).next()||r),3!==r.nodeType||n||0!==i||(r=new e(r,a.getBody()).prev()||r),r}function z(t,n,r,i){function o(e){var t=U.create("span",{id:g,"data-mce-bogus":!0,style:b?"color:red":""});return e&&t.appendChild(a.getDoc().createTextNode(X)),t}function l(e,t){for(;e;){if(3===e.nodeType&&e.nodeValue!==X||e.childNodes.length>1)return!1;t&&1===e.nodeType&&t.push(e),e=e.firstChild}return!0}function c(e){for(;e;){if(e.id===g)return e;e=e.parentNode}}function u(t){var n;if(t)for(n=new e(t,t),t=n.current();t;t=n.next())if(3===t.nodeType)return t}function d(e,t){var n,r;if(e)r=$.getRng(!0),l(e)?(t!==!1&&(r.setStartBefore(e),r.setEndBefore(e)),U.remove(e)):(n=u(e),n.nodeValue.charAt(0)===X&&(n.deleteData(0,1),r.startContainer==n&&r.startOffset>0&&r.setStart(n,r.startOffset-1),r.endContainer==n&&r.endOffset>0&&r.setEnd(n,r.endOffset-1)),U.remove(e,1)),$.setRng(r);else if(e=c($.getStart()),!e)for(;e=U.get(g);)d(e,!1)}function p(){var e,t,i,a,s,l,d;e=$.getRng(!0),a=e.startOffset,l=e.startContainer,d=l.nodeValue,t=c($.getStart()),t&&(i=u(t)),d&&a>0&&a=0;h--)u.appendChild(U.clone(p[h],!1)),u=u.firstChild;u.appendChild(U.doc.createTextNode(X)),u=u.firstChild;var g=U.getParent(d,s);g&&U.isEmpty(g)?d.parentNode.replaceChild(m,d):U.insertAfter(m,d),$.setCursorLocation(u,1),U.isEmpty(d)&&U.remove(d)}}function m(){var e;e=c($.getStart()),e&&!U.isEmpty(e)&<(e,function(e){1!=e.nodeType||e.id===g||U.isEmpty(e)||U.setAttrib(e,"data-mce-bogus",null)},"childNodes")}var g="_mce_caret",b=a.settings.caret_debug;a._hasCaretEvents||(it=function(){var e=[],t;if(l(c($.getStart()),e))for(t=e.length;t--;)U.setAttrib(e[t],"data-mce-bogus","1")},rt=function(e){var t=e.keyCode;d(),(8==t||37==t||39==t)&&d(c($.getStart())),m()},a.on("SetContent",function(e){e.selection&&m()}),a._hasCaretEvents=!0),"apply"==t?p():h()}function W(t){var n=t.startContainer,r=t.startOffset,i,o,a,s,l;if(3==n.nodeType&&r>=n.nodeValue.length&&(r=G(n),n=n.parentNode,i=!0),1==n.nodeType)for(s=n.childNodes,n=s[Math.min(r,s.length-1)],o=new e(n,U.getParent(n,U.isBlock)),(r>s.length-1||i)&&o.next(),a=o.current();a;a=o.next())if(3==a.nodeType&&!B(a))return l=U.create("a",{"data-mce-bogus":"all"},X),a.parentNode.insertBefore(l,a),t.setStart(a,0),$.setRng(t),void U.remove(l)}var V={},U=a.dom,$=a.selection,q=new t(U),j=a.schema.isValidChild,Y=U.isBlock,K=a.settings.forced_root_block,G=U.nodeIndex,X="\ufeff",J=/^(src|href|style)$/,Q=!1,Z=!0,et,tt,nt=U.getContentEditable,rt,it,ot=n.isBookmarkNode,at=i.each,st=i.grep,lt=i.walk,ct=i.extend;ct(this,{get:f,register:p,unregister:h,apply:v,remove:y,toggle:b,match:x,matchAll:w,matchNode:C,canApply:_,formatChanged:E,getCssText:N}),u(),d(),a.on("BeforeGetContent",function(e){it&&"raw"!=e.format&&it()}),a.on("mouseup keydown",function(e){rt&&rt(e)})}}),r(I,[B,u,d,N],function(e,t,n,r){var i=n.trim,o;return o=new RegExp(["]+data-mce-bogus[^>]+>[\u200b\ufeff]+<\\/span>",'\\s?data-mce-selected="[^"]+"'].join("|"),"gi"),function(n){function a(){var e=n.getContent({format:"raw",no_events:1}),t=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,a,s,l,c,u,d=n.schema;for(e=e.replace(o,""),u=d.getShortEndedElements();c=t.exec(e);)s=t.lastIndex,l=c[0].length,a=u[c[1]]?s:r.findEndTag(d,e,s),e=e.substring(0,s-l)+e.substring(a),t.lastIndex=s-l;return i(e)}function s(e){l.typing=!1,l.add({},e)}var l=this,c=0,u=[],d,f,p=0;return n.on("init",function(){l.add()}),n.on("BeforeExecCommand",function(e){var t=e.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&l.beforeChange()}),n.on("ExecCommand",function(e){var t=e.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&s(e)}),n.on("ObjectResizeStart",function(){l.beforeChange()}),n.on("SaveContent ObjectResized blur",s),n.on("DragEnd",s),n.on("KeyUp",function(e){var r=e.keyCode;(r>=33&&36>=r||r>=37&&40>=r||45==r||13==r||e.ctrlKey)&&(s(),n.nodeChanged()),(46==r||8==r||t.mac&&(91==r||93==r))&&n.nodeChanged(),f&&l.typing&&(n.isDirty()||(n.isNotDirty=!u[0]||a()==u[0].content,n.isNotDirty||n.fire("change",{level:u[0],lastLevel:null})),n.fire("TypingUndo"),f=!1,n.nodeChanged())}),n.on("KeyDown",function(t){var n=t.keyCode;if(n>=33&&36>=n||n>=37&&40>=n||45==n)return void(l.typing&&s(t));var r=e.modifierPressed(t);!(16>n||n>20)||224==n||91==n||l.typing||r||(l.beforeChange(),l.typing=!0,l.add({},t),f=!0)}),n.on("MouseDown",function(e){l.typing&&s(e)}),n.addShortcut("ctrl+z","","Undo"),n.addShortcut("ctrl+y,ctrl+shift+z","","Redo"),n.on("AddUndo Undo Redo ClearUndos",function(e){e.isDefaultPrevented()||n.nodeChanged()}),l={data:u,typing:!1,beforeChange:function(){p||(d=n.selection.getBookmark(2,!0))},add:function(e,t){var r,i=n.settings,o;if(e=e||{},e.content=a(),p||n.removed)return null;if(o=u[c],n.fire("BeforeAddUndo",{level:e,lastLevel:o,originalEvent:t}).isDefaultPrevented())return null;if(o&&o.content==e.content)return null;if(u[c]&&(u[c].beforeBookmark=d),i.custom_undo_redo_levels&&u.length>i.custom_undo_redo_levels){for(r=0;r0&&(n.isNotDirty=!1,n.fire("change",s)),e},undo:function(){var e;return l.typing&&(l.add(),l.typing=!1),c>0&&(e=u[--c],0===c&&(n.isNotDirty=!0),n.setContent(e.content,{format:"raw"}),n.selection.moveToBookmark(e.beforeBookmark),n.fire("undo",{level:e})),e},redo:function(){var e;return c0||l.typing&&u[0]&&a()!=u[0].content},hasRedo:function(){return cB)&&(u=a.create("br"),t.parentNode.insertBefore(u,t)),l.setStartBefore(t),l.setEndBefore(t)):(l.setStartAfter(t),l.setEndAfter(t)):(l.setStart(t,0),l.setEnd(t,0));s.setRng(l),a.remove(u),s.scrollIntoView(t)}}function g(e){var t=l.forced_root_block;t&&t.toLowerCase()===e.tagName.toLowerCase()&&a.setAttribs(e,l.forced_root_block_attrs)}function v(e){var t=T,n,i,o,s=u.getTextInlineElements();if(e||"TABLE"==P?(n=a.create(e||I),g(n)):n=A.cloneNode(!1),o=n,l.keep_styles!==!1)do if(s[t.nodeName]){if("_mce_caret"==t.id)continue;i=t.cloneNode(!1),a.setAttrib(i,"id",""),n.hasChildNodes()?(i.appendChild(n.firstChild),n.appendChild(i)):(o=i,n.appendChild(i))}while(t=t.parentNode);return r||(o.innerHTML='
      '),n}function y(t){var n,r,i;if(3==T.nodeType&&(t?R>0:RT.childNodes.length-1,T=T.childNodes[Math.min(R,T.childNodes.length-1)]||T,R=F&&3==T.nodeType?T.nodeValue.length:0),S=_(T)){if(c.beforeChange(),!a.isBlock(S)&&S!=a.getRoot())return void((!I||D)&&x());if((I&&!D||!I&&D)&&(T=b(T,R)),A=a.getParent(T,a.isBlock),M=A?a.getParent(A.parentNode,a.isBlock):null,P=A?A.nodeName.toUpperCase():"",O=M?M.nodeName.toUpperCase():"","LI"!=O||o.ctrlKey||(A=M,P=O),/^(LI|DT|DD)$/.test(P)){if(!I&&D)return void x();if(a.isEmpty(A))return void C()}if("PRE"==P&&l.br_in_pre!==!1){if(!D)return void x()}else if(!I&&!D&&"LI"!=P||I&&D)return void x();I&&A===i.getBody()||(I=I||"P",y()?(L=/^(H[1-6]|PRE|FIGURE)$/.test(P)&&"HGROUP"!=O?v(I):v(),l.end_container_on_empty_block&&f(M)&&a.isEmpty(A)?L=a.split(M,A):a.insertAfter(L,A),m(L)):y(!0)?(L=A.parentNode.insertBefore(v(),A),p(L),m(A)):(k=N.cloneRange(),k.setEndAfter(A),H=k.extractContents(),w(H),L=H.firstChild,a.insertAfter(H,A),h(L),E(A),m(L)),a.setAttrib(L,"id",""),i.fire("NewBlock",{newBlock:L}),c.add())}}}var a=i.dom,s=i.selection,l=i.settings,c=i.undoManager,u=i.schema,d=u.getNonEmptyElements();i.on("keydown",function(e){13==e.keyCode&&o(e)!==!1&&e.preventDefault()})}}),r(z,[],function(){return function(e){function t(){var t=i.getStart(),s=e.getBody(),l,c,u,d,f,p,h,m=-16777215,g,v,y,b,C;if(C=n.forced_root_block,t&&1===t.nodeType&&C){for(;t&&t!=s;){if(a[t.nodeName])return;t=t.parentNode}if(l=i.getRng(),l.setStart){c=l.startContainer,u=l.startOffset,d=l.endContainer,f=l.endOffset;try{v=e.getDoc().activeElement===s}catch(x){}}else l.item&&(t=l.item(0),l=e.getDoc().body.createTextRange(),l.moveToElementText(t)),v=l.parentElement().ownerDocument===e.getDoc(),y=l.duplicate(),y.collapse(!0),u=-1*y.move("character",m),y.collapsed||(y=l.duplicate(),y.collapse(!1),f=-1*y.move("character",m)-u);for(t=s.firstChild,b=s.nodeName.toLowerCase();t;)if((3===t.nodeType||1==t.nodeType&&!a[t.nodeName])&&o.isValidChild(b,C.toLowerCase())){if(3===t.nodeType&&0===t.nodeValue.length){h=t,t=t.nextSibling,r.remove(h);continue}p||(p=r.create(C,e.settings.forced_root_block_attrs),t.parentNode.insertBefore(p,t),g=!0),h=t,t=t.nextSibling,p.appendChild(h)}else p=null,t=t.nextSibling;if(g&&v){if(l.setStart)l.setStart(c,u),l.setEnd(d,f),i.setRng(l);else try{l=e.getDoc().body.createTextRange(),l.moveToElementText(s),l.collapse(!0),l.moveStart("character",u),f>0&&l.moveEnd("character",f),l.select()}catch(x){}e.nodeChanged()}}}var n=e.settings,r=e.dom,i=e.selection,o=e.schema,a=o.getBlockElements();n.forced_root_block&&e.on("NodeChange",t)}}),r(W,[T,u,d,M,x,h],function(e,n,r,i,o,a){var s=r.each,l=r.extend,c=r.map,u=r.inArray,d=r.explode,f=n.gecko,p=n.ie,h=n.ie&&n.ie<11,m=!0,g=!1;return function(r){function v(e,t,n){var r;return e=e.toLowerCase(),(r=T.exec[e])?(r(e,t,n),m):g}function y(e){var t;return e=e.toLowerCase(),(t=T.state[e])?t(e):-1}function b(e){var t;return e=e.toLowerCase(),(t=T.value[e])?t(e):g}function C(e,t){t=t||"exec",s(e,function(e,n){s(n.toLowerCase().split(","),function(n){T[t][n]=e})})}function x(e,n,i){return n===t&&(n=g),i===t&&(i=null),r.getDoc().execCommand(e,n,i)}function w(e){return A.match(e)}function _(e,n){A.toggle(e,n?{value:n}:t),r.nodeChanged()}function E(e){B=S.getBookmark(e)}function N(){S.moveToBookmark(B)}var k=r.dom,S=r.selection,T={state:{},exec:{},value:{}},R=r.settings,A=r.formatter,B;l(this,{execCommand:v,queryCommandState:y,queryCommandValue:b,addCommands:C}),C({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){r.undoManager.add()},"Cut,Copy,Paste":function(e){var t=r.getDoc(),i;try{x(e)}catch(o){i=m}if(i||!t.queryCommandSupported(e)){var a=r.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");n.mac&&(a=a.replace(/Ctrl\+/g,"\u2318+")),r.windowManager.alert(a)}},unlink:function(){if(S.isCollapsed()){var e=S.getNode();return void("A"==e.tagName&&r.dom.remove(e,!0))}A.remove("link")},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(e){var t=e.substring(7);"full"==t&&(t="justify"),s("left,center,right,justify".split(","),function(e){t!=e&&A.remove("align"+e)}),_("align"+t),v("mceRepaint") +},"InsertUnorderedList,InsertOrderedList":function(e){var t,n;x(e),t=k.getParent(S.getNode(),"ol,ul"),t&&(n=t.parentNode,/^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName)&&(E(),k.split(n,t),N()))},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){_(e)},"ForeColor,HiliteColor,FontName":function(e,t,n){_(e,n)},FontSize:function(e,t,n){var r,i;n>=1&&7>=n&&(i=d(R.font_size_style_values),r=d(R.font_size_classes),n=r?r[n-1]||n:i[n-1]||n),_(e,n)},RemoveFormat:function(e){A.remove(e)},mceBlockQuote:function(){_("blockquote")},FormatBlock:function(e,t,n){return _(n||"p")},mceCleanup:function(){var e=S.getBookmark();r.setContent(r.getContent({cleanup:m}),{cleanup:m}),S.moveToBookmark(e)},mceRemoveNode:function(e,t,n){var i=n||S.getNode();i!=r.getBody()&&(E(),r.dom.remove(i,m),N())},mceSelectNodeDepth:function(e,t,n){var i=0;k.getParent(S.getNode(),function(e){return 1==e.nodeType&&i++==n?(S.select(e),g):void 0},r.getBody())},mceSelectNode:function(e,t,n){S.select(n)},mceInsertContent:function(t,n,o){function a(e){function t(e){return r[e]&&3==r[e].nodeType}var n,r,i;return n=S.getRng(!0),r=n.startContainer,i=n.startOffset,3==r.nodeType&&(i>0?e=e.replace(/^ /," "):t("previousSibling")||(e=e.replace(/^ /," ")),i|)$/," "):t("nextSibling")||(e=e.replace(/( | )(
      |)$/," "))),e}function l(e){if(w)for(b=e.firstChild;b;b=b.walk(!0))_[b.name]&&b.attr("data-mce-new","true")}function c(){if(w){var e=r.getBody(),t=new i(k);s(k.select("*[data-mce-new]"),function(n){n.removeAttribute("data-mce-new");for(var r=n.parentNode;r&&r!=e;r=r.parentNode)t.compare(r,n)&&k.remove(n,!0)})}}var u,d,f,h,m,g,v,y,b,C,x,w,_=r.schema.getTextInlineElements();"string"!=typeof o&&(w=o.merge,o=o.content),/^ | $/.test(o)&&(o=a(o)),u=r.parser,d=new e({},r.schema),x='​',g={content:o,format:"html",selection:!0},r.fire("BeforeSetContent",g),o=g.content,-1==o.indexOf("{$caret}")&&(o+="{$caret}"),o=o.replace(/\{\$caret\}/,x),y=S.getRng();var E=y.startContainer||(y.parentElement?y.parentElement():null),N=r.getBody();E===N&&S.isCollapsed()&&k.isBlock(N.firstChild)&&k.isEmpty(N.firstChild)&&(y=k.createRng(),y.setStart(N.firstChild,0),y.setEnd(N.firstChild,0),S.setRng(y)),S.isCollapsed()||r.getDoc().execCommand("Delete",!1,null),f=S.getNode();var T={context:f.nodeName.toLowerCase()};if(m=u.parse(o,T),l(m),b=m.lastChild,"mce_marker"==b.attr("id"))for(v=b,b=b.prev;b;b=b.walk(!0))if(3==b.type||!k.isBlock(b.name)){r.schema.isValidChild(b.parent.name,"span")&&b.parent.insert(v,b,"br"===b.name);break}if(T.invalid){for(S.setContent(x),f=S.getNode(),h=r.getBody(),9==f.nodeType?f=b=h:b=f;b!==h;)f=b,b=b.parentNode;o=f==h?h.innerHTML:k.getOuterHTML(f),o=d.serialize(u.parse(o.replace(//i,function(){return d.serialize(m)}))),f==h?k.setHTML(h,o):k.setOuterHTML(f,o)}else o=d.serialize(m),b=f.firstChild,C=f.lastChild,!b||b===C&&"BR"===b.nodeName?k.setHTML(f,o):S.setContent(o);c(),v=k.get("mce_marker"),S.scrollIntoView(v),y=k.createRng(),b=v.previousSibling,b&&3==b.nodeType?(y.setStart(b,b.nodeValue.length),p||(C=v.nextSibling,C&&3==C.nodeType&&(b.appendData(C.data),C.parentNode.removeChild(C)))):(y.setStartBefore(v),y.setEndBefore(v)),k.remove(v),S.setRng(y),r.fire("SetContent",g),r.addVisual()},mceInsertRawHTML:function(e,t,n){S.setContent("tiny_mce_marker"),r.setContent(r.getContent().replace(/tiny_mce_marker/g,function(){return n}))},mceToggleFormat:function(e,t,n){_(n)},mceSetContent:function(e,t,n){r.setContent(n)},"Indent,Outdent":function(e){var t,n,i;t=R.indentation,n=/[a-z%]+$/i.exec(t),t=parseInt(t,10),y("InsertUnorderedList")||y("InsertOrderedList")?x(e):(R.forced_root_block||k.getParent(S.getNode(),k.isBlock)||A.apply("div"),s(S.getSelectedBlocks(),function(o){if("LI"!=o.nodeName){var a=r.getParam("indent_use_margin",!1)?"margin":"padding";a+="rtl"==k.getStyle(o,"direction",!0)?"Right":"Left","outdent"==e?(i=Math.max(0,parseInt(o.style[a]||0,10)-t),k.setStyle(o,a,i?i+n:"")):(i=parseInt(o.style[a]||0,10)+t+n,k.setStyle(o,a,i))}}))},mceRepaint:function(){if(f)try{E(m),S.getSel()&&S.getSel().selectAllChildren(r.getBody()),S.collapse(m),N()}catch(e){}},InsertHorizontalRule:function(){r.execCommand("mceInsertContent",!1,"
      ")},mceToggleVisualAid:function(){r.hasVisual=!r.hasVisual,r.addVisual()},mceReplaceContent:function(e,t,n){r.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,S.getContent({format:"text"})))},mceInsertLink:function(e,t,n){var r;"string"==typeof n&&(n={href:n}),r=k.getParent(S.getNode(),"a"),n.href=n.href.replace(" ","%20"),r&&n.href||A.remove("link"),n.href&&A.apply("link",n,r)},selectAll:function(){var e=k.getRoot(),t;S.getRng().setStart?(t=k.createRng(),t.setStart(e,0),t.setEnd(e,e.childNodes.length),S.setRng(t)):(t=S.getRng(),t.item||(t.moveToElementText(e),t.select()))},"delete":function(){x("Delete");var e=r.getBody();k.isEmpty(e)&&(r.setContent(""),e.firstChild&&k.isBlock(e.firstChild)?r.selection.setCursorLocation(e.firstChild,0):r.selection.setCursorLocation(e,0))},mceNewDocument:function(){r.setContent("")},InsertLineBreak:function(e,t,n){function i(){for(var e=new a(p,v),t,n=r.schema.getNonEmptyElements();t=e.next();)if(n[t.nodeName.toLowerCase()]||t.length>0)return!0}var s=n,l,c,u,d=S.getRng(!0);new o(k).normalize(d);var f=d.startOffset,p=d.startContainer;if(1==p.nodeType&&p.hasChildNodes()){var g=f>p.childNodes.length-1;p=p.childNodes[Math.min(f,p.childNodes.length-1)]||p,f=g&&3==p.nodeType?p.nodeValue.length:0}var v=k.getParent(p,k.isBlock),y=v?v.nodeName.toUpperCase():"",b=v?k.getParent(v.parentNode,k.isBlock):null,C=b?b.nodeName.toUpperCase():"",x=s&&s.ctrlKey;"LI"!=C||x||(v=b,y=C),p&&3==p.nodeType&&f>=p.nodeValue.length&&(h||i()||(l=k.create("br"),d.insertNode(l),d.setStartAfter(l),d.setEndAfter(l),c=!0)),l=k.create("br"),d.insertNode(l);var w=k.doc.documentMode;return h&&"PRE"==y&&(!w||8>w)&&l.parentNode.insertBefore(k.doc.createTextNode("\r"),l),u=k.create("span",{}," "),l.parentNode.insertBefore(u,l),S.scrollIntoView(u),k.remove(u),c?(d.setStartBefore(l),d.setEndBefore(l)):(d.setStartAfter(l),d.setEndAfter(l)),S.setRng(d),r.undoManager.add(),m}}),C({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(e){var t="align"+e.substring(7),n=S.isCollapsed()?[k.getParent(S.getNode(),k.isBlock)]:S.getSelectedBlocks(),r=c(n,function(e){return!!A.matchNode(e,t)});return-1!==u(r,m)},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){return w(e)},mceBlockQuote:function(){return w("blockquote")},Outdent:function(){var e;if(R.inline_styles){if((e=k.getParent(S.getStart(),k.isBlock))&&parseInt(e.style.paddingLeft,10)>0)return m;if((e=k.getParent(S.getEnd(),k.isBlock))&&parseInt(e.style.paddingLeft,10)>0)return m}return y("InsertUnorderedList")||y("InsertOrderedList")||!R.inline_styles&&!!k.getParent(S.getNode(),"BLOCKQUOTE")},"InsertUnorderedList,InsertOrderedList":function(e){var t=k.getParent(S.getNode(),"ul,ol");return t&&("insertunorderedlist"===e&&"UL"===t.tagName||"insertorderedlist"===e&&"OL"===t.tagName)}},"state"),C({"FontSize,FontName":function(e){var t=0,n;return(n=k.getParent(S.getNode(),"span"))&&(t="fontsize"==e?n.style.fontSize:n.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()),t}},"value"),C({Undo:function(){r.undoManager.undo()},Redo:function(){r.undoManager.redo()}})}}),r(V,[d],function(e){function t(e,o){var a=this,s,l;if(e=r(e),o=a.settings=o||{},s=o.base_uri,/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(a.source=e);var c=0===e.indexOf("//");0!==e.indexOf("/")||c||(e=(s?s.protocol||"http":"http")+"://mce_host"+e),/^[\w\-]*:?\/\//.test(e)||(l=o.base_uri?o.base_uri.path:new t(location.href).directory,""===o.base_uri.protocol?e="//mce_host"+a.toAbsPath(l,e):(e=/([^#?]*)([#?]?.*)/.exec(e),e=(s&&s.protocol||"http")+"://mce_host"+a.toAbsPath(l,e[1])+e[2])),e=e.replace(/@@/g,"(mce_at)"),e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e),n(i,function(t,n){var r=e[n];r&&(r=r.replace(/\(mce_at\)/g,"@@")),a[t]=r}),s&&(a.protocol||(a.protocol=s.protocol),a.userInfo||(a.userInfo=s.userInfo),a.port||"mce_host"!==a.host||(a.port=s.port),a.host&&"mce_host"!==a.host||(a.host=s.host),a.source=""),c&&(a.protocol="")}var n=e.each,r=e.trim,i="source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),o={ftp:21,http:80,https:443,mailto:25};return t.prototype={setPath:function(e){var t=this;e=/^(.*?)\/?(\w+)?$/.exec(e),t.path=e[0],t.directory=e[1],t.file=e[2],t.source="",t.getURI()},toRelative:function(e){var n=this,r;if("./"===e)return e;if(e=new t(e,{base_uri:n}),"mce_host"!=e.host&&n.host!=e.host&&e.host||n.port!=e.port||n.protocol!=e.protocol&&""!==e.protocol)return e.getURI();var i=n.getURI(),o=e.getURI();return i==o||"/"==i.charAt(i.length-1)&&i.substr(0,i.length-1)==o?i:(r=n.toRelPath(n.path,e.path),e.query&&(r+="?"+e.query),e.anchor&&(r+="#"+e.anchor),r)},toAbsolute:function(e,n){return e=new t(e,{base_uri:this}),e.getURI(n&&this.isSameOrigin(e))},isSameOrigin:function(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;var t=o[this.protocol];if(t&&(this.port||t)==(e.port||t))return!0}return!1},toRelPath:function(e,t){var n,r=0,i="",o,a;if(e=e.substring(0,e.lastIndexOf("/")),e=e.split("/"),n=t.split("/"),e.length>=n.length)for(o=0,a=e.length;a>o;o++)if(o>=n.length||e[o]!=n[o]){r=o+1;break}if(e.lengtho;o++)if(o>=e.length||e[o]!=n[o]){r=o+1;break}if(1===r)return t;for(o=0,a=e.length-(r-1);a>o;o++)i+="../";for(o=r-1,a=n.length;a>o;o++)i+=o!=r-1?"/"+n[o]:n[o];return i},toAbsPath:function(e,t){var r,i=0,o=[],a,s;for(a=/\/$/.test(t)?"/":"",e=e.split("/"),t=t.split("/"),n(e,function(e){e&&o.push(e)}),e=o,r=t.length-1,o=[];r>=0;r--)0!==t[r].length&&"."!==t[r]&&(".."!==t[r]?i>0?i--:o.push(t[r]):i++);return r=e.length-i,s=0>=r?o.reverse().join("/"):e.slice(0,r).join("/")+"/"+o.reverse().join("/"),0!==s.indexOf("/")&&(s="/"+s),a&&s.lastIndexOf("/")!==s.length-1&&(s+=a),s},getURI:function(e){var t,n=this;return(!n.source||e)&&(t="",e||(t+=n.protocol?n.protocol+"://":"//",n.userInfo&&(t+=n.userInfo+"@"),n.host&&(t+=n.host),n.port&&(t+=":"+n.port)),n.path&&(t+=n.path),n.query&&(t+="?"+n.query),n.anchor&&(t+="#"+n.anchor),n.source=t),n.source}},t}),r(U,[d],function(e){function t(){}var n=e.each,r=e.extend,i,o;return t.extend=i=function(e){function t(){var e,t,n,r=this;if(!o&&(r.init&&r.init.apply(r,arguments),t=r.Mixins))for(e=t.length;e--;)n=t[e],n.init&&n.init.apply(r,arguments)}function a(){return this}function s(e,t){return function(){var n=this,r=n._super,i;return n._super=c[e],i=t.apply(n,arguments),n._super=r,i}}var l=this,c=l.prototype,u,d,f;o=!0,u=new l,o=!1,e.Mixins&&(n(e.Mixins,function(t){t=t;for(var n in t)"init"!==n&&(e[n]=t[n])}),c.Mixins&&(e.Mixins=c.Mixins.concat(e.Mixins))),e.Methods&&n(e.Methods.split(","),function(t){e[t]=a}),e.Properties&&n(e.Properties.split(","),function(t){var n="_"+t;e[t]=function(e){var t=this,r;return e!==r?(t[n]=e,t):t[n]}}),e.Statics&&n(e.Statics,function(e,n){t[n]=e}),e.Defaults&&c.Defaults&&(e.Defaults=r({},c.Defaults,e.Defaults));for(d in e)f=e[d],u[d]="function"==typeof f&&c[d]?s(d,f):f;return t.prototype=u,t.constructor=t,t.extend=i,t},t}),r($,[d],function(e){function t(t){function n(){return!1}function r(){return!0}function i(e,i){var o,s,l,c;if(e=e.toLowerCase(),i=i||{},i.type=e,i.target||(i.target=u),i.preventDefault||(i.preventDefault=function(){i.isDefaultPrevented=r},i.stopPropagation=function(){i.isPropagationStopped=r},i.stopImmediatePropagation=function(){i.isImmediatePropagationStopped=r},i.isDefaultPrevented=n,i.isPropagationStopped=n,i.isImmediatePropagationStopped=n),t.beforeFire&&t.beforeFire(i),o=d[e])for(s=0,l=o.length;l>s;s++){if(c=o[s],c.once&&a(e,c.func),i.isImmediatePropagationStopped())return i.stopPropagation(),i;if(c.func.call(u,i)===!1)return i.preventDefault(),i}return i}function o(t,r,i,o){var a,s,l;if(r===!1&&(r=n),r)for(r={func:r},o&&e.extend(r,o),s=t.toLowerCase().split(" "),l=s.length;l--;)t=s[l],a=d[t],a||(a=d[t]=[],f(t,!0)),i?a.unshift(r):a.push(r);return c}function a(e,t){var n,r,i,o,a;if(e)for(o=e.toLowerCase().split(" "),n=o.length;n--;){if(e=o[n],r=d[e],!e){for(i in d)f(i,!1),delete d[i];return c}if(r){if(t)for(a=r.length;a--;)r[a].func===t&&(r=r.slice(0,a).concat(r.slice(a+1)),d[e]=r);else r.length=0;r.length||(f(e,!1),delete d[e])}}else{for(e in d)f(e,!1);d={}}return c}function s(e,t,n){return o(e,t,n,{once:!0})}function l(e){return e=e.toLowerCase(),!(!d[e]||0===d[e].length)}var c=this,u,d={},f;t=t||{},u=t.scope||c,f=t.toggleEvent||n,c.fire=i,c.on=o,c.off=a,c.once=s,c.has=l}var n=e.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchend"," ");return t.isNative=function(e){return!!n[e.toLowerCase()]},t}),r(q,[U],function(e){function t(e){for(var t=[],n=e.length,r;n--;)r=e[n],r.__checked||(t.push(r),r.__checked=1);for(n=t.length;n--;)delete t[n].__checked;return t}var n=/^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i,r=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,i=/^\s*|\s*$/g,o,a=e.extend({init:function(e){function t(e){return e?(e=e.toLowerCase(),function(t){return"*"===e||t.type===e}):void 0}function o(e){return e?function(t){return t._name===e}:void 0}function a(e){return e?(e=e.split("."),function(t){for(var n=e.length;n--;)if(!t.hasClass(e[n]))return!1;return!0}):void 0}function s(e,t,n){return e?function(r){var i=r[e]?r[e]():"";return t?"="===t?i===n:"*="===t?i.indexOf(n)>=0:"~="===t?(" "+i+" ").indexOf(" "+n+" ")>=0:"!="===t?i!=n:"^="===t?0===i.indexOf(n):"$="===t?i.substr(i.length-n.length)===n:!1:!!n}:void 0}function l(e){var t;return e?(e=/(?:not\((.+)\))|(.+)/i.exec(e),e[1]?(t=u(e[1],[]),function(e){return!d(e,t)}):(e=e[2],function(t,n,r){return"first"===e?0===n:"last"===e?n===r-1:"even"===e?n%2===0:"odd"===e?n%2===1:t[e]?t[e]():!1})):void 0}function c(e,r,c){function u(e){e&&r.push(e)}var d;return d=n.exec(e.replace(i,"")),u(t(d[1])),u(o(d[2])),u(a(d[3])),u(s(d[4],d[5],d[6])),u(l(d[7])),r.psuedo=!!d[7],r.direct=c,r}function u(e,t){var n=[],i,o,a;do if(r.exec(""),o=r.exec(e),o&&(e=o[3],n.push(o[1]),o[2])){i=o[3];break}while(o);for(i&&u(i,t),e=[],a=0;a"!=n[a]&&e.push(c(n[a],[],">"===n[a-1]));return t.push(e),t}var d=this.match;this._selectors=u(e,[])},match:function(e,t){var n,r,i,o,a,s,l,c,u,d,f,p,h;for(t=t||this._selectors,n=0,r=t.length;r>n;n++){for(a=t[n],o=a.length,h=e,p=0,i=o-1;i>=0;i--)for(c=a[i];h;){if(c.psuedo)for(f=h.parent().items(),u=d=f.length;u--&&f[u]!==h;);for(s=0,l=c.length;l>s;s++)if(!c[s](h,u,d)){s=l+1;break}if(s===l){p++;break}if(i===o-1)break;h=h.parent()}if(p===o)return!0}return!1},find:function(e){function n(e,t,i){var o,a,s,l,c,u=t[i];for(o=0,a=e.length;a>o;o++){for(c=e[o],s=0,l=u.length;l>s;s++)if(!u[s](c,o,a)){s=l+1;break}if(s===l)i==t.length-1?r.push(c):c.items&&n(c.items(),t,i+1);else if(u.direct)return;c.items&&n(c.items(),t,i)}}var r=[],i,s,l=this._selectors;if(e.items){for(i=0,s=l.length;s>i;i++)n(e.items(),l[i],0);s>1&&(r=t(r))}return o||(o=a.Collection),new o(r)}});return a}),r(j,[d,q,U],function(e,t,n){var r,i,o=Array.prototype.push,a=Array.prototype.slice;return i={length:0,init:function(e){e&&this.add(e)},add:function(t){var n=this;return e.isArray(t)?o.apply(n,t):t instanceof r?n.add(t.toArray()):o.call(n,t),n},set:function(e){var t=this,n=t.length,r;for(t.length=0,t.add(e),r=t.length;n>r;r++)delete t[r];return t},filter:function(e){var n=this,i,o,a=[],s,l;for("string"==typeof e?(e=new t(e),l=function(t){return e.match(t)}):l=e,i=0,o=n.length;o>i;i++)s=n[i],l(s)&&a.push(s);return new r(a)},slice:function(){return new r(a.apply(this,arguments))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},each:function(t){return e.each(this,t),this},toArray:function(){return e.toArray(this)},indexOf:function(e){for(var t=this,n=t.length;n--&&t[n]!==e;);return n},reverse:function(){return new r(e.toArray(this).reverse())},hasClass:function(e){return this[0]?this[0].hasClass(e):!1},prop:function(e,t){var n=this,r,i;return t!==r?(n.each(function(n){n[e]&&n[e](t)}),n):(i=n[0],i&&i[e]?i[e]():void 0)},exec:function(t){var n=this,r=e.toArray(arguments).slice(1);return n.each(function(e){e[t]&&e[t].apply(e,r)}),n},remove:function(){for(var e=this.length;e--;)this[e].remove();return this}},e.each("fire on off show hide addClass removeClass append prepend before after reflow".split(" "),function(t){i[t]=function(){var n=e.toArray(arguments);return this.each(function(e){t in e&&e[t].apply(e,n)}),this}}),e.each("text name disabled active selected checked visible parent value data".split(" "),function(e){i[e]=function(t){return this.prop(e,t)}}),r=n.extend(i),t.Collection=r,r}),r(Y,[d,y],function(e,t){var n=0;return{id:function(){return"mceu_"+n++},createFragment:function(e){return t.DOM.createFragment(e)},getWindowSize:function(){return t.DOM.getViewPort()},getSize:function(e){var t,n;if(e.getBoundingClientRect){var r=e.getBoundingClientRect();t=Math.max(r.width||r.right-r.left,e.offsetWidth),n=Math.max(r.height||r.bottom-r.bottom,e.offsetHeight)}else t=e.offsetWidth,n=e.offsetHeight;return{width:t,height:n}},getPos:function(e,n){return t.DOM.getPos(e,n)},getViewPort:function(e){return t.DOM.getViewPort(e)},get:function(e){return document.getElementById(e)},addClass:function(e,n){return t.DOM.addClass(e,n)},removeClass:function(e,n){return t.DOM.removeClass(e,n)},hasClass:function(e,n){return t.DOM.hasClass(e,n)},toggleClass:function(e,n,r){return t.DOM.toggleClass(e,n,r)},css:function(e,n,r){return t.DOM.setStyle(e,n,r)},getRuntimeStyle:function(e,n){return t.DOM.getStyle(e,n,!0)},on:function(e,n,r,i){return t.DOM.bind(e,n,r,i)},off:function(e,n,r){return t.DOM.unbind(e,n,r)},fire:function(e,n,r){return t.DOM.fire(e,n,r)},innerHtml:function(e,n){t.DOM.setHTML(e,n)}}}),r(K,[U,d,$,j,Y],function(e,t,n,r,i){function o(e){return e._eventDispatcher||(e._eventDispatcher=new n({scope:e,toggleEvent:function(t,r){r&&n.isNative(t)&&(e._nativeEvents||(e._nativeEvents={}),e._nativeEvents[t]=!0,e._rendered&&e.bindPendingEvents())}})),e._eventDispatcher}var a="onmousewheel"in document,s=!1,l="mce-",c=e.extend({Statics:{classPrefix:l},isRtl:function(){return c.rtl},classPrefix:l,init:function(e){var n=this,r,o;if(n.settings=e=t.extend({},n.Defaults,e),n._id=e.id||i.id(),n._text=n._name="",n._width=n._height=0,n._aria={role:e.role},this._elmCache={},r=e.classes)for(r=r.split(" "),r.map={},o=r.length;o--;)r.map[r[o]]=!0;n._classes=r||[],n.visible(!0),t.each("title text width height name classes visible disabled active value".split(" "),function(t){var r=e[t],i;r!==i?n[t](r):n["_"+t]===i&&(n["_"+t]=!1)}),n.on("click",function(){return n.disabled()?!1:void 0}),e.classes&&t.each(e.classes.split(" "),function(e){n.addClass(e)}),n.settings=e,n._borderBox=n.parseBox(e.border),n._paddingBox=n.parseBox(e.padding),n._marginBox=n.parseBox(e.margin),e.hidden&&n.hide()},Properties:"parent,title,text,width,height,disabled,active,name,value",Methods:"renderHtml",getContainerElm:function(){return document.body},getParentCtrl:function(e){for(var t,n=this.getRoot().controlIdLookup;e&&n&&!(t=n[e.id]);)e=e.parentNode;return t},parseBox:function(e){var t,n=10;if(e)return"number"==typeof e?(e=e||0,{top:e,left:e,bottom:e,right:e}):(e=e.split(" "),t=e.length,1===t?e[1]=e[2]=e[3]=e[0]:2===t?(e[2]=e[0],e[3]=e[1]):3===t&&(e[3]=e[1]),{top:parseInt(e[0],n)||0,right:parseInt(e[1],n)||0,bottom:parseInt(e[2],n)||0,left:parseInt(e[3],n)||0})},borderBox:function(){return this._borderBox},paddingBox:function(){return this._paddingBox},marginBox:function(){return this._marginBox},measureBox:function(e,t){function n(t){var n=document.defaultView;return n?(t=t.replace(/[A-Z]/g,function(e){return"-"+e}),n.getComputedStyle(e,null).getPropertyValue(t)):e.currentStyle[t]}function r(e){var t=parseFloat(n(e),10);return isNaN(t)?0:t}return{top:r(t+"TopWidth"),right:r(t+"RightWidth"),bottom:r(t+"BottomWidth"),left:r(t+"LeftWidth")}},initLayoutRect:function(){var e=this,t=e.settings,n,r,o=e.getEl(),a,s,l,c,u,d,f,p;n=e._borderBox=e._borderBox||e.measureBox(o,"border"),e._paddingBox=e._paddingBox||e.measureBox(o,"padding"),e._marginBox=e._marginBox||e.measureBox(o,"margin"),p=i.getSize(o),d=t.minWidth,f=t.minHeight,l=d||p.width,c=f||p.height,a=t.width,s=t.height,u=t.autoResize,u="undefined"!=typeof u?u:!a&&!s,a=a||l,s=s||c;var h=n.left+n.right,m=n.top+n.bottom,g=t.maxWidth||65535,v=t.maxHeight||65535;return e._layoutRect=r={x:t.x||0,y:t.y||0,w:a,h:s,deltaW:h,deltaH:m,contentW:a-h,contentH:s-m,innerW:a-h,innerH:s-m,startMinWidth:d||0,startMinHeight:f||0,minW:Math.min(l,g),minH:Math.min(c,v),maxW:g,maxH:v,autoResize:u,scrollW:0},e._lastLayoutRect={},r},layoutRect:function(e){var t=this,n=t._layoutRect,r,i,o,a,s,l;return n||(n=t.initLayoutRect()),e?(o=n.deltaW,a=n.deltaH,e.x!==s&&(n.x=e.x),e.y!==s&&(n.y=e.y),e.minW!==s&&(n.minW=e.minW),e.minH!==s&&(n.minH=e.minH),i=e.w,i!==s&&(i=in.maxW?n.maxW:i,n.w=i,n.innerW=i-o),i=e.h,i!==s&&(i=in.maxH?n.maxH:i,n.h=i,n.innerH=i-a),i=e.innerW,i!==s&&(i=in.maxW-o?n.maxW-o:i,n.innerW=i,n.w=i+o),i=e.innerH,i!==s&&(i=in.maxH-a?n.maxH-a:i,n.innerH=i,n.h=i+a),e.contentW!==s&&(n.contentW=e.contentW),e.contentH!==s&&(n.contentH=e.contentH),r=t._lastLayoutRect,(r.x!==n.x||r.y!==n.y||r.w!==n.w||r.h!==n.h)&&(l=c.repaintControls,l&&l.map&&!l.map[t._id]&&(l.push(t),l.map[t._id]=!0),r.x=n.x,r.y=n.y,r.w=n.w,r.h=n.h),t):n},repaint:function(){var e=this,t,n,r,i,o=0,a=0,s,l;l=document.createRange?function(e){return e}:Math.round,t=e.getEl().style,r=e._layoutRect,s=e._lastRepaintRect||{},i=e._borderBox,o=i.left+i.right,a=i.top+i.bottom,r.x!==s.x&&(t.left=l(r.x)+"px",s.x=r.x),r.y!==s.y&&(t.top=l(r.y)+"px",s.y=r.y),r.w!==s.w&&(t.width=l(r.w-o)+"px",s.w=r.w),r.h!==s.h&&(t.height=l(r.h-a)+"px",s.h=r.h),e._hasBody&&r.innerW!==s.innerW&&(n=e.getEl("body").style,n.width=l(r.innerW)+"px",s.innerW=r.innerW),e._hasBody&&r.innerH!==s.innerH&&(n=n||e.getEl("body").style,n.height=l(r.innerH)+"px",s.innerH=r.innerH),e._lastRepaintRect=s,e.fire("repaint",{},!1)},on:function(e,t){function n(e){var t,n;return"string"!=typeof e?e:function(i){return t||r.parentsAndSelf().each(function(r){var i=r.settings.callbacks;return i&&(t=i[e])?(n=r,!1):void 0}),t.call(n,i)}}var r=this;return o(r).on(e,n(t)),r},off:function(e,t){return o(this).off(e,t),this},fire:function(e,t,n){var r=this;if(t=t||{},t.control||(t.control=r),t=o(r).fire(e,t),n!==!1&&r.parent)for(var i=r.parent();i&&!t.isPropagationStopped();)i.fire(e,t,!1),i=i.parent();return t},hasEventListeners:function(e){return o(this).has(e)},parents:function(e){var t=this,n,i=new r;for(n=t.parent();n;n=n.parent())i.add(n);return e&&(i=i.filter(e)),i},parentsAndSelf:function(e){return new r(this).add(this.parents(e))},next:function(){var e=this.parent().items();return e[e.indexOf(this)+1]},prev:function(){var e=this.parent().items();return e[e.indexOf(this)-1]},findCommonAncestor:function(e,t){for(var n;e;){for(n=t;n&&e!=n;)n=n.parent();if(e==n)break;e=e.parent()}return e},hasClass:function(e,t){var n=this._classes[t||"control"];return e=this.classPrefix+e,n&&!!n.map[e]},addClass:function(e,t){var n=this,r,i;return e=this.classPrefix+e,r=n._classes[t||"control"],r||(r=[],r.map={},n._classes[t||"control"]=r),r.map[e]||(r.map[e]=e,r.push(e),n._rendered&&(i=n.getEl(t),i&&(i.className=r.join(" ")))),n},removeClass:function(e,t){var n=this,r,i,o;if(e=this.classPrefix+e,r=n._classes[t||"control"],r&&r.map[e])for(delete r.map[e],i=r.length;i--;)r[i]===e&&r.splice(i,1);return n._rendered&&(o=n.getEl(t),o&&(o.className=r.join(" "))),n},toggleClass:function(e,t,n){var r=this;return t?r.addClass(e,n):r.removeClass(e,n),r},classes:function(e){var t=this._classes[e||"control"];return t?t.join(" "):""},innerHtml:function(e){return i.innerHtml(this.getEl(),e),this},getEl:function(e){var t=e?this._id+"-"+e:this._id;return this._elmCache[t]||(this._elmCache[t]=i.get(t)),this._elmCache[t]},visible:function(e){var t=this,n;return"undefined"!=typeof e?(t._visible!==e&&(t._rendered&&(t.getEl().style.display=e?"":"none"),t._visible=e,n=t.parent(),n&&(n._lastRect=null),t.fire(e?"show":"hide")),t):t._visible},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(e){}return this},blur:function(){return this.getEl().blur(),this},aria:function(e,t){var n=this,r=n.getEl(n.ariaTarget);return"undefined"==typeof t?n._aria[e]:(n._aria[e]=t,n._rendered&&r.setAttribute("role"==e?e:"aria-"+e,t),n)},encode:function(e,t){return t!==!1&&(e=this.translate(e)),(e||"").replace(/[&<>"]/g,function(e){return"&#"+e.charCodeAt(0)+";"})},translate:function(e){return c.translate?c.translate(e):e},before:function(e){var t=this,n=t.parent();return n&&n.insert(e,n.items().indexOf(t),!0),t},after:function(e){var t=this,n=t.parent();return n&&n.insert(e,n.items().indexOf(t)),t},remove:function(){var e=this,t=e.getEl(),n=e.parent(),r,o;if(e.items){var a=e.items().toArray();for(o=a.length;o--;)a[o].remove()}n&&n.items&&(r=[],n.items().each(function(t){t!==e&&r.push(t)}),n.items().set(r),n._lastRect=null),e._eventsRoot&&e._eventsRoot==e&&i.off(t);var s=e.getRoot().controlIdLookup;return s&&delete s[e._id],t&&t.parentNode&&t.parentNode.removeChild(t),e._rendered=!1,e},renderBefore:function(e){var t=this;return e.parentNode.insertBefore(i.createFragment(t.renderHtml()),e),t.postRender(),t},renderTo:function(e){var t=this;return e=e||t.getContainerElm(),e.appendChild(i.createFragment(t.renderHtml())),t.postRender(),t},postRender:function(){var e=this,t=e.settings,n,r,o,a,s;for(a in t)0===a.indexOf("on")&&e.on(a.substr(2),t[a]);if(e._eventsRoot){for(o=e.parent();!s&&o;o=o.parent())s=o._eventsRoot;if(s)for(a in s._nativeEvents)e._nativeEvents[a]=!0}e.bindPendingEvents(),t.style&&(n=e.getEl(),n&&(n.setAttribute("style",t.style),n.style.cssText=t.style)),e._visible||i.css(e.getEl(),"display","none"),e.settings.border&&(r=e.borderBox(),i.css(e.getEl(),{"border-top-width":r.top,"border-right-width":r.right,"border-bottom-width":r.bottom,"border-left-width":r.left}));var l=e.getRoot();l.controlIdLookup||(l.controlIdLookup={}),l.controlIdLookup[e._id]=e;for(var c in e._aria)e.aria(c,e._aria[c]);e.fire("postrender",{},!1)},scrollIntoView:function(e){function t(e,t){var n,r,i=e;for(n=r=0;i&&i!=t&&i.nodeType;)n+=i.offsetLeft||0,r+=i.offsetTop||0,i=i.offsetParent;return{x:n,y:r}}var n=this.getEl(),r=n.parentNode,i,o,a,s,l,c,u=t(n,r);return i=u.x,o=u.y,a=n.offsetWidth,s=n.offsetHeight,l=r.clientWidth,c=r.clientHeight,"end"==e?(i-=l-a,o-=c-s):"center"==e&&(i-=l/2-a/2,o-=c/2-s/2),r.scrollLeft=i,r.scrollTop=o,this},bindPendingEvents:function(){function e(e){var t=o.getParentCtrl(e.target);t&&t.fire(e.type,e)}function t(){var e=d._lastHoverCtrl;e&&(e.fire("mouseleave",{target:e.getEl()}),e.parents().each(function(e){e.fire("mouseleave",{target:e.getEl()})}),d._lastHoverCtrl=null)}function n(e){var t=o.getParentCtrl(e.target),n=d._lastHoverCtrl,r=0,i,a,s;if(t!==n){if(d._lastHoverCtrl=t,a=t.parents().toArray().reverse(),a.push(t),n){for(s=n.parents().toArray().reverse(),s.push(n),r=0;r=r;i--)n=s[i],n.fire("mouseleave",{target:n.getEl()})}for(i=r;il;l++)d=u[l]._eventsRoot;for(d||(d=u[u.length-1]||o),o._eventsRoot=d,c=l,l=0;c>l;l++)u[l]._eventsRoot=d;var h=d._delegates;h||(h=d._delegates={});for(p in f){if(!f)return!1;"wheel"!==p||s?("mouseenter"===p||"mouseleave"===p?d._hasMouseEnter||(i.on(d.getEl(),"mouseleave",t),i.on(d.getEl(),"mouseover",n),d._hasMouseEnter=1):h[p]||(i.on(d.getEl(),p,e),h[p]=!0),f[p]=!1):a?i.on(o.getEl(),"mousewheel",r):i.on(o.getEl(),"DOMMouseScroll",r)}}},getRoot:function(){for(var e=this,t,n=[];e;){if(e.rootControl){t=e.rootControl;break}n.push(e),t=e,e=e.parent()}t||(t=this);for(var r=n.length;r--;)n[r].rootControl=t;return t},reflow:function(){return this.repaint(),this}});return c}),r(G,[],function(){var e={},t;return{add:function(t,n){e[t.toLowerCase()]=n},has:function(t){return!!e[t.toLowerCase()]},create:function(n,r){var i,o,a;if(!t){a=tinymce.ui;for(o in a)e[o.toLowerCase()]=a[o];t=!0}if("string"==typeof n?(r=r||{},r.type=n):(r=n,n=r.type),n=n.toLowerCase(),i=e[n],!i)throw new Error("Could not find control by type: "+n);return i=new i(r),i.type=n,i}}}),r(X,[],function(){return function(e){function t(e){return e=e||b,e&&e.getAttribute("role")}function n(e){for(var n,r=e||b;r=r.parentNode;)if(n=t(r))return n}function r(e){var t=b;return t?t.getAttribute("aria-"+e):void 0}function i(e){var t=e.tagName.toUpperCase();return"INPUT"==t||"TEXTAREA"==t}function o(e){return i(e)&&!e.hidden?!0:/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell)$/.test(t(e))?!0:!1}function a(e){function t(e){if(1==e.nodeType&&"none"!=e.style.display){o(e)&&n.push(e);for(var r=0;re?e=t.length-1:e>=t.length&&(e=0),t[e]&&t[e].focus(),e}function u(e,t){var n=-1,r=s();t=t||a(r.getEl());for(var i=0;i=0&&(n=t.getEl(),n&&n.parentNode.removeChild(n),n=e.getEl(),n&&n.parentNode.removeChild(n)),t.parent(this)},create:function(t){var n=this,i,a=[];return o.isArray(t)||(t=[t]),o.each(t,function(t){t&&(t instanceof e||("string"==typeof t&&(t={type:t}),i=o.extend({},n.settings.defaults,t),t.type=i.type=i.type||t.type||n.settings.defaultType||(i.defaults?i.defaults.type:null),t=r.create(i)),a.push(t))}),a},renderNew:function(){var e=this;return e.items().each(function(t,n){var r,i;t.parent(e),t._rendered||(r=e.getEl("body"),i=a.createFragment(t.renderHtml()),r.hasChildNodes()&&n<=r.childNodes.length-1?r.insertBefore(i,r.childNodes[n]):r.appendChild(i),t.postRender())}),e._layout.applyClasses(e),e._lastRect=null,e},append:function(e){return this.add(e).renderNew()},prepend:function(e){var t=this;return t.items().set(t.create(e).concat(t.items().toArray())),t.renderNew()},insert:function(e,t,n){var r=this,i,o,a;return e=r.create(e),i=r.items(),!n&&t=0&&t
      '+(e.settings.html||"")+t.renderHtml(e)+"
      "},postRender:function(){var e=this,t;return e.items().exec("postRender"),e._super(),e._layout.postRender(e),e._rendered=!0,e.settings.style&&a.css(e.getEl(),e.settings.style),e.settings.border&&(t=e.borderBox(),a.css(e.getEl(),{"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left})),e.parent()||(e.keyboardNav=new i({root:e})),e},initLayoutRect:function(){var e=this,t=e._super();return e._layout.recalc(e),t},recalc:function(){var e=this,t=e._layoutRect,n=e._lastRect;return n&&n.w==t.w&&n.h==t.h?void 0:(e._layout.recalc(e),t=e.layoutRect(),e._lastRect={x:t.x,y:t.y,w:t.w,h:t.h},!0)},reflow:function(){var t;if(this.visible()){for(e.repaintControls=[],e.repaintControls.map={},this.recalc(),t=e.repaintControls.length;t--;)e.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),e.repaintControls=[]}return this}})}),r(Q,[Y],function(e){function t(){var e=document,t,n,r,i,o,a,s,l,c=Math.max;return t=e.documentElement,n=e.body,r=c(t.scrollWidth,n.scrollWidth),i=c(t.clientWidth,n.clientWidth),o=c(t.offsetWidth,n.offsetWidth),a=c(t.scrollHeight,n.scrollHeight),s=c(t.clientHeight,n.clientHeight),l=c(t.offsetHeight,n.offsetHeight),{width:o>r?i:r,height:l>a?s:a}}return function(n,r){function i(){return a.getElementById(r.handle||n)}var o,a=document,s,l,c,u,d,f;r=r||{},l=function(n){var l=t(),p,h;n.preventDefault(),s=n.button,p=i(),d=n.screenX,f=n.screenY,h=window.getComputedStyle?window.getComputedStyle(p,null).getPropertyValue("cursor"):p.runtimeStyle.cursor,o=a.createElement("div"),e.css(o,{position:"absolute",top:0,left:0,width:l.width,height:l.height,zIndex:2147483647,opacity:1e-4,cursor:h}),a.body.appendChild(o),e.on(a,"mousemove",u),e.on(a,"mouseup",c),r.start(n)},u=function(e){return e.button!==s?c(e):(e.deltaX=e.screenX-d,e.deltaY=e.screenY-f,e.preventDefault(),void r.drag(e))},c=function(t){e.off(a,"mousemove",u),e.off(a,"mouseup",c),o.parentNode.removeChild(o),r.stop&&r.stop(t)},this.destroy=function(){e.off(i())},e.on(i(),"mousedown",l)}}),r(Z,[Y,Q],function(e,t){return{init:function(){var e=this;e.on("repaint",e.renderScroll)},renderScroll:function(){function n(){function t(t,a,s,l,c,u){var d,f,p,h,m,g,v,y,b;if(f=i.getEl("scroll"+t)){if(y=a.toLowerCase(),b=s.toLowerCase(),i.getEl("absend")&&e.css(i.getEl("absend"),y,i.layoutRect()[l]-1),!c)return void e.css(f,"display","none");e.css(f,"display","block"),d=i.getEl("body"),p=i.getEl("scroll"+t+"t"),h=d["client"+s]-2*o,h-=n&&r?f["client"+u]:0,m=d["scroll"+s],g=h/m,v={},v[y]=d["offset"+a]+o,v[b]=h,e.css(f,v),v={},v[y]=d["scroll"+a]*g,v[b]=h*g,e.css(p,v)}}var n,r,a;a=i.getEl("body"),n=a.scrollWidth>a.clientWidth,r=a.scrollHeight>a.clientHeight,t("h","Left","Width","contentW",n,"Height"),t("v","Top","Height","contentH",r,"Width")}function r(){function n(n,r,a,s,l){var c,u=i._id+"-scroll"+n,d=i.classPrefix;i.getEl().appendChild(e.createFragment('
      ')),i.draghelper=new t(u+"t",{start:function(){c=i.getEl("body")["scroll"+r],e.addClass(e.get(u),d+"active")},drag:function(e){var t,u,d,f,p=i.layoutRect();u=p.contentW>p.innerW,d=p.contentH>p.innerH,f=i.getEl("body")["client"+a]-2*o,f-=u&&d?i.getEl("scroll"+n)["client"+l]:0,t=f/i.getEl("body")["scroll"+a],i.getEl("body")["scroll"+r]=c+e["delta"+s]/t},stop:function(){e.removeClass(e.get(u),d+"active")}})}i.addClass("scroll"),n("v","Top","Height","Y","Width"),n("h","Left","Width","X","Height")}var i=this,o=2;i.settings.autoScroll&&(i._hasScroll||(i._hasScroll=!0,r(),i.on("wheel",function(e){var t=i.getEl("body");t.scrollLeft+=10*(e.deltaX||0),t.scrollTop+=10*e.deltaY,n()}),e.on(i.getEl("body"),"scroll",n)),n())}}}),r(et,[J,Z],function(e,t){return e.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[t],renderHtml:function(){var e=this,t=e._layout,n=e.settings.html;return e.preRender(),t.preRender(e),"undefined"==typeof n?n='
      '+t.renderHtml(e)+"
      ":("function"==typeof n&&(n=n.call(e)),e._hasBody=!1),'
      '+(e._preBodyHtml||"")+n+"
      "}})}),r(tt,[Y],function(e){function t(t,n,r){var i,o,a,s,l,c,u,d,f,p;return f=e.getViewPort(),o=e.getPos(n),a=o.x,s=o.y,t._fixed&&"static"==e.getRuntimeStyle(document.body,"position")&&(a-=f.x,s-=f.y),i=t.getEl(),p=e.getSize(i),l=p.width,c=p.height,p=e.getSize(n),u=p.width,d=p.height,r=(r||"").split(""),"b"===r[0]&&(s+=d),"r"===r[1]&&(a+=u),"c"===r[0]&&(s+=Math.round(d/2)),"c"===r[1]&&(a+=Math.round(u/2)),"b"===r[3]&&(s-=c),"r"===r[4]&&(a-=l),"c"===r[3]&&(s-=Math.round(c/2)),"c"===r[4]&&(a-=Math.round(l/2)),{x:a,y:s,w:l,h:c}}return{testMoveRel:function(n,r){for(var i=e.getViewPort(),o=0;o0&&a.x+a.w0&&a.y+a.hi.x&&a.x+a.wi.y&&a.y+a.he?0:e+n>t?(e=t-n,0>e?0:e):e}var i=this;if(i.settings.constrainToViewport){var o=e.getViewPort(window),a=i.layoutRect();t=r(t,o.w+o.x,a.w),n=r(n,o.h+o.y,a.h)}return i._rendered?i.layoutRect({x:t,y:n}).repaint():(i.settings.x=t,i.settings.y=n),i.fire("move",{x:t,y:n}),i}}}),r(nt,[Y],function(e){return{resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(t,n){if(1>=t||1>=n){var r=e.getWindowSize();t=1>=t?t*r.w:t,n=1>=n?n*r.h:n}return this._layoutRect.autoResize=!1,this.layoutRect({minW:t,minH:n,w:t,h:n}).reflow()},resizeBy:function(e,t){var n=this,r=n.layoutRect();return n.resizeTo(r.w+e,r.h+t)}}}),r(rt,[et,tt,nt,Y],function(e,t,n,r){function i(){function e(e,t){for(;e;){if(e==t)return!0;e=e.parent()}}u||(u=function(t){if(2!=t.button)for(var n=p.length;n--;){var r=p[n],i=r.getParentCtrl(t.target);if(r.settings.autohide){if(i&&(e(i,r)||r.parent()===i))continue;t=r.fire("autohide",{target:t.target}),t.isDefaultPrevented()||r.hide()}}},r.on(document,"click",u))}function o(){d||(d=function(){var e;for(e=p.length;e--;)s(p[e])},r.on(window,"scroll",d))}function a(){if(!f){var e=document.documentElement,t=e.clientWidth,n=e.clientHeight;f=function(){document.all&&t==e.clientWidth&&n==e.clientHeight||(t=e.clientWidth,n=e.clientHeight,g.hideAll())},r.on(window,"resize",f)}}function s(e){function t(t,n){for(var r,i=0;in&&(e.fixed(!1).layoutRect({y:e._autoFixY}).repaint(),t(!1,e._autoFixY-n)):(e._autoFixY=e.layoutRect().y,e._autoFixY
      '),n=n.firstChild,t.getContainerElm().appendChild(n),setTimeout(function(){r.addClass(n,i+"in"),r.addClass(t.getEl(),i+"in")},0),m=!0),l(!0,t)}}),t.on("show",function(){t.parents().each(function(e){return e._fixed?(t.fixed(!0),!1):void 0})}),e.popover&&(t._preBodyHtml='
      ',t.addClass("popover").addClass("bottom").addClass(t.isRtl()?"end":"start"))},fixed:function(e){var t=this;if(t._fixed!=e){if(t._rendered){var n=r.getViewPort();e?t.layoutRect().y-=n.y:t.layoutRect().y+=n.y}t.toggleClass("fixed",e),t._fixed=e}return t},show:function(){var e=this,t,n=e._super();for(t=p.length;t--&&p[t]!==e;);return-1===t&&p.push(e),n},hide:function(){return c(this),l(!1,this),this._super()},hideAll:function(){g.hideAll()},close:function(){var e=this;return e.fire("close").isDefaultPrevented()||(e.remove(),l(!1,e)),e},remove:function(){c(this),this._super()},postRender:function(){var e=this;return e.settings.bodyRole&&this.getEl("body").setAttribute("role",e.settings.bodyRole),e._super()}});return g.hideAll=function(){for(var e=p.length;e--;){var t=p[e];t&&t.settings.autohide&&(t.hide(),p.splice(e,1))}},g}),r(it,[rt,et,Y,Q],function(e,t,n,r){var i=e.extend({modal:!0,Defaults:{border:1,layout:"flex",containerCls:"panel",role:"dialog",callbacks:{submit:function(){this.fire("submit",{data:this.toJSON()})},close:function(){this.close()}}},init:function(e){var n=this;n._super(e),n.isRtl()&&n.addClass("rtl"),n.addClass("window"),n._fixed=!0,e.buttons&&(n.statusbar=new t({layout:"flex",border:"1 0 0 0",spacing:3,padding:10,align:"center",pack:n.isRtl()?"start":"end",defaults:{type:"button"},items:e.buttons}),n.statusbar.addClass("foot"),n.statusbar.parent(n)),n.on("click",function(e){-1!=e.target.className.indexOf(n.classPrefix+"close")&&n.close()}),n.on("cancel",function(){n.close()}),n.aria("describedby",n.describedBy||n._id+"-none"),n.aria("label",e.title),n._fullscreen=!1},recalc:function(){var e=this,t=e.statusbar,r,i,o,a;e._fullscreen&&(e.layoutRect(n.getWindowSize()),e.layoutRect().contentH=e.layoutRect().innerH),e._super(),r=e.layoutRect(),e.settings.title&&!e._fullscreen&&(i=r.headerW,i>r.w&&(o=r.x-Math.max(0,i/2),e.layoutRect({w:i,x:o}),a=!0)),t&&(t.layoutRect({w:e.layoutRect().innerW}).recalc(),i=t.layoutRect().minW+r.deltaW,i>r.w&&(o=r.x-Math.max(0,i-r.w),e.layoutRect({w:i,x:o}),a=!0)),a&&e.recalc()},initLayoutRect:function(){var e=this,t=e._super(),r=0,i;if(e.settings.title&&!e._fullscreen){i=e.getEl("head");var o=n.getSize(i);t.headerW=o.width,t.headerH=o.height,r+=t.headerH}e.statusbar&&(r+=e.statusbar.layoutRect().h),t.deltaH+=r,t.minH+=r,t.h+=r;var a=n.getWindowSize();return t.x=Math.max(0,a.w/2-t.w/2),t.y=Math.max(0,a.h/2-t.h/2),t},renderHtml:function(){var e=this,t=e._layout,n=e._id,r=e.classPrefix,i=e.settings,o="",a="",s=i.html;return e.preRender(),t.preRender(e),i.title&&(o='
      '+e.encode(i.title)+'
      '),i.url&&(s=''),"undefined"==typeof s&&(s=t.renderHtml(e)),e.statusbar&&(a=e.statusbar.renderHtml()),'
      '+o+'
      '+s+"
      "+a+"
      "},fullscreen:function(e){var t=this,r=document.documentElement,i,o=t.classPrefix,a;if(e!=t._fullscreen)if(n.on(window,"resize",function(){var e;if(t._fullscreen)if(i)t._timer||(t._timer=setTimeout(function(){var e=n.getWindowSize();t.moveTo(0,0).resizeTo(e.w,e.h),t._timer=0},50));else{e=(new Date).getTime();var r=n.getWindowSize();t.moveTo(0,0).resizeTo(r.w,r.h),(new Date).getTime()-e>50&&(i=!0)}}),a=t.layoutRect(),t._fullscreen=e,e){t._initial={x:a.x,y:a.y,w:a.w,h:a.h},t._borderBox=t.parseBox("0"),t.getEl("head").style.display="none",a.deltaH-=a.headerH+2,n.addClass(r,o+"fullscreen"),n.addClass(document.body,o+"fullscreen"),t.addClass("fullscreen");var s=n.getWindowSize();t.moveTo(0,0).resizeTo(s.w,s.h)}else t._borderBox=t.parseBox(t.settings.border),t.getEl("head").style.display="",a.deltaH+=a.headerH,n.removeClass(r,o+"fullscreen"),n.removeClass(document.body,o+"fullscreen"),t.removeClass("fullscreen"),t.moveTo(t._initial.x,t._initial.y).resizeTo(t._initial.w,t._initial.h);return t.reflow()},postRender:function(){var e=this,t;setTimeout(function(){e.addClass("in")},0),e._super(),e.statusbar&&e.statusbar.postRender(),e.focus(),this.dragHelper=new r(e._id+"-dragh",{start:function(){t={x:e.layoutRect().x,y:e.layoutRect().y}},drag:function(n){e.moveTo(t.x+n.deltaX,t.y+n.deltaY)}}),e.on("submit",function(t){t.isDefaultPrevented()||e.close()})},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var e=this,t=e.classPrefix;e.dragHelper.destroy(),e._super(),e.statusbar&&this.statusbar.remove(),e._fullscreen&&(n.removeClass(document.documentElement,t+"fullscreen"),n.removeClass(document.body,t+"fullscreen"))},getContentWindow:function(){var e=this.getEl().getElementsByTagName("iframe")[0];return e?e.contentWindow:null}});return i}),r(ot,[it],function(e){var t=e.extend({init:function(e){e={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}},this._super(e)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(n){function r(e,t,n){return{type:"button",text:e,subtype:n?"primary":"",onClick:function(e){e.control.parents()[1].close(),o(t)}}}var i,o=n.callback||function(){};switch(n.buttons){case t.OK_CANCEL:i=[r("Ok",!0,!0),r("Cancel",!1)];break;case t.YES_NO:case t.YES_NO_CANCEL:i=[r("Yes",1,!0),r("No",0)],n.buttons==t.YES_NO_CANCEL&&i.push(r("Cancel",-1));break;default:i=[r("Ok",!0,!0)]}return new e({padding:20,x:n.x,y:n.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:i,title:n.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:n.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:n.onClose,onCancel:function(){o(!1)}}).renderTo(document.body).reflow()},alert:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,t.msgBox(e)},confirm:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,e.buttons=t.OK_CANCEL,t.msgBox(e)}}});return t}),r(at,[it,ot],function(e,t){return function(n){function r(){return o.length?o[o.length-1]:void 0}var i=this,o=[];i.windows=o,n.on("remove",function(){for(var e=o.length;e--;)o[e].close()}),i.open=function(t,r){var i;return n.editorManager.setActive(n),t.title=t.title||" ",t.url=t.url||t.file,t.url&&(t.width=parseInt(t.width||320,10),t.height=parseInt(t.height||240,10)),t.body&&(t.items={defaults:t.defaults,type:t.bodyType||"form",items:t.body}),t.url||t.buttons||(t.buttons=[{text:"Ok",subtype:"primary",onclick:function(){i.find("form")[0].submit()}},{text:"Cancel",onclick:function(){i.close()}}]),i=new e(t),o.push(i),i.on("close",function(){for(var e=o.length;e--;)o[e]===i&&o.splice(e,1);o.length||n.focus()}),t.data&&i.on("postRender",function(){this.find("*").each(function(e){var n=e.name();n in t.data&&e.value(t.data[n])})}),i.features=t||{},i.params=r||{},1===o.length&&n.nodeChanged(),i.renderTo().reflow()},i.alert=function(e,r,i){t.alert(e,function(){r?r.call(i||this):n.focus()})},i.confirm=function(e,n,r){t.confirm(e,function(e){n.call(r||this,e)})},i.close=function(){r()&&r().close()},i.getParams=function(){return r()?r().params:null},i.setParams=function(e){r()&&(r().params=e)},i.getWindows=function(){return o}}}),r(st,[B,x,_,g,u,d],function(e,t,n,r,i,o){return function(a){function s(e,t){try{a.getDoc().execCommand(e,!1,t)}catch(n){}}function l(){var e=a.getDoc().documentMode;return e?e:6}function c(e){return e.isDefaultPrevented()}function u(){function t(e){var t=new i(function(){});o.each(a.getBody().getElementsByTagName("*"),function(e){"SPAN"==e.tagName&&e.setAttribute("mce-data-marked",1),!e.hasAttribute("data-mce-style")&&e.hasAttribute("style")&&a.dom.setAttrib(e,"style",a.dom.getAttrib(e,"style"))}),t.observe(a.getDoc(),{childList:!0,attributes:!0,subtree:!0,attributeFilter:["style"]}),a.getDoc().execCommand(e?"ForwardDelete":"Delete",!1,null);var n=a.selection.getRng(),r=n.startContainer.parentNode;o.each(t.takeRecords(),function(e){if(q.isChildOf(e.target,a.getBody())){if("style"==e.attributeName){var t=e.target.getAttribute("data-mce-style");t?e.target.setAttribute("style",t):e.target.removeAttribute("style")}o.each(e.addedNodes,function(e){if("SPAN"==e.nodeName&&!e.getAttribute("mce-data-marked")){var t,i;e==r&&(t=n.startOffset,i=e.firstChild),q.remove(e,!0),i&&(n.setStart(i,t),n.setEnd(i,t),a.selection.setRng(n))}})}}),t.disconnect(),o.each(a.dom.select("span[mce-data-marked]"),function(e){e.removeAttribute("mce-data-marked")})}var n=a.getDoc(),r="data:text/mce-internal,",i=window.MutationObserver,s,l;i||(s=!0,i=function(){function e(e){var t=e.relatedNode||e.target;n.push({target:t,addedNodes:[t]})}function t(e){var t=e.relatedNode||e.target;n.push({target:t,attributeName:e.attrName})}var n=[],r;this.observe=function(n){r=n,r.addEventListener("DOMSubtreeModified",e,!1),r.addEventListener("DOMNodeInsertedIntoDocument",e,!1),r.addEventListener("DOMNodeInserted",e,!1),r.addEventListener("DOMAttrModified",t,!1)},this.disconnect=function(){r.removeEventListener("DOMSubtreeModified",e,!1),r.removeEventListener("DOMNodeInsertedIntoDocument",e,!1),r.removeEventListener("DOMNodeInserted",e,!1),r.removeEventListener("DOMAttrModified",t,!1)},this.takeRecords=function(){return n}}),a.on("keydown",function(n){var r=n.keyCode==$,i=e.metaKeyPressed(n);if(!c(n)&&(r||n.keyCode==U)){var o=a.selection.getRng(),s=o.startContainer,l=o.startOffset;if(!i&&o.collapsed&&3==s.nodeType&&(r?l0))return;n.preventDefault(),i&&a.selection.getSel().modify("extend",r?"forward":"backward","word"),t(r)}}),a.on("keypress",function(n){c(n)||j.isCollapsed()||!n.charCode||e.metaKeyPressed(n)||(n.preventDefault(),t(!0),a.selection.setContent(String.fromCharCode(n.charCode)))}),a.addCommand("Delete",function(){t()}),a.addCommand("ForwardDelete",function(){t(!0)}),s||(a.on("dragstart",function(e){var t;a.selection.isCollapsed()&&"IMG"==e.target.tagName&&j.select(e.target),l=j.getRng(),t=a.selection.getContent(),t.length>0&&e.dataTransfer.setData("URL","data:text/mce-internal,"+escape(t))}),a.on("drop",function(e){if(!c(e)){var i=e.dataTransfer.getData("URL");if(!i||-1==i.indexOf(r)||!n.caretRangeFromPoint)return;i=unescape(i.substr(r.length)),n.caretRangeFromPoint&&(e.preventDefault(),window.setTimeout(function(){var r=n.caretRangeFromPoint(e.x,e.y);l&&(j.setRng(l),l=null),t(),j.setRng(r),a.insertContent(i)},0))}}),a.on("cut",function(e){!c(e)&&e.clipboardData&&(e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/html",a.selection.getContent()),e.clipboardData.setData("text/plain",a.selection.getContent({format:"text"})),t(!0))}))}function d(){function e(e){var t=q.create("body"),n=e.cloneContents();return t.appendChild(n),j.serializer.serialize(t,{format:"html"})}function n(n){if(!n.setStart){if(n.item)return!1;var r=n.duplicate();return r.moveToElementText(a.getBody()),t.compareRanges(n,r)}var i=e(n),o=q.createRng();o.selectNode(a.getBody());var s=e(o);return i===s}a.on("keydown",function(e){var t=e.keyCode,r,i;if(!c(e)&&(t==$||t==U)){if(r=a.selection.isCollapsed(),i=a.getBody(),r&&!q.isEmpty(i))return;if(!r&&!n(a.selection.getRng()))return;e.preventDefault(),a.setContent(""),i.firstChild&&q.isBlock(i.firstChild)?a.selection.setCursorLocation(i.firstChild,0):a.selection.setCursorLocation(i,0),a.nodeChanged()}})}function f(){a.shortcuts.add("ctrl+a",null,"SelectAll")}function p(){a.settings.content_editable||(q.bind(a.getDoc(),"focusin",function(){j.setRng(j.getRng())}),q.bind(a.getDoc(),"mousedown mouseup",function(e){e.target==a.getDoc().documentElement&&(a.getBody().focus(),"mousedown"==e.type?j.placeCaretAt(e.clientX,e.clientY):j.setRng(j.getRng()))}))}function h(){a.on("keydown",function(e){if(!c(e)&&e.keyCode===U){if(!a.getBody().getElementsByTagName("hr").length)return;if(j.isCollapsed()&&0===j.getRng(!0).startOffset){var t=j.getNode(),n=t.previousSibling;if("HR"==t.nodeName)return q.remove(t),void e.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(q.remove(n),e.preventDefault())}}})}function m(){window.Range.prototype.getClientRects||a.on("mousedown",function(e){if(!c(e)&&"HTML"===e.target.nodeName){var t=a.getBody();t.blur(),setTimeout(function(){t.focus()},0)}})}function g(){a.on("click",function(e){var t=e.target;/^(IMG|HR)$/.test(t.nodeName)&&(e.preventDefault(),j.getSel().setBaseAndExtent(t,0,t,1),a.nodeChanged()),"A"==t.nodeName&&q.hasClass(t,"mce-item-anchor")&&(e.preventDefault(),j.select(t))})}function v(){function e(){var e=q.getAttribs(j.getStart().cloneNode(!1));return function(){var t=j.getStart();t!==a.getBody()&&(q.setAttrib(t,"style",null),V(e,function(e){t.setAttributeNode(e.cloneNode(!0))}))}}function t(){return!j.isCollapsed()&&q.getParent(j.getStart(),q.isBlock)!=q.getParent(j.getEnd(),q.isBlock)}a.on("keypress",function(n){var r;return c(n)||8!=n.keyCode&&46!=n.keyCode||!t()?void 0:(r=e(),a.getDoc().execCommand("delete",!1,null),r(),n.preventDefault(),!1)}),q.bind(a.getDoc(),"cut",function(n){var r;!c(n)&&t()&&(r=e(),setTimeout(function(){r()},0))})}function y(){document.body.setAttribute("role","application")}function b(){a.on("keydown",function(e){if(!c(e)&&e.keyCode===U&&j.isCollapsed()&&0===j.getRng(!0).startOffset){var t=j.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}})}function C(){l()>7||(s("RespectVisibilityInDesign",!0),a.contentStyles.push(".mceHideBrInPre pre br {display: none}"),q.addClass(a.getBody(),"mceHideBrInPre"),K.addNodeFilter("pre",function(e){for(var t=e.length,r,i,o,a;t--;)for(r=e[t].getAll("br"),i=r.length;i--;)o=r[i],a=o.prev,a&&3===a.type&&"\n"!=a.value.charAt(a.value-1)?a.value+="\n":o.parent.insert(new n("#text",3),o,!0).value="\n"}),G.addNodeFilter("pre",function(e){for(var t=e.length,n,r,i,o;t--;)for(n=e[t].getAll("br"),r=n.length;r--;)i=n[r],o=i.prev,o&&3==o.type&&(o.value=o.value.replace(/\r?\n$/,""))}))}function x(){q.bind(a.getBody(),"mouseup",function(){var e,t=j.getNode();"IMG"==t.nodeName&&((e=q.getStyle(t,"width"))&&(q.setAttrib(t,"width",e.replace(/[^0-9%]+/g,"")),q.setStyle(t,"width","")),(e=q.getStyle(t,"height"))&&(q.setAttrib(t,"height",e.replace(/[^0-9%]+/g,"")),q.setStyle(t,"height","")))})}function w(){a.on("keydown",function(t){var n,r,i,o,s;if(!c(t)&&t.keyCode==e.BACKSPACE&&(n=j.getRng(),r=n.startContainer,i=n.startOffset,o=q.getRoot(),s=r,n.collapsed&&0===i)){for(;s&&s.parentNode&&s.parentNode.firstChild==s&&s.parentNode!=o;)s=s.parentNode;"BLOCKQUOTE"===s.tagName&&(a.formatter.toggle("blockquote",null,s),n=q.createRng(),n.setStart(r,0),n.setEnd(r,0),j.setRng(n))}})}function _(){function e(){a._refreshContentEditable(),s("StyleWithCSS",!1),s("enableInlineTableEditing",!1),Y.object_resizing||s("enableObjectResizing",!1)}Y.readonly||a.on("BeforeExecCommand MouseDown",e)}function E(){function e(){V(q.select("a"),function(e){var t=e.parentNode,n=q.getRoot();if(t.lastChild===e){for(;t&&!q.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}q.add(t,"br",{"data-mce-bogus":1})}})}a.on("SetContent ExecCommand",function(t){("setcontent"==t.type||"mceInsertLink"===t.command)&&e()})}function N(){Y.forced_root_block&&a.on("init",function(){s("DefaultParagraphSeparator",Y.forced_root_block)})}function k(){a.on("Undo Redo SetContent",function(e){e.initial||a.execCommand("mceRepaint")})}function S(){a.on("keydown",function(e){var t;c(e)||e.keyCode!=U||(t=a.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),a.undoManager.beforeChange(),q.remove(t.item(0)),a.undoManager.add()))})}function T(){var e;l()>=10&&(e="",V("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),a.contentStyles.push(e+"{padding-right: 1px !important}"))}function R(){l()<9&&(K.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),G.addNodeFilter("noscript",function(e){for(var t=e.length,i,o,a;t--;)i=e[t],o=e[t].firstChild,o?o.value=r.decode(o.value):(a=i.attributes.map["data-mce-innertext"],a&&(i.attr("data-mce-innertext",null),o=new n("#text",3),o.value=a,o.raw=!0,i.append(o)))}))}function A(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),q.unbind(r,"mouseup",n),q.unbind(r,"mousemove",t),a=o=0}var r=q.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,q.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(q.bind(r,"mouseup",n),q.bind(r,"mousemove",t),q.getRoot().focus(),a.select())}})}function B(){a.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||j.normalize()},!0)}function D(){a.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function L(){a.inline||a.on("keydown",function(){document.activeElement==document.body&&a.getWin().focus()})}function H(){a.inline||(a.contentStyles.push("body {min-height: 150px}"),a.on("click",function(e){"HTML"==e.target.nodeName&&(a.getBody().focus(),a.selection.normalize(),a.nodeChanged())}))}function M(){i.mac&&a.on("keydown",function(t){!e.metaKeyPressed(t)||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),a.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","word"))})}function P(){s("AutoUrlDetect",!1)}function O(){a.inline||a.on("focus blur beforegetcontent",function(){var e=a.dom.create("br");a.getBody().appendChild(e),e.parentNode.removeChild(e)},!0)}function I(){a.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),a.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function F(){a.on("touchstart",function(e){var t,n,r,i;t=e.target,n=(new Date).getTime(),i=e.changedTouches,!i||i.length>1||(r=i[0],a.once("touchend",function(e){var i=e.changedTouches[0],o;(new Date).getTime()-n>500||Math.abs(r.clientX-i.clientX)>5||Math.abs(r.clientY-i.clientY)>5||(o={target:t},V("pageX pageY clientX clientY screenX screenY".split(" "),function(e){o[e]=i[e]}),o=a.fire("click",o),o.isDefaultPrevented()||(a.selection.placeCaretAt(i.clientX,i.clientY),a.nodeChanged()))}))})}function z(){a.on("init",function(){a.dom.bind(a.getBody(),"submit",function(e){e.preventDefault()})})}function W(){K.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}var V=o.each,U=e.BACKSPACE,$=e.DELETE,q=a.dom,j=a.selection,Y=a.settings,K=a.parser,G=a.serializer,X=i.gecko,J=i.ie,Q=i.webkit;w(),d(),B(),Q&&(u(),p(),g(),N(),z(),b(),W(),F(),i.iOS?(L(),H(),I()):f()),J&&i.ie<11&&(h(),y(),C(),x(),S(),T(),R(),A()),i.ie>=11&&(H(),O(),b()),i.ie&&(f(),P()),X&&(h(),m(),v(),_(),E(),k(),D(),M(),b())}}),r(lt,[$],function(e){function t(t){return t._eventDispatcher||(t._eventDispatcher=new e({scope:t,toggleEvent:function(n,r){e.isNative(n)&&t.toggleNativeEvent&&t.toggleNativeEvent(n,r)}})),t._eventDispatcher}return{fire:function(e,n,r){var i=this;if(i.removed&&"remove"!==e)return n;if(n=t(i).fire(e,n,r),r!==!1&&i.parent)for(var o=i.parent();o&&!n.isPropagationStopped();)o.fire(e,n,!1),o=o.parent();return n},on:function(e,n,r){return t(this).on(e,n,r)},off:function(e,n){return t(this).off(e,n)},once:function(e,n){return t(this).once(e,n)},hasEventListeners:function(e){return t(this).has(e)}}}),r(ct,[lt,y,d],function(e,t,n){function r(e,t){return"selectionchange"==t?e.getDoc():!e.inline&&/^mouse|click|contextmenu|drop|dragover|dragend/.test(t)?e.getDoc().documentElement:e.settings.event_root?(e.eventRoot||(e.eventRoot=o.select(e.settings.event_root)[0]),e.eventRoot):e.getBody()}function i(e,t){var n=r(e,t),i;if(e.delegates||(e.delegates={}),!e.delegates[t])if(e.settings.event_root){if(a||(a={},e.editorManager.on("removeEditor",function(){var t;if(!e.editorManager.activeEditor&&a){for(t in a)e.dom.unbind(r(e,t));a=null}})),a[t])return;i=function(n){for(var r=n.target,i=e.editorManager.editors,a=i.length;a--;){var s=i[a].getBody();(s===r||o.isChildOf(r,s))&&(i[a].hidden||i[a].fire(t,n))}},a[t]=i,o.bind(n,t,i)}else i=function(n){e.hidden||e.fire(t,n)},o.bind(n,t,i),e.delegates[t]=i}var o=t.DOM,a,s={bindPendingEventDelegates:function(){var e=this;n.each(e._pendingNativeEvents,function(t){i(e,t)})},toggleNativeEvent:function(e,t){var n=this;n.settings.readonly||"focus"!=e&&"blur"!=e&&(t?n.initialized?i(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&(n.dom.unbind(r(n,e),e,n.delegates[e]),delete n.delegates[e]))},unbindAllNativeEvents:function(){var e=this,t;if(e.delegates){for(t in e.delegates)e.dom.unbind(r(e,t),t,e.delegates[t]);delete e.delegates}e.inline||(e.getBody().onload=null,e.dom.unbind(e.getWin()),e.dom.unbind(e.getDoc())),e.dom.unbind(e.getBody()),e.dom.unbind(e.getContainer())}};return s=n.extend({},e,s)}),r(ut,[d,u],function(e,t){var n=e.each,r=e.explode,i={f9:120,f10:121,f11:122};return function(o){var a=this,s={};o.on("keyup keypress keydown",function(e){(e.altKey||e.ctrlKey||e.metaKey)&&!e.isDefaultPrevented()&&n(s,function(n){var r=t.mac?e.metaKey:e.ctrlKey;if(n.ctrl==r&&n.alt==e.altKey&&n.shift==e.shiftKey)return e.keyCode==n.keyCode||e.charCode&&e.charCode==n.charCode?(e.preventDefault(),"keydown"==e.type&&n.func.call(n.scope),!0):void 0 +})}),a.add=function(t,a,l,c){var u;return u=l,"string"==typeof l?l=function(){o.execCommand(u,!1,null)}:e.isArray(u)&&(l=function(){o.execCommand(u[0],u[1],u[2])}),n(r(t.toLowerCase()),function(e){var t={func:l,scope:c||o,desc:o.translate(a),alt:!1,ctrl:!1,shift:!1};n(r(e,"+"),function(e){switch(e){case"alt":case"ctrl":case"shift":t[e]=!0;break;default:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=i[e]||e.toUpperCase().charCodeAt(0))}}),s[(t.ctrl?"ctrl":"")+","+(t.alt?"alt":"")+","+(t.shift?"shift":"")+","+t.keyCode]=t}),!0}}}),r(dt,[y,f,C,w,_,R,T,H,O,I,F,z,W,V,b,l,at,E,k,st,u,d,ct,ut],function(e,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E){function N(e,t,i){var o=this,a,s;a=o.documentBaseUrl=i.documentBaseURL,s=i.baseURI,o.settings=t=R({id:e,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:a,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",validate:!0,entity_encoding:"named",url_converter:o.convertURL,url_converter_scope:o,ie7_compat:!0},t),r.language=t.language||"en",r.languageLoad=t.language_load,r.baseURL=i.baseURL,o.id=t.id=e,o.isNotDirty=!0,o.plugins={},o.documentBaseURI=new h(t.document_base_url||a,{base_uri:s}),o.baseURI=s,o.contentCSS=[],o.contentStyles=[],o.shortcuts=new E(o),o.execCommands={},o.queryStateCommands={},o.queryValueCommands={},o.loadedCSS={},t.target&&(o.targetElm=t.target),o.suffix=i.suffix,o.editorManager=i,o.inline=t.inline,t.cache_suffix&&(x.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),i.fire("SetupEditor",o),o.execCallback("setup",o),o.$=n.overrideDefaults(function(){return{context:o.inline?o.getBody():o.getDoc(),element:o.getBody()}})}var k=e.DOM,S=r.ThemeManager,T=r.PluginManager,R=w.extend,A=w.each,B=w.explode,D=w.inArray,L=w.trim,H=w.resolve,M=g.Event,P=x.gecko,O=x.ie;return N.prototype={render:function(){function e(){k.unbind(window,"ready",e),n.render()}function t(){var e=m.ScriptLoader;if(r.language&&"en"!=r.language&&!r.language_url&&(r.language_url=n.editorManager.baseURL+"/langs/"+r.language+".js"),r.language_url&&e.add(r.language_url),r.theme&&"function"!=typeof r.theme&&"-"!=r.theme.charAt(0)&&!S.urls[r.theme]){var t=r.theme_url;t=t?n.documentBaseURI.toAbsolute(t):"themes/"+r.theme+"/theme"+o+".js",S.load(r.theme,t)}w.isArray(r.plugins)&&(r.plugins=r.plugins.join(" ")),A(r.external_plugins,function(e,t){T.load(t,e),r.plugins+=" "+t}),A(r.plugins.split(/[ ,]/),function(e){if(e=L(e),e&&!T.urls[e])if("-"==e.charAt(0)){e=e.substr(1,e.length);var t=T.dependencies(e);A(t,function(e){var t={prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"};e=T.createUrl(t,e),T.load(e.resource,e)})}else T.load(e,{prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"})}),e.loadQueue(function(){n.removed||n.init()})}var n=this,r=n.settings,i=n.id,o=n.suffix;if(!M.domLoaded)return void k.bind(window,"ready",e);if(n.getElement()&&x.contentEditable){r.inline?n.inline=!0:(n.orgVisibility=n.getElement().style.visibility,n.getElement().style.visibility="hidden");var a=n.getElement().form||k.getParent(i,"form");a&&(n.formElement=a,r.hidden_input&&!/TEXTAREA|INPUT/i.test(n.getElement().nodeName)&&(k.insertAfter(k.create("input",{type:"hidden",name:i}),i),n.hasHiddenInput=!0),n.formEventDelegate=function(e){n.fire(e.type,e)},k.bind(a,"submit reset",n.formEventDelegate),n.on("reset",function(){n.setContent(n.startContent,{format:"raw"})}),!r.submit_patch||a.submit.nodeType||a.submit.length||a._mceOldSubmit||(a._mceOldSubmit=a.submit,a.submit=function(){return n.editorManager.triggerSave(),n.isNotDirty=!0,a._mceOldSubmit(a)})),n.windowManager=new v(n),"xml"==r.encoding&&n.on("GetContent",function(e){e.save&&(e.content=k.encode(e.content))}),r.add_form_submit_trigger&&n.on("submit",function(){n.initialized&&n.save()}),r.add_unload_trigger&&(n._beforeUnload=function(){!n.initialized||n.destroyed||n.isHidden()||n.save({format:"raw",no_events:!0,set_dirty:!1})},n.editorManager.on("BeforeUnload",n._beforeUnload)),t()}},init:function(){function e(n){var r=T.get(n),i,o;i=T.urls[n]||t.documentBaseUrl.replace(/\/$/,""),n=L(n),r&&-1===D(m,n)&&(A(T.dependencies(n),function(t){e(t)}),o=new r(t,i,t.$),t.plugins[n]=o,o.init&&(o.init(t,i),m.push(n)))}var t=this,n=t.settings,r=t.getElement(),i,o,a,s,l,c,u,d,f,p,h,m=[];if(t.rtl=this.editorManager.i18n.rtl,t.editorManager.add(t),n.aria_label=n.aria_label||k.getAttrib(r,"aria-label",t.getLang("aria.rich_text_area")),n.theme&&("function"!=typeof n.theme?(n.theme=n.theme.replace(/-/,""),c=S.get(n.theme),t.theme=new c(t,S.urls[n.theme]),t.theme.init&&t.theme.init(t,S.urls[n.theme]||t.documentBaseUrl.replace(/\/$/,""),t.$)):t.theme=n.theme),A(n.plugins.replace(/\-/g,"").split(/[ ,]/),e),n.render_ui&&t.theme&&(t.orgDisplay=r.style.display,"function"!=typeof n.theme?(i=n.width||r.style.width||r.offsetWidth,o=n.height||r.style.height||r.offsetHeight,a=n.min_height||100,p=/^[0-9\.]+(|px)$/i,p.test(""+i)&&(i=Math.max(parseInt(i,10),100)),p.test(""+o)&&(o=Math.max(parseInt(o,10),a)),l=t.theme.renderUI({targetNode:r,width:i,height:o,deltaWidth:n.delta_width,deltaHeight:n.delta_height}),n.content_editable||(o=(l.iframeHeight||o)+("number"==typeof o?l.deltaHeight||0:""),a>o&&(o=a))):(l=n.theme(t,r),l.editorContainer.nodeType&&(l.editorContainer=l.editorContainer.id=l.editorContainer.id||t.id+"_parent"),l.iframeContainer.nodeType&&(l.iframeContainer=l.iframeContainer.id=l.iframeContainer.id||t.id+"_iframecontainer"),o=l.iframeHeight||r.offsetHeight),t.editorContainer=l.editorContainer),n.content_css&&A(B(n.content_css),function(e){t.contentCSS.push(t.documentBaseURI.toAbsolute(e))}),n.content_style&&t.contentStyles.push(n.content_style),n.content_editable)return r=s=l=null,t.initContentBody();for(t.iframeHTML=n.doctype+"",n.document_base_url!=t.documentBaseUrl&&(t.iframeHTML+=''),!x.caretAfter&&n.ie7_compat&&(t.iframeHTML+=''),t.iframeHTML+='',h=0;h',t.loadedCSS[g]=!0}d=n.body_id||"tinymce",-1!=d.indexOf("=")&&(d=t.getParam("body_id","","hash"),d=d[t.id]||d),f=n.body_class||"",-1!=f.indexOf("=")&&(f=t.getParam("body_class","","hash"),f=f[t.id]||""),n.content_security_policy&&(t.iframeHTML+=''),t.iframeHTML+='
      ';var v='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody(true);})()';document.domain!=location.hostname&&(u=v);var y=k.create("iframe",{id:t.id+"_ifr",frameBorder:"0",allowTransparency:"true",title:t.editorManager.translate("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),style:{width:"100%",height:o,display:"block"}});if(y.onload=function(){y.onload=null,t.fire("load")},k.setAttrib(y,"src",u||'javascript:""'),t.contentAreaContainer=l.iframeContainer,t.iframeElement=y,s=k.add(l.iframeContainer,y),O)try{t.getDoc()}catch(b){s.src=u=v}l.editorContainer&&(k.get(l.editorContainer).style.display=t.orgDisplay,t.hidden=k.isHidden(l.editorContainer)),t.getElement().style.display="none",k.setAttrib(t.id,"aria-hidden",!0),u||t.initContentBody(),r=s=l=null},initContentBody:function(t){var n=this,r=n.settings,s=n.getElement(),h=n.getDoc(),m,g;r.inline||(n.getElement().style.visibility=n.orgVisibility),t||r.content_editable||(h.open(),h.write(n.iframeHTML),h.close()),r.content_editable&&(n.on("remove",function(){var e=this.getBody();k.removeClass(e,"mce-content-body"),k.removeClass(e,"mce-edit-focus"),k.setAttrib(e,"contentEditable",null)}),k.addClass(s,"mce-content-body"),n.contentDocument=h=r.content_document||document,n.contentWindow=r.content_window||window,n.bodyElement=s,r.content_document=r.content_window=null,r.root_name=s.nodeName.toLowerCase()),m=n.getBody(),m.disabled=!0,r.readonly||(n.inline&&"static"==k.getStyle(m,"position",!0)&&(m.style.position="relative"),m.contentEditable=n.getParam("content_editable_state",!0)),m.disabled=!1,n.schema=new y(r),n.dom=new e(h,{keep_values:!0,url_converter:n.convertURL,url_converter_scope:n,hex_colors:r.force_hex_style_colors,class_filter:r.class_filter,update_styles:!0,root_element:n.inline?n.getBody():null,collect:r.content_editable,schema:n.schema,onSetAttrib:function(e){n.fire("SetAttrib",e)}}),n.parser=new b(r,n.schema),n.parser.addAttributeFilter("src,href,style,tabindex",function(e,t){for(var r=e.length,i,o=n.dom,a,s;r--;)i=e[r],a=i.attr(t),s="data-mce-"+t,i.attributes.map[s]||("style"===t?(a=o.serializeStyle(o.parseStyle(a),i.name),a.length||(a=null),i.attr(s,a),i.attr(t,a)):"tabindex"===t?(i.attr(s,a),i.attr(t,null)):i.attr(s,n.convertURL(a,t,i.name)))}),n.parser.addNodeFilter("script",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("type","mce-"+(n.attr("type")||"no/type"))}),n.parser.addNodeFilter("#cdata",function(e){for(var t=e.length,n;t--;)n=e[t],n.type=8,n.name="#comment",n.value="[CDATA["+n.value+"]]"}),n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(e){for(var t=e.length,r,i=n.schema.getNonEmptyElements();t--;)r=e[t],r.isEmpty(i)&&(r.append(new o("br",1)).shortEnded=!0)}),n.serializer=new a(r,n),n.selection=new l(n.dom,n.getWin(),n.serializer,n),n.formatter=new c(n),n.undoManager=new u(n),n.forceBlocks=new f(n),n.enterKey=new d(n),n.editorCommands=new p(n),n._nodeChangeDispatcher=new i(n),n.fire("PreInit"),r.browser_spellcheck||r.gecko_spellcheck||(h.body.spellcheck=!1,k.setAttrib(m,"spellcheck","false")),n.fire("PostRender"),n.quirks=new C(n),r.directionality&&(m.dir=r.directionality),r.nowrap&&(m.style.whiteSpace="nowrap"),r.protect&&n.on("BeforeSetContent",function(e){A(r.protect,function(t){e.content=e.content.replace(t,function(e){return""})})}),n.on("SetContent",function(){n.addVisual(n.getBody())}),r.padd_empty_editor&&n.on("PostProcess",function(e){e.content=e.content.replace(/^(]*>( | |\s|\u00a0|)<\/p>[\r\n]*|
      [\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.contentStyles.length>0&&(g="",A(n.contentStyles,function(e){g+=e+"\r\n"}),n.dom.addStyle(g)),A(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&setTimeout(function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.focus()},100),s=h=m=null},focus:function(e){var t=this,n=t.selection,r=t.settings.content_editable,i,o,a=t.getDoc(),s;if(!e){if(i=n.getRng(),i.item&&(o=i.item(0)),t._refreshContentEditable(),r||(x.opera||t.getBody().focus(),t.getWin().focus()),P||r){if(s=t.getBody(),s.setActive)try{s.setActive()}catch(l){s.focus()}else s.focus();r&&n.normalize()}o&&o.ownerDocument==a&&(i=a.body.createControlRange(),i.addElement(o),i.select())}t.editorManager.setActive(t)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?H(r):0,n=H(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?A(r.split(r.indexOf("=")>0?/[;,](?![^=;,]*(?:[;,]|$))/:","),function(e){e=e.split("="),i[L(e[0])]=L(e.length>1?e[1]:e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addCommand:function(e,t,n){this.execCommands[e]={func:t,scope:n||this}},addQueryStateHandler:function(e,t,n){this.queryStateCommands[e]={func:t,scope:n||this}},addQueryValueHandler:function(e,t,n){this.queryValueCommands[e]={func:t,scope:n||this}},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){var i=this,o=0,a;if(/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(e)||r&&r.skip_focus||i.focus(),r=R({},r),r=i.fire("BeforeExecCommand",{command:e,ui:t,value:n}),r.isDefaultPrevented())return!1;if((a=i.execCommands[e])&&a.func.call(a.scope,t,n)!==!0)return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;if(A(i.plugins,function(r){return r.execCommand&&r.execCommand(e,t,n)?(i.fire("ExecCommand",{command:e,ui:t,value:n}),o=!0,!1):void 0}),o)return o;if(i.theme&&i.theme.execCommand&&i.theme.execCommand(e,t,n))return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;if(i.editorCommands.execCommand(e,t,n))return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;try{o=i.getDoc().execCommand(e,t,n)}catch(s){}return o?(i.fire("ExecCommand",{command:e,ui:t,value:n}),!0):!1},queryCommandState:function(e){var t=this,n,r;if(!t._isHidden()){if((n=t.queryStateCommands[e])&&(r=n.func.call(n.scope),r===!0||r===!1))return r;if(r=t.editorCommands.queryCommandState(e),-1!==r)return r;try{return t.getDoc().queryCommandState(e)}catch(i){}}},queryCommandValue:function(e){var n=this,r,i;if(!n._isHidden()){if((r=n.queryValueCommands[e])&&(i=r.func.call(r.scope),i!==!0))return i;if(i=n.editorCommands.queryCommandValue(e),i!==t)return i;try{return n.getDoc().queryCommandValue(e)}catch(o){}}},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(k.show(e.getContainer()),k.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(O&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(k.hide(e.getContainer()),k.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;return r?(e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i):void 0},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=k.getParent(t.id,"form"))&&A(i.elements,function(e){return e.name==t.id?(e.value=r,!1):void 0})),e.element=n=null,e.set_dirty!==!1&&(t.isNotDirty=!0),r},setContent:function(e,t){var n=this,r=n.getBody(),i;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(i=n.settings.forced_root_block,i&&n.schema.isValidChild(r.nodeName.toLowerCase(),i.toLowerCase())?(e=O&&11>O?"":'
      ',e=n.dom.createHTML(i,n.settings.forced_root_block_attrs,e)):O||(e='
      '),n.dom.setHTML(r,e),n.fire("SetContent",t)):("raw"!==t.format&&(e=new s({},n.schema).serialize(n.parser.parse(e,{isRootContent:!0}))),t.content=L(e),n.dom.setHTML(r,t.content),t.no_events||n.fire("SetContent",t)),t.content},getContent:function(e){var t=this,n,r=t.getBody();return e=e||{},e.format=e.format||"html",e.get=!0,e.getInner=!0,e.no_events||t.fire("BeforeGetContent",e),n="raw"==e.format?r.innerHTML:"text"==e.format?r.innerText||r.textContent:t.serializer.serialize(r,e),e.content="text"!=e.format?L(n):n,e.no_events||t.fire("GetContent",e),e.content},insertContent:function(e,t){t&&(e=R({content:e},t)),this.execCommand("mceInsertContent",!1,e)},isDirty:function(){return!this.isNotDirty},getContainer:function(){var e=this;return e.container||(e.container=k.get(e.editorContainer||e.id+"_parent")),e.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=k.get(this.id)),this.targetElm},getWin:function(){var e=this,t;return e.contentWindow||(t=e.iframeElement,t&&(e.contentWindow=t.contentWindow)),e.contentWindow},getDoc:function(){var e=this,t;return e.contentDocument||(t=e.getWin(),t&&(e.contentDocument=t.document)),e.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(e,t,n){var r=this,i=r.settings;return i.urlconverter_callback?r.execCallback("urlconverter_callback",e,n,!0,t):!i.convert_urls||n&&"LINK"==n.nodeName||0===e.indexOf("file:")||0===e.length?e:i.relative_urls?r.documentBaseURI.toRelative(e):e=r.documentBaseURI.toAbsolute(e,i.remove_script_host)},addVisual:function(e){var n=this,r=n.settings,i=n.dom,o;e=e||n.getBody(),n.hasVisual===t&&(n.hasVisual=r.visual),A(i.select("table,a",e),function(e){var t;switch(e.nodeName){case"TABLE":return o=r.visual_table_class||"mce-item-table",t=i.getAttrib(e,"border"),void(t&&"0"!=t||!n.hasVisual?i.removeClass(e,o):i.addClass(e,o));case"A":return void(i.getAttrib(e,"href",!1)||(t=i.getAttrib(e,"name")||e.id,o=r.visual_anchor_class||"mce-item-anchor",t&&n.hasVisual?i.addClass(e,o):i.removeClass(e,o)))}}),n.fire("VisualAid",{element:e,hasVisual:n.hasVisual})},remove:function(){var e=this;e.removed||(e.save(),e.removed=1,e.unbindAllNativeEvents(),e.hasHiddenInput&&k.remove(e.getElement().nextSibling),e.inline||(O&&10>O&&e.getDoc().execCommand("SelectAll",!1,null),k.setStyle(e.id,"display",e.orgDisplay),e.getBody().onload=null),e.fire("remove"),e.editorManager.remove(e),k.remove(e.getContainer()),e.destroy())},destroy:function(e){var t=this,n;if(!t.destroyed){if(!e&&!t.removed)return void t.remove();e||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),t.selection.destroy(),t.dom.destroy()),n=t.formElement,n&&(n._mceOldSubmit&&(n.submit=n._mceOldSubmit,n._mceOldSubmit=null),k.unbind(n,"submit reset",t.formEventDelegate)),t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null,t.selection&&(t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null),t.destroyed=1}},_refreshContentEditable:function(){var e=this,t,n;e._isHidden()&&(t=e.getBody(),n=t.parentNode,n.removeChild(t),n.appendChild(t),t.focus())},_isHidden:function(){var e;return P?(e=this.selection.getSel(),!e||!e.rangeCount||0===e.rangeCount):0}},R(N.prototype,_),N}),r(ft,[],function(){var e={};return{rtl:!1,add:function(t,n){for(var r in n)e[r]=n[r];this.rtl=this.rtl||"rtl"===e._dir},translate:function(t){if("undefined"==typeof t)return t;if("string"!=typeof t&&t.raw)return t.raw;if(t.push){var n=t.slice(1);t=(e[t[0]]||t[0]).replace(/\{([^\}]+)\}/g,function(e,t){return n[t]})}return e[t]||t},data:e}}),r(pt,[y,u],function(e,t){function n(e){function s(){try{return document.activeElement}catch(e){return document.body}}function l(e,t){if(t&&t.startContainer){if(!e.isChildOf(t.startContainer,e.getRoot())||!e.isChildOf(t.endContainer,e.getRoot()))return;return{startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}}return t}function c(e,t){var n;return t.startContainer?(n=e.getDoc().createRange(),n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset)):n=t,n}function u(e){return!!a.getParent(e,n.isEditorUIElement)}function d(n){var d=n.editor;d.on("init",function(){(d.inline||t.ie)&&("onbeforedeactivate"in document&&t.ie<9?d.dom.bind(d.getBody(),"beforedeactivate",function(e){if(e.target==d.getBody())try{d.lastRng=d.selection.getRng()}catch(t){}}):d.on("nodechange mouseup keyup",function(e){var t=s();"nodechange"==e.type&&e.selectionChange||(t&&t.id==d.id+"_ifr"&&(t=d.getBody()),d.dom.isChildOf(t,d.getBody())&&(d.lastRng=d.selection.getRng()))}),t.webkit&&!r&&(r=function(){var t=e.activeEditor;if(t&&t.selection){var n=t.selection.getRng();n&&!n.collapsed&&(d.lastRng=n)}},a.bind(document,"selectionchange",r)))}),d.on("setcontent",function(){d.lastRng=null}),d.on("mousedown",function(){d.selection.lastFocusBookmark=null}),d.on("focusin",function(){var t=e.focusedEditor;d.selection.lastFocusBookmark&&(d.selection.setRng(c(d,d.selection.lastFocusBookmark)),d.selection.lastFocusBookmark=null),t!=d&&(t&&t.fire("blur",{focusedEditor:d}),e.setActive(d),e.focusedEditor=d,d.fire("focus",{blurredEditor:t}),d.focus(!0)),d.lastRng=null}),d.on("focusout",function(){window.setTimeout(function(){var t=e.focusedEditor;u(s())||t!=d||(d.fire("blur",{focusedEditor:null}),e.focusedEditor=null,d.selection&&(d.selection.lastFocusBookmark=null))},0)}),i||(i=function(t){var n=e.activeEditor;n&&t.target.ownerDocument==document&&(n.selection&&t.target!=n.getBody()&&(n.selection.lastFocusBookmark=l(n.dom,n.lastRng)),t.target==document.body||u(t.target)||e.focusedEditor!=n||(n.fire("blur",{focusedEditor:null}),e.focusedEditor=null))},a.bind(document,"focusin",i)),d.inline&&!o&&(o=function(t){var n=e.activeEditor;if(n.inline&&!n.dom.isChildOf(t.target,n.getBody())){var r=n.selection.getRng();r.collapsed||(n.lastRng=r)}},a.bind(document,"mouseup",o))}function f(t){e.focusedEditor==t.editor&&(e.focusedEditor=null),e.activeEditor||(a.unbind(document,"selectionchange",r),a.unbind(document,"focusin",i),a.unbind(document,"mouseup",o),r=i=o=null)}e.on("AddEditor",d),e.on("RemoveEditor",f)}var r,i,o,a=e.DOM;return n.isEditorUIElement=function(e){return-1!==e.className.toString().indexOf("mce-")},n}),r(ht,[dt,f,y,V,u,d,lt,ft,pt],function(e,t,n,r,i,o,a,s,l){function c(e){var t=v.editors,n;delete t[e.id];for(var r=0;r0&&p(f(e),function(e){var n;(n=d.get(e))?r(e,t,n):p(document.forms,function(n){p(n.elements,function(n){n.name===e&&(e="mce_editor_"+m++,d.setAttrib(n,"id",e),r(e,t,n))})})});break;case"textareas":case"specific_textareas":p(d.select("textarea"),function(e){t.editor_deselector&&o(e,t.editor_deselector)||(!t.editor_selector||o(e,t.editor_selector))&&r(n(e),t,e)})}t.oninit&&(e=s=0,p(l,function(t){s++,t.initialized?e++:t.on("init",function(){e++,e==s&&i("oninit")}),e==s&&i("oninit")}))}var s=this,l=[];s.settings=t,d.bind(window,"ready",a)},get:function(e){return arguments.length?e in this.editors?this.editors[e]:null:this.editors},add:function(e){var t=this,n=t.editors;return n[e.id]=e,n.push(e),t.activeEditor=e,t.fire("AddEditor",{editor:e}),g||(g=function(){t.fire("BeforeUnload")},d.bind(window,"beforeunload",g)),e},createEditor:function(t,n){return this.add(new e(t,n,this))},remove:function(e){var t=this,n,r=t.editors,i;{if(e)return"string"==typeof e?(e=e.selector||e,void p(d.select(e),function(e){i=r[e.id],i&&t.remove(i)})):(i=e,r[i.id]?(c(i)&&t.fire("RemoveEditor",{editor:i}),r.length||d.unbind(window,"beforeunload",g),i.remove(),i):null);for(n=r.length-1;n>=0;n--)t.remove(r[n])}},execCommand:function(t,n,r){var i=this,o=i.get(r);switch(t){case"mceAddEditor":return i.get(r)||new e(r,i.settings,i).render(),!0;case"mceRemoveEditor":return o&&o.remove(),!0;case"mceToggleEditor":return o?(o.isHidden()?o.show():o.hide(),!0):(i.execCommand("mceAddEditor",0,r),!0)}return i.activeEditor?i.activeEditor.execCommand(t,n,r):!1},triggerSave:function(){p(this.editors,function(e){e.save()})},addI18n:function(e,t){s.add(e,t)},translate:function(e){return s.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!=e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e}},h(v,a),v.setup(),window.tinymce=window.tinyMCE=v,v}),r(mt,[ht,d],function(e,t){var n=t.each,r=t.explode;e.on("AddEditor",function(e){var t=e.editor;t.on("preInit",function(){function e(e,t){n(t,function(t,n){t&&s.setStyle(e,n,t)}),s.rename(e,"span")}function i(e){s=t.dom,l.convert_fonts_to_spans&&n(s.select("font,u,strike",e.node),function(e){o[e.nodeName.toLowerCase()](s,e)})}var o,a,s,l=t.settings;l.inline_styles&&(a=r(l.font_size_legacy_values),o={font:function(t,n){e(n,{backgroundColor:n.style.backgroundColor,color:n.color,fontFamily:n.face,fontSize:a[parseInt(n.size,10)-1]})},u:function(t,n){e(n,{textDecoration:"underline"})},strike:function(t,n){e(n,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",i))})})}),r(gt,[lt,d],function(e,t){var n={send:function(e){function t(){!e.async||4==r.readyState||i++>1e4?(e.success&&1e4>i&&200==r.status?e.success.call(e.success_scope,""+r.responseText,r,e):e.error&&e.error.call(e.error_scope,i>1e4?"TIMED_OUT":"GENERAL",r,e),r=null):setTimeout(t,10)}var r,i=0;if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=e.async===!1?!1:!0,e.data=e.data||"",r=new XMLHttpRequest){if(r.overrideMimeType&&r.overrideMimeType(e.content_type),r.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(r.withCredentials=!0),e.content_type&&r.setRequestHeader("Content-Type",e.content_type),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r=n.fire("beforeSend",{xhr:r,settings:e}).xhr,r.send(e.data),!e.async)return t();setTimeout(t,10)}}};return t.extend(n,e),n}),r(vt,[],function(){function e(t,n){var r,i,o,a;if(n=n||'"',null===t)return"null";if(o=typeof t,"string"==o)return i="\bb t\nn\ff\rr\"\"''\\\\",n+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=i.indexOf(t),r+1?"\\"+i.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e))})+n;if("object"==o){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(r=0,i="[";r0?",":"")+e(t[r],n);return i+"]"}i="{";for(a in t)t.hasOwnProperty(a)&&(i+="function"!=typeof t[a]?(i.length>1?","+n:n)+a+n+":"+e(t[a],n):"");return i+"}"}return""+t}return{serialize:e,parse:function(e){try{return window[String.fromCharCode(101)+"val"]("("+e+")")}catch(t){}}}}),r(yt,[vt,gt,d],function(e,t,n){function r(e){this.settings=i({},e),this.count=0}var i=n.extend;return r.sendRPC=function(e){return(new r).send(e)},r.prototype={send:function(n){var r=n.error,o=n.success;n=i(this.settings,n),n.success=function(t,i){t=e.parse(t),"undefined"==typeof t&&(t={error:"JSON Parse error."}),t.error?r.call(n.error_scope||n.scope,t.error,i):o.call(n.success_scope||n.scope,t.result)},n.error=function(e,t){r&&r.call(n.error_scope||n.scope,e,t)},n.data=e.serialize({id:n.id||"c"+this.count++,method:n.method,params:n.params}),n.content_type="application/json",t.send(n)}},r}),r(bt,[y],function(e){return{callbacks:{},count:0,send:function(n){var r=this,i=e.DOM,o=n.count!==t?n.count:r.count,a="tinymce_jsonp_"+o;r.callbacks[o]=function(e){i.remove(a),delete r.callbacks[o],n.callback(e)},i.add(i.doc.body,"script",{id:a,src:n.url,type:"text/javascript"}),r.count++}}}),r(Ct,[],function(){function e(){s=[];for(var e in a)s.push(e);i.length=s.length}function n(){function n(e){var n,r;return r=e!==t?u+e:i.indexOf(",",u),-1===r||r>i.length?null:(n=i.substring(u,r),u=r+1,n)}var r,i,s,u=0;if(a={},c){o.load(l),i=o.getAttribute(l)||"";do{var d=n();if(null===d)break;if(r=n(parseInt(d,32)||0),null!==r){if(d=n(),null===d)break;s=n(parseInt(d,32)||0),r&&(a[r]=s)}}while(null!==r);e()}}function r(){var t,n="";if(c){for(var r in a)t=a[r],n+=(n?",":"")+r.length.toString(32)+","+r+","+t.length.toString(32)+","+t;o.setAttribute(l,n);try{o.save(l)}catch(i){}e()}}var i,o,a,s,l,c;try{if(window.localStorage)return localStorage}catch(u){}return l="tinymce",o=document.documentElement,c=!!o.addBehavior,c&&o.addBehavior("#default#userData"),i={key:function(e){return s[e]},getItem:function(e){return e in a?a[e]:null},setItem:function(e,t){a[e]=""+t,r()},removeItem:function(e){delete a[e],r()},clear:function(){a={},r()}},n(),i}),r(xt,[y,l,b,C,d,u],function(e,t,n,r,i,o){var a=window.tinymce;return a.DOM=e.DOM,a.ScriptLoader=n.ScriptLoader,a.PluginManager=r.PluginManager,a.ThemeManager=r.ThemeManager,a.dom=a.dom||{},a.dom.Event=t.Event,i.each(i,function(e,t){a[t]=e}),i.each("isOpera isWebKit isIE isGecko isMac".split(" "),function(e){a[e]=o[e.substr(2).toLowerCase()]}),{}}),r(wt,[U,d],function(e,t){return e.extend({Defaults:{firstControlClass:"first",lastControlClass:"last"},init:function(e){this.settings=t.extend({},this.Defaults,e)},preRender:function(e){e.addClass(this.settings.containerClass,"body")},applyClasses:function(e){var t=this,n=t.settings,r,i,o;r=e.items().filter(":visible"),i=n.firstControlClass,o=n.lastControlClass,r.each(function(e){e.removeClass(i).removeClass(o),n.controlClass&&e.addClass(n.controlClass)}),r.eq(0).addClass(i),r.eq(-1).addClass(o)},renderHtml:function(e){var t=this,n=t.settings,r,i=""; +return r=e.items(),r.eq(0).addClass(n.firstControlClass),r.eq(-1).addClass(n.lastControlClass),r.each(function(e){n.controlClass&&e.addClass(n.controlClass),i+=e.renderHtml()}),i},recalc:function(){},postRender:function(){}})}),r(_t,[wt],function(e){return e.extend({Defaults:{containerClass:"abs-layout",controlClass:"abs-layout-item"},recalc:function(e){e.items().filter(":visible").each(function(e){var t=e.settings;e.layoutRect({x:t.x,y:t.y,w:t.w,h:t.h}),e.recalc&&e.recalc()})},renderHtml:function(e){return'
      '+this._super(e)}})}),r(Et,[K,tt],function(e,t){return e.extend({Mixins:[t],Defaults:{classes:"widget tooltip tooltip-n"},text:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t._rendered&&(t.getEl().lastChild.innerHTML=t.encode(e)),t):t._value},renderHtml:function(){var e=this,t=e.classPrefix;return'"},repaint:function(){var e=this,t,n;t=e.getEl().style,n=e._layoutRect,t.left=n.x+"px",t.top=n.y+"px",t.zIndex=131070}})}),r(Nt,[K,Et],function(e,t){var n,r=e.extend({init:function(e){var t=this;t._super(e),e=t.settings,t.canFocus=!0,e.tooltip&&r.tooltips!==!1&&(t.on("mouseenter",function(n){var r=t.tooltip().moveTo(-65535);if(n.control==t){var i=r.text(e.tooltip).show().testMoveRel(t.getEl(),["bc-tc","bc-tl","bc-tr"]);r.toggleClass("tooltip-n","bc-tc"==i),r.toggleClass("tooltip-nw","bc-tl"==i),r.toggleClass("tooltip-ne","bc-tr"==i),r.moveRel(t.getEl(),i)}else r.hide()}),t.on("mouseleave mousedown click",function(){t.tooltip().hide()})),t.aria("label",e.ariaLabel||e.tooltip)},tooltip:function(){return n||(n=new t({type:"tooltip"}),n.renderTo()),n},active:function(e){var t=this,n;return e!==n&&(t.aria("pressed",e),t.toggleClass("active",e)),t._super(e)},disabled:function(e){var t=this,n;return e!==n&&(t.aria("disabled",e),t.toggleClass("disabled",e)),t._super(e)},postRender:function(){var e=this,t=e.settings;e._rendered=!0,e._super(),e.parent()||!t.width&&!t.height||(e.initLayoutRect(),e.repaint()),t.autofocus&&e.focus()},remove:function(){this._super(),n&&(n.remove(),n=null)}});return r}),r(kt,[Nt],function(e){return e.extend({Defaults:{classes:"widget btn",role:"button"},init:function(e){var t=this,n;t.on("click mousedown",function(e){e.preventDefault()}),t._super(e),n=e.size,e.subtype&&t.addClass(e.subtype),n&&t.addClass("btn-"+n)},icon:function(e){var t=this,n=t.classPrefix;if("undefined"==typeof e)return t.settings.icon;if(t.settings.icon=e,e=e?n+"ico "+n+"i-"+t.settings.icon:"",t._rendered){var r=t.getEl().firstChild,i=r.getElementsByTagName("i")[0];e?(i&&i==r.firstChild||(i=document.createElement("i"),r.insertBefore(i,r.firstChild)),i.className=e):i&&r.removeChild(i),t.text(t._text)}return t},repaint:function(){var e=this.getEl().firstChild.style;e.width=e.height="100%",this._super()},text:function(e){var t=this;if(t._rendered){var n=t.getEl().lastChild.lastChild;n&&(n.data=t.translate(e))}return t._super(e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.settings.icon,i;return i=e.settings.image,i?(r="none","string"!=typeof i&&(i=window.getSelection?i[0]:i[1]),i=" style=\"background-image: url('"+i+"')\""):i="",r=e.settings.icon?n+"ico "+n+"i-"+r:"",'
      "}})}),r(St,[J],function(e){return e.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var e=this,t=e._layout;return e.addClass("btn-group"),e.preRender(),t.preRender(e),'
      '+(e.settings.html||"")+t.renderHtml(e)+"
      "}})}),r(Tt,[Nt],function(e){return e.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(e){var t=this;t._super(e),t.on("click mousedown",function(e){e.preventDefault()}),t.on("click",function(e){e.preventDefault(),t.disabled()||t.checked(!t.checked())}),t.checked(t.settings.checked)},checked:function(e){var t=this;return"undefined"!=typeof e?(e?t.addClass("checked"):t.removeClass("checked"),t._checked=e,t.aria("checked",e),t):t._checked},value:function(e){return this.checked(e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix;return'
      '+e.encode(e._text)+"
      "}})}),r(Rt,[Nt,G,Y],function(e,t,n){return e.extend({init:function(e){var t=this;t._super(e),t.addClass("combobox"),t.subinput=!0,t.ariaTarget="inp",e=t.settings,e.menu=e.menu||e.values,e.menu&&(e.icon="caret"),t.on("click",function(n){for(var r=n.target,i=t.getEl();r&&r!=i;)r.id&&-1!=r.id.indexOf("-open")&&(t.fire("action"),e.menu&&(t.showMenu(),n.aria&&t.menu.items()[0].focus())),r=r.parentNode}),t.on("keydown",function(e){"INPUT"==e.target.nodeName&&13==e.keyCode&&t.parents().reverse().each(function(n){return e.preventDefault(),t.fire("change"),n.hasEventListeners("submit")&&n.toJSON?(n.fire("submit",{data:n.toJSON()}),!1):void 0})}),e.placeholder&&(t.addClass("placeholder"),t.on("focusin",function(){t._hasOnChange||(n.on(t.getEl("inp"),"change",function(){t.fire("change")}),t._hasOnChange=!0),t.hasClass("placeholder")&&(t.getEl("inp").value="",t.removeClass("placeholder"))}),t.on("focusout",function(){0===t.value().length&&(t.getEl("inp").value=e.placeholder,t.addClass("placeholder"))}))},showMenu:function(){var e=this,n=e.settings,r;e.menu||(r=n.menu||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",e.menu=t.create(r).parent(e).renderTo(e.getContainerElm()),e.fire("createmenu"),e.menu.reflow(),e.menu.on("cancel",function(t){t.control===e.menu&&e.focus()}),e.menu.on("show hide",function(t){t.control.items().each(function(t){t.active(t.value()==e.value())})}).fire("show"),e.menu.on("select",function(t){e.value(t.control.value())}),e.on("focusin",function(t){"INPUT"==t.target.tagName.toUpperCase()&&e.menu.hide()}),e.aria("expanded",!0)),e.menu.show(),e.menu.layoutRect({w:e.layoutRect().w}),e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},value:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t.removeClass("placeholder"),t._rendered&&(t.getEl("inp").value=e),t):t._rendered?(e=t.getEl("inp").value,e!=t.settings.placeholder?e:""):t._value},disabled:function(e){var t=this;return t._rendered&&"undefined"!=typeof e&&(t.getEl("inp").disabled=e),t._super(e)},focus:function(){this.getEl("inp").focus()},repaint:function(){var e=this,t=e.getEl(),r=e.getEl("open"),i=e.layoutRect(),o,a;o=r?i.w-n.getSize(r).width-10:i.w-10;var s=document;return s.all&&(!s.documentMode||s.documentMode<=8)&&(a=e.layoutRect().h-2+"px"),n.css(t.firstChild,{width:o,lineHeight:a}),e._super(),e},postRender:function(){var e=this;return n.on(this.getEl("inp"),"change",function(){e.fire("change")}),e._super()},remove:function(){n.off(this.getEl("inp")),this._super()},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.classPrefix,i=n.value||n.placeholder||"",o,a,s="",l="";return"spellcheck"in n&&(l+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(l+=' maxlength="'+n.maxLength+'"'),n.size&&(l+=' size="'+n.size+'"'),n.subtype&&(l+=' type="'+n.subtype+'"'),e.disabled()&&(l+=' disabled="disabled"'),o=n.icon,o&&"caret"!=o&&(o=r+"ico "+r+"i-"+n.icon),a=e._text,(o||a)&&(s='
      ",e.addClass("has-open")),'
      "+s+"
      "}})}),r(At,[Rt],function(e){return e.extend({init:function(e){var t=this;e.spellcheck=!1,e.onaction&&(e.icon="none"),t._super(e),t.addClass("colorbox"),t.on("change keyup postrender",function(){t.repaintColor(t.value())})},repaintColor:function(e){var t=this.getEl().getElementsByTagName("i")[0];if(t)try{t.style.background=e}catch(n){}},value:function(e){var t=this;return"undefined"!=typeof e&&t._rendered&&t.repaintColor(e),t._super(e)}})}),r(Bt,[kt,rt],function(e,t){return e.extend({showPanel:function(){var e=this,n=e.settings;if(e.active(!0),e.panel)e.panel.show();else{var r=n.panel;r.type&&(r={layout:"grid",items:r}),r.role=r.role||"dialog",r.popover=!0,r.autohide=!0,r.ariaRoot=!0,e.panel=new t(r).on("hide",function(){e.active(!1)}).on("cancel",function(t){t.stopPropagation(),e.focus(),e.hidePanel()}).parent(e).renderTo(e.getContainerElm()),e.panel.fire("show"),e.panel.reflow()}e.panel.moveRel(e.getEl(),n.popoverAlign||(e.isRtl()?["bc-tr","bc-tc"]:["bc-tl","bc-tc"]))},hidePanel:function(){var e=this;e.panel&&e.panel.hide()},postRender:function(){var e=this;return e.aria("haspopup",!0),e.on("click",function(t){t.control===e&&(e.panel&&e.panel.visible()?e.hidePanel():(e.showPanel(),e.panel.focus(!!t.aria)))}),e._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})}),r(Dt,[Bt,y],function(e,t){var n=t.DOM;return e.extend({init:function(e){this._super(e),this.addClass("colorbutton")},color:function(e){return e?(this._color=e,this.getEl("preview").style.backgroundColor=e,this):this._color},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.settings.icon?n+"ico "+n+"i-"+e.settings.icon:"",i=e.settings.image?" style=\"background-image: url('"+e.settings.image+"')\"":"";return'
      '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(r){r.aria&&"down"==r.aria.key||r.control!=e||n.getParent(r.target,"."+e.classPrefix+"open")||(r.stopImmediatePropagation(),t.call(e,r))}),delete e.settings.onclick,e._super()}})}),r(Lt,[],function(){function e(e){function i(e,i,o){var a,s,l,c,u,d;return a=0,s=0,l=0,e/=255,i/=255,o/=255,u=t(e,t(i,o)),d=n(e,n(i,o)),u==d?(l=u,{h:0,s:0,v:100*l}):(c=e==u?i-o:o==u?e-i:o-e,a=e==u?3:o==u?1:5,a=60*(a-c/(d-u)),s=(d-u)/d,l=d,{h:r(a),s:r(100*s),v:r(100*l)})}function o(e,i,o){var a,s,l,c;if(e=(parseInt(e,10)||0)%360,i=parseInt(i,10)/100,o=parseInt(o,10)/100,i=n(0,t(i,1)),o=n(0,t(o,1)),0===i)return void(d=f=p=r(255*o));switch(a=e/60,s=o*i,l=s*(1-Math.abs(a%2-1)),c=o-s,Math.floor(a)){case 0:d=s,f=l,p=0;break;case 1:d=l,f=s,p=0;break;case 2:d=0,f=s,p=l;break;case 3:d=0,f=l,p=s;break;case 4:d=l,f=0,p=s;break;case 5:d=s,f=0,p=l;break;default:d=f=p=0}d=r(255*(d+c)),f=r(255*(f+c)),p=r(255*(p+c))}function a(){function e(e){return e=parseInt(e,10).toString(16),e.length>1?e:"0"+e}return"#"+e(d)+e(f)+e(p)}function s(){return{r:d,g:f,b:p}}function l(){return i(d,f,p)}function c(e){var t;return"object"==typeof e?"r"in e?(d=e.r,f=e.g,p=e.b):"v"in e&&o(e.h,e.s,e.v):(t=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(e))?(d=parseInt(t[1],10),f=parseInt(t[2],10),p=parseInt(t[3],10)):(t=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(e))?(d=parseInt(t[1],16),f=parseInt(t[2],16),p=parseInt(t[3],16)):(t=/#([0-F])([0-F])([0-F])/gi.exec(e))&&(d=parseInt(t[1]+t[1],16),f=parseInt(t[2]+t[2],16),p=parseInt(t[3]+t[3],16)),d=0>d?0:d>255?255:d,f=0>f?0:f>255?255:f,p=0>p?0:p>255?255:p,u}var u=this,d=0,f=0,p=0;e&&c(e),u.toRgb=s,u.toHsv=l,u.toHex=a,u.parse=c}var t=Math.min,n=Math.max,r=Math.round;return e}),r(Ht,[Nt,Q,Y,Lt],function(e,t,n,r){return e.extend({Defaults:{classes:"widget colorpicker"},init:function(e){this._super(e)},postRender:function(){function e(e,t){var r=n.getPos(e),i,o;return i=t.pageX-r.x,o=t.pageY-r.y,i=Math.max(0,Math.min(i/e.clientWidth,1)),o=Math.max(0,Math.min(o/e.clientHeight,1)),{x:i,y:o}}function i(e,t){var i=(360-e.h)/360;n.css(d,{top:100*i+"%"}),t||n.css(p,{left:e.s+"%",top:100-e.v+"%"}),f.style.background=new r({s:100,v:100,h:e.h}).toHex(),s.color().parse({s:e.s,v:e.v,h:e.h})}function o(t){var n;n=e(f,t),c.s=100*n.x,c.v=100*(1-n.y),i(c),s.fire("change")}function a(t){var n;n=e(u,t),c=l.toHsv(),c.h=360*(1-n.y),i(c,!0),s.fire("change")}var s=this,l=s.color(),c,u,d,f,p;u=s.getEl("h"),d=s.getEl("hp"),f=s.getEl("sv"),p=s.getEl("svp"),s._repaint=function(){c=l.toHsv(),i(c)},s._super(),s._svdraghelper=new t(s._id+"-sv",{start:o,drag:o}),s._hdraghelper=new t(s._id+"-h",{start:a,drag:a}),s._repaint()},rgb:function(){return this.color().toRgb()},value:function(e){var t=this;return arguments.length?(t.color().parse(e),void(t._rendered&&t._repaint())):t.color().toHex()},color:function(){return this._color||(this._color=new r),this._color},renderHtml:function(){function e(){var e,t,n="",i,a;for(i="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",a=o.split(","),e=0,t=a.length-1;t>e;e++)n+='
      ';return n}var t=this,n=t._id,r=t.classPrefix,i,o="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",a="background: -ms-linear-gradient(top,"+o+");background: linear-gradient(to bottom,"+o+");";return i='
      '+e()+'
      ','
      '+i+"
      "}})}),r(Mt,[Nt],function(e){return e.extend({init:function(e){var t=this;e.delimiter||(e.delimiter="\xbb"),t._super(e),t.addClass("path"),t.canFocus=!0,t.on("click",function(e){var n,r=e.target;(n=r.getAttribute("data-index"))&&t.fire("select",{value:t.data()[n],index:n})})},focus:function(){var e=this;return e.getEl().firstChild.focus(),e},data:function(e){var t=this;return"undefined"!=typeof e?(t._data=e,t.update(),t):t._data},update:function(){this.innerHtml(this._getPathHtml())},postRender:function(){var e=this;e._super(),e.data(e.settings.data)},renderHtml:function(){var e=this;return'
      '+e._getPathHtml()+"
      "},_getPathHtml:function(){var e=this,t=e._data||[],n,r,i="",o=e.classPrefix;for(n=0,r=t.length;r>n;n++)i+=(n>0?'":"")+'
      '+t[n].name+"
      ";return i||(i='
      \xa0
      '),i}})}),r(Pt,[Mt,ht],function(e,t){return e.extend({postRender:function(){function e(e){if(1===e.nodeType){if("BR"==e.nodeName||e.getAttribute("data-mce-bogus"))return!0;if("bookmark"===e.getAttribute("data-mce-type"))return!0}return!1}var n=this,r=t.activeEditor;return n.on("select",function(e){r.focus(),r.selection.select(this.data()[e.index].element),r.nodeChanged()}),r.on("nodeChange",function(t){for(var i=[],o=t.parents,a=o.length;a--;)if(1==o[a].nodeType&&!e(o[a])){var s=r.fire("ResolveName",{name:o[a].nodeName.toLowerCase(),target:o[a]});if(s.isDefaultPrevented()||i.push({name:s.name,element:o[a]}),s.isPropagationStopped())break}n.data(i)}),n._super()}})}),r(Ot,[J],function(e){return e.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.addClass("formitem"),t.preRender(e),'
      '+(e.settings.title?'
      '+e.settings.title+"
      ":"")+'
      '+(e.settings.html||"")+t.renderHtml(e)+"
      "}})}),r(It,[J,Ot,d],function(e,t,n){return e.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:20,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var e=this,r=e.items();e.settings.formItemDefaults||(e.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),r.each(function(r){var i,o=r.settings.label;o&&(i=new t(n.extend({items:{type:"label",id:r._id+"-l",text:o,flex:0,forId:r._id,disabled:r.disabled()}},e.settings.formItemDefaults)),i.type="formitem",r.aria("labelledby",r._id+"-l"),"undefined"==typeof r.settings.flex&&(r.settings.flex=1),e.replace(r,i),i.add(r))})},recalcLabels:function(){var e=this,t=0,n=[],r,i,o;if(e.settings.labelGapCalc!==!1)for(o="children"==e.settings.labelGapCalc?e.find("formitem"):e.items(),o.filter("formitem").each(function(e){var r=e.items()[0],i=r.getEl().clientWidth;t=i>t?i:t,n.push(r)}),i=e.settings.labelGap||0,r=n.length;r--;)n[r].settings.minWidth=t+i},visible:function(e){var t=this._super(e);return e===!0&&this._rendered&&this.recalcLabels(),t},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var e=this;e._super(),e.recalcLabels(),e.fromJSON(e.settings.data)}})}),r(Ft,[It],function(e){return e.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.preRender(),t.preRender(e),'
      '+(e.settings.title?''+e.settings.title+"":"")+'
      '+(e.settings.html||"")+t.renderHtml(e)+"
      "}})}),r(zt,[Rt,d],function(e,t){return e.extend({init:function(e){var n=this,r=tinymce.activeEditor,i=r.settings,o,a,s;e.spellcheck=!1,s=i.file_picker_types||i.file_browser_callback_types,s&&(s=t.makeMap(s,/[, ]/)),(!s||s[e.filetype])&&(a=i.file_picker_callback,!a||s&&!s[e.filetype]?(a=i.file_browser_callback,!a||s&&!s[e.filetype]||(o=function(){a(n.getEl("inp").id,n.value(),e.filetype,window)})):o=function(){var i=n.fire("beforecall").meta;i=t.extend({filetype:e.filetype},i),a.call(r,function(e,t){n.value(e).fire("change",{meta:t})},n.value(),i)}),o&&(e.icon="browse",e.onaction=o),n._super(e)}})}),r(Wt,[_t],function(e){return e.extend({recalc:function(e){var t=e.layoutRect(),n=e.paddingBox();e.items().filter(":visible").each(function(e){e.layoutRect({x:n.left,y:n.top,w:t.innerW-n.right-n.left,h:t.innerH-n.top-n.bottom}),e.recalc&&e.recalc()})}})}),r(Vt,[_t],function(e){return e.extend({recalc:function(e){var t,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v=[],y,b,C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F,z=Math.max,W=Math.min;for(r=e.items().filter(":visible"),i=e.layoutRect(),o=e._paddingBox,a=e.settings,f=e.isRtl()?a.direction||"row-reversed":a.direction,s=a.align,l=e.isRtl()?a.pack||"end":a.pack,c=a.spacing||0,("row-reversed"==f||"column-reverse"==f)&&(r=r.set(r.toArray().reverse()),f=f.split("-")[0]),"column"==f?(k="y",E="h",N="minH",S="maxH",R="innerH",T="top",A="deltaH",B="contentH",P="left",H="w",D="x",L="innerW",M="minW",O="right",I="deltaW",F="contentW"):(k="x",E="w",N="minW",S="maxW",R="innerW",T="left",A="deltaW",B="contentW",P="top",H="h",D="y",L="innerH",M="minH",O="bottom",I="deltaH",F="contentH"),d=i[R]-o[T]-o[T],_=u=0,t=0,n=r.length;n>t;t++)p=r[t],h=p.layoutRect(),m=p.settings,g=m.flex,d-=n-1>t?c:0,g>0&&(u+=g,h[S]&&v.push(p),h.flex=g),d-=h[N],y=o[P]+h[M]+o[O],y>_&&(_=y);if(x={},x[N]=0>d?i[N]-d+i[A]:i[R]-d+i[A],x[M]=_+i[I],x[B]=i[R]-d,x[F]=_,x.minW=W(x.minW,i.maxW),x.minH=W(x.minH,i.maxH),x.minW=z(x.minW,i.startMinWidth),x.minH=z(x.minH,i.startMinHeight),!i.autoResize||x.minW==i.minW&&x.minH==i.minH){for(C=d/u,t=0,n=v.length;n>t;t++)p=v[t],h=p.layoutRect(),b=h[S],y=h[N]+h.flex*C,y>b?(d-=h[S]-h[N],u-=h.flex,h.flex=0,h.maxFlexSize=b):h.maxFlexSize=0;for(C=d/u,w=o[T],x={},0===u&&("end"==l?w=d+o[T]:"center"==l?(w=Math.round(i[R]/2-(i[R]-d)/2)+o[T],0>w&&(w=o[T])):"justify"==l&&(w=o[T],c=Math.floor(d/(r.length-1)))),x[D]=o[P],t=0,n=r.length;n>t;t++)p=r[t],h=p.layoutRect(),y=h.maxFlexSize||h[N],"center"===s?x[D]=Math.round(i[L]/2-h[H]/2):"stretch"===s?(x[H]=z(h[M]||0,i[L]-o[P]-o[O]),x[D]=o[P]):"end"===s&&(x[D]=i[L]-h[H]-o.top),h.flex>0&&(y+=h.flex*C),x[E]=y,x[k]=w,p.layoutRect(x),p.recalc&&p.recalc(),w+=y+c}else if(x.w=x.minW,x.h=x.minH,e.layoutRect(x),this.recalc(e),null===e._lastRect){var V=e.parent();V&&(V._lastRect=null,V.recalc())}}})}),r(Ut,[wt],function(e){return e.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(e){e.items().filter(":visible").each(function(e){e.recalc&&e.recalc()})}})}),r($t,[K,Nt,rt,d,ht,u],function(e,t,n,r,i,o){function a(e){function t(t,n){return function(){var r=this;e.on("nodeChange",function(i){var o=e.formatter,a=null;s(i.parents,function(e){return s(t,function(t){return n?o.matchNode(e,n,{value:t.value})&&(a=t.value):o.matchNode(e,t.value)&&(a=t.value),a?!1:void 0}),a?!1:void 0}),r.value(a)})}}function r(e){e=e.replace(/;$/,"").split(";");for(var t=e.length;t--;)e[t]=e[t].split("=");return e}function i(){function t(e){var n=[];if(e)return s(e,function(e){var o={text:e.title,icon:e.icon};if(e.items)o.menu=t(e.items);else{var a=e.format||"custom"+r++;e.format||(e.name=a,i.push(e)),o.format=a,o.cmd=e.cmd}n.push(o)}),n}function n(){var n;return n=t(e.settings.style_formats_merge?e.settings.style_formats?o.concat(e.settings.style_formats):o:e.settings.style_formats||o)}var r=0,i=[],o=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}];return e.on("init",function(){s(i,function(t){e.formatter.register(t.name,t)})}),{type:"menu",items:n(),onPostRender:function(t){e.fire("renderFormatsMenu",{control:t.control})},itemDefaults:{preview:!0,textStyle:function(){return this.settings.format?e.formatter.getCssText(this.settings.format):void 0},onPostRender:function(){var t=this;t.parent().on("show",function(){var n,r;n=t.settings.format,n&&(t.disabled(!e.formatter.canApply(n)),t.active(e.formatter.match(n))),r=t.settings.cmd,r&&t.active(e.queryCommandState(r))})},onclick:function(){this.settings.format&&l(this.settings.format),this.settings.cmd&&e.execCommand(this.settings.cmd)}}}}function o(t){return function(){function n(){return e.undoManager?e.undoManager[t]():!1}var r=this;t="redo"==t?"hasRedo":"hasUndo",r.disabled(!n()),e.on("Undo Redo AddUndo TypingUndo ClearUndos",function(){r.disabled(!n())})}}function a(){var t=this;e.on("VisualAid",function(e){t.active(e.hasVisual)}),t.active(e.hasVisual)}function l(t){t.control&&(t=t.control.value()),t&&e.execCommand("mceToggleFormat",!1,t)}var c;c=i(),s({bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript"},function(t,n){e.addButton(n,{tooltip:t,onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",shortcut:"Ctrl+N",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Ctrl+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Ctrl+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Ctrl+X"],copy:["Copy","Copy","Ctrl+C"],paste:["Paste","Paste","Ctrl+V"],selectall:["Select all","SelectAll","Ctrl+A"],bold:["Bold","Bold","Ctrl+B"],italic:["Italic","Italic","Ctrl+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Address=address;Pre=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(qt,[_t],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;f++)_+=N[f]+(f>0?b:0),R-=(f>0?b:0)+N[f];if(w+=g.left+g.right,_+=g.top+g.bottom,l={},l.minW=w+(o.w-o.innerW),l.minH=_+(o.h-o.innerH),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH,l.minW=Math.min(l.minW,o.maxW),l.minH=Math.min(l.minH,o.maxH),l.minW=Math.max(l.minW,o.startMinWidth),l.minH=Math.max(l.minH,o.startMinHeight),!o.autoResize||l.minW==o.minW&&l.minH==o.minH){o.autoResize&&(l=e.layoutRect(l),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH);var D;D="start"==t.packV?0:R>0?Math.floor(R/n):0;var L=0,H=t.flexWidths;if(H)for(d=0;dd;d++)E[d]+=H?H[d]*M:M;for(h=g.top,f=0;n>f;f++){for(p=g.left,s=N[f]+D,d=0;r>d&&(B=A?f*r+r-1-d:f*r+d,u=i[B],u);d++)m=u.settings,c=u.layoutRect(),a=Math.max(E[d],c.startMinWidth),c.x=p,c.y=h,v=m.alignH||(C?C[d]||C[0]:null),"center"==v?c.x=p+a/2-c.w/2:"right"==v?c.x=p+a-c.w:"stretch"==v&&(c.w=a),v=m.alignV||(x?x[d]||x[0]:null),"center"==v?c.y=h+s/2-c.h/2:"bottom"==v?c.y=h+s-c.h:"stretch"==v&&(c.h=s),u.layoutRect(c),p+=a+y,u.recalc&&u.recalc();h+=s+b}}else if(l.w=l.minW,l.h=l.minH,e.layoutRect(l),this.recalc(e),null===e._lastRect){var P=e.parent();P&&(P._lastRect=null,P.recalc())}}})}),r(jt,[Nt],function(e){return e.extend({renderHtml:function(){var e=this;return e.addClass("iframe"),e.canFocus=!1,''},src:function(e){this.getEl().src=e},html:function(e,t){var n=this,r=this.getEl().contentWindow.document.body;return r?(r.innerHTML=e,t&&t()):setTimeout(function(){n.html(e)},0),this}})}),r(Yt,[Nt,Y],function(e,t){return e.extend({init:function(e){var t=this;t._super(e),t.addClass("widget"),t.addClass("label"),t.canFocus=!1,e.multiline&&t.addClass("autoscroll"),e.strong&&t.addClass("strong")},initLayoutRect:function(){var e=this,n=e._super();if(e.settings.multiline){var r=t.getSize(e.getEl());r.width>n.maxW&&(n.minW=n.maxW,e.addClass("multiline")),e.getEl().style.width=n.minW+"px",n.startMinH=n.h=n.minH=Math.min(n.maxH,t.getSize(e.getEl()).height)}return n},repaint:function(){var e=this;return e.settings.multiline||(e.getEl().style.lineHeight=e.layoutRect().h+"px"),e._super()},text:function(e){var t=this;return t._rendered&&e&&this.innerHtml(t.encode(e)),t._super(e)},renderHtml:function(){var e=this,t=e.settings.forId;return'" +}})}),r(Kt,[J],function(e){return e.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(e){var t=this;t._super(e),t.addClass("toolbar")},postRender:function(){var e=this;return e.items().addClass("toolbar-item"),e._super()}})}),r(Gt,[Kt],function(e){return e.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})}),r(Xt,[kt,G,Gt],function(e,t,n){function r(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1}var i=e.extend({init:function(e){var t=this;t._renderOpen=!0,t._super(e),t.addClass("menubtn"),e.fixedWidth&&t.addClass("fixed-width"),t.aria("haspopup",!0),t.hasPopup=!0},showMenu:function(){var e=this,n=e.settings,r;return e.menu&&e.menu.visible()?e.hideMenu():(e.menu||(r=n.menu||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",e.menu=t.create(r).parent(e).renderTo(),e.fire("createmenu"),e.menu.reflow(),e.menu.on("cancel",function(t){t.control.parent()===e.menu&&(t.stopPropagation(),e.focus(),e.hideMenu())}),e.menu.on("select",function(){e.focus()}),e.menu.on("show hide",function(t){t.control==e.menu&&e.activeMenu("show"==t.type),e.aria("expanded","show"==t.type)}).fire("show")),e.menu.show(),e.menu.layoutRect({w:e.layoutRect().w}),void e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]))},hideMenu:function(){var e=this;e.menu&&(e.menu.items().each(function(e){e.hideMenu&&e.hideMenu()}),e.menu.hide())},activeMenu:function(e){this.toggleClass("active",e)},renderHtml:function(){var e=this,t=e._id,r=e.classPrefix,i=e.settings.icon,o;return o=e.settings.image,o?(i="none","string"!=typeof o&&(o=window.getSelection?o[0]:o[1]),o=" style=\"background-image: url('"+o+"')\""):o="",i=e.settings.icon?r+"ico "+r+"i-"+i:"",e.aria("role",e.parent()instanceof n?"menuitem":"button"),'
      '},postRender:function(){var e=this;return e.on("click",function(t){t.control===e&&r(t.target,e.getEl())&&(e.showMenu(),t.aria&&e.menu.items()[0].focus())}),e.on("mouseenter",function(t){var n=t.control,r=e.parent(),o;n&&r&&n instanceof i&&n.parent()==r&&(r.items().filter("MenuButton").each(function(e){e.hideMenu&&e!=n&&(e.menu&&e.menu.visible()&&(o=!0),e.hideMenu())}),o&&(n.focus(),n.showMenu()))}),e._super()},text:function(e){var t=this,n,r;if(t._rendered)for(r=t.getEl("open").getElementsByTagName("span"),n=0;n0&&(o=r[0].text,n._value=r[0].value),e.menu=r),e.text=e.text||o||r[0].text,n._super(e),n.addClass("listbox"),n.on("select",function(t){var r=t.control;a&&(t.lastControl=a),e.multiple?r.active(!r.active()):n.value(t.control.settings.value),a=r})},value:function(e){function t(e,n){e.items().each(function(e){i=e.value()===n,i&&(o=o||e.text()),e.active(i),e.menu&&t(e.menu,n)})}function n(t){for(var r=0;r'+("-"!==o?'\xa0":"")+("-"!==o?''+o+"":"")+(l?'
      '+l+"
      ":"")+(r.menu?'
      ':"")+"
      "},postRender:function(){var e=this,t=e.settings,n=t.textStyle;if("function"==typeof n&&(n=n.call(this)),n){var r=e.getEl("text");r&&r.setAttribute("style",n)}return e.on("mouseenter click",function(n){n.control===e&&(t.menu||"click"!==n.type?(e.showMenu(),n.aria&&e.menu.focus(!0)):(e.fire("select"),e.parent().hideAll()))}),e._super(),e},active:function(e){return"undefined"!=typeof e&&this.aria("checked",e),this._super(e)},remove:function(){this._super(),this.menu&&this.menu.remove()}})}),r(Zt,[rt,Qt,d],function(e,t,n){var r=e.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(e){var t=this;if(e.autohide=!0,e.constrainToViewport=!0,e.itemDefaults)for(var r=e.items,i=r.length;i--;)r[i]=n.extend({},e.itemDefaults,r[i]);t._super(e),t.addClass("menu")},repaint:function(){return this.toggleClass("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var e=this;e.hideAll(),e.fire("select")},hideAll:function(){var e=this;return this.find("menuitem").exec("hideMenu"),e._super()},preRender:function(){var e=this;return e.items().each(function(t){var n=t.settings;return n.icon||n.selectable?(e._hasIcons=!0,!1):void 0}),e._super()}});return r}),r(en,[Tt],function(e){return e.extend({Defaults:{classes:"radio",role:"radio"}})}),r(tn,[Nt,Q],function(e,t){return e.extend({renderHtml:function(){var e=this,t=e.classPrefix;return e.addClass("resizehandle"),"both"==e.settings.direction&&e.addClass("resizehandle-both"),e.canFocus=!1,'
      '},postRender:function(){var e=this;e._super(),e.resizeDragHelper=new t(this._id,{start:function(){e.fire("ResizeStart")},drag:function(t){"both"!=e.settings.direction&&(t.deltaX=0),e.fire("Resize",t)},stop:function(){e.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})}),r(nn,[Nt],function(e){return e.extend({renderHtml:function(){var e=this;return e.addClass("spacer"),e.canFocus=!1,'
      '}})}),r(rn,[Xt,Y],function(e,t){return e.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var e=this,n=e.getEl(),r=e.layoutRect(),i,o;return e._super(),i=n.firstChild,o=n.lastChild,t.css(i,{width:r.w-t.getSize(o).width,height:r.h-2}),t.css(o,{height:r.h-2}),e},activeMenu:function(e){var n=this;t.toggleClass(n.getEl().lastChild,n.classPrefix+"active",e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r,i=e.settings.icon;return r=e.settings.image,r?(i="none","string"!=typeof r&&(r=window.getSelection?r[0]:r[1]),r=" style=\"background-image: url('"+r+"')\""):r="",i=e.settings.icon?n+"ico "+n+"i-"+i:"",'
      '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(e){var n=e.target;if(e.control==this)for(;n;){if(e.aria&&"down"!=e.aria.key||"BUTTON"==n.nodeName&&-1==n.className.indexOf("open"))return e.stopImmediatePropagation(),void t.call(this,e);n=n.parentNode}}),delete e.settings.onclick,e._super()}})}),r(on,[Ut],function(e){return e.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"}})}),r(an,[et,Y],function(e,t){return e.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(e){var n;this.activeTabId&&(n=this.getEl(this.activeTabId),t.removeClass(n,this.classPrefix+"active"),n.setAttribute("aria-selected","false")),this.activeTabId="t"+e,n=this.getEl("t"+e),n.setAttribute("aria-selected","true"),t.addClass(n,this.classPrefix+"active"),this.items()[e].show().fire("showtab"),this.reflow(),this.items().each(function(t,n){e!=n&&t.hide()})},renderHtml:function(){var e=this,t=e._layout,n="",r=e.classPrefix;return e.preRender(),t.preRender(e),e.items().each(function(t,i){var o=e._id+"-t"+i;t.aria("role","tabpanel"),t.aria("labelledby",o),n+='"}),'
      '+n+'
      '+t.renderHtml(e)+"
      "},postRender:function(){var e=this;e._super(),e.settings.activeTab=e.settings.activeTab||0,e.activateTab(e.settings.activeTab),this.on("click",function(t){var n=t.target.parentNode;if(t.target.parentNode.id==e._id+"-head")for(var r=n.childNodes.length;r--;)n.childNodes[r]==t.target&&e.activateTab(r)})},initLayoutRect:function(){var e=this,n,r,i;r=t.getSize(e.getEl("head")).width,r=0>r?0:r,i=0,e.items().each(function(e){r=Math.max(r,e.layoutRect().minW),i=Math.max(i,e.layoutRect().minH)}),e.items().each(function(e){e.settings.x=0,e.settings.y=0,e.settings.w=r,e.settings.h=i,e.layoutRect({x:0,y:0,w:r,h:i})});var o=t.getSize(e.getEl("head")).height;return e.settings.minWidth=r,e.settings.minHeight=i+o,n=e._super(),n.deltaH+=o,n.innerH=n.h-n.deltaH,n}})}),r(sn,[Nt,Y],function(e,t){return e.extend({init:function(e){var t=this;t._super(e),t._value=e.value||"",t.addClass("textbox"),e.multiline?t.addClass("multiline"):t.on("keydown",function(e){13==e.keyCode&&t.parents().reverse().each(function(t){return e.preventDefault(),t.hasEventListeners("submit")&&t.toJSON?(t.fire("submit",{data:t.toJSON()}),!1):void 0})})},disabled:function(e){var t=this;return t._rendered&&"undefined"!=typeof e&&(t.getEl().disabled=e),t._super(e)},value:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t._rendered&&(t.getEl().value=e),t):t._rendered?t.getEl().value:t._value},repaint:function(){var e=this,t,n,r,i=0,o=0,a;t=e.getEl().style,n=e._layoutRect,a=e._lastRepaintRect||{};var s=document;return!e.settings.multiline&&s.all&&(!s.documentMode||s.documentMode<=8)&&(t.lineHeight=n.h-o+"px"),r=e._borderBox,i=r.left+r.right+8,o=r.top+r.bottom+(e.settings.multiline?8:0),n.x!==a.x&&(t.left=n.x+"px",a.x=n.x),n.y!==a.y&&(t.top=n.y+"px",a.y=n.y),n.w!==a.w&&(t.width=n.w-i+"px",a.w=n.w),n.h!==a.h&&(t.height=n.h-o+"px",a.h=n.h),e._lastRepaintRect=a,e.fire("repaint",{},!1),e},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.encode(e._value,!1),i="";return"spellcheck"in n&&(i+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(i+=' maxlength="'+n.maxLength+'"'),n.size&&(i+=' size="'+n.size+'"'),n.subtype&&(i+=' type="'+n.subtype+'"'),e.disabled()&&(i+=' disabled="disabled"'),n.multiline?'":'"},postRender:function(){var e=this;return t.on(e.getEl(),"change",function(t){e.fire("change",t)}),e._super()},remove:function(){t.off(this.getEl()),this._super()}})}),r(ln,[Y,K],function(e,t){return function(n,r){var i=this,o,a=t.classPrefix;i.show=function(t){return i.hide(),o=!0,window.setTimeout(function(){o&&n.appendChild(e.createFragment('
      '))},t||0),i},i.hide=function(){var e=n.lastChild;return e&&-1!=e.className.indexOf("throbber")&&e.parentNode.removeChild(e),o=!1,i}}}),a([l,c,u,d,f,p,h,m,g,y,b,C,_,E,N,k,S,T,R,A,B,D,L,H,M,O,I,F,z,W,V,U,$,q,j,Y,K,G,X,J,Q,Z,et,tt,nt,rt,it,ot,at,st,lt,ct,ut,dt,ft,pt,ht,mt,gt,vt,yt,bt,Ct,xt,wt,_t,Et,Nt,kt,St,Tt,Rt,At,Bt,Dt,Lt,Ht,Mt,Pt,Ot,It,Ft,zt,Wt,Vt,Ut,$t,qt,jt,Yt,Kt,Gt,Xt,Jt,Qt,Zt,en,tn,nn,rn,on,an,sn,ln])}(this); +/*! + + handlebars v1.3.0 + +Copyright (C) 2011 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +@license +*/ +/* exported Handlebars */ +var Handlebars = (function() { +// handlebars/safe-string.js +var __module4__ = (function() { + "use strict"; + var __exports__; + // Build out our basic SafeString type + function SafeString(string) { + this.string = string; + } + + SafeString.prototype.toString = function() { + return "" + this.string; + }; + + __exports__ = SafeString; + return __exports__; +})(); + +// handlebars/utils.js +var __module3__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + /*jshint -W004 */ + var SafeString = __dependency1__; + + var escape = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + function escapeChar(chr) { + return escape[chr] || "&"; + } + + function extend(obj, value) { + for(var key in value) { + if(Object.prototype.hasOwnProperty.call(value, key)) { + obj[key] = value[key]; + } + } + } + + __exports__.extend = extend;var toString = Object.prototype.toString; + __exports__.toString = toString; + // Sourced from lodash + // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt + var isFunction = function(value) { + return typeof value === 'function'; + }; + // fallback for older versions of Chrome and Safari + if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; + } + var isFunction; + __exports__.isFunction = isFunction; + var isArray = Array.isArray || function(value) { + return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; + }; + __exports__.isArray = isArray; + + function escapeExpression(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof SafeString) { + return string.toString(); + } else if (!string && string !== 0) { + return ""; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = "" + string; + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + } + + __exports__.escapeExpression = escapeExpression;function isEmpty(value) { + if (!value && value !== 0) { + return true; + } else if (isArray(value) && value.length === 0) { + return true; + } else { + return false; + } + } + + __exports__.isEmpty = isEmpty; + return __exports__; +})(__module4__); + +// handlebars/exception.js +var __module5__ = (function() { + "use strict"; + var __exports__; + + var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + + function Exception(message, node) { + var line; + if (node && node.firstLine) { + line = node.firstLine; + + message += ' - ' + line + ':' + node.firstColumn; + } + + var tmp = Error.prototype.constructor.call(this, message); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } + + if (line) { + this.lineNumber = line; + this.column = node.firstColumn; + } + } + + Exception.prototype = new Error(); + + __exports__ = Exception; + return __exports__; +})(); + +// handlebars/base.js +var __module2__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var Utils = __dependency1__; + var Exception = __dependency2__; + + var VERSION = "1.3.0"; + __exports__.VERSION = VERSION;var COMPILER_REVISION = 4; + __exports__.COMPILER_REVISION = COMPILER_REVISION; + var REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '>= 1.0.0' + }; + __exports__.REVISION_CHANGES = REVISION_CHANGES; + var isArray = Utils.isArray, + isFunction = Utils.isFunction, + toString = Utils.toString, + objectType = '[object Object]'; + + function HandlebarsEnvironment(helpers, partials) { + this.helpers = helpers || {}; + this.partials = partials || {}; + + registerDefaultHelpers(this); + } + + __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = { + constructor: HandlebarsEnvironment, + + logger: logger, + log: log, + + registerHelper: function(name, fn, inverse) { + if (toString.call(name) === objectType) { + if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); } + Utils.extend(this.helpers, name); + } else { + if (inverse) { fn.not = inverse; } + this.helpers[name] = fn; + } + }, + + registerPartial: function(name, str) { + if (toString.call(name) === objectType) { + Utils.extend(this.partials, name); + } else { + this.partials[name] = str; + } + } + }; + + function registerDefaultHelpers(instance) { + instance.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Exception("Missing helper: '" + arg + "'"); + } + }); + + instance.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + if (isFunction(context)) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if (isArray(context)) { + if(context.length > 0) { + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } + }); + + instance.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (isFunction(context)) { context = context.call(this); } + + if (options.data) { + data = createFrame(options.data); + } + + if(context && typeof context === 'object') { + if (isArray(context)) { + for(var j = context.length; i 0) { + throw new Exception("Invalid path: " + original, this); + } else if (part === "..") { + depth++; + } else { + this.isScoped = true; + } + } else { + dig.push(part); + } + } + + this.original = original; + this.parts = dig; + this.string = dig.join('.'); + this.depth = depth; + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; + + this.stringModeValue = this.string; + }, + + PartialNameNode: function(name, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "PARTIAL_NAME"; + this.name = name.original; + }, + + DataNode: function(id, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "DATA"; + this.id = id; + }, + + StringNode: function(string, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "STRING"; + this.original = + this.string = + this.stringModeValue = string; + }, + + IntegerNode: function(integer, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "INTEGER"; + this.original = + this.integer = integer; + this.stringModeValue = Number(integer); + }, + + BooleanNode: function(bool, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "BOOLEAN"; + this.bool = bool; + this.stringModeValue = bool === "true"; + }, + + CommentNode: function(comment, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "comment"; + this.comment = comment; + } + }; + + // Must be exported as an object rather than the root of the module as the jison lexer + // most modify the object to operate properly. + __exports__ = AST; + return __exports__; +})(__module5__); + +// handlebars/compiler/parser.js +var __module9__ = (function() { + "use strict"; + var __exports__; + /* jshint ignore:start */ + /* Jison generated parser */ + var handlebars = (function(){ + var parser = {trace: function trace() { }, + yy: {}, + symbols_: {"error":2,"root":3,"statements":4,"EOF":5,"program":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"sexpr":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"partial_option0":27,"sexpr_repetition0":28,"sexpr_option0":29,"dataName":30,"param":31,"STRING":32,"INTEGER":33,"BOOLEAN":34,"OPEN_SEXPR":35,"CLOSE_SEXPR":36,"hash":37,"hash_repetition_plus0":38,"hashSegment":39,"ID":40,"EQUALS":41,"DATA":42,"pathSegments":43,"SEP":44,"$accept":0,"$end":1}, + terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",35:"OPEN_SEXPR",36:"CLOSE_SEXPR",40:"ID",41:"EQUALS",42:"DATA",44:"SEP"}, + productions_: [0,[3,2],[3,1],[6,2],[6,3],[6,2],[6,1],[6,1],[6,0],[4,1],[4,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,4],[7,2],[17,3],[17,1],[31,1],[31,1],[31,1],[31,1],[31,1],[31,3],[37,1],[39,3],[26,1],[26,1],[26,1],[30,2],[21,1],[43,3],[43,1],[27,0],[27,1],[28,0],[28,2],[29,0],[29,1],[38,1],[38,2]], + performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { + + var $0 = $$.length - 1; + switch (yystate) { + case 1: return new yy.ProgramNode($$[$0-1], this._$); + break; + case 2: return new yy.ProgramNode([], this._$); + break; + case 3:this.$ = new yy.ProgramNode([], $$[$0-1], $$[$0], this._$); + break; + case 4:this.$ = new yy.ProgramNode($$[$0-2], $$[$0-1], $$[$0], this._$); + break; + case 5:this.$ = new yy.ProgramNode($$[$0-1], $$[$0], [], this._$); + break; + case 6:this.$ = new yy.ProgramNode($$[$0], this._$); + break; + case 7:this.$ = new yy.ProgramNode([], this._$); + break; + case 8:this.$ = new yy.ProgramNode([], this._$); + break; + case 9:this.$ = [$$[$0]]; + break; + case 10: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; + break; + case 11:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0], this._$); + break; + case 12:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0], this._$); + break; + case 13:this.$ = $$[$0]; + break; + case 14:this.$ = $$[$0]; + break; + case 15:this.$ = new yy.ContentNode($$[$0], this._$); + break; + case 16:this.$ = new yy.CommentNode($$[$0], this._$); + break; + case 17:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 18:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 19:this.$ = {path: $$[$0-1], strip: stripFlags($$[$0-2], $$[$0])}; + break; + case 20:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 21:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 22:this.$ = new yy.PartialNode($$[$0-2], $$[$0-1], stripFlags($$[$0-3], $$[$0]), this._$); + break; + case 23:this.$ = stripFlags($$[$0-1], $$[$0]); + break; + case 24:this.$ = new yy.SexprNode([$$[$0-2]].concat($$[$0-1]), $$[$0], this._$); + break; + case 25:this.$ = new yy.SexprNode([$$[$0]], null, this._$); + break; + case 26:this.$ = $$[$0]; + break; + case 27:this.$ = new yy.StringNode($$[$0], this._$); + break; + case 28:this.$ = new yy.IntegerNode($$[$0], this._$); + break; + case 29:this.$ = new yy.BooleanNode($$[$0], this._$); + break; + case 30:this.$ = $$[$0]; + break; + case 31:$$[$0-1].isHelper = true; this.$ = $$[$0-1]; + break; + case 32:this.$ = new yy.HashNode($$[$0], this._$); + break; + case 33:this.$ = [$$[$0-2], $$[$0]]; + break; + case 34:this.$ = new yy.PartialNameNode($$[$0], this._$); + break; + case 35:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0], this._$), this._$); + break; + case 36:this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0], this._$)); + break; + case 37:this.$ = new yy.DataNode($$[$0], this._$); + break; + case 38:this.$ = new yy.IdNode($$[$0], this._$); + break; + case 39: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2]; + break; + case 40:this.$ = [{part: $$[$0]}]; + break; + case 43:this.$ = []; + break; + case 44:$$[$0-1].push($$[$0]); + break; + case 47:this.$ = [$$[$0]]; + break; + case 48:$$[$0-1].push($$[$0]); + break; + } + }, + table: [{3:1,4:2,5:[1,3],8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[3]},{5:[1,16],8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[2,2]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{4:20,6:18,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{4:20,6:22,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{17:23,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:29,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:30,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:31,21:24,30:25,40:[1,28],42:[1,27],43:26},{21:33,26:32,32:[1,34],33:[1,35],40:[1,28],43:26},{1:[2,1]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{10:36,20:[1,37]},{4:38,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,7],22:[1,13],23:[1,14],25:[1,15]},{7:39,8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,6],22:[1,13],23:[1,14],25:[1,15]},{17:23,18:[1,40],21:24,30:25,40:[1,28],42:[1,27],43:26},{10:41,20:[1,37]},{18:[1,42]},{18:[2,43],24:[2,43],28:43,32:[2,43],33:[2,43],34:[2,43],35:[2,43],36:[2,43],40:[2,43],42:[2,43]},{18:[2,25],24:[2,25],36:[2,25]},{18:[2,38],24:[2,38],32:[2,38],33:[2,38],34:[2,38],35:[2,38],36:[2,38],40:[2,38],42:[2,38],44:[1,44]},{21:45,40:[1,28],43:26},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,40],36:[2,40],40:[2,40],42:[2,40],44:[2,40]},{18:[1,46]},{18:[1,47]},{24:[1,48]},{18:[2,41],21:50,27:49,40:[1,28],43:26},{18:[2,34],40:[2,34]},{18:[2,35],40:[2,35]},{18:[2,36],40:[2,36]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{21:51,40:[1,28],43:26},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,3],22:[1,13],23:[1,14],25:[1,15]},{4:52,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,5],22:[1,13],23:[1,14],25:[1,15]},{14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]},{18:[2,45],21:56,24:[2,45],29:53,30:60,31:54,32:[1,57],33:[1,58],34:[1,59],35:[1,61],36:[2,45],37:55,38:62,39:63,40:[1,64],42:[1,27],43:26},{40:[1,65]},{18:[2,37],24:[2,37],32:[2,37],33:[2,37],34:[2,37],35:[2,37],36:[2,37],40:[2,37],42:[2,37]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,66]},{18:[2,42]},{18:[1,67]},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],25:[1,15]},{18:[2,24],24:[2,24],36:[2,24]},{18:[2,44],24:[2,44],32:[2,44],33:[2,44],34:[2,44],35:[2,44],36:[2,44],40:[2,44],42:[2,44]},{18:[2,46],24:[2,46],36:[2,46]},{18:[2,26],24:[2,26],32:[2,26],33:[2,26],34:[2,26],35:[2,26],36:[2,26],40:[2,26],42:[2,26]},{18:[2,27],24:[2,27],32:[2,27],33:[2,27],34:[2,27],35:[2,27],36:[2,27],40:[2,27],42:[2,27]},{18:[2,28],24:[2,28],32:[2,28],33:[2,28],34:[2,28],35:[2,28],36:[2,28],40:[2,28],42:[2,28]},{18:[2,29],24:[2,29],32:[2,29],33:[2,29],34:[2,29],35:[2,29],36:[2,29],40:[2,29],42:[2,29]},{18:[2,30],24:[2,30],32:[2,30],33:[2,30],34:[2,30],35:[2,30],36:[2,30],40:[2,30],42:[2,30]},{17:68,21:24,30:25,40:[1,28],42:[1,27],43:26},{18:[2,32],24:[2,32],36:[2,32],39:69,40:[1,70]},{18:[2,47],24:[2,47],36:[2,47],40:[2,47]},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,40],36:[2,40],40:[2,40],41:[1,71],42:[2,40],44:[2,40]},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],35:[2,39],36:[2,39],40:[2,39],42:[2,39],44:[2,39]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{36:[1,72]},{18:[2,48],24:[2,48],36:[2,48],40:[2,48]},{41:[1,71]},{21:56,30:60,31:73,32:[1,57],33:[1,58],34:[1,59],35:[1,61],40:[1,28],42:[1,27],43:26},{18:[2,31],24:[2,31],32:[2,31],33:[2,31],34:[2,31],35:[2,31],36:[2,31],40:[2,31],42:[2,31]},{18:[2,33],24:[2,33],36:[2,33],40:[2,33]}], + defaultActions: {3:[2,2],16:[2,1],50:[2,42]}, + parseError: function parseError(str, hash) { + throw new Error(str); + }, + parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == "undefined") + this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === "function") + this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== "number") { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + if (!recovering) { + expected = []; + for (p in table[state]) + if (this.terminals_[p] && p > 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + + + function stripFlags(open, close) { + return { + left: open.charAt(2) === '~', + right: close.charAt(0) === '~' || close.charAt(1) === '~' + }; + } + + /* Jison generated lexer */ + var lexer = (function(){ + var lexer = ({EOF:1, + parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + setInput:function (input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; + if (this.options.ranges) this.yylloc.range = [0,0]; + this.offset = 0; + return this; + }, + input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, + unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length-len-1); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length-1); + this.matched = this.matched.substr(0, this.matched.length-1); + + if (lines.length-1) this.yylineno -= lines.length-1; + var r = this.yylloc.range; + + this.yylloc = {first_line: this.yylloc.first_line, + last_line: this.yylineno+1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, + more:function () { + this._more = true; + return this; + }, + less:function (n) { + this.unput(this.match.slice(n)); + }, + pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); + }, + showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c+"^"; + }, + next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, + match, + tempMatch, + index, + col, + lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i=0;i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = {first_line: this.yylloc.last_line, + last_line: this.yylineno+1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); + if (this.done && this._input) this.done = false; + if (token) return token; + else return; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + {text: "", token: null, line: this.yylineno}); + } + }, + lex:function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, + begin:function begin(condition) { + this.conditionStack.push(condition); + }, + popState:function popState() { + return this.conditionStack.pop(); + }, + _currentRules:function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; + }, + topState:function () { + return this.conditionStack[this.conditionStack.length-2]; + }, + pushState:function begin(condition) { + this.begin(condition); + }}); + lexer.options = {}; + lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + + + function strip(start, end) { + return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end); + } + + + var YYSTATE=YY_START + switch($avoiding_name_collisions) { + case 0: + if(yy_.yytext.slice(-2) === "\\\\") { + strip(0,1); + this.begin("mu"); + } else if(yy_.yytext.slice(-1) === "\\") { + strip(0,1); + this.begin("emu"); + } else { + this.begin("mu"); + } + if(yy_.yytext) return 14; + + break; + case 1:return 14; + break; + case 2: + this.popState(); + return 14; + + break; + case 3:strip(0,4); this.popState(); return 15; + break; + case 4:return 35; + break; + case 5:return 36; + break; + case 6:return 25; + break; + case 7:return 16; + break; + case 8:return 20; + break; + case 9:return 19; + break; + case 10:return 19; + break; + case 11:return 23; + break; + case 12:return 22; + break; + case 13:this.popState(); this.begin('com'); + break; + case 14:strip(3,5); this.popState(); return 15; + break; + case 15:return 22; + break; + case 16:return 41; + break; + case 17:return 40; + break; + case 18:return 40; + break; + case 19:return 44; + break; + case 20:// ignore whitespace + break; + case 21:this.popState(); return 24; + break; + case 22:this.popState(); return 18; + break; + case 23:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 32; + break; + case 24:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 32; + break; + case 25:return 42; + break; + case 26:return 34; + break; + case 27:return 34; + break; + case 28:return 33; + break; + case 29:return 40; + break; + case 30:yy_.yytext = strip(1,2); return 40; + break; + case 31:return 'INVALID'; + break; + case 32:return 5; + break; + } + }; + lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; + lexer.conditions = {"mu":{"rules":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[3],"inclusive":false},"INITIAL":{"rules":[0,1,32],"inclusive":true}}; + return lexer;})() + parser.lexer = lexer; + function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; + return new Parser; + })();__exports__ = handlebars; + /* jshint ignore:end */ + return __exports__; +})(); + +// handlebars/compiler/base.js +var __module8__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var parser = __dependency1__; + var AST = __dependency2__; + + __exports__.parser = parser; + + function parse(input) { + // Just return if an already-compile AST was passed in. + if(input.constructor === AST.ProgramNode) { return input; } + + parser.yy = AST; + return parser.parse(input); + } + + __exports__.parse = parse; + return __exports__; +})(__module9__, __module7__); + +// handlebars/compiler/compiler.js +var __module10__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + var Exception = __dependency1__; + + function Compiler() {} + + __exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a + // function in a context. This is necessary for mustache compatibility, which + // requires that context functions in blocks are evaluated by blockHelperMissing, + // and then proceed as if the resulting value was provided to blockHelperMissing. + + Compiler.prototype = { + compiler: Compiler, + + disassemble: function() { + var opcodes = this.opcodes, opcode, out = [], params, param; + + for (var i=0, l=opcodes.length; i 0) { + this.source[1] = this.source[1] + ", " + locals.join(", "); + } + + // Generate minimizer alias mappings + if (!this.isChild) { + for (var alias in this.context.aliases) { + if (this.context.aliases.hasOwnProperty(alias)) { + this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; + } + } + } + + if (this.source[1]) { + this.source[1] = "var " + this.source[1].substring(2) + ";"; + } + + // Merge children + if (!this.isChild) { + this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; + } + + if (!this.environment.isSimple) { + this.pushSource("return buffer;"); + } + + var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; + + for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } + return this.topStackName(); + }, + topStackName: function() { + return "stack" + this.stackSlot; + }, + flushInline: function() { + var inlineStack = this.inlineStack; + if (inlineStack.length) { + this.inlineStack = []; + for (var i = 0, len = inlineStack.length; i < len; i++) { + var entry = inlineStack[i]; + if (entry instanceof Literal) { + this.compileStack.push(entry); + } else { + this.pushStack(entry); + } + } + } + }, + isInline: function() { + return this.inlineStack.length; + }, + + popStack: function(wrapped) { + var inline = this.isInline(), + item = (inline ? this.inlineStack : this.compileStack).pop(); + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + if (!inline) { + if (!this.stackSlot) { + throw new Exception('Invalid stack pop'); + } + this.stackSlot--; + } + return item; + } + }, + + topStack: function(wrapped) { + var stack = (this.isInline() ? this.inlineStack : this.compileStack), + item = stack[stack.length - 1]; + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + return item; + } + }, + + quotedString: function(str) { + return '"' + str + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2029/g, '\\u2029') + '"'; + }, + + setupHelper: function(paramSize, name, missingParams) { + var params = [], + paramsInit = this.setupParams(paramSize, params, missingParams); + var foundHelper = this.nameLookup('helpers', name, 'helper'); + + return { + params: params, + paramsInit: paramsInit, + name: foundHelper, + callParams: ["depth0"].concat(params).join(", "), + helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ") + }; + }, + + setupOptions: function(paramSize, params) { + var options = [], contexts = [], types = [], param, inverse, program; + + options.push("hash:" + this.popStack()); + + if (this.options.stringParams) { + options.push("hashTypes:" + this.popStack()); + options.push("hashContexts:" + this.popStack()); + } + + inverse = this.popStack(); + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + if (!program) { + this.context.aliases.self = "this"; + program = "self.noop"; + } + + if (!inverse) { + this.context.aliases.self = "this"; + inverse = "self.noop"; + } + + options.push("inverse:" + inverse); + options.push("fn:" + program); + } + + for(var i=0; ij;j++)if(a=arguments[j],null!==a||void 0!==a)for(b in a)c=g[b],d=a[b],g!==d&&(i&&d&&(OpenSeadragon.isPlainObject(d)||(e=OpenSeadragon.isArray(d)))?(e?(e=!1,f=c&&OpenSeadragon.isArray(c)?c:[]):f=c&&OpenSeadragon.isPlainObject(c)?c:{},g[b]=OpenSeadragon.extend(i,f,d)):void 0!==d&&(g[b]=d));return g},a.extend(a,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,pixelsPerWheelLine:40,autoResize:!0,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorRotate:!0,degrees:0,opacity:1,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,useCanvas:!0,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:"#437AB2"},SIGNAL:"----seadragon----",delegate:function(a,b){return function(){var c=arguments;return void 0===c&&(c=[]),b.apply(a,c)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5},getElement:function(a){return"string"==typeof a&&(a=document.getElementById(a)),a},getElementPosition:function(c){var d,e,f=new a.Point;for(c=a.getElement(c),d="fixed"==a.getElementStyle(c).position,e=b(c,d);e;)f.x+=c.offsetLeft,f.y+=c.offsetTop,d&&(f=f.plus(a.getPageScroll())),c=e,d="fixed"==a.getElementStyle(c).position,e=b(c,d);return f},getElementOffset:function(b){b=a.getElement(b);var c,d,e=b&&b.ownerDocument,f={top:0,left:0};return e?(c=e.documentElement,"undefined"!=typeof b.getBoundingClientRect&&(f=b.getBoundingClientRect()),d=e==e.window?e:9===e.nodeType?e.defaultView||e.parentWindow:!1,new a.Point(f.left+(d.pageXOffset||c.scrollLeft)-(c.clientLeft||0),f.top+(d.pageYOffset||c.scrollTop)-(c.clientTop||0))):new a.Point},getElementSize:function(b){return b=a.getElement(b),new a.Point(b.clientWidth,b.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(b){return b=a.getElement(b),b.currentStyle}:function(b){return b=a.getElement(b),window.getComputedStyle(b,"")},pointInElement:function(b,c){b=a.getElement(b);var d=a.getElementOffset(b),e=a.getElementSize(b);return c.x>=d.x&&c.x=d.y},getEvent:function(b){return a.getEvent=b?function(a){return a}:function(){return window.event},a.getEvent(b)},getMousePosition:function(b){if("number"==typeof b.pageX)a.getMousePosition=function(b){var c=new a.Point;return b=a.getEvent(b),c.x=b.pageX,c.y=b.pageY,c};else{if("number"!=typeof b.clientX)throw new Error("Unknown event mouse position, no known technique.");a.getMousePosition=function(b){var c=new a.Point;return b=a.getEvent(b),c.x=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,c.y=b.clientY+document.body.scrollTop+document.documentElement.scrollTop,c}}return a.getMousePosition(b)},getPageScroll:function(){var b=document.documentElement||{},c=document.body||{};if("number"==typeof window.pageXOffset)a.getPageScroll=function(){return new a.Point(window.pageXOffset,window.pageYOffset)};else if(c.scrollLeft||c.scrollTop)a.getPageScroll=function(){return new a.Point(document.body.scrollLeft,document.body.scrollTop)};else{if(!b.scrollLeft&&!b.scrollTop)return new a.Point(0,0);a.getPageScroll=function(){return new a.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)}}return a.getPageScroll()},setPageScroll:function(b){if("undefined"!=typeof window.scrollTo)a.setPageScroll=function(a){window.scrollTo(a.x,a.y)};else{var c=a.getPageScroll();if(c.x===b.x&&c.y===b.y)return;document.body.scrollLeft=b.x,document.body.scrollTop=b.y;var d=a.getPageScroll();if(d.x!==c.x&&d.y!==c.y)return void(a.setPageScroll=function(a){document.body.scrollLeft=a.x,document.body.scrollTop=a.y});if(document.documentElement.scrollLeft=b.x,document.documentElement.scrollTop=b.y,d=a.getPageScroll(),d.x!==c.x&&d.y!==c.y)return void(a.setPageScroll=function(a){document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y});a.setPageScroll=function(){}}return a.setPageScroll(b)},getWindowSize:function(){var b=document.documentElement||{},c=document.body||{};if("number"==typeof window.innerWidth)a.getWindowSize=function(){return new a.Point(window.innerWidth,window.innerHeight)};else if(b.clientWidth||b.clientHeight)a.getWindowSize=function(){return new a.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else{if(!c.clientWidth&&!c.clientHeight)throw new Error("Unknown window size, no known technique.");a.getWindowSize=function(){return new a.Point(document.body.clientWidth,document.body.clientHeight)}}return a.getWindowSize()},makeCenteredNode:function(b){b=a.getElement(b);var c=[a.makeNeutralElement("div"),a.makeNeutralElement("div"),a.makeNeutralElement("div")];return a.extend(c[0].style,{display:"table",height:"100%",width:"100%"}),a.extend(c[1].style,{display:"table-row"}),a.extend(c[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),c[0].appendChild(c[1]),c[1].appendChild(c[2]),c[2].appendChild(b),c[0]},makeNeutralElement:function(a){var b=document.createElement(a),c=b.style;return c.background="transparent none",c.border="none",c.margin="0px",c.padding="0px",c.position="static",b},now:function(){return a.now=Date.now?Date.now:function(){return(new Date).getTime()},a.now()},makeTransparentImage:function(b){return a.makeTransparentImage=function(b){var c=a.makeNeutralElement("img");return c.src=b,c},a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<7&&(a.makeTransparentImage=function(b){var c=a.makeNeutralElement("img"),d=null;return d=a.makeNeutralElement("span"),d.style.display="inline-block",c.onload=function(){d.style.width=d.style.width||c.width+"px",d.style.height=d.style.height||c.height+"px",c.onload=null,c=null},c.src=b,d.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"', sizingMethod='scale')",d}),a.makeTransparentImage(b)},setElementOpacity:function(b,c,d){var e,f;b=a.getElement(b),d&&!a.Browser.alpha&&(c=Math.round(c)),a.Browser.opacity?b.style.opacity=1>c?c:"":1>c?(e=Math.round(100*c),f="alpha(opacity="+e+")",b.style.filter=f):b.style.filter=""},setElementTouchActionNone:function(b){b=a.getElement(b),"undefined"!=typeof b.style.touchAction?b.style.touchAction="none":"undefined"!=typeof b.style.msTouchAction&&(b.style.msTouchAction="none")},addClass:function(b,c){b=a.getElement(b),b.className?-1===(" "+b.className+" ").indexOf(" "+c+" ")&&(b.className+=" "+c):b.className=c},indexOf:function(a,b,c){return this.indexOf=Array.prototype.indexOf?function(a,b,c){return a.indexOf(b,c)}:function(a,b,c){var d,e,f=c?c:0;if(!a)throw new TypeError;if(e=a.length,0===e||f>=e)return-1;for(0>f&&(f=e-Math.abs(f)),d=f;e>d;d++)if(a[d]===b)return d;return-1},this.indexOf(a,b,c)},removeClass:function(b,c){var d,e,f=[];for(b=a.getElement(b),d=b.className.split(/\s+/),e=0;e=0?(a.Browser.vendor=a.BROWSERS.FIREFOX,a.Browser.version=parseFloat(e.substring(e.indexOf("Firefox")+8))):e.indexOf("Safari")>=0?(a.Browser.vendor=e.indexOf("Chrome")>=0?a.BROWSERS.CHROME:a.BROWSERS.SAFARI,a.Browser.version=parseFloat(e.substring(e.substring(0,e.indexOf("Safari")).lastIndexOf("/")+1,e.indexOf("Safari")))):(b=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),null!==b.exec(e)&&(a.Browser.vendor=a.BROWSERS.IE,a.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":a.Browser.vendor=a.BROWSERS.OPERA,a.Browser.version=parseFloat(c)}var f,g,h,i=window.location.search.substring(1),j=i.split("&");for(h=0;h0&&(d[f.substring(0,g)]=decodeURIComponent(f.substring(g+1)));a.Browser.alpha=!(a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<9||a.Browser.vendor==a.BROWSERS.CHROME&&a.Browser.version<2),a.Browser.opacity=!(a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<9)}();var e=function(){};a.console=window.console||{log:e,debug:e,info:e,warn:e,error:e,assert:e},function(b){var c=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame,d=b.cancelAnimationFrame||b.mozCancelAnimationFrame||b.webkitCancelAnimationFrame||b.msCancelAnimationFrame;if(c&&d)a.requestAnimationFrame=function(){return c.apply(b,arguments)},a.cancelAnimationFrame=function(){return d.apply(b,arguments)};else{var e,f=[],g=[],h=0;a.requestAnimationFrame=function(b){return f.push([++h,b]),e||(e=setInterval(function(){if(f.length){var b=a.now(),c=g;for(g=f,f=c;g.length;)g.shift()[1](b)}else clearInterval(e),e=void 0},20)),h},a.cancelAnimationFrame=function(a){var b,c;for(b=0,c=f.length;c>b;b+=1)if(f[b][0]===a)return void f.splice(b,1);for(b=0,c=g.length;c>b;b+=1)if(g[b][0]===a)return void g.splice(b,1)}}}(window),a._processDZIError=function(a){var b=a.getElementsByTagName("Message")[0],c=b.firstChild.nodeValue;throw new Error(c)}}(OpenSeadragon),function(a){var b={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.fullscreenElement},b.requestFullScreen=function(a){return a.requestFullscreen()},b.exitFullScreen=function(){document.exitFullscreen()},b.fullScreenEventName="fullscreenchange",b.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.msFullscreenElement},b.requestFullScreen=function(a){return a.msRequestFullscreen()},b.exitFullScreen=function(){document.msExitFullscreen()},b.fullScreenEventName="MSFullscreenChange",b.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.webkitFullscreenElement},b.requestFullScreen=function(a){return a.webkitRequestFullscreen()},b.exitFullScreen=function(){document.webkitExitFullscreen()},b.fullScreenEventName="webkitfullscreenchange",b.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},b.requestFullScreen=function(a){return a.webkitRequestFullScreen()},b.exitFullScreen=function(){document.webkitCancelFullScreen()},b.fullScreenEventName="webkitfullscreenchange",b.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.mozFullScreenElement},b.requestFullScreen=function(a){return a.mozRequestFullScreen()},b.exitFullScreen=function(){document.mozCancelFullScreen()},b.fullScreenEventName="mozfullscreenchange",b.fullScreenErrorEventName="mozfullscreenerror"),b.isFullScreen=function(){return null!==b.getFullScreenElement()},b.cancelFullScreen=function(){a.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),b.exitFullScreen()},a.extend(a,b)}(OpenSeadragon),function(a){a.EventSource=function(){this.events={}},a.EventSource.prototype={addHandler:function(b,c,d){var e=this.events[b];e||(this.events[b]=e=[]),c&&a.isFunction(c)&&(e[e.length]={handler:c,userData:d||null})},removeHandler:function(b,c){var d,e=this.events[b],f=[];if(e&&a.isArray(e)){for(d=0;dd;d++)b[d]&&(c.eventSource=a,c.userData=b[d].userData,b[d].handler(c))}):null},raiseEvent:function(a,b){var c=this.getHandler(a);c&&(b||(b={}),c(this,b))}}}(OpenSeadragon),function(a){function b(b){var c,d,e=bb[b.hash];if(!e.tracking){for(d=0;dd;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});W(b,c,f)}function D(b,c){var d,e=c.changedTouches.length,f=[];for(d=0;e>d;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});X(b,c,f)}function E(b,c){var d,e,f=c.changedTouches.length,h=[];for(d=a.now(),e=0;f>e;e++)h.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:g(c.changedTouches[e]),currentTime:d});a.MouseTracker.haveTouchEnter||W(b,c,h),Y(b,c,h,0),a.cancelEvent(c)}function F(b,c){var d,e,f=c.changedTouches.length,h=[];for(d=a.now(),e=0;f>e;e++)h.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:g(c.changedTouches[e]),currentTime:d});Z(b,c,h,0),!a.MouseTracker.haveTouchEnter&&f>0&&X(b,c,h),a.cancelEvent(c)}function G(b,c){var d,e=c.changedTouches.length,f=[];for(d=0;e>d;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});$(b,c,f),a.cancelEvent(c)}function H(a,b){var c,d=b.changedTouches.length,e=[];for(c=0;d>c;c++)e.push({id:b.changedTouches[c].identifier,type:"touch"});_(a,b,e)}function I(a,b){return b.stopPropagation(),b.preventDefault(),!1}function J(a,b){return b.stopPropagation(),b.preventDefault(),!1}function K(b,c){var d;this===c.relatedTarget||s(c.currentTarget,c.relatedTarget)||(d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},W(b,c,[d]))}function L(b,c){var d;this===c.relatedTarget||s(c.currentTarget,c.relatedTarget)||(d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},X(b,c,[d]))}function M(b,c){var e;e={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},Y(b,c,[e],c.button)&&(d(b,!1),a.stopEvent(c)),(b.clickHandler||b.dblClickHandler||b.pressHandler||b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.cancelEvent(c)}function N(a,b){P(a,b)}function O(b,c){var d=b.getActivePointersListByType(f(c));d.getById(c.pointerId)&&P(b,c),a.stopEvent(c)}function P(b,c){var d;d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},Z(b,c,[d],c.button)&&e(b,!1)}function Q(a,b){S(a,b)}function R(b,c){var d=b.getActivePointersListByType(f(c));d.getById(c.pointerId)&&S(b,c),a.stopEvent(c)}function S(b,c){var d;d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},$(b,c,[d])}function T(a,b){var c;c={id:b.pointerId,type:f(b)},_(a,b,[c])}function U(a,b){return b.hasOwnProperty("isPrimary")||(b.isPrimary=0===a.getLength()?!0:!1),b.speed=0,b.direction=0,b.contactPos=b.currentPos,b.contactTime=b.currentTime,b.lastPos=b.currentPos,b.lastTime=b.currentTime,a.add(b)}function V(a,b){var c,d;return a.getById(b.id)?(c=a.removeById(b.id),b.hasOwnProperty("isPrimary")||(d=a.getPrimary(),d||(d=a.getByIndex(0),d&&(d.isPrimary=!0)))):c=a.getLength(),c}function W(b,c,d){var e,f,g,h,j=b.getActivePointersListByType(d[0].type),k=d.length;for(e=0;k>e;e++)f=d[e],g=j.getById(f.id),g?(g.insideElement=!0,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime,f=g):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,U(j,f)),b.enterHandler&&(h=b.enterHandler({eventSource:b,pointerType:f.type,position:i(f.currentPos,b.element),buttons:j.buttons,insideElementPressed:f.insideElementPressed,buttonDownAny:0!==j.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),h===!1&&a.cancelEvent(c))}function X(b,c,d){var e,f,g,h,j=(bb[b.hash],b.getActivePointersListByType(d[0].type)),k=d.length;for(e=0;k>e;e++)f=d[e],g=j.getById(f.id),g&&(g.captured?(g.insideElement=!1,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):V(j,g),f=g),b.exitHandler&&(h=b.exitHandler({eventSource:b,pointerType:f.type,position:i(f.currentPos,b.element),buttons:j.buttons,insideElementPressed:g?g.insideElementPressed:!1,buttonDownAny:0!==j.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),h===!1&&a.cancelEvent(c))}function Y(b,c,d,e){var f,g,h,k,l=bb[b.hash],m=b.getActivePointersListByType(d[0].type),n=d.length;if("undefined"!=typeof c.buttons?m.buttons=c.buttons:0===e?m.buttons|=1:1===e?m.buttons|=4:2===e?m.buttons|=2:3===e?m.buttons|=8:4===e?m.buttons|=16:5===e&&(m.buttons|=32),0!==e&&1!==e)return!1;for(g=0;n>g;g++)h=d[g],k=m.getById(h.id),k?(k.captured=!0,k.insideElementPressed=!0,k.insideElement=!0,k.contactPos=h.currentPos,k.contactTime=h.currentTime,k.lastPos=k.currentPos,k.lastTime=k.currentTime,k.currentPos=h.currentPos,k.currentTime=h.currentTime,h=k):(h.captured=!0,h.insideElementPressed=!0,h.insideElement=!0,U(m,h)),m.contacts++,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.addPoint(b,h),1===m.contacts?b.pressHandler&&(f=b.pressHandler({eventSource:b,pointerType:h.type,position:i(h.contactPos,b.element),buttons:m.buttons,isTouchEvent:"touch"===h.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)):2===m.contacts&&b.pinchHandler&&"touch"===h.type&&(l.pinchGPoints=m.asArray(),l.lastPinchDist=l.currentPinchDist=l.pinchGPoints[0].currentPos.distanceTo(l.pinchGPoints[1].currentPos),l.lastPinchCenter=l.currentPinchCenter=j(l.pinchGPoints[0].currentPos,l.pinchGPoints[1].currentPos));return!0}function Z(b,c,d,e){var f,g,h,k,l,m,n,o=bb[b.hash],p=b.getActivePointersListByType(d[0].type),q=d.length,r=!1,s=!1;if("undefined"!=typeof c.buttons?p.buttons=c.buttons:0===e?p.buttons^=-2:1===e?p.buttons^=-5:2===e?p.buttons^=-3:3===e?p.buttons^=-9:4===e?p.buttons^=-17:5===e&&(p.buttons^=-33),0!==e&&1!==e)return!1;for(k=0;q>k;k++)l=d[k],m=p.getById(l.id),m&&(m.captured&&(m.captured=!1,r=!0,s=!0),m.lastPos=m.currentPos,m.lastTime=m.currentTime,m.currentPos=l.currentPos,m.currentTime=l.currentTime,m.insideElement||V(p,m),g=m.currentPos,h=m.currentTime,s?(p.contacts--,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.removePoint(b,m),0===p.contacts?(b.releaseHandler&&(f=b.releaseHandler({eventSource:b,pointerType:m.type,position:i(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),b.dragEndHandler&&!m.currentPos.equals(m.contactPos)&&(f=b.dragEndHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),speed:m.speed,direction:m.direction,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),(b.clickHandler||b.dblClickHandler)&&m.insideElement&&(n=h-m.contactTime<=b.clickTimeThreshold&&m.contactPos.distanceTo(g)<=b.clickDistThreshold,b.clickHandler&&(f=b.clickHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),quick:n,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),b.dblClickHandler&&n&&(p.clicks++,1===p.clicks?(o.lastClickPos=g,o.dblClickTimeOut=setTimeout(function(){p.clicks=0},b.dblClickTimeThreshold)):2===p.clicks&&(clearTimeout(o.dblClickTimeOut),p.clicks=0,o.lastClickPos.distanceTo(g)<=b.dblClickDistThreshold&&(f=b.dblClickHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),o.lastClickPos=null)))):2===p.contacts&&b.pinchHandler&&"touch"===m.type&&(o.pinchGPoints=p.asArray(),o.lastPinchDist=o.currentPinchDist=o.pinchGPoints[0].currentPos.distanceTo(o.pinchGPoints[1].currentPos),o.lastPinchCenter=o.currentPinchCenter=j(o.pinchGPoints[0].currentPos,o.pinchGPoints[1].currentPos))):b.releaseHandler&&(f=b.releaseHandler({eventSource:b,pointerType:m.type,position:i(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c))); +return r}function $(b,c,d){var e,f,g,h,k,l,m=bb[b.hash],n=b.getActivePointersListByType(d[0].type),o=d.length;for("undefined"!=typeof c.buttons&&(n.buttons=c.buttons),e=0;o>e;e++)f=d[e],g=n.getById(f.id),g?(f.hasOwnProperty("isPrimary")&&(g.isPrimary=f.isPrimary),g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,U(n,f));b.stopHandler&&"mouse"===d[0].type&&(clearTimeout(b.stopTimeOut),b.stopTimeOut=setTimeout(function(){ab(b,c,d[0].type)},b.stopDelay)),0===n.contacts?b.moveHandler&&(l=b.moveHandler({eventSource:b,pointerType:d[0].type,position:i(d[0].currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===d[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)):1===n.contacts?(b.moveHandler&&(g=n.asArray()[0],l=b.moveHandler({eventSource:b,pointerType:g.type,position:i(g.currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)),b.dragHandler&&(g=n.asArray()[0],k=g.currentPos.minus(g.lastPos),l=b.dragHandler({eventSource:b,pointerType:g.type,position:i(g.currentPos,b.element),buttons:n.buttons,delta:k,speed:g.speed,direction:g.direction,shift:c.shiftKey,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c))):2===n.contacts&&(b.moveHandler&&(h=n.asArray(),l=b.moveHandler({eventSource:b,pointerType:h[0].type,position:i(j(h[0].currentPos,h[1].currentPos),b.element),buttons:n.buttons,isTouchEvent:"touch"===h[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)),b.pinchHandler&&"touch"===d[0].type&&(k=m.pinchGPoints[0].currentPos.distanceTo(m.pinchGPoints[1].currentPos),k!=m.currentPinchDist&&(m.lastPinchDist=m.currentPinchDist,m.currentPinchDist=k,m.lastPinchCenter=m.currentPinchCenter,m.currentPinchCenter=j(m.pinchGPoints[0].currentPos,m.pinchGPoints[1].currentPos),l=b.pinchHandler({eventSource:b,pointerType:"touch",gesturePoints:m.pinchGPoints,lastCenter:i(m.lastPinchCenter,b.element),center:i(m.currentPinchCenter,b.element),lastDistance:m.lastPinchDist,distance:m.currentPinchDist,shift:c.shiftKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c))))}function _(a,b,c){Z(a,b,c,0),X(a,b,c)}function ab(a,b,c){a.stopHandler&&a.stopHandler({eventSource:a,pointerType:c,position:h(b,a.element),buttons:a.getActivePointersListByType(c).buttons,isTouchEvent:"touch"===c,originalEvent:b,preventDefaultAction:!1,userData:a.userData})}var bb={};a.MouseTracker=function(b){var c=arguments;a.isPlainObject(b)||(b={element:c[0],clickTimeThreshold:c[1],clickDistThreshold:c[2]}),this.hash=Math.random(),this.element=a.getElement(b.element),this.clickTimeThreshold=b.clickTimeThreshold||a.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=b.clickDistThreshold||a.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=b.dblClickTimeThreshold||a.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=b.dblClickDistThreshold||a.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=b.userData||null,this.stopDelay=b.stopDelay||50,this.enterHandler=b.enterHandler||null,this.exitHandler=b.exitHandler||null,this.pressHandler=b.pressHandler||null,this.releaseHandler=b.releaseHandler||null,this.moveHandler=b.moveHandler||null,this.scrollHandler=b.scrollHandler||null,this.clickHandler=b.clickHandler||null,this.dblClickHandler=b.dblClickHandler||null,this.dragHandler=b.dragHandler||null,this.dragEndHandler=b.dragEndHandler||null,this.pinchHandler=b.pinchHandler||null,this.stopHandler=b.stopHandler||null,this.keyHandler=b.keyHandler||null,this.focusHandler=b.focusHandler||null,this.blurHandler=b.blurHandler||null;var d=this;bb[this.hash]={click:function(a){k(d,a)},dblclick:function(a){l(d,a)},keypress:function(a){m(d,a)},focus:function(a){n(d,a)},blur:function(a){o(d,a)},wheel:function(a){p(d,a)},mousewheel:function(a){q(d,a)},DOMMouseScroll:function(a){q(d,a)},MozMousePixelScroll:function(a){q(d,a)},mouseover:function(a){t(d,a)},mouseout:function(a){u(d,a)},mousedown:function(a){v(d,a)},mouseup:function(a){w(d,a)},mouseupcaptured:function(a){x(d,a)},mousemove:function(a){z(d,a)},mousemovecaptured:function(a){A(d,a)},touchenter:function(a){C(d,a)},touchleave:function(a){D(d,a)},touchstart:function(a){E(d,a)},touchend:function(a){F(d,a)},touchmove:function(a){G(d,a)},touchcancel:function(a){H(d,a)},gesturestart:function(a){I(d,a)},gesturechange:function(a){J(d,a)},pointerover:function(a){K(d,a)},MSPointerOver:function(a){K(d,a)},pointerout:function(a){L(d,a)},MSPointerOut:function(a){L(d,a)},pointerdown:function(a){M(d,a)},MSPointerDown:function(a){M(d,a)},pointerup:function(a){N(d,a)},MSPointerUp:function(a){N(d,a)},pointermove:function(a){Q(d,a)},MSPointerMove:function(a){Q(d,a)},pointercancel:function(a){T(d,a)},MSPointerCancel:function(a){T(d,a)},pointerupcaptured:function(a){O(d,a)},pointermovecaptured:function(a){R(d,a)},tracking:!1,activePointersLists:[],capturing:!1,pointerCaptureCount:0,lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null}},a.MouseTracker.prototype={destroy:function(){c(this),this.element=null,bb[this.hash]=null,delete bb[this.hash]},isTracking:function(){return bb[this.hash].tracking},setTracking:function(a){return a?b(this):c(this),this},getActivePointersListByType:function(b){var c,d,e=bb[this.hash],f=e.activePointersLists.length;for(c=0;f>c;c++)if(e.activePointersLists[c].type===b)return e.activePointersLists[c];return d=new a.MouseTracker.GesturePointList(b),e.activePointersLists.push(d),d},enterHandler:function(){},exitHandler:function(){},pressHandler:function(){},releaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}},a.MouseTracker.gesturePointVelocityTracker=function(){var b=[],c=0,d=0,e=function(a,b){return a.hash.toString()+b.type+b.id.toString()},f=function(){var c,e,f,g,h,i,j=b.length,k=a.now();for(g=k-d,d=k,c=0;j>c;c++)e=b[c],f=e.gPoint,f.direction=Math.atan2(f.currentPos.y-e.lastPos.y,f.currentPos.x-e.lastPos.x),h=e.lastPos.distanceTo(f.currentPos),e.lastPos=f.currentPos,i=1e3*h/(g+1),f.speed=.75*i+.25*f.speed},g=function(g,h){var i=e(g,h);b.push({guid:i,gPoint:h,lastPos:h.currentPos}),1===b.length&&(d=a.now(),c=window.setInterval(f,50))},h=function(a,d){var f,g=e(a,d),h=b.length;for(f=0;h>f;f++)if(b[f].guid===g){b.splice(f,1),h--,0===h&&window.clearInterval(c);break}};return{addPoint:g,removePoint:h}}(),a.MouseTracker.wheelEventName=a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",a.MouseTracker.supportsMouseCapture=function(){var b=document.createElement("div");return a.isFunction(b.setCapture)&&a.isFunction(b.releaseCapture)}(),a.MouseTracker.subscribeEvents=["click","dblclick","keypress","focus","blur",a.MouseTracker.wheelEventName],"DOMMouseScroll"==a.MouseTracker.wheelEventName&&a.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(a.MouseTracker.subscribeEvents.push("pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),a.MouseTracker.unprefixedPointerEvents=!0,a.MouseTracker.maxTouchPoints=navigator.maxTouchPoints?navigator.maxTouchPoints:0,a.MouseTracker.haveTouchEnter=!1,a.MouseTracker.haveMouseEnter=!1):window.MSPointerEvent?(a.MouseTracker.subscribeEvents.push("MSPointerOver","MSPointerOut","MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"),a.MouseTracker.unprefixedPointerEvents=!1,a.MouseTracker.maxTouchPoints=navigator.msMaxTouchPoints?navigator.msMaxTouchPoints:0,a.MouseTracker.haveTouchEnter=!1,a.MouseTracker.haveMouseEnter=!1):(a.MouseTracker.subscribeEvents.push("mouseover","mouseout","mousedown","mouseup","mousemove"),a.MouseTracker.haveMouseEnter=!1,"ontouchstart"in window?(a.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ontouchenter"in window?(a.MouseTracker.subscribeEvents.push("touchenter","touchleave"),a.MouseTracker.haveTouchEnter=!0):a.MouseTracker.haveTouchEnter=!1):a.MouseTracker.haveTouchEnter=!1,"ongesturestart"in window&&a.MouseTracker.subscribeEvents.push("gesturestart","gesturechange"),a.MouseTracker.mousePointerId="legacy-mouse",a.MouseTracker.maxTouchPoints=10),a.MouseTracker.GesturePointList=function(a){this._gPoints=[],this.type=a,this.buttons=0,this.contacts=0,this.clicks=0},a.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(a){return this._gPoints.push(a)},removeById:function(a){var b,c=this._gPoints.length;for(b=0;c>b;b++)if(this._gPoints[b].id===a){this._gPoints.splice(b,1);break}return this._gPoints.length},getByIndex:function(a){return ab;b++)if(this._gPoints[b].id===a)return this._gPoints[b];return null},getPrimary:function(){var a,b=this._gPoints.length;for(a=0;b>a;a++)if(this._gPoints[a].isPrimary)return this._gPoints[a];return null}}}(OpenSeadragon),function(a){a.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},a.Control=function(b,c,d){var e=b.parentNode;"number"==typeof c&&(a.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013"),c={anchor:c}),c.attachToViewer="undefined"==typeof c.attachToViewer?!0:c.attachToViewer,this.autoFade="undefined"==typeof c.autoFade?!0:c.autoFade,this.element=b,this.anchor=c.anchor,this.container=d,this.anchor==a.ControlAnchor.ABSOLUTE?(this.wrapper=a.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top="number"==typeof c.top?c.top+"px":c.top,this.wrapper.style.left="number"==typeof c.left?c.left+"px":c.left,this.wrapper.style.height="number"==typeof c.height?c.height+"px":c.height,this.wrapper.style.width="number"==typeof c.width?c.width+"px":c.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=a.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor==a.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),c.attachToViewer?this.anchor==a.ControlAnchor.TOP_RIGHT||this.anchor==a.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):e.appendChild(this.wrapper)},a.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.container.removeChild(this.wrapper)},isVisible:function(){return"none"!=this.wrapper.style.display},setVisible:function(b){this.wrapper.style.display=b?this.anchor==a.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(b){this.element[a.SIGNAL]&&a.Browser.vendor==a.BROWSERS.IE?a.setElementOpacity(this.element,b,!0):a.setElementOpacity(this.wrapper,b,!0)}}}(OpenSeadragon),function(a){function b(a,b){var c,d=a.controls;for(c=d.length-1;c>=0;c--)if(d[c].element==b)return c;return-1}a.ControlDock=function(b){var c,d,e=["topleft","topright","bottomright","bottomleft"];for(a.extend(!0,this,{id:"controldock-"+a.now()+"-"+Math.floor(1e6*Math.random()),container:a.makeNeutralElement("div"),controls:[]},b),this.container.onsubmit=function(){return!1},this.element&&(this.element=a.getElement(this.element),this.element.appendChild(this.container),this.element.style.position="relative",this.container.style.width="100%",this.container.style.height="100%"),d=0;d=0)){switch(d.anchor){case a.ControlAnchor.TOP_RIGHT:e=this.controls.topright,c.style.position="relative",c.style.paddingRight="0px",c.style.paddingTop="0px";break;case a.ControlAnchor.BOTTOM_RIGHT:e=this.controls.bottomright,c.style.position="relative",c.style.paddingRight="0px",c.style.paddingBottom="0px";break;case a.ControlAnchor.BOTTOM_LEFT:e=this.controls.bottomleft,c.style.position="relative",c.style.paddingLeft="0px",c.style.paddingBottom="0px";break;case a.ControlAnchor.TOP_LEFT:e=this.controls.topleft,c.style.position="relative",c.style.paddingLeft="0px",c.style.paddingTop="0px";break;case a.ControlAnchor.ABSOLUTE:e=this.container,c.style.margin="0px",c.style.padding="0px";break;default:case a.ControlAnchor.NONE:e=this.container,c.style.margin="0px",c.style.padding="0px"}this.controls.push(new a.Control(c,d,e)),c.style.display="inline-block"}},removeControl:function(c){c=a.getElement(c);var d=b(this,c);return d>=0&&(this.controls[d].destroy(),this.controls.splice(d,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var a;for(a=this.controls.length-1;a>=0;a--)if(this.controls[a].isVisible())return!0;return!1},setControlsEnabled:function(a){var b;for(b=this.controls.length-1;b>=0;b--)this.controls[b].setVisible(a);return this}}}(OpenSeadragon),function($){function _getSafeElemSize(a){return a=$.getElement(a),new $.Point(0===a.clientWidth?1:a.clientWidth,0===a.clientHeight?1:a.clientHeight)}function getTileSourceImplementation(viewer,tileSource,successCallback,failCallback){var _this=viewer;"string"==$.type(tileSource)&&(tileSource.match(/\s*<.*/)?tileSource=$.parseXml(tileSource):tileSource.match(/\s*[\{\[].*/)&&(tileSource=eval("("+tileSource+")"))),setTimeout(function(){if("string"==$.type(tileSource))tileSource=new $.TileSource(tileSource,function(a){successCallback(a.tileSource)}),tileSource.addHandler("open-failed",function(a){failCallback(a)});else if($.isPlainObject(tileSource)||tileSource.nodeType)if($.isFunction(tileSource.getTileUrl)){var a=new $.TileSource(tileSource);a.getTileUrl=tileSource.getTileUrl,successCallback(a)}else{var b=$.TileSource.determineType(_this,tileSource);if(!b)return void failCallback({message:"Unable to load TileSource",source:tileSource});var c=b.prototype.configure.apply(_this,[tileSource]),d=new b(c);successCallback(d)}else successCallback(tileSource)},1)}function openTileSource(a,b,c){var d,e=a;c=c||{},e.source&&e.close(),THIS[e.hash].prevContainerSize=_getSafeElemSize(e.container),e.collectionMode?(e.source=new $.TileSourceCollection({rows:e.collectionRows,layout:e.collectionLayout,tileSize:e.collectionTileSize,tileSources:e.tileSources,tileMargin:e.collectionTileMargin}),e.viewport=e.viewport?e.viewport:new $.Viewport({collectionMode:!0,collectionTileSource:e.source,containerSize:THIS[e.hash].prevContainerSize,springStiffness:e.springStiffness,animationTime:e.animationTime,showNavigator:!1,minZoomImageRatio:1,maxZoomPixelRatio:1,viewer:e,degrees:e.degrees})):(b&&(e.source=b),e.viewport=e.viewport?e.viewport:new $.Viewport({containerSize:THIS[e.hash].prevContainerSize,springStiffness:e.springStiffness,animationTime:e.animationTime,minZoomImageRatio:e.minZoomImageRatio,maxZoomPixelRatio:e.maxZoomPixelRatio,visibilityRatio:e.visibilityRatio,wrapHorizontal:e.wrapHorizontal,wrapVertical:e.wrapVertical,defaultZoomLevel:e.defaultZoomLevel,minZoomLevel:e.minZoomLevel,maxZoomLevel:e.maxZoomLevel,viewer:e,degrees:e.degrees,navigatorRotate:e.navigatorRotate,homeFillsViewer:e.homeFillsViewer})),e.source.overlays=e.source.overlays||[],e.imageLoader=new $.ImageLoader,e.tileCache=new $.TileCache({maxImageCacheCount:e.maxImageCacheCount}),e.world=new $.World({viewer:e}),e.world.addHandler("add-item",function(){e.viewport.setHomeBounds(e.world.getHomeBounds(),e.world.getContentFactor()),THIS[e.hash].forceRedraw=!0}),e.world.addHandler("remove-item",function(){e.viewport.setHomeBounds(e.world.getHomeBounds(),e.world.getContentFactor()),THIS[e.hash].forceRedraw=!0}),e.drawer=new $.Drawer({viewer:e,viewport:e.viewport,element:e.canvas,opacity:e.opacity,debugGridColor:e.debugGridColor});var f=new $.TiledImage({viewer:e,source:e.source,viewport:e.viewport,drawer:e.drawer,tileCache:e.tileCache,imageLoader:e.imageLoader,x:c.x,y:c.y,width:c.width,height:c.height,imageLoaderLimit:e.imageLoaderLimit,minZoomImageRatio:e.minZoomImageRatio,wrapHorizontal:e.wrapHorizontal,wrapVertical:e.wrapVertical,immediateRender:e.immediateRender,blendTime:e.blendTime,alwaysBlend:e.alwaysBlend,minPixelRatio:e.collectionMode?0:e.minPixelRatio,debugMode:e.debugMode,debugGridColor:e.debugGridColor,crossOriginPolicy:e.crossOriginPolicy});return e.world.addItem(f),e.viewport.goHome(!0),e.drawer.canRotate()||(e.rotateLeft&&(d=e.buttons.buttons.indexOf(e.rotateLeft),e.buttons.buttons.splice(d,1),e.buttons.element.removeChild(e.rotateLeft.element)),e.rotateRight&&(d=e.buttons.buttons.indexOf(e.rotateRight),e.buttons.buttons.splice(d,1),e.buttons.element.removeChild(e.rotateRight.element))),e.showNavigator&&!e.collectionMode&&(e.navigator?e.navigator.open(b):e.navigator=new $.Navigator({id:e.navigatorId,position:e.navigatorPosition,sizeRatio:e.navigatorSizeRatio,maintainSizeRatio:e.navigatorMaintainSizeRatio,top:e.navigatorTop,left:e.navigatorLeft,width:e.navigatorWidth,height:e.navigatorHeight,autoResize:e.navigatorAutoResize,tileSources:b,tileHost:e.tileHost,prefixUrl:e.prefixUrl,viewer:e,navigatorRotate:e.navigatorRotate})),e.showReferenceStrip&&!e.referenceStrip&&(e.referenceStrip=new $.ReferenceStrip({id:e.referenceStripElement,position:e.referenceStripPosition,sizeRatio:e.referenceStripSizeRatio,scroll:e.referenceStripScroll,height:e.referenceStripHeight,width:e.referenceStripWidth,tileSources:e.tileSources,tileHost:e.tileHost,prefixUrl:e.prefixUrl,viewer:e})),THIS[e.hash].animating=!1,THIS[e.hash].forceRedraw=!0,e._updateRequestId=scheduleUpdate(e,updateMulti),VIEWERS[e.hash]=e,loadOverlays(e),e.raiseEvent("open",{source:b}),e}function loadOverlays(a){a.currentOverlays=[];for(var b=0;b=0;c--)if(a[c].element===b)return c;return-1}function drawOverlays(a,b,c){var d,e=b.length;for(d=0;e>d;d++)b[d].drawHTML(c,a)}function scheduleUpdate(a,b){return $.requestAnimationFrame(function(){b(a)})}function scheduleControlsFade(a){$.requestAnimationFrame(function(){updateControlsFade(a)})}function beginControlsAutoHide(a){a.autoHideControls&&(a.controlsShouldFade=!0,a.controlsFadeBeginTime=$.now()+a.controlsFadeDelay,window.setTimeout(function(){scheduleControlsFade(a)},a.controlsFadeDelay))}function updateControlsFade(a){var b,c,d,e;if(a.controlsShouldFade){for(b=$.now(),c=b-a.controlsFadeBeginTime,d=1-c/a.controlsFadeLength,d=Math.min(1,d),d=Math.max(0,d),e=a.controls.length-1;e>=0;e--)a.controls[e].autoFade&&a.controls[e].setOpacity(d);d>0&&scheduleControlsFade(a)}}function abortControlsAutoHide(a){var b;for(a.controlsShouldFade=!1,b=a.controls.length-1;b>=0;b--)a.controls[b].setOpacity(1)}function onFocus(){abortControlsAutoHide(this)}function onBlur(){beginControlsAutoHide(this)}function onCanvasClick(a){var b;!a.preventDefaultAction&&this.viewport&&a.quick&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.clickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-click",{tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDblClick(a){var b;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.dblClickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-double-click",{tracker:a.eventSource,position:a.position,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDrag(a){var b;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta.negate()),b.flickEnabled),this.constrainDuringPan&&this.viewport.applyConstraints()),this.raiseEvent("canvas-drag",{tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDragEnd(a){var b;if(!a.preventDefaultAction&&this.viewport){if(b=this.gestureSettingsByDeviceType(a.pointerType),b.flickEnabled&&a.speed>=b.flickMinSpeed){var c=b.flickMomentum*a.speed*Math.cos(a.direction-Math.PI/180*this.viewport.degrees),d=b.flickMomentum*a.speed*Math.sin(a.direction-Math.PI/180*this.viewport.degrees),e=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),f=this.viewport.pointFromPixel(new $.Point(e.x-c,e.y-d));this.panHorizontal||(f.x=e.x),this.panVertical||(f.y=e.y),this.viewport.panTo(f,!1)}this.viewport.applyConstraints()}this.raiseEvent("canvas-drag-end",{tracker:a.eventSource,position:a.position,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasRelease(a){this.raiseEvent("canvas-release",{tracker:a.eventSource,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function onCanvasPinch(a){var b,c,d,e;if(!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.pinchToZoom&&(c=this.viewport.pointFromPixel(a.center,!0),d=this.viewport.pointFromPixel(a.lastCenter,!0),e=d.minus(c),this.panHorizontal||(e.x=0),this.panVertical||(e.y=0),this.viewport.zoomBy(a.distance/a.lastDistance,c,!0),this.viewport.panBy(e,!0),this.viewport.applyConstraints()),b.pinchRotate)){var f=Math.atan2(a.gesturePoints[0].currentPos.y-a.gesturePoints[1].currentPos.y,a.gesturePoints[0].currentPos.x-a.gesturePoints[1].currentPos.x),g=Math.atan2(a.gesturePoints[0].lastPos.y-a.gesturePoints[1].lastPos.y,a.gesturePoints[0].lastPos.x-a.gesturePoints[1].lastPos.x);this.viewport.setRotation(this.viewport.getRotation()+(f-g)*(180/Math.PI))}return this.raiseEvent("canvas-pinch",{tracker:a.eventSource,gesturePoints:a.gesturePoints,lastCenter:a.lastCenter,center:a.center,lastDistance:a.lastDistance,distance:a.distance,shift:a.shift,originalEvent:a.originalEvent}),!1}function onCanvasScroll(a){var b,c;return!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.scrollToZoom&&(c=Math.pow(this.zoomPerScroll,a.scroll),this.viewport.zoomBy(c,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent}),!1}function onContainerExit(a){a.insideElementPressed||(THIS[this.hash].mouseInside=!1,THIS[this.hash].animating||beginControlsAutoHide(this)),this.raiseEvent("container-exit",{tracker:a.eventSource,position:a.position,buttons:a.buttons,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function onContainerPress(a){"touch"!==a.pointerType||$.MouseTracker.haveTouchEnter||(THIS[this.hash].mouseInside=!0,abortControlsAutoHide(this))}function onContainerRelease(a){(!a.insideElementReleased||"touch"===a.pointerType&&!$.MouseTracker.haveTouchEnter)&&(THIS[this.hash].mouseInside=!1,THIS[this.hash].animating||beginControlsAutoHide(this)),this.raiseEvent("container-release",{tracker:a.eventSource,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function onContainerEnter(a){THIS[this.hash].mouseInside=!0,abortControlsAutoHide(this),this.raiseEvent("container-enter",{tracker:a.eventSource,position:a.position,buttons:a.buttons,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function updateMulti(a){return a.source?(updateOnce(a),void(a.source&&(a._updateRequestId=scheduleUpdate(a,updateMulti)))):void(a._updateRequestId=null)}function updateOnce(a){var b,c;if(a.source){if(a.autoResize&&(b=_getSafeElemSize(a.container),!b.equals(THIS[a.hash].prevContainerSize))){var d=a.viewport.getBounds(),e=a.viewport.getCenter();resizeViewportAndRecenter(a,b,d,e),THIS[a.hash].prevContainerSize=b,THIS[a.hash].forceRedraw=!0}c=a.viewport.update(),a.referenceStrip&&(c=a.referenceStrip.update(a.viewport)||c),!THIS[a.hash].animating&&c&&(a.raiseEvent("animation-start"),abortControlsAutoHide(a)),c?(updateWorld(a),drawOverlays(a.viewport,a.currentOverlays,a.overlaysContainer),a.navigator&&a.navigator.update(a.viewport),a.raiseEvent("animation")):(THIS[a.hash].forceRedraw||a.world.needsUpdate())&&(updateWorld(a),drawOverlays(a.viewport,a.currentOverlays,a.overlaysContainer),a.navigator&&a.navigator.update(a.viewport),THIS[a.hash].forceRedraw=!1),THIS[a.hash].animating&&!c&&(a.raiseEvent("animation-finish"),THIS[a.hash].mouseInside||beginControlsAutoHide(a)),THIS[a.hash].animating=c}}function resizeViewportAndRecenter(a,b,c,d){var e=a.viewport;e.resize(b,!0);var f=1/a.source.aspectRatio,g=c.width<=1?c.width:1,h=c.height<=f?c.height:f,i=new $.Rect(d.x-g/2,d.y-h/2,g,h);e.fitBounds(i,!0)}function updateWorld(a){a.drawer.clear(),a.world.update(),a.raiseEvent("update-viewport",{})}function resolveUrl(a,b){return a?a+b:b}function beginZoomingIn(){THIS[this.hash].lastZoomTime=$.now(),THIS[this.hash].zoomFactor=this.zoomPerSecond,THIS[this.hash].zooming=!0,scheduleZoom(this)}function beginZoomingOut(){THIS[this.hash].lastZoomTime=$.now(),THIS[this.hash].zoomFactor=1/this.zoomPerSecond,THIS[this.hash].zooming=!0,scheduleZoom(this)}function endZooming(){THIS[this.hash].zooming=!1}function scheduleZoom(a){$.requestAnimationFrame($.delegate(a,doZoom))}function doZoom(){var a,b,c;THIS[this.hash].zooming&&this.viewport&&(a=$.now(),b=a-THIS[this.hash].lastZoomTime,c=Math.pow(THIS[this.hash].zoomFactor,b/1e3),this.viewport.zoomBy(c),this.viewport.applyConstraints(),THIS[this.hash].lastZoomTime=a,scheduleZoom(this))}function doSingleZoomIn(){this.viewport&&(THIS[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function doSingleZoomOut(){this.viewport&&(THIS[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function lightUp(){this.buttons.emulateEnter(),this.buttons.emulateExit()}function onHome(){this.viewport&&this.viewport.goHome()}function onFullScreen(){this.isFullPage()&&!$.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttons&&this.buttons.emulateExit(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function onRotateLeft(){if(this.viewport){var a=this.viewport.getRotation();0===a?a=270:a-=90,this.viewport.setRotation(a)}}function onRotateRight(){if(this.viewport){var a=this.viewport.getRotation();270===a?a=0:a+=90,this.viewport.setRotation(a)}}function onPrevious(){var a=THIS[this.hash].sequence-1;this.navPrevNextWrap&&0>a&&(a+=this.tileSources.length),this.goToPage(a)}function onNext(){var a=THIS[this.hash].sequence+1;this.navPrevNextWrap&&a>=this.tileSources.length&&(a=0),this.goToPage(a)}var THIS={},VIEWERS={};$.Viewer=function(a){var b,c=arguments,d=this;if($.isPlainObject(a)||(a={id:c[0],xmlPath:c.length>1?c[1]:void 0,prefixUrl:c.length>2?c[2]:void 0,controls:c.length>3?c[3]:void 0,overlays:c.length>4?c[4]:void 0}),a.config&&($.extend(!0,a,a.config),delete a.config),$.extend(!0,this,{id:a.id,hash:a.hash||a.id,element:null,container:null,keyboardCommandArea:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttons:null,profiler:null},$.DEFAULT_SETTINGS,a),"undefined"==typeof this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");"undefined"!=typeof THIS[this.hash]&&$.console.warn("Hash "+this.hash+" has already been used."),THIS[this.hash]={fsBoundsDelta:new $.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,sequenced:!1,sequence:0,fullPage:!1,onfullscreenchange:null},this._updateRequestId=null,this.currentOverlays=[],$.EventSource.call(this),this.addHandler("open-failed",function(a){var b=$.getString("Errors.OpenFailed",a.eventSource,a.message);d._showMessage(b)}),$.ControlDock.call(this,a);var e;for(this.xmlPath&&(this.tileSources=[this.xmlPath]),this.tileSources&&($.isArray(this.tileSources)?(this.tileSources.length>1&&(THIS[this.hash].sequenced=!0),this.initialPage>this.tileSources.length-1&&(this.initialPage=this.tileSources.length-1),e=this.tileSources[this.initialPage],THIS[this.hash].sequence=this.initialPage):e=this.tileSources),this.element=this.element||document.getElementById(this.id),this.canvas=$.makeNeutralElement("div"),this.keyboardCommandArea=$.makeNeutralElement("textarea"),this.overlaysContainer=$.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",function(a){a.width="100%",a.height="100%",a.overflow="hidden",a.position="absolute",a.top="0px",a.left="0px"}(this.canvas.style),$.setElementTouchActionNone(this.canvas),this.container.className="openseadragon-container",function(a){a.width="100%",a.height="100%",a.position="relative",a.overflow="hidden",a.left="0px",a.top="0px",a.textAlign="left"}(this.container.style),this.keyboardCommandArea.className="keyboard-command-area",function(a){a.width="100%",a.height="100%",a.overflow="hidden",a.position="absolute",a.top="0px",a.left="0px",a.resize="none"}(this.keyboardCommandArea.style),this.container.insertBefore(this.canvas,this.container.firstChild),this.container.insertBefore(this.keyboardCommandArea,this.container.firstChild),this.element.appendChild(this.container),this.canvas.appendChild(this.overlaysContainer),this.bodyWidth=document.body.style.width,this.bodyHeight=document.body.style.height,this.bodyOverflow=document.body.style.overflow,this.docOverflow=document.documentElement.style.overflow,this.keyboardCommandArea.innerTracker=new $.MouseTracker({_this:this,element:this.keyboardCommandArea,focusHandler:function(a){if(!a.preventDefaultAction){var b=$.getElementPosition(this.element); +window.scrollTo(0,b.y)}},keyHandler:function(a){if(!a.preventDefaultAction)switch(a.keyCode){case 61:return d.viewport.zoomBy(1.1),d.viewport.applyConstraints(),!1;case 45:return d.viewport.zoomBy(.9),d.viewport.applyConstraints(),!1;case 48:return d.viewport.goHome(),d.viewport.applyConstraints(),!1;case 119:case 87:case 38:return a.shift?d.viewport.zoomBy(1.1):d.viewport.panBy(new $.Point(0,-.05)),d.viewport.applyConstraints(),!1;case 115:case 83:case 40:return a.shift?d.viewport.zoomBy(.9):d.viewport.panBy(new $.Point(0,.05)),d.viewport.applyConstraints(),!1;case 97:case 37:return d.viewport.panBy(new $.Point(-.05,0)),d.viewport.applyConstraints(),!1;case 100:case 39:return d.viewport.panBy(new $.Point(.05,0)),d.viewport.applyConstraints(),!1;default:return!0}}}).setTracking(!0),this.innerTracker=new $.MouseTracker({element:this.canvas,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,clickHandler:$.delegate(this,onCanvasClick),dblClickHandler:$.delegate(this,onCanvasDblClick),dragHandler:$.delegate(this,onCanvasDrag),dragEndHandler:$.delegate(this,onCanvasDragEnd),releaseHandler:$.delegate(this,onCanvasRelease),scrollHandler:$.delegate(this,onCanvasScroll),pinchHandler:$.delegate(this,onCanvasPinch)}).setTracking(this.mouseNavEnabled?!0:!1),this.outerTracker=new $.MouseTracker({element:this.container,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:$.delegate(this,onContainerEnter),exitHandler:$.delegate(this,onContainerExit),pressHandler:$.delegate(this,onContainerPress),releaseHandler:$.delegate(this,onContainerRelease)}).setTracking(this.mouseNavEnabled?!0:!1),this.toolbar&&(this.toolbar=new $.ControlDock({element:this.toolbar})),this.bindStandardControls(),this.bindSequenceControls(),e&&(this.open(e),this.tileSources.length>1&&this._updateSequenceButtons(this.initialPage)),b=0;bc;c++)this.previousBody.push(d.childNodes[0]),d.removeChild(d.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,d.appendChild(this.toolbar.element),$.addClass(this.toolbar.element,"fullpage")),$.addClass(this.element,"fullpage"),d.appendChild(this.element),this.element.style.height=$.getWindowSize().y+"px",this.element.style.width=$.getWindowSize().x+"px",this.toolbar&&this.toolbar.element&&(this.element.style.height=$.getElementSize(this.element).y-$.getElementSize(this.toolbar.element).y+"px"),THIS[this.hash].fullPage=!0,$.delegate(this,onContainerEnter)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,e.margin=this.bodyMargin,f.margin=this.docMargin,e.padding=this.bodyPadding,f.padding=this.docPadding,e.width=this.bodyWidth,e.height=this.bodyHeight,d.removeChild(this.element),b=this.previousBody.length,c=0;b>c;c++)d.appendChild(this.previousBody.shift());$.removeClass(this.element,"fullpage"),THIS[this.hash].prevElementParent.insertBefore(this.element,THIS[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(d.removeChild(this.toolbar.element),$.removeClass(this.toolbar.element,"fullpage"),this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling),delete this.toolbar.parentNode,delete this.toolbar.nextSibling),this.element.style.width=THIS[this.hash].prevElementWidth,this.element.style.height=THIS[this.hash].prevElementHeight;var i=0,j=function(){$.setPageScroll(g.pageScroll);var a=$.getPageScroll();i++,(10>i&&a.x!==g.pageScroll.x||a.y!==g.pageScroll.y)&&$.requestAnimationFrame(j)};$.requestAnimationFrame(j),THIS[this.hash].fullPage=!1,$.delegate(this,onContainerExit)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:a}),this},setFullScreen:function(a){var b=this;if(!$.supportsFullScreen)return this.setFullPage(a);if($.isFullScreen()===a)return this;var c={fullScreen:a,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",c),c.preventDefaultAction)return this;if(a){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var d=function(){var a=$.isFullScreen();a||($.removeEvent(document,$.fullScreenEventName,d),$.removeEvent(document,$.fullScreenErrorEventName,d),b.setFullPage(!1),b.isFullPage()&&(b.element.style.width=b.fullPageStyleWidth,b.element.style.height=b.fullPageStyleHeight)),b.navigator&&b.viewport&&b.navigator.update(b.viewport),b.raiseEvent("full-screen",{fullScreen:a})};$.addEvent(document,$.fullScreenEventName,d),$.addEvent(document,$.fullScreenErrorEventName,d),$.requestFullScreen(document.body)}else $.exitFullScreen();return this},isVisible:function(){return"hidden"!=this.container.style.visibility},setVisible:function(a){return this.container.style.visibility=a?"":"hidden",this.raiseEvent("visible",{visible:a}),this},addTiledImage:function(a){function b(a){c.raiseEvent("add-item-failed",a)}$.console.assert(a,"[Viewer.addTiledImage] options is required"),$.console.assert(a.tileSource,"[Viewer.addTiledImage] options.tileSource is required");var c=this,d=a.tileSource;if(!this.isOpen())throw new Error("An image must be loaded before adding additional images.");getTileSourceImplementation(this,d,function(d){if(d instanceof Array)return void b({message:"[Viewer.addTiledImage] Sequences can not be added.",source:d,options:a});var e=new $.TiledImage({viewer:c,source:d,viewport:c.viewport,drawer:c.drawer,tileCache:c.tileCache,imageLoader:c.imageLoader,x:a.x,y:a.y,width:a.width,height:a.height,imageLoaderLimit:c.imageLoaderLimit,minZoomImageRatio:c.minZoomImageRatio,wrapHorizontal:c.wrapHorizontal,wrapVertical:c.wrapVertical,immediateRender:c.immediateRender,blendTime:c.blendTime,alwaysBlend:c.alwaysBlend,minPixelRatio:c.minPixelRatio,debugMode:c.debugMode,debugGridColor:c.debugGridColor});c.world.addItem(e,{index:a.index})},function(c){c.options=a,b(c)})},addLayer:function(a){var b=this;$.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var c=function(d){b.world.removeHandler("add-item",c),b.raiseEvent("add-layer",{options:a,drawer:d.item})},d=function(a){b.removeHandler("add-item-failed",d),b.raiseEvent("add-layer-failed",a)};return this.world.addHandler("add-item",c),this.addHandler("add-item-failed",d),this.addTiledImage(a),this},getLayerAtLevel:function(a){return $.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(a)},getLevelOfLayer:function(a){return $.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(a)},getLayersCount:function(){return $.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(a,b){return $.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(a,b)},removeLayer:function(a){return $.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(a)},forceRedraw:function(){return THIS[this.hash].forceRedraw=!0,this},bindSequenceControls:function(){var a=$.delegate(this,onFocus),b=$.delegate(this,onBlur),c=$.delegate(this,onNext),d=$.delegate(this,onPrevious),e=this.navImages,f=!0;return this.showSequenceControl&&THIS[this.hash].sequenced&&((this.previousButton||this.nextButton)&&(f=!1),this.previousButton=new $.Button({element:this.previousButton?$.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.PreviousPage"),srcRest:resolveUrl(this.prefixUrl,e.previous.REST),srcGroup:resolveUrl(this.prefixUrl,e.previous.GROUP),srcHover:resolveUrl(this.prefixUrl,e.previous.HOVER),srcDown:resolveUrl(this.prefixUrl,e.previous.DOWN),onRelease:d,onFocus:a,onBlur:b}),this.nextButton=new $.Button({element:this.nextButton?$.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.NextPage"),srcRest:resolveUrl(this.prefixUrl,e.next.REST),srcGroup:resolveUrl(this.prefixUrl,e.next.GROUP),srcHover:resolveUrl(this.prefixUrl,e.next.HOVER),srcDown:resolveUrl(this.prefixUrl,e.next.DOWN),onRelease:c,onFocus:a,onBlur:b}),this.navPrevNextWrap||this.previousButton.disable(),f&&(this.paging=new $.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.pagingControl=this.paging.element,this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:$.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||$.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var a=$.delegate(this,beginZoomingIn),b=$.delegate(this,endZooming),c=$.delegate(this,doSingleZoomIn),d=$.delegate(this,beginZoomingOut),e=$.delegate(this,doSingleZoomOut),f=$.delegate(this,onHome),g=$.delegate(this,onFullScreen),h=$.delegate(this,onRotateLeft),i=$.delegate(this,onRotateRight),j=$.delegate(this,onFocus),k=$.delegate(this,onBlur),l=this.navImages,m=[],n=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton)&&(n=!1),this.showZoomControl&&(m.push(this.zoomInButton=new $.Button({element:this.zoomInButton?$.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.ZoomIn"),srcRest:resolveUrl(this.prefixUrl,l.zoomIn.REST),srcGroup:resolveUrl(this.prefixUrl,l.zoomIn.GROUP),srcHover:resolveUrl(this.prefixUrl,l.zoomIn.HOVER),srcDown:resolveUrl(this.prefixUrl,l.zoomIn.DOWN),onPress:a,onRelease:b,onClick:c,onEnter:a,onExit:b,onFocus:j,onBlur:k})),m.push(this.zoomOutButton=new $.Button({element:this.zoomOutButton?$.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.ZoomOut"),srcRest:resolveUrl(this.prefixUrl,l.zoomOut.REST),srcGroup:resolveUrl(this.prefixUrl,l.zoomOut.GROUP),srcHover:resolveUrl(this.prefixUrl,l.zoomOut.HOVER),srcDown:resolveUrl(this.prefixUrl,l.zoomOut.DOWN),onPress:d,onRelease:b,onClick:e,onEnter:d,onExit:b,onFocus:j,onBlur:k}))),this.showHomeControl&&m.push(this.homeButton=new $.Button({element:this.homeButton?$.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.Home"),srcRest:resolveUrl(this.prefixUrl,l.home.REST),srcGroup:resolveUrl(this.prefixUrl,l.home.GROUP),srcHover:resolveUrl(this.prefixUrl,l.home.HOVER),srcDown:resolveUrl(this.prefixUrl,l.home.DOWN),onRelease:f,onFocus:j,onBlur:k})),this.showFullPageControl&&m.push(this.fullPageButton=new $.Button({element:this.fullPageButton?$.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.FullPage"),srcRest:resolveUrl(this.prefixUrl,l.fullpage.REST),srcGroup:resolveUrl(this.prefixUrl,l.fullpage.GROUP),srcHover:resolveUrl(this.prefixUrl,l.fullpage.HOVER),srcDown:resolveUrl(this.prefixUrl,l.fullpage.DOWN),onRelease:g,onFocus:j,onBlur:k})),this.showRotationControl&&(m.push(this.rotateLeftButton=new $.Button({element:this.rotateLeftButton?$.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.RotateLeft"),srcRest:resolveUrl(this.prefixUrl,l.rotateleft.REST),srcGroup:resolveUrl(this.prefixUrl,l.rotateleft.GROUP),srcHover:resolveUrl(this.prefixUrl,l.rotateleft.HOVER),srcDown:resolveUrl(this.prefixUrl,l.rotateleft.DOWN),onRelease:h,onFocus:j,onBlur:k})),m.push(this.rotateRightButton=new $.Button({element:this.rotateRightButton?$.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.RotateRight"),srcRest:resolveUrl(this.prefixUrl,l.rotateright.REST),srcGroup:resolveUrl(this.prefixUrl,l.rotateright.GROUP),srcHover:resolveUrl(this.prefixUrl,l.rotateright.HOVER),srcDown:resolveUrl(this.prefixUrl,l.rotateright.DOWN),onRelease:i,onFocus:j,onBlur:k}))),n&&(this.buttons=new $.ButtonGroup({buttons:m,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttons.element,this.addHandler("open",$.delegate(this,lightUp)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:$.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||$.ControlAnchor.TOP_LEFT}))),this},currentPage:function(){return THIS[this.hash].sequence},goToPage:function(a){return a>=0&&a=0?this:(this.currentOverlays.push(getOverlayObject(this,e)),THIS[this.hash].forceRedraw=!0,this.raiseEvent("add-overlay",{element:a,location:e.location,placement:e.placement}),this)},updateOverlay:function(a,b,c){var d;return a=$.getElement(a),d=getOverlayIndex(this.currentOverlays,a),d>=0&&(this.currentOverlays[d].update(b,c),THIS[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:a,location:b,placement:c})),this},removeOverlay:function(a){var b;return a=$.getElement(a),b=getOverlayIndex(this.currentOverlays,a),b>=0&&(this.currentOverlays[b].destroy(),this.currentOverlays.splice(b,1),THIS[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:a})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return THIS[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},_updateSequenceButtons:function(a){this.nextButton&&(this.tileSources.length-1===a?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(a>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(a){this._hideMessage();var b=$.makeNeutralElement("div");b.appendChild(document.createTextNode(a)),this.messageDiv=$.makeCenteredNode(b),$.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var a=this.messageDiv;a&&(a.parentNode.removeChild(a),delete this.messageDiv)},gestureSettingsByDeviceType:function(a){switch(a){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}}})}(OpenSeadragon),function(a){function b(a){a.quick&&this.viewer.viewport&&(this.viewer.viewport.panTo(this.viewport.pointFromPixel(a.position).rotate(-this.viewer.viewport.degrees,this.viewer.viewport.getHomeBounds().getCenter())),this.viewer.viewport.applyConstraints())}function c(a){this.viewer.viewport&&(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta)))}function d(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function e(a){return this.viewer.raiseEvent("navigator-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent}),!1}function f(a,b){a.style.webkitTransform="rotate("+b+"deg)",a.style.mozTransform="rotate("+b+"deg)",a.style.msTransform="rotate("+b+"deg)",a.style.oTransform="rotate("+b+"deg)",a.style.transform="rotate("+b+"deg)"}a.Navigator=function(g){var h,i,j,k=g.viewer,l=this;g.id?(this.element=document.getElementById(g.id),g.controlOptions={anchor:a.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(g.id="navigator-"+a.now(),this.element=a.makeNeutralElement("div"),g.controlOptions={anchor:a.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:!0},g.position&&("BOTTOM_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_RIGHT:"BOTTOM_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_LEFT:"TOP_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_RIGHT:"TOP_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_LEFT:"ABSOLUTE"==g.position&&(g.controlOptions.anchor=a.ControlAnchor.ABSOLUTE,g.controlOptions.top=g.top,g.controlOptions.left=g.left,g.controlOptions.height=g.height,g.controlOptions.width=g.width))),this.element.id=g.id,this.element.className+=" navigator",g=a.extend(!0,{sizeRatio:a.DEFAULT_SETTINGS.navigatorSizeRatio},g,{element:this.element,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,autoResize:g.autoResize}),g.minPixelRatio=this.minPixelRatio=k.minPixelRatio,a.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new a.Point(1,1),this.totalBorderWidths=new a.Point(2*this.borderWidth,2*this.borderWidth).minus(this.fudge),g.controlOptions.anchor!=a.ControlAnchor.NONE&&!function(a,b){a.margin="0px",a.border=b+"px solid #555",a.padding="0px",a.background="#000",a.opacity=.8,a.overflow="hidden"}(this.element.style,this.borderWidth),this.displayRegion=a.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(a,b){a.position="relative",a.top="0px",a.left="0px",a.fontSize="0px",a.overflow="hidden",a.border=b+"px solid #900",a.margin="0px",a.padding="0px",a.background="transparent",a["float"]="left",a.cssFloat="left",a.styleFloat="left",a.zIndex=999999999,a.cursor="default"}(this.displayRegion.style,this.borderWidth),this.displayRegionContainer=a.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",this.element.innerTracker=new a.MouseTracker({element:this.element,dragHandler:a.delegate(this,c),clickHandler:a.delegate(this,b),releaseHandler:a.delegate(this,d),scrollHandler:a.delegate(this,e)}).setTracking(!0),k.addControl(this.element,g.controlOptions),g.controlOptions.anchor!=a.ControlAnchor.ABSOLUTE&&g.controlOptions.anchor!=a.ControlAnchor.NONE&&(g.width&&g.height?(this.element.style.height="number"==typeof g.height?g.height+"px":g.height,this.element.style.width="number"==typeof g.width?g.width+"px":g.width):(h=a.getElementSize(k.element),this.element.style.height=Math.round(h.y*g.sizeRatio)+"px",this.element.style.width=Math.round(h.x*g.sizeRatio)+"px",this.oldViewerSize=h),i=a.getElementSize(this.element),this.elementArea=i.x*i.y),this.oldContainerSize=new a.Point(0,0),a.Viewer.apply(this,[g]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer),j=this.element.getElementsByTagName("textarea")[0],j&&j.parentNode.removeChild(j),g.navigatorRotate&&g.viewer.addHandler("rotate",function(a){f(l.displayRegionContainer,a.degrees),f(l.displayRegion,-a.degrees),l.viewport.setRotation(a.degrees)})},a.extend(a.Navigator.prototype,a.EventSource.prototype,a.Viewer.prototype,{updateSize:function(){if(this.viewport){var b=new a.Point(0===this.container.clientWidth?1:this.container.clientWidth,0===this.container.clientHeight?1:this.container.clientHeight);if(!b.equals(this.oldContainerSize)){var c=this.viewport.getBounds(),d=this.viewport.getCenter();this.viewport.resize(b,!0);var e=1/this.source.aspectRatio,f=c.width<=1?c.width:1,g=c.height<=e?c.height:e,h=new a.Rect(d.x-f/2,d.y-g/2,f,g);this.viewport.fitBounds(h,!0),this.oldContainerSize=b,this.drawer.update()}}},update:function(b){var c,d,e,f,g,h;c=a.getElementSize(this.viewer.element),c.equals(this.oldViewerSize)||(this.oldViewerSize=c,this.maintainSizeRatio?(d=c.x*this.sizeRatio,e=c.y*this.sizeRatio):(d=Math.sqrt(this.elementArea*(c.x/c.y)),e=this.elementArea/d),this.element.style.width=Math.round(d)+"px",this.element.style.height=Math.round(e)+"px",this.updateSize()),b&&this.viewport&&(f=b.getBounds(!0),g=this.viewport.pixelFromPoint(f.getTopLeft(),!1),h=this.viewport.pixelFromPoint(f.getBottomRight(),!1).minus(this.totalBorderWidths),function(a){a.top=Math.round(g.y)+"px",a.left=Math.round(g.x)+"px";var b=Math.abs(g.x-h.x),c=Math.abs(g.y-h.y);a.width=Math.round(Math.max(b,0))+"px",a.height=Math.round(Math.max(c,0))+"px"}(this.displayRegion.style))},open:function(b){this.updateSize();var c=this.viewer.viewport.containerSize.times(this.sizeRatio),d=b.getTileSize(b.maxLevel);return this.minPixelRatio=d>c.x||d>c.y?Math.min(c.x,c.y)/d:this.viewer.minPixelRatio,a.Viewer.prototype.open.apply(this,[b])}})}(OpenSeadragon),function(a){var b={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right"}};a.extend(a,{getString:function(c){var d,e=c.split("."),f=null,g=arguments,h=b;for(d=0;d=c));b++);return Math.max(0,b-1)},getTileAtPoint:function(a,b){var c=b.times(this.dimensions.x).times(this.getLevelScale(a)),d=Math.floor(c.x/this.getTileSize(a)),e=Math.floor(c.y/this.getTileSize(a));return new $.Point(d,e)},getTileBounds:function(a,b,c){var d=this.dimensions.times(this.getLevelScale(a)),e=this.getTileSize(a),f=0===b?0:e*b-this.tileOverlap,g=0===c?0:e*c-this.tileOverlap,h=e+(0===b?1:2)*this.tileOverlap,i=e+(0===c?1:2)*this.tileOverlap,j=1/d.x;return h=Math.min(h,d.x-f),i=Math.min(i,d.y-g),new $.Rect(f*j,g*j,h*j,i*j)},getImageInfo:function(a){var b,c,d,e,f,g,h,i=this;a&&(f=a.split("/"),g=f[f.length-1],h=g.lastIndexOf("."),h>-1&&(f[f.length-1]=g.slice(0,h))),c=function(b){"string"==typeof b&&(b=$.parseXml(b));var c=$.TileSource.determineType(i,b,a);return c?(e=c.prototype.configure.apply(i,[b,a]),d=new c(e),i.ready=!0,void i.raiseEvent("ready",{tileSource:d})):void i.raiseEvent("open-failed",{message:"Unable to load TileSource",source:a})},a.match(/\.js$/)?(b=a.split("/").pop().replace(".js",""),$.jsonp({url:a,async:!1,callbackName:b,callback:c})):$.makeAjaxRequest(a,function(a){var b=processResponse(a);c(b)},function(b,c){var d;try{d="HTTP "+b.status+" attempting to load TileSource"}catch(e){var f;f="undefined"!=typeof c&&c.toString?c.toString():"Unknown error",d=f+" attempting to load TileSource"}i.raiseEvent("open-failed",{message:d,source:a})})},supports:function(){return!1},configure:function(){throw new Error("Method not implemented.")},getTileUrl:function(){throw new Error("Method not implemented.")},tileExists:function(a,b,c){var d=this.getNumTiles(a);return a>=this.minLevel&&a<=this.maxLevel&&b>=0&&c>=0&&b=0;c--)for(d=this.displayRects[c],e=d.minLevel;e<=d.maxLevel;e++)this._levelRects[e]||(this._levelRects[e]=[]),this._levelRects[e].push(d);a.TileSource.apply(this,[f])},a.extend(a.DziTileSource.prototype,a.TileSource.prototype,{supports:function(a){var b;return a.Image?b=a.Image.xmlns:a.documentElement&&"Image"==a.documentElement.localName&&(b=a.documentElement.namespaceURI),"http://schemas.microsoft.com/deepzoom/2008"==b||"http://schemas.microsoft.com/deepzoom/2009"==b},configure:function(d,e){var f;return f=a.isPlainObject(d)?c(this,d):b(this,d),e&&!f.tilesUrl&&(f.tilesUrl=e.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/,"$1_files/"),f.queryParams=-1!=e.search(/\.(dzi|xml|js)\?/)?e.match(/\?.*/):""),f},getTileUrl:function(a,b,c){return[this.tilesUrl,a,"/",b,"_",c,".",this.fileFormat,this.queryParams].join("")},tileExists:function(a,b,c){var d,e,f,g,h,i,j,k=this._levelRects[a];if(!k||!k.length)return!0;for(j=k.length-1;j>=0;j--)if(d=k[j],!(ad.maxLevel)&&(e=this.getLevelScale(a),f=d.x*e,g=d.y*e,h=f+d.width*e,i=g+d.height*e,f=Math.floor(f/this.tileSize),g=Math.floor(g/this.tileSize),h=Math.ceil(h/this.tileSize),i=Math.ceil(i/this.tileSize),b>=f&&h>b&&c>=g&&i>c))return!0;return!1}})}(OpenSeadragon),function(a){function b(b){if(!b||!b.documentElement)throw new Error(a.getString("Errors.Xml"));var d=b.documentElement,e=d.tagName,f=null;if("info"==e)try{return f={},c(d,f),f}catch(g){throw g instanceof Error?g:new Error(a.getString("Errors.IIIF"))}throw new Error(a.getString("Errors.IIIF"))}function c(b,d,e){var f,g;if(3==b.nodeType&&e)g=b.nodeValue.trim(),g.match(/^\d*$/)&&(g=Number(g)),d[e]?(a.isArray(d[e])||(d[e]=[d[e]]),d[e].push(g)):d[e]=g;else if(1==b.nodeType)for(f=0;f0?Math.max.apply(null,h):f,this.tile_width=b.tileSize,this.tile_height=b.tileSize}b.maxLevel||(b.maxLevel=this.scale_factors?Math.floor(Math.pow(Math.max.apply(null,this.scale_factors),.5)):Number(Math.ceil(Math.log(Math.max(this.width,this.height),2)))),a.TileSource.apply(this,[b])},a.extend(a.IIIFTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.protocol&&"http://iiif.io/api/image"==a.protocol?!0:!a["@context"]||"http://library.stanford.edu/iiif/image-api/1.1/context.json"!=a["@context"]&&"http://iiif.io/api/image/1/context.json"!=a["@context"]?a.profile&&0===a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")?!0:a.identifier&&a.width&&a.height?!0:a.documentElement&&"info"==a.documentElement.tagName&&"http://library.stanford.edu/iiif/image-api/ns/"==a.documentElement.namespaceURI?!0:!1:!0},configure:function(c,d){if(a.isPlainObject(c))return c["@context"]?c:(c["@context"]="http://iiif.io/api/image/1.0/context.json",c["@id"]=d.replace("/info.json",""),c);var e=b(c);return e["@context"]="http://iiif.io/api/image/1.0/context.json",e["@id"]=d.replace("/info.xml",""),e},getTileSize:function(a){var b=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[b]&&(this.tileSize=this.tileSizePerScaleFactor[b]),this.tileSize},getTileUrl:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n="0",o=Math.pow(.5,this.maxLevel-a),p=Math.ceil(this.width*o),q=Math.ceil(this.height*o);return d=Math.ceil(this.getTileSize(a)/o),e=d,l=this["@context"].indexOf("/1.0/context.json")>-1||this["@context"].indexOf("/1.1/context.json")>-1||this["@context"].indexOf("/1/context.json")>-1?"native.jpg":"default.jpg",pf?e/256:f/256,c.maxLevel=Math.ceil(Math.log(d)/Math.log(2))-1,c.tileSize=256,c.width=e,c.height=f,a.TileSource.apply(this,[c])},a.extend(a.TmsTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.type&&"tiledmapservice"==a.type},configure:function(a){return a},getTileUrl:function(a,b,c){var d=this.getNumTiles(a).y-1;return this.tilesUrl+a+"/"+b+"/"+(d-c)+".png"}})}(OpenSeadragon),function(a){function b(b){var c,d,e=[];for(d=0;d");return e.sort(function(a,b){return a.height-b.height})}function c(b,c){if(!c||!c.documentElement)throw new Error(a.getString("Errors.Xml"));var e,f,g=c.documentElement,h=g.tagName,i=null,j=[];if("image"==h)try{for(i={type:g.getAttribute("type"),levels:[]},j=g.getElementsByTagName("level"),f=0;f0?(e=d.levels[d.levels.length-1].width,f=d.levels[d.levels.length-1].height):(e=0,f=0,a.console.error("No supported image formats found")),a.extend(!0,d,{width:e,height:f,tileSize:Math.max(f,e),tileOverlap:0,minLevel:0,maxLevel:d.levels.length>0?d.levels.length-1:0}),a.TileSource.apply(this,[d]),this.levels=d.levels},a.extend(a.LegacyTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.type&&"legacy-image-pyramid"==a.type||a.documentElement&&"legacy-image-pyramid"==a.documentElement.getAttribute("type")},configure:function(b){var e;return e=a.isPlainObject(b)?d(this,b):c(this,b)},getLevelScale:function(a){var b=0/0;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width),b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileAtPoint:function(){return new a.Point(0,0)},getTileUrl:function(a){var b=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].url),b}})}(OpenSeadragon),function(a){a.TileSourceCollection=function(b){var c;c=a.isPlainObject(b)?b:{tileSize:arguments[0],tileSources:arguments[1],rows:arguments[2],layout:arguments[3]},c.layout||(c.layout="horizontal");var d=0,e=1,f=Math.ceil(c.tileSources.length/c.rows),g=f>=c.rows?f:c.rows;for("horizontal"==c.layout?(c.width=c.tileSize*f,c.height=c.tileSize*c.rows):(c.height=c.tileSize*f,c.width=c.tileSize*c.rows),c.tileOverlap=-c.tileMargin,c.tilesPerRow=f;e0&&b(c))}function d(c){c.shouldFade=!0,c.fadeBeginTime=a.now()+c.fadeDelay,window.setTimeout(function(){b(c)},c.fadeDelay)}function e(b){b.shouldFade=!1,b.imgGroup&&a.setElementOpacity(b.imgGroup,1,!0)}function f(b,c){b.element.disabled||(c>=a.ButtonState.GROUP&&b.currentState==a.ButtonState.REST&&(e(b),b.currentState=a.ButtonState.GROUP),c>=a.ButtonState.HOVER&&b.currentState==a.ButtonState.GROUP&&(b.imgHover&&(b.imgHover.style.visibility=""),b.currentState=a.ButtonState.HOVER),c>=a.ButtonState.DOWN&&b.currentState==a.ButtonState.HOVER&&(b.imgDown&&(b.imgDown.style.visibility=""),b.currentState=a.ButtonState.DOWN))}function g(b,c){b.element.disabled||(c<=a.ButtonState.HOVER&&b.currentState==a.ButtonState.DOWN&&(b.imgDown&&(b.imgDown.style.visibility="hidden"),b.currentState=a.ButtonState.HOVER),c<=a.ButtonState.GROUP&&b.currentState==a.ButtonState.HOVER&&(b.imgHover&&(b.imgHover.style.visibility="hidden"),b.currentState=a.ButtonState.GROUP),c<=a.ButtonState.REST&&b.currentState==a.ButtonState.GROUP&&(d(b),b.currentState=a.ButtonState.REST))}a.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},a.Button=function(b){var c=this;a.EventSource.call(this),a.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null},b),this.element=b.element||a.makeNeutralElement("div"),b.element||(this.imgRest=a.makeTransparentImage(this.srcRest),this.imgGroup=a.makeTransparentImage(this.srcGroup),this.imgHover=a.makeTransparentImage(this.srcHover),this.imgDown=a.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,this.element.style.position="relative",a.setElementTouchActionNone(this.element),this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute",this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px",this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px",this.imgHover.style.visibility=this.imgDown.style.visibility="hidden",a.Browser.vendor==a.BROWSERS.FIREFOX&&a.Browser.version<3&&(this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top=""),this.element.appendChild(this.imgRest),this.element.appendChild(this.imgGroup),this.element.appendChild(this.imgHover),this.element.appendChild(this.imgDown)),this.addHandler("press",this.onPress),this.addHandler("release",this.onRelease),this.addHandler("click",this.onClick),this.addHandler("enter",this.onEnter),this.addHandler("exit",this.onExit),this.addHandler("focus",this.onFocus),this.addHandler("blur",this.onBlur),this.currentState=a.ButtonState.GROUP,this.fadeBeginTime=null,this.shouldFade=!1,this.element.style.display="inline-block",this.element.style.position="relative",this.element.title=this.tooltip,this.tracker=new a.MouseTracker({element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(b){b.insideElementPressed?(f(c,a.ButtonState.DOWN),c.raiseEvent("enter",{originalEvent:b.originalEvent})):b.buttonDownAny||f(c,a.ButtonState.HOVER)},focusHandler:function(a){this.enterHandler(a),c.raiseEvent("focus",{originalEvent:a.originalEvent})},exitHandler:function(b){g(c,a.ButtonState.GROUP),b.insideElementPressed&&c.raiseEvent("exit",{originalEvent:b.originalEvent})},blurHandler:function(a){this.exitHandler(a),c.raiseEvent("blur",{originalEvent:a.originalEvent})},pressHandler:function(b){f(c,a.ButtonState.DOWN),c.raiseEvent("press",{originalEvent:b.originalEvent})},releaseHandler:function(b){b.insideElementPressed&&b.insideElementReleased?(g(c,a.ButtonState.HOVER),c.raiseEvent("release",{originalEvent:b.originalEvent})):b.insideElementPressed?g(c,a.ButtonState.GROUP):f(c,a.ButtonState.HOVER)},clickHandler:function(a){a.quick&&c.raiseEvent("click",{originalEvent:a.originalEvent})},keyHandler:function(a){return 13===a.keyCode?(c.raiseEvent("click",{originalEvent:a.originalEvent}),c.raiseEvent("release",{originalEvent:a.originalEvent}),!1):!0}}).setTracking(!0),g(this,a.ButtonState.REST)},a.extend(a.Button.prototype,a.EventSource.prototype,{notifyGroupEnter:function(){f(this,a.ButtonState.GROUP)},notifyGroupExit:function(){g(this,a.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,a.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,a.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()}})}(OpenSeadragon),function(a){a.ButtonGroup=function(b){a.extend(!0,this,{buttons:[],clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},b);var c,d=this.buttons.concat([]),e=this;if(this.element=b.element||a.makeNeutralElement("div"),!b.group)for(this.label=a.makeNeutralElement("label"),this.element.style.display="inline-block",this.element.appendChild(this.label),c=0;c0?c>-(f-h.x)&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.x<0&&0>c&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.y>0?e>-(g-h.y)&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y)):-b.delta.y<0&&0>e&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y))),!1}function c(b){var c=Number(this.element.style.marginLeft.replace("px","")),e=Number(this.element.style.marginTop.replace("px","")),f=Number(this.element.style.width.replace("px","")),g=Number(this.element.style.height.replace("px","")),h=a.getElementSize(this.viewer.canvas);return this.element&&("horizontal"==this.scroll?b.scroll>0?c>-(f-h.x)&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0&&0>c&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0?e>h.y-g&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll)):b.scroll>0&&0>e&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll))),!1}function d(b,c,d){var e,f,g,h,i,j,k;for(e="horizontal"==b.scroll?b.panelWidth:b.panelHeight,f=Math.ceil(c/e)+5,g=Math.ceil((Math.abs(d)+c)/e)+1,f=g-f,f=0>f?0:f,j=f;g>j&&jj+g.x-this.panelWidth?(c=Math.min(c,h-g.x),this.element.style.marginLeft=-c+"px",d(this,g.x,-c)):j>c&&(c=Math.max(0,c-g.x/2),this.element.style.marginLeft=-c+"px",d(this,g.x,-c))):(c=Number(b)*(this.panelHeight+3),c>k+g.y-this.panelHeight?(c=Math.min(c,i-g.y),this.element.style.marginTop=-c+"px",d(this,g.y,-c)):k>c&&(c=Math.max(0,c-g.y/2),this.element.style.marginTop=-c+"px",d(this,g.y,-c))),this.currentPage=b,a.getElement(f.id+"-displayregion").focus(),e.call(this,{eventSource:this.innerTracker}))},update:function(){return h[this.id].animating?(a.console.log("image reference strip update"),!0):!1}})}(OpenSeadragon),function(a){a.DisplayRect=function(b,c,d,e,f,g){a.Rect.apply(this,[b,c,d,e]),this.minLevel=f,this.maxLevel=g},a.extend(a.DisplayRect.prototype,a.Rect.prototype)}(OpenSeadragon),function(a){function b(a,b){return(1-Math.exp(a*-b))/(1-Math.exp(-a))}a.Spring=function(b){var c=arguments;"object"!=typeof b&&(b={initial:c.length&&"number"==typeof c[0]?c[0]:0,springStiffness:c.length>1?c[1].springStiffness:5,animationTime:c.length>1?c[1].animationTime:1.5}),a.extend(!0,this,b),this.current={value:"number"==typeof this.initial?this.initial:0,time:a.now()},this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time}},a.Spring.prototype={resetTo:function(a){this.target.value=a,this.target.time=this.current.time,this.start.value=this.target.value,this.start.time=this.target.time},springTo:function(a){this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=a,this.target.time=this.start.time+1e3*this.animationTime},shiftBy:function(a){this.start.value+=a,this.target.value+=a},update:function(){this.current.time=a.now(),this.current.value=this.current.time>=this.target.time?this.target.value:this.start.value+(this.target.value-this.start.value)*b(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time))}}}(OpenSeadragon),function(a){function b(b){a.extend(!0,this,{timeout:a.DEFAULT_SETTINGS.timeout,jobId:null},b),this.image=null}function c(a,b,c){var d;a.jobsInProgress--,(!a.jobLimit||a.jobsInProgress0&&(d=a.jobQueue.shift(),d.start()),c(b.image)}b.prototype={start:function(){var a=this;this.image=new Image,this.crossOriginPolicy!==!1&&(this.image.crossOrigin=this.crossOriginPolicy),this.image.onload=function(){a.finish(!0)},this.image.onabort=this.image.onerror=function(){a.finish(!1)},this.jobId=window.setTimeout(function(){a.finish(!1)},this.timeout),this.image.src=this.src},finish:function(a){this.image.onload=this.image.onerror=this.image.onabort=null,a||(this.image=null),this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},a.ImageLoader=function(){a.extend(!0,this,{jobLimit:a.DEFAULT_SETTINGS.imageLoaderLimit,jobQueue:[],jobsInProgress:0})},a.ImageLoader.prototype={addJob:function(a){var d=this,e=function(b){c(d,b,a.callback)},f={src:a.src,crossOriginPolicy:a.crossOriginPolicy,callback:e},g=new b(f);!this.jobLimit||this.jobsInProgress0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),a.console.assert(b.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this.setHomeBounds(new a.Rect(0,0,1,b.y/b.x),b.x),this},setHomeBounds:function(b,c){a.console.assert(b,"[Viewport.setHomeBounds] bounds is required"),a.console.assert(b instanceof a.Rect,"[Viewport.setHomeBounds] bounds must be an OpenSeadragon.Rect"),a.console.assert(b.width>0,"[Viewport.setHomeBounds] bounds.width must be greater than 0"),a.console.assert(b.height>0,"[Viewport.setHomeBounds] bounds.height must be greater than 0"),this.homeBounds=b.clone(),this.contentSize=this.homeBounds.getSize().times(c),this.contentAspectX=this.contentSize.x/this.contentSize.y,this.contentAspectY=this.contentSize.y/this.contentSize.x,this.fitWidthBounds=new a.Rect(this.homeBounds.x,this.homeBounds.y,this.homeBounds.width,this.homeBounds.width),this.fitHeightBounds=new a.Rect(this.homeBounds.x,this.homeBounds.y,this.homeBounds.height,this.homeBounds.height),this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this.contentSize.clone(),contentFactor:c,homeBounds:this.homeBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var a,b=this.contentAspectX/this.getAspectRatio();return a=this.homeFillsViewer?b>=1?b:1:b>=1?1:b,a/this.homeBounds.width},getHomeBounds:function(){return this.homeBounds.clone()},goHome:function(a){return this.viewer&&this.viewer.raiseEvent("home",{immediately:a}),this.fitBounds(this.getHomeBounds(),a)},getMinZoom:function(){var a=this.getHomeZoom(),b=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*a;return Math.min(b,a)},getMaxZoom:function(){var a=this.maxZoomLevel;return a||(a=this.contentSize.x*this.maxZoomPixelRatio/this.containerSize.x,a/=this.homeBounds.width),Math.max(a,this.getHomeZoom())},getAspectRatio:function(){return this.containerSize.x/this.containerSize.y},getContainerSize:function(){return new a.Point(this.containerSize.x,this.containerSize.y)},getBounds:function(b){var c=this.getCenter(b),d=1/this.getZoom(b),e=d/this.getAspectRatio();return new a.Rect(c.x-d/2,c.y-e/2,d,e)},getCenter:function(b){var c,d,e,f,g,h,i,j,k=new a.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),l=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return b?k:this.zoomPoint?(c=this.pixelFromPoint(this.zoomPoint,!0),d=this.getZoom(),e=1/d,f=e/this.getAspectRatio(),g=new a.Rect(k.x-e/2,k.y-f/2,e,f),h=this.zoomPoint.minus(g.getTopLeft()).times(this.containerSize.x/g.width),i=h.minus(c),j=i.divide(this.containerSize.x*d),l.plus(j)):l},getZoom:function(a){return a?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyBoundaryConstraints:function(b,c){var d=0,e=0,f=new a.Rect(b.x,b.y,b.width,b.height),g=this.visibilityRatio*f.width,h=this.visibilityRatio*f.height;if(this.wrapHorizontal);else{var i=f.x+(f.width-g);this.homeBounds.x>i&&(d=this.homeBounds.x-i);var j=this.homeBounds.x+this.homeBounds.width,k=f.x+g;if(k>j){var l=j-k;d=d?(d+l)/2:l}}if(this.wrapVertical);else{var m=f.y+(f.height-h);this.homeBounds.y>m&&(e=this.homeBounds.y-m);var n=this.homeBounds.y+this.homeBounds.height,o=f.y+h;if(o>n){var p=n-o;e=e?(e+p)/2:p}}return(d||e)&&(f.x+=d,f.y+=e),this.viewer&&this.viewer.raiseEvent("constrain",{immediately:c}),f},applyConstraints:function(a){var b,c,d=this.getZoom(),e=Math.max(Math.min(d,this.getMaxZoom()),this.getMinZoom());return d!=e&&this.zoomTo(e,this.zoomPoint,a),b=this.getBounds(),c=this._applyBoundaryConstraints(b,a),(b.x!==c.x||b.y!==c.y||a)&&this.fitBounds(c,a),this},ensureVisible:function(a){return this.applyConstraints(a)},_fitBounds:function(b,c){c=c||{};var d,e,f,g,h,i,j=c.immediately||!1,k=c.constraints||!1,l=this.getAspectRatio(),m=b.getCenter(),n=new a.Rect(b.x,b.y,b.width,b.height);return n.getAspectRatio()>=l?(n.height=b.width/l,n.y=m.y-n.height/2):(n.width=b.height*l,n.x=m.x-n.width/2),k&&(h=n.getAspectRatio()),this.panTo(this.getCenter(!0),!0),this.zoomTo(this.getZoom(!0),null,!0),d=this.getBounds(),e=this.getZoom(),f=1/n.width,k&&(i=Math.max(Math.min(f,this.getMaxZoom()),this.getMinZoom()),f!==i&&(f=i,n.width=1/f,n.x=m.x-n.width/2,n.height=n.width/h,n.y=m.y-n.height/2),n=this._applyBoundaryConstraints(n,j)),f==e||n.width==d.width?this.panTo(k?n.getCenter():m,j):(g=d.getTopLeft().times(this.containerSize.x/d.width).minus(n.getTopLeft().times(this.containerSize.x/n.width)).divide(this.containerSize.x/d.width-this.containerSize.x/n.width),this.zoomTo(f,g,j))},fitBounds:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!1})},fitBoundsWithConstraints:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!0})},fitVertically:function(a){var b=this.getCenter();return this.wrapHorizontal&&(b.x=(1+b.x%1)%1,this.centerSpringX.resetTo(b.x),this.centerSpringX.update()),this.wrapVertical&&(b.y=(this.contentAspectY+b.y%this.contentAspectY)%this.contentAspectY,this.centerSpringY.resetTo(b.y),this.centerSpringY.update()),this.fitBounds(this.fitHeightBounds,a)},fitHorizontally:function(a){var b=this.getCenter();return this.wrapHorizontal&&(b.x=(this.contentAspectX+b.x%this.contentAspectX)%this.contentAspectX,this.centerSpringX.resetTo(b.x),this.centerSpringX.update()),this.wrapVertical&&(b.y=(1+b.y%1)%1,this.centerSpringY.resetTo(b.y),this.centerSpringY.update()),this.fitBounds(this.fitWidthBounds,a)},panBy:function(b,c){var d=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return b=b.rotate(-this.degrees,new a.Point(0,0)),this.panTo(d.plus(b),c)},panTo:function(a,b){return b?(this.centerSpringX.resetTo(a.x),this.centerSpringY.resetTo(a.y)):(this.centerSpringX.springTo(a.x),this.centerSpringY.springTo(a.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:a,immediately:b}),this},zoomBy:function(b,c,d){return c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)&&(c=c.rotate(-this.degrees,new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value))),this.zoomTo(this.zoomSpring.target.value*b,c,d)},zoomTo:function(b,c,d){return this.zoomPoint=c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)?c:null,d?this.zoomSpring.resetTo(b):this.zoomSpring.springTo(b),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:b,refPoint:c,immediately:d}),this},setRotation:function(a){return this.viewer&&this.viewer.drawer.canRotate()?(a=(a+360)%360,this.degrees=a,this.viewer.forceRedraw(),null!==this.viewer&&this.viewer.raiseEvent("rotate",{degrees:a}),this):this},getRotation:function(){return this.degrees},resize:function(b,c){var d,e=this.getBounds(),f=e;return this.containerSize=new a.Point(b.x,b.y),c&&(d=b.x/this.containerSize.x,f.width=e.width*d,f.height=f.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:b,maintain:c}),this.fitBounds(f,!0)},update:function(){var a,b,c,d,e=this.centerSpringX.current.value,f=this.centerSpringY.current.value,g=this.zoomSpring.current.value;return this.zoomPoint&&(a=this.pixelFromPoint(this.zoomPoint,!0)),this.zoomSpring.update(),this.zoomPoint&&this.zoomSpring.current.value!=g?(b=this.pixelFromPoint(this.zoomPoint,!0),c=b.minus(a),d=this.deltaPointsFromPixels(c,!0),this.centerSpringX.shiftBy(d.x),this.centerSpringY.shiftBy(d.y)):this.zoomPoint=null,this.centerSpringX.update(),this.centerSpringY.update(),this.centerSpringX.current.value!=e||this.centerSpringY.current.value!=f||this.zoomSpring.current.value!=g},deltaPixelsFromPoints:function(a,b){return a.times(this.containerSize.x*this.getZoom(b))},deltaPointsFromPixels:function(a,b){return a.divide(this.containerSize.x*this.getZoom(b))},pixelFromPoint:function(a,b){var c=this.getBounds(b);return a.minus(c.getTopLeft()).times(this.containerSize.x/c.width)},pointFromPixel:function(a,b){var c=this.getBounds(b);return a.divide(this.containerSize.x/c.width).plus(c.getTopLeft())},viewportToImageCoordinates:function(b,c){return 1==arguments.length?this.viewportToImageCoordinates(b.x,b.y):new a.Point(b*this.contentSize.x,c*this.contentSize.y*this.contentAspectX)},imageToViewportCoordinates:function(b,c){return 1==arguments.length?this.imageToViewportCoordinates(b.x,b.y):new a.Point(b/this.contentSize.x,c/this.contentSize.y/this.contentAspectX)},imageToViewportRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.imageToViewportRectangle(h.x,h.y,h.width,h.height)):(f=this.imageToViewportCoordinates(b,c),g=this.imageToViewportCoordinates(d,e),new a.Rect(f.x,f.y,g.x,g.y))},viewportToImageRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.viewportToImageRectangle(h.x,h.y,h.width,h.height)):(f=this.viewportToImageCoordinates(b,c),g=this.viewportToImageCoordinates(d,e),new a.Rect(f.x,f.y,g.x,g.y))},viewerElementToImageCoordinates:function(a){var b=this.pointFromPixel(a,!0);return this.viewportToImageCoordinates(b)},imageToViewerElementCoordinates:function(a){var b=this.imageToViewportCoordinates(a);return this.pixelFromPoint(b,!0)},windowToImageCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(b)},imageToWindowCoordinates:function(a){var b=this.imageToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(a){return this.pointFromPixel(a,!0)},viewportToViewerElementCoordinates:function(a){return this.pixelFromPoint(a,!0)},windowToViewportCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(b)},viewportToWindowCoordinates:function(a){var b=this.viewportToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},viewportToImageZoom:function(a){var b=this.viewer.source.dimensions.x,c=this.getContainerSize().x,d=c/b;return a*d},imageToViewportZoom:function(a){var b=this.viewer.source.dimensions.x,c=this.getContainerSize().x,d=b/c;return a*d}}}(OpenSeadragon),function(a){function b(b){b.updateAgain=!1;var d,e,g,h,i,k,l,m,n=null,p=!1,q=a.now(),r=(b.viewport.getContainerSize(),b.viewport.getBounds(!0)),s=r.getTopLeft(),t=r.getBottomRight(),u=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(0),!0).x*b._scale,v=Math.max(b.source.minLevel,Math.floor(Math.log(b.minZoomImageRatio)/Math.log(2))),w=Math.min(Math.abs(b.source.maxLevel),Math.abs(Math.floor(Math.log(u/b.minPixelRatio)/Math.log(2)))),x=b.viewport.degrees;for(s.x-=b._worldX,s.y-=b._worldY,t.x-=b._worldX,t.y-=b._worldY;b.lastDrawn.length>0;)d=b.lastDrawn.pop(),d.beingDrawn=!1;if(90===x||270===x){var y=r.rotate(x);s=y.getTopLeft(),t=y.getBottomRight()}else if(0!==x){var z=r.rotate(90);r.x-=z.width/2,r.y-=z.height/2,r.width+=z.width,r.height+=z.height,s=r.getTopLeft(),t=r.getBottomRight()}if(!(!b.wrapHorizontal&&(t.x<0||s.x>b._worldWidth)||!b.wrapVertical&&(t.y<0||s.y>b._worldHeight))){b.wrapHorizontal||(s.x=Math.max(s.x,0),t.x=Math.min(t.x,b._worldWidth)),b.wrapVertical||(s.y=Math.max(s.y,0),t.y=Math.min(t.y,b._worldHeight)),v=Math.min(v,w);var A;for(e=w;e>=v;e--){if(A=!1,g=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!0).x*b._scale,!p&&g>=b.minPixelRatio||e==v)A=!0,p=!0;else if(!p)continue;if(h=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!1).x*b._scale,i=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(Math.max(b.source.getClosestLevel(b.viewport.containerSize)-1,0)),!1).x*b._scale,k=b.immediateRender?1:i,l=Math.min(1,(g-.5)/.5),m=k/Math.abs(k-h),n=c(b,p,A,e,l,m,s,t,q,n),j(b.coverage,e))break}o(b,b.lastDrawn),n&&(f(b,n,q),b.updateAgain=!0)}}function c(a,b,c,e,f,g,h,i,j,k){var l,n,o,p,q,r=a.viewport.pixelFromPoint(a.viewport.getCenter());for(a.viewer&&a.viewer.raiseEvent("update-level",{havedrawn:b,level:e,opacity:f,visibility:g,topleft:h,bottomright:i,currenttime:j,best:k}),o=a.source.getTileAtPoint(e,h.divide(a._scale)),p=a.source.getTileAtPoint(e,i.divide(a._scale)),q=a.source.getNumTiles(e),m(a.coverage,e),a.wrapHorizontal||(p.x=Math.min(p.x,q.x-1)),a.wrapVertical||(p.y=Math.min(p.y,q.y-1)),l=o.x;l<=p.x;l++)for(n=o.y;n<=p.y;n++)k=d(a,c,b,l,n,e,f,g,r,q,j,k);return k}function d(a,b,c,d,f,g,j,m,o,p,q,r){var s=e(d,f,g,a.source,a.tilesMatrix,q,p,a._worldWidth,a._worldHeight),t=b;if(a.viewer&&a.viewer.raiseEvent("update-tile",{tile:s}),l(a.coverage,g,d,f,!1),!s.exists)return r;if(c&&!t&&(k(a.coverage,g,d,f)?l(a.coverage,g,d,f,!0):t=!0),!t)return r;if(h(s,a.source.tileOverlap,a.viewport,o,m,a),s.loaded){var u=i(a,s,d,f,g,j,q);u&&(a.updateAgain=!0)}else s.loading||(r=n(r,s));return r}function e(b,c,d,e,f,g,h,i,j){var k,l,m,n,o,p;return f[d]||(f[d]={}),f[d][b]||(f[d][b]={}),f[d][b][c]||(k=(h.x+b%h.x)%h.x,l=(h.y+c%h.y)%h.y,m=e.getTileBounds(d,k,l),n=e.tileExists(d,k,l),o=e.getTileUrl(d,k,l),m.x+=i*(b-k)/h.x,m.y+=j*(c-l)/h.y,f[d][b][c]=new a.Tile(d,b,c,m,n,o)),p=f[d][b][c],p.lastTouchTime=g,p}function f(a,b,c){b.loading=!0,a._imageLoader.addJob({src:b.url,crossOriginPolicy:a.crossOriginPolicy,callback:function(d){g(a,b,c,d)}})}function g(b,c,d,e){if(c.loading=!1,b.midUpdate)return void a.console.warn("Tile load callback in middle of drawing routine.");if(e){if(dh)return!0;return!1}function j(a,b,c,d){var e,f,g,h;if(!a[b])return!1;if(void 0===c||void 0===d){e=a[b];for(g in e)if(e.hasOwnProperty(g)){f=e[g];for(h in f)if(f.hasOwnProperty(h)&&!f[h])return!1}return!0}return void 0===a[b][c]||void 0===a[b][c][d]||a[b][c][d]===!0}function k(a,b,c,d){return void 0===c||void 0===d?j(a,b+1):j(a,b+1,2*c,2*d)&&j(a,b+1,2*c,2*d+1)&&j(a,b+1,2*c+1,2*d)&&j(a,b+1,2*c+1,2*d+1)}function l(b,c,d,e,f){return b[c]?(b[c][d]||(b[c][d]={}),void(b[c][d][e]=f)):void a.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",c)}function m(a,b){a[b]={}}function n(a,b){return a?b.visibility>a.visibility?b:b.visibility==a.visibility&&b.distance=0;d--){if(e=c[d],b._drawer.drawTile(e),e.beingDrawn=!0,b.debugMode)try{b._drawer.drawDebugInfo(e,c.length,d)}catch(f){a.console.error(f)}b.viewer&&b.viewer.raiseEvent("tile-drawn",{tile:e})}}a.TiledImage=function(b){a.console.assert(b.tileCache,"[TiledImage] options.tileCache is required"),a.console.assert(b.drawer,"[TiledImage] options.drawer is required"),a.console.assert(b.viewer,"[TiledImage] options.viewer is required"),a.console.assert(b.imageLoader,"[TiledImage] options.imageLoader is required"),this._tileCache=b.tileCache,delete b.tileCache,this._drawer=b.drawer,delete b.drawer,this._imageLoader=b.imageLoader,delete b.imageLoader,this._worldX=b.x||0,delete b.x,this._worldY=b.y||0,delete b.y,this.normHeight=b.source.dimensions.y/b.source.dimensions.x,b.width?(this._scale=b.width,delete b.width,b.height&&(a.console.error("specifying both width and height to a tiledImage is not supported"),delete b.height)):b.height?(this._scale=b.height/this.normHeight,delete b.height):this._scale=1,this._worldWidth=this._scale,this._worldHeight=this.normHeight*this._scale,a.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},lastDrawn:[],lastResetTime:0,midUpdate:!1,updateAgain:!0,minZoomImageRatio:a.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:a.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:a.DEFAULT_SETTINGS.wrapVertical,immediateRender:a.DEFAULT_SETTINGS.immediateRender,blendTime:a.DEFAULT_SETTINGS.blendTime,alwaysBlend:a.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:a.DEFAULT_SETTINGS.minPixelRatio,debugMode:a.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:a.DEFAULT_SETTINGS.crossOriginPolicy},b)},a.TiledImage.prototype={needsUpdate:function(){return this.updateAgain},reset:function(){return this._tileCache.clearTilesFor(this),this.lastResetTime=a.now(),this.updateAgain=!0,this},update:function(){return this.midUpdate=!0,b(this),this.midUpdate=!1,this},destroy:function(){this.reset()},getWorldBounds:function(){return new a.Rect(this._worldX,this._worldY,this._worldWidth,this._worldHeight)},getContentSize:function(){return new a.Point(this.source.dimensions.x,this.source.dimensions.y)}}}(OpenSeadragon),function(a){var b=function(b){a.console.assert(b,"[TileCache.cacheTile] params is required"),a.console.assert(b.tile,"[TileCache.cacheTile] params.tile is required"),a.console.assert(b.tiledImage,"[TileCache.cacheTile] params.tiledImage is required"),this.tile=b.tile,this.tiledImage=b.tiledImage};a.TileCache=function(b){b=b||{},this._tilesLoaded=[],this._maxImageCacheCount=b.maxImageCacheCount||a.DEFAULT_SETTINGS.maxImageCacheCount},a.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(c){a.console.assert(c,"[TileCache.cacheTile] params is required"),a.console.assert(c.tile,"[TileCache.cacheTile] params.tile is required"),a.console.assert(c.tiledImage,"[TileCache.cacheTile] params.tiledImage is required");var d=c.cutoff||0,e=this._tilesLoaded.length;if(this._tilesLoaded.length>=this._maxImageCacheCount){for(var f,g,h,i,j,k,l=null,m=-1,n=this._tilesLoaded.length-1;n>=0;n--)k=this._tilesLoaded[n],f=k.tile,f.level<=d||f.beingDrawn||(l?(i=f.lastTouchTime,g=l.lastTouchTime,j=f.level,h=l.level,(g>i||i==g&&j>h)&&(l=f,m=n)):(l=f,m=n));l&&m>=0&&(l.unload(),e=m)}this._tilesLoaded[e]=new b({tile:c.tile,tiledImage:c.tiledImage})},clearTilesFor:function(a){for(var b,c=0;c=this._items.length)throw new Error("Index bigger than number of layers.");c!==d&&-1!==d&&(this._items.splice(d,1),this._items.splice(c,0,b),this.raiseEvent("item-index-changed",{item:b,previousIndex:d,newIndex:c}))},removeItem:function(b){a.console.assert(b,"[World.removeItem] item is required");var c=this._items.indexOf(b);-1!==c&&(this._items.splice(c,1),this._figureSizes(),this.raiseEvent("remove-item",{item:b}))},resetItems:function(){for(var a=0;apa&&(oa.scrollX||oa.scrollY)){e=ua.select(aa.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=e[0][0].getScreenCTM();pa=!(i.f||i.e),e.remove()}return pa?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var u=n.getBoundingClientRect();return[t.clientX-u.left-n.clientLeft,t.clientY-u.top-n.clientTop]}function p(n){for(var t=-1,e=n.length,r=[];++t0&&(n=n.substring(0,o));var l=ka.get(n);return l&&(n=l,c=z),o?t?i:r:t?q:u}function C(n,t){return function(e){var r=ua.event;ua.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ua.event=r}}}function z(n,t){var e=C(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||r.compareDocumentPosition(t)&8)||e.call(t,n)}}function D(n,t){for(var e=0,r=n.length;r>e;e++)for(var i,u=n[e],a=0,o=u.length;o>a;a++)(i=u[a])&&t(i,a,e);return n}function j(n){return va(n,Aa),n}function L(){}function F(n,t,e){return new H(n,t,e)}function H(n,t,e){this.h=n,this.s=t,this.l=e}function P(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(a-u)*n/60:180>n?a:240>n?u+(a-u)*(240-n)/60:u}function i(n){return Math.round(r(n)*255)}var u,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+t):e+t-e*t,u=2*e-a,tt(i(n+120),i(n),i(n-120))}function R(n){return n>0?1:0>n?-1:0}function O(n){return Math.acos(Math.max(-1,Math.min(1,n)))}function Y(n){return n>1?Da/2:-1>n?-Da/2:Math.asin(n)}function U(n){return(Math.exp(n)-Math.exp(-n))/2}function I(n){return(Math.exp(n)+Math.exp(-n))/2}function V(n){return(n=Math.sin(n/2))*n}function X(n,t,e){return new Z(n,t,e)}function Z(n,t,e){this.h=n,this.c=t,this.l=e}function B(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),$(e,Math.cos(n*=La)*t,Math.sin(n)*t)}function $(n,t,e){return new J(n,t,e)}function J(n,t,e){this.l=n,this.a=t,this.b=e}function G(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=W(i)*Ra,r=W(r)*Oa,u=W(u)*Ya,tt(nt(3.2404542*i-1.5371385*r-.4985314*u),nt(-.969266*i+1.8760108*r+.041556*u),nt(.0556434*i-.2040259*r+1.0572252*u))}function K(n,t,e){return n>0?X(Math.atan2(e,t)*Fa,Math.sqrt(t*t+e*e),n):X(0/0,0/0,n)}function W(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function Q(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function nt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function tt(n,t,e){return new et(n,t,e)}function et(n,t,e){this.r=n,this.g=t,this.b=e}function rt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function it(n,t,e){var r,i,u,a=0,o=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(ct(i[0]),ct(i[1]),ct(i[2]))}return(u=Va.get(n))?t(u.r,u.g,u.b):(null!=n&&n.charAt(0)==="#"&&(n.length===4?(a=n.charAt(1),a+=a,o=n.charAt(2),o+=o,c=n.charAt(3),c+=c):n.length===7&&(a=n.substring(1,3),o=n.substring(3,5),c=n.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),c=parseInt(c,16)),t(a,o,c))}function ut(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),a=Math.max(n,t,e),o=a-u,c=(a+u)/2;return o?(i=.5>c?o/(a+u):o/(2-a-u),r=n==a?(t-e)/o+(e>t?6:0):t==a?(e-n)/o+2:(n-t)/o+4,r*=60):(r=0/0,i=c>0&&1>c?0:r),F(r,i,c)}function at(n,t,e){n=ot(n),t=ot(t),e=ot(e);var r=Q((.4124564*n+.3575761*t+.1804375*e)/Ra),i=Q((.2126729*n+.7151522*t+.072175*e)/Oa),u=Q((.0193339*n+.119192*t+.9503041*e)/Ya);return $(116*i-16,500*(r-i),200*(i-u))}function ot(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function ct(n){var t=parseFloat(n);return n.charAt(n.length-1)==="%"?Math.round(2.55*t):t}function lt(n){return"function"==typeof n?n:function(){return n}}function ft(n){return n}function st(n){return function(t,e,r){return arguments.length===2&&"function"==typeof e&&(r=e,e=null),ht(t,e,n,r)}}function ht(n,t,e,r){function i(){var n,t=c.status;if(!t&&c.responseText||t>=200&&300>t||304===t){try{n=e.call(u,c)}catch(r){return a.error.call(u,r),void 0}a.load.call(u,n)}else a.error.call(u,c)}var u={},a=ua.dispatch("progress","load","error"),o={},c=new(oa.XDomainRequest&&/^(http(s)?:)?\/\//.test(n)?XDomainRequest:XMLHttpRequest);return"onload"in c?c.onload=c.onerror=i:c.onreadystatechange=function(){c.readyState>3&&i()},c.onprogress=function(n){var t=ua.event;ua.event=n;try{a.progress.call(u,c)}finally{ua.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?o[n]:(null==t?delete o[n]:o[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(da(arguments)))}}),u.send=function(e,r,i){if(arguments.length===2&&"function"==typeof r&&(i=r,r=null),c.open(e,n,!0),null==t||"accept"in o||(o.accept=t+",*/*"),c.setRequestHeader)for(var a in o)c.setRequestHeader(a,o[a]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),c.send(null==r?null:r),u},u.abort=function(){return c.abort(),u},ua.rebind(u,a,"on"),null==r?u:u.get(gt(r))}function gt(n){return n.length===1?function(t,e){n(null==t?e:null)}:n}function pt(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var a=ua.xhr(n,t,u);return a.row=function(n){return arguments.length?a.response((e=n)==null?r:i(n)):e},a.row(e)}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function a(t){return t.map(o).join(n)}function o(n){return c.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var c=RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return a;if(i)return i=!1,u;var t=f;if(n.charCodeAt(t)===34){for(var e=t;e++f;){var r=n.charCodeAt(f++),o=1;if(10===r)i=!0;else if(13===r)i=!0,n.charCodeAt(f)===10&&(++f,++o);else if(r!==l)continue;return n.substring(t,f-o)}return n.substring(t)}for(var r,i,u={},a={},o=[],c=n.length,f=0,s=0;(r=e())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=e();(!t||(h=t(h,s++)))&&o.push(h)}return o},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new u,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(a).join("\n")},e}function dt(){var n=mt(),t=vt()-n;t>24?(isFinite(t)&&(clearTimeout($a),$a=setTimeout(dt,t)),Ba=0):(Ba=1,Ja(dt))}function mt(){for(var n=Date.now(),t=Xa;t;)n>=t.time&&(t.flush=t.callback(n-t.time)),t=t.next;return n}function vt(){for(var n,t=Xa,e=1/0;t;)t.flush?t=n?n.next=t.next:Xa=t.next:(t.time8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Mt(n,t){return t-(n?Math.ceil(Math.log(n)/Math.LN10):1)}function xt(n){return n+""}function bt(n,t){n&&uo.hasOwnProperty(n.type)&&uo[n.type](n,t)}function _t(n,t,e){var r,i=-1,u=n.length-e;for(t.lineStart();++i1||(1>lo&&(lo=1,fo=so=ho=go=0),po.point=function(i,u){i*=La;var a=Math.cos(u*=La);t=a*Math.cos(i),e=a*Math.sin(i),r=Math.sin(u),po.point=n})}function Ft(){po.point=Dt}function Ht(){return!0}function Pt(n,t,e,r,i){var u=[],a=[];if(n.forEach(function(n){if(!((t=n.length-1)<=0)){var t,e=n[0],r=n[t];if(zt(e,r)){i.lineStart();for(var o=0;t>o;++o)i.point((e=n[o])[0],e[1]);return i.lineEnd(),void 0}var c={point:e,points:n,other:null,visited:!1,entry:!0,subject:!0},l={point:e,points:[e],other:c,visited:!1,entry:!1,subject:!1};c.other=l,u.push(c),a.push(l),c={point:r,points:[r],other:null,visited:!1,entry:!1,subject:!0},l={point:r,points:[r],other:c,visited:!1,entry:!0,subject:!1},c.other=l,u.push(c),a.push(l)}}),a.sort(t),Rt(u),Rt(a),u.length){if(e)for(var o=1,c=!e(a[0].point),l=a.length;l>o;++o)a[o].entry=c=!c;for(var f,s,h,g=u[0];;){for(f=g;f.visited;)if((f=f.next)===g)return;s=f.points,i.lineStart();do{if(f.visited=f.other.visited=!0,f.entry){if(f.subject)for(var o=0;o=0;)i.point((h=s[o])[0],h[1])}else r(f.point,f.prev.point,-1,i);f=f.prev}f=f.other,s=f.points}while(!f.visited);i.lineEnd()}}}function Rt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r1&&2&t&&e.push(e.pop().concat(e.shift())),s.push(e.filter(Yt))}var s,h,g,p,d,m=t(r),v={point:i,lineStart:a,lineEnd:o,polygonStart:function(){v.point=c,v.lineStart=l,v.lineEnd=f,p=!1,g=h=0,s=[],r.polygonStart()},polygonEnd:function(){v.point=i,v.lineStart=a,v.lineEnd=o,s=ua.merge(s),s.length?Pt(s,Vt,null,e,r):(-ja>h||p&&-ja>g)&&(r.lineStart(),e(null,null,1,r),r.lineEnd()),r.polygonEnd(),s=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}},y=Ut(),M=t(y);return v}}function Yt(n){return n.length>1}function Ut(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:q,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function It(n,t){if(!(e=n.length))return 0;for(var e,r,i,u=0,a=0,o=n[0],c=o[0],l=o[1],f=Math.cos(l),s=Math.atan2(t*Math.sin(c)*f,Math.sin(l)),h=1-t*Math.cos(c)*f,g=s;++u2&&(a+=4*(r-s)):a+=Math.abs(h-2)0?Da:-Da,c=Math.abs(u-e);Math.abs(c-Da)0?Da/2:-Da/2),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(o,r),n.point(u,r),t=0):i!==o&&c>=Da&&(Math.abs(e-i)ja?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*a)):(t+r)/2}function Bt(n,t,e,r){var i;if(null==n)i=e*Da/2,r.point(-Da,i),r.point(0,i),r.point(Da,i),r.point(Da,0),r.point(Da,-i),r.point(0,-i),r.point(-Da,-i),r.point(-Da,0),r.point(-Da,i);else if(Math.abs(n[0]-t[0])>ja){var u=(n[0]u}function e(n){var e,u,c,l,f;return{lineStart:function(){l=c=!1,f=1},point:function(s,h){var g,p=[s,h],d=t(s,h),m=a?d?0:i(s,h):d?i(s+(0>s?Da:-Da),h):0;if(!e&&(l=c=d)&&n.lineStart(),d!==c&&(g=r(e,p),(zt(e,g)||zt(p,g))&&(p[0]+=ja,p[1]+=ja,d=t(p[0],p[1]))),d!==c)f=0,d?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(o&&e&&a^d){var v;m&u||!(v=r(p,e,!0))||(f=0,a?(n.lineStart(),n.point(v[0][0],v[0][1]),n.point(v[1][0],v[1][1]),n.lineEnd()):(n.point(v[1][0],v[1][1]),n.lineEnd(),n.lineStart(),n.point(v[0][0],v[0][1])))}!d||e&&zt(e,p)||n.point(p[0],p[1]),e=p,c=d,u=m},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return f|(l&&c)<<1}}}function r(n,t,e){var r=Et(n),i=Et(t),a=[1,0,0],o=At(r,i),c=kt(o,o),l=o[0],f=c-l*l;if(!f)return!e&&n;var s=u*c/f,h=-u*l/f,g=At(a,o),p=qt(a,s),d=qt(o,h);Nt(p,d);var m=g,v=kt(p,m),y=kt(m,m),M=v*v-y*(kt(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=qt(m,(-v-x)/y);if(Nt(b,p),b=Ct(b),!e)return b;var _,w=n[0],S=t[0],E=n[1],k=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=Math.abs(A-Da)A;if(!N&&E>k&&(_=E,E=k,k=_),q?N?E+k>0^b[1]<(Math.abs(b[0]-w)Da^(w<=b[0]&&b[0]<=S)){var T=qt(m,(-v+x)/y);return Nt(T,p),[b,Ct(T)]}}}function i(t,e){var r=a?n:Da-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),a=u>0,o=Math.abs(u)>ja,c=oe(n,6*La);return Ot(t,e,c)}function Jt(n,t,e,r){function i(r,i){return Math.abs(r[0]-n)0?0:3:Math.abs(r[0]-e)0?2:1:Math.abs(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return a(n.point,t.point)}function a(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}function o(i,u){var a=u[0]-i[0],o=u[1]-i[1],c=[0,1];return Math.abs(a)0&&(i[0]+=c[0]*a,i[1]+=c[0]*o),!0):!1}return function(c){function l(u){var a=i(u,-1),o=f([0===a||3===a?n:e,a>1?r:t]);return o}function f(n){for(var t=0,e=M.length,r=n[1],i=0;e>i;++i)for(var u,a=1,o=M[i],c=o.length,l=o[0];c>a;++a)u=o[a],l[1]<=r?u[1]>r&&s(l,u,n)>0&&++t:u[1]<=r&&s(l,u,n)<0&&--t,l=u;return 0!==t}function s(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}function h(u,o,c,l){var f=0,s=0;if(null==u||(f=i(u,c))!==(s=i(o,c))||a(u,o)<0^c>0){do l.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+c+4)%4)!==s)}else l.point(o[0],o[1])}function g(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function p(n,t){g(n,t)&&c.point(n,t)}function d(){T.point=v,M&&M.push(x=[]),A=!0,k=!1,S=E=0/0}function m(){y&&(v(b,_),w&&k&&q.rejoin(),y.push(q.buffer())),T.point=p,k&&c.lineEnd()}function v(n,t){n=Math.max(-vo,Math.min(vo,n)),t=Math.max(-vo,Math.min(vo,t));var e=g(n,t);if(M&&x.push([n,t]),A)b=n,_=t,w=e,A=!1,e&&(c.lineStart(),c.point(n,t));else if(e&&k)c.point(n,t);else{var r=[S,E],i=[n,t];o(r,i)?(k||(c.lineStart(),c.point(r[0],r[1])),c.point(i[0],i[1]),e||c.lineEnd()):e&&(c.lineStart(),c.point(n,t))}S=n,E=t,k=e}var y,M,x,b,_,w,S,E,k,A,N=c,q=Ut(),T={point:p,lineStart:d,lineEnd:m,polygonStart:function(){c=q,y=[],M=[]},polygonEnd:function(){c=N,(y=ua.merge(y)).length?(c.polygonStart(),Pt(y,u,l,h,c),c.polygonEnd()):f([n,t])&&(c.polygonStart(),c.lineStart(),h(null,null,1,c),c.lineEnd(),c.polygonEnd()),y=M=x=null}};return T}}function Gt(n,t,e){if(Math.abs(t)=n;var r=n/t;if(t>0){if(r>e[1])return!1;r>e[0]&&(e[0]=r)}else{if(r4*r&&d--){var x=a+h,b=o+g,_=c+p,w=Math.sqrt(x*x+b*b+_*_),S=Math.asin(_/=w),E=Math.abs(Math.abs(_)-1)r||Math.abs((v*q+y*T)/M-.5)>.3)&&(e(t,i,u,a,o,c,A,N,E,x/=w,b/=w,_,d,m),m.point(A,N),e(A,N,E,x,b,_,l,f,s,h,g,p,d,m))}}var r=.5,i=16;return t.precision=function(n){return arguments.length?(i=(r=n*n)>0&&16,t):Math.sqrt(r)},t}function Qt(n){return ne(function(){return n})()}function ne(n){function t(n){return n=a(n[0]*La,n[1]*La),[n[0]*f+o,c-n[1]*f]}function e(n){return n=a.invert((n[0]-o)/f,(c-n[1])/f),n&&[n[0]*Fa,n[1]*Fa]}function r(){a=Kt(u=re(d,m,v),i);var n=i(g,p);return o=s-n[0]*f,c=h+n[1]*f,t}var i,u,a,o,c,l=Wt(function(n,t){return n=i(n,t),[n[0]*f+o,c-n[1]*f]}),f=150,s=480,h=250,g=0,p=0,d=0,m=0,v=0,y=mo,M=ft,x=null,b=null;return t.stream=function(n){return te(u,y(l(M(n))))},t.clipAngle=function(n){return arguments.length?(y=null==n?(x=n,mo):$t((x=+n)*La),t):x},t.clipExtent=function(n){return arguments.length?(b=n,M=null==n?ft:Jt(n[0][0],n[0][1],n[1][0],n[1][1]),t):b},t.scale=function(n){return arguments.length?(f=+n,r()):f},t.translate=function(n){return arguments.length?(s=+n[0],h=+n[1],r()):[s,h]},t.center=function(n){return arguments.length?(g=n[0]%360*La,p=n[1]%360*La,r()):[g*Fa,p*Fa]},t.rotate=function(n){return arguments.length?(d=n[0]%360*La,m=n[1]%360*La,v=n.length>2?n[2]%360*La:0,r()):[d*Fa,m*Fa,v*Fa]},ua.rebind(t,l,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function te(n,t){return{point:function(e,r){r=n(e*La,r*La),e=r[0],t.point(e>Da?e-2*Da:-Da>e?e+2*Da:e,r[1])},sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function ee(n,t){return[n,t]}function re(n,t,e){return n?t||e?Kt(ue(n),ae(t,e)):ue(n):t||e?ae(t,e):ee}function ie(n){return function(t,e){return t+=n,[t>Da?t-2*Da:-Da>t?t+2*Da:t,e]}}function ue(n){var t=ie(n);return t.invert=ie(-n),t}function ae(n,t){function e(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*r+o*i;return[Math.atan2(c*u-f*a,o*r-l*i),Math.asin(Math.max(-1,Math.min(1,f*u+c*a)))]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),a=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*u-c*a;return[Math.atan2(c*u+l*a,o*r+f*i),Math.asin(Math.max(-1,Math.min(1,f*r-o*i)))]},e}function oe(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,a,o){null!=i?(i=ce(e,i),u=ce(e,u),(a>0?u>i:i>u)&&(i+=2*a*Da)):(i=n+2*a*Da,u=n);for(var c,l=a*t,f=i;a>0?f>u:u>f;f-=l)o.point((c=Ct([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function ce(n,t){var e=Et(t);e[0]-=n,Tt(e);var r=O(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-ja)%(2*Math.PI)}function le(n,t,e){var r=ua.range(n,t-ja,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function fe(n,t,e){var r=ua.range(n,t-ja,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function se(n){return n.source}function he(n){return n.target}function ge(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),a=Math.cos(r),o=Math.sin(r),c=i*Math.cos(n),l=i*Math.sin(n),f=a*Math.cos(e),s=a*Math.sin(e),h=2*Math.asin(Math.sqrt(V(r-t)+i*a*V(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*f,i=e*l+t*s,a=e*u+t*o;return[Math.atan2(i,r)*Fa,Math.atan2(a,Math.sqrt(r*r+i*i))*Fa]}:function(){return[n*Fa,t*Fa]};return p.distance=h,p}function pe(){function n(n,i){var u=Math.sin(i*=La),a=Math.cos(i),o=Math.abs((n*=La)-t),c=Math.cos(o);yo+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*u-e*a*c)*o),e*u+r*a*c),t=n,e=u,r=a}var t,e,r;Mo.point=function(i,u){t=i*La,e=Math.sin(u*=La),r=Math.cos(u),Mo.point=n},Mo.lineEnd=function(){Mo.point=Mo.lineEnd=q}}function de(n){var t=0,e=Da/3,r=ne(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Da/180,e=n[1]*Da/180):[180*(t/Da),180*(e/Da)]},i}function me(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),a-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),a=Math.sqrt(u)/i;return e.invert=function(n,t){var e=a-t;return[Math.atan2(n,e)/i,Y((u-(n*n+e*e)*i*i)/(2*i))]},e}function ve(){function n(n,t){bo+=i*n-r*t,r=n,i=t}var t,e,r,i;ko.point=function(u,a){ko.point=n,t=r=u,e=i=a},ko.lineEnd=function(){n(t,e)}}function ye(n,t){_o>n&&(_o=n),n>So&&(So=n),wo>t&&(wo=t),t>Eo&&(Eo=t)}function Me(){function n(n,t){a.push("M",n,",",t,u)}function t(n,t){a.push("M",n,",",t),o.point=e}function e(n,t){a.push("L",n,",",t)}function r(){o.point=n}function i(){a.push("Z")}var u=xe(4.5),a=[],o={point:n,lineStart:function(){o.point=t},lineEnd:r,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=r,o.point=n},pointRadius:function(n){return u=xe(n),o},result:function(){if(a.length){var n=a.join("");return a=[],n}}};return o}function xe(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function be(n,t){lo||(so+=n,ho+=t,++go)}function _e(){function n(n,r){var i=n-t,u=r-e,a=Math.sqrt(i*i+u*u);so+=a*(t+n)/2,ho+=a*(e+r)/2,go+=a,t=n,e=r}var t,e;if(1!==lo){if(!(1>lo))return;lo=1,so=ho=go=0}No.point=function(r,i){No.point=n,t=r,e=i}}function we(){No.point=be}function Se(){function n(n,t){var e=i*n-r*t;so+=e*(r+n),ho+=e*(i+t),go+=3*e,r=n,i=t}var t,e,r,i;2>lo&&(lo=2,so=ho=go=0),No.point=function(u,a){No.point=n,t=r=u,e=i=a},No.lineEnd=function(){n(t,e)}}function Ee(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,a,0,2*Da)}function e(t,e){n.moveTo(t,e),o.point=r}function r(t,e){n.lineTo(t,e)}function i(){o.point=t}function u(){n.closePath()}var a=4.5,o={point:t,lineStart:function(){o.point=e},lineEnd:i,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=i,o.point=t},pointRadius:function(n){return a=n,o},result:q};return o}function ke(n){var t=Wt(function(t,e){return n([t*Fa,e*Fa])});return function(n){return n=t(n),{point:function(t,e){n.point(t*La,e*La)},sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}}function Ae(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(n*u,r*a),Math.asin(r&&e*u/r)]},e}function Ne(n,t){function e(n,t){var e=Math.abs(Math.abs(t)-Da/2)1){o=t[1],u=n[c],c++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var l=2;l9&&(i=3*t/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));for(o=-1;++o<=c;)i=(n[Math.min(c,o+1)][0]-n[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}function nr(n){return n.length<3?Fe(n):n[0]+Ie(n,Qe(n))}function tr(n,t,e,r){var i,u,a,o,c,l,f;return i=r[n],u=i[0],a=i[1],i=r[t],o=i[0],c=i[1],i=r[e],l=i[0],f=i[1],(f-a)*(o-u)-(c-a)*(l-u)>0}function er(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function rr(n,t,e,r){var i=n[0],u=e[0],a=t[0]-i,o=r[0]-u,c=n[1],l=e[1],f=t[1]-c,s=r[1]-l,h=(o*(c-l)-s*(i-u))/(s*a-o*f);return[i+h*a,c+h*f]}function ir(n,t){var e={list:n.map(function(n,t){return{index:t,x:n[0],y:n[1]}}).sort(function(n,t){return n.yt.y?1:n.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(n,t){return{edge:n,side:t,vertex:null,l:null,r:null}},insert:function(n,t){t.l=n,t.r=n.r,n.r.l=t,n.r=t},leftBound:function(n){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,n));return t=t.l},del:function(n){n.l.r=n.r,n.r.l=n.l,n.edge=null},right:function(n){return n.r},left:function(n){return n.l},leftRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[n.side]},rightRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[Po[n.side]]}},i={bisect:function(n,t){var e={region:{l:n,r:t},ep:{l:null,r:null}},r=t.x-n.x,i=t.y-n.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=n.x*r+n.y*i+.5*(r*r+i*i),u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(n,t){var e=n.edge,r=t.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(Math.abs(i)<1e-10)return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,c=(r.c*e.a-e.c*r.a)/i,l=e.region.r,f=r.region.r;l.y=a.region.r.x;return s&&u.side==="l"||!s&&u.side==="r"?null:{x:o,y:c}},rightOf:function(n,t){var e=n.edge,r=e.region.r,i=t.x>r.x;if(i&&n.side==="l")return 1;if(!i&&n.side==="r")return 0;if(e.a===1){var u=t.y-r.y,a=t.x-r.x,o=0,c=0;if(!i&&e.b<0||i&&e.b>=0?c=o=u>=e.b*a:(c=t.x+t.y*e.b>e.c,e.b<0&&(c=!c),c||(o=1)),!o){var l=r.x-e.region.l.x;c=e.b*(a*a-u*u)h*h+g*g}return n.side==="l"?c:!c},endPoint:function(n,e,r){n.ep[e]=r,n.ep[Po[e]]&&t(n)},distance:function(n,t){var e=n.x-t.x,r=n.y-t.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(n,t,e){n.vertex=t,n.ystar=t.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(n.ystar>o.ystar||n.ystar==o.ystar&&t.x>o.vertex.x))break}i.splice(r,0,n)},del:function(n){for(var t=0,e=u.list,r=e.length;r>t&&e[t]!=n;++t);e.splice(t,1)},empty:function(){return u.list.length===0},nextEvent:function(n){for(var t=0,e=u.list,r=e.length;r>t;++t)if(e[t]==n)return e[t+1];return null},min:function(){var n=u.list[0];return{x:n.vertex.x,y:n.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,c,l,f,s,h,g,p,d,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||M.yg.y&&(p=h,h=g,g=p,y="r"),v=i.bisect(h,g),s=r.createHalfEdge(v,y),r.insert(l,s),i.endPoint(v,Po[y],m),d=i.intersect(l,s),d&&(u.del(l),u.insert(l,d,i.distance(d,h))),d=i.intersect(s,f),d&&u.insert(s,d,i.distance(d,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))t(o.edge)}function ur(n){return n.x}function ar(n){return n.y}function or(){return{leaf:!0,nodes:[],point:null,x:null,y:null}}function cr(n,t,e,r,i,u){if(!n(t,e,r,i,u)){var a=.5*(e+i),o=.5*(r+u),c=t.nodes;c[0]&&cr(n,c[0],e,r,a,o),c[1]&&cr(n,c[1],a,r,i,o),c[2]&&cr(n,c[2],e,o,a,u),c[3]&&cr(n,c[3],a,o,i,u)}}function lr(n,t){n=ua.rgb(n),t=ua.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,a=t.g-r,o=t.b-i;return function(n){return"#"+rt(Math.round(e+u*n))+rt(Math.round(r+a*n))+rt(Math.round(i+o*n))}}function fr(n){var t=[n.a,n.b],e=[n.c,n.d],r=hr(t),i=sr(t,e),u=hr(gr(e,t,-i))||0;t[0]*e[1]180?f+=360:f-l>180&&(l+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:pr(l,f)})):f&&r.push(r.pop()+"rotate("+f+")"),s!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:pr(s,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:pr(g[0],p[0])},{i:e-2,x:pr(g[1],p[1])})):(p[0]!=1||p[1]!=1)&&r.push(r.pop()+"scale("+p+")"),e=i.length,function(n){for(var t,u=-1;++ur;++r)if(a=f[r],a.x==e[0]){if(a.i)if(l[a.i+1]==null)for(l[a.i-1]+=a.x,l.splice(a.i,1),i=r+1;u>i;++i)f[i].i--;else for(l[a.i-1]+=a.x+l[a.i+1],l.splice(a.i,2),i=r+1;u>i;++i)f[i].i-=2;else if(l[a.i+1]==null)l[a.i]=a.x;else for(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1),i=r+1;u>i;++i)f[i].i--;f.splice(r,1),u--,r--}else a.x=pr(parseFloat(e[0]),parseFloat(a.x));for(;u>r;)a=f.pop(),l[a.i+1]==null?l[a.i]=a.x:(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1)),u--;return l.length===1?l[0]==null?(a=f[0].x,function(n){return a(n)+""}):function(){return t}:function(n){for(r=0;u>r;++r)l[(a=f[r]).i]=a.x(n);return l.join("")}}function yr(n,t){for(var e,r=ua.interpolators.length;--r>=0&&!(e=ua.interpolators[r](n,t)););return e}function Mr(n){return"transform"==n?dr:yr}function xr(n,t){var e,r=[],i=[],u=n.length,a=t.length,o=Math.min(n.length,t.length);for(e=0;o>e;++e)r.push(yr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;a>e;++e)i[e]=t[e];return function(n){for(e=0;o>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function Er(n){return n*n*n}function kr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Ar(n){return function(t){return Math.pow(t,n)}}function Nr(n){return 1-Math.cos(n*Da/2)}function qr(n){return Math.pow(2,10*(n-1))}function Tr(n){return 1-Math.sqrt(1-n*n)}function Cr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/(2*Da)*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,10*-r)*Math.sin(2*(r-e)*Da/t)}}function zr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Dr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function jr(n,t){n=ua.hcl(n),t=ua.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,a=t.c-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return B(e+u*n,r+a*n,i+o*n)+""}}function Lr(n,t){n=ua.hsl(n),t=ua.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,a=t.s-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return P(e+u*n,r+a*n,i+o*n)+""}}function Fr(n,t){n=ua.lab(n),t=ua.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,a=t.a-r,o=t.b-i;return function(n){return G(e+u*n,r+a*n,i+o*n)+""}}function Hr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Pr(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return(e-n)*t}}function Rr(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return Math.max(0,Math.min(1,(e-n)*t))}}function Or(n){for(var t=n.source,e=n.target,r=Ur(t,e),i=[t];t!==r;)t=t.parent,i.push(t);for(var u=i.length;e!==r;)i.splice(u,0,e),e=e.parent;return i}function Yr(n){for(var t=[],e=n.parent;null!=e;)t.push(n),n=e,e=e.parent;return t.push(n),t}function Ur(n,t){if(n===t)return n;for(var e=Yr(n),r=Yr(t),i=e.pop(),u=r.pop(),a=null;i===u;)a=i,i=e.pop(),u=r.pop();return a}function Ir(n){n.fixed|=2}function Vr(n){n.fixed&=-7}function Xr(n){n.fixed|=4,n.px=n.x,n.py=n.y}function Zr(n){n.fixed&=-5}function Br(n,t,e){var r=0,i=0;if(n.charge=0,!n.leaf)for(var u,a=n.nodes,o=a.length,c=-1;++ce;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function ui(n){return n.reduce(ai,0)}function ai(n,t){return n+t[1]}function oi(n,t){return ci(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function ci(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function li(n){return[ua.min(n),ua.max(n)]}function fi(n,t){return n.parent==t.parent?1:2}function si(n){var t=n.children;return t&&t.length?t[0]:n._tree.thread}function hi(n){var t,e=n.children;return e&&(t=e.length)?e[t-1]:n._tree.thread}function gi(n,t){var e=n.children;if(e&&(i=e.length))for(var r,i,u=-1;++u0&&(n=r);return n}function pi(n,t){return n.x-t.x}function di(n,t){return t.x-n.x}function mi(n,t){return n.depth-t.depth}function vi(n,t){function e(n,r){var i=n.children;if(i&&(a=i.length))for(var u,a,o=null,c=-1;++c=0;)t=i[u]._tree,t.prelim+=e,t.mod+=e,e+=t.shift+(r+=t.change)}function Mi(n,t,e){n=n._tree,t=t._tree;var r=e/(t.number-n.number);n.change+=r,t.change-=r,t.shift+=e,t.prelim+=e,t.mod+=e}function xi(n,t,e){return n._tree.ancestor.parent==t.parent?n._tree.ancestor:e}function bi(n,t){return n.value-t.value}function _i(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function wi(n,t){n._pack_next=t,t._pack_prev=n}function Si(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return i*i-e*e-r*r>.001}function Ei(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,i,u,a,o,c,l,f=1/0,s=-1/0,h=1/0,g=-1/0;if(e.forEach(ki),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(i=e[1],i.x=i.r,i.y=0,t(i),l>2))for(u=e[2],qi(r,i,u),t(u),_i(r,u),r._pack_prev=u,_i(u,i),i=r._pack_next,a=3;l>a;a++){qi(r,i,u=e[a]);var p=0,d=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,d++)if(Si(o,u)){p=1;break}if(1==p)for(c=r._pack_prev;c!==o._pack_prev&&!Si(c,u);c=c._pack_prev,m++);p?(m>d||d==m&&i.ra;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function ki(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ni(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,a=i.length;++ui&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Fi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Hi(n){return n.rangeExtent?n.rangeExtent():Fi(n.range())}function Pi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Ri(n,t){var e,r=0,i=n.length-1,u=n[r],a=n[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),(t=t(a-u))&&(n[r]=t.floor(u),n[i]=t.ceil(a)),n}function Oi(n,t,e,r){var i=[],u=[],a=0,o=Math.min(n.length,t.length)-1;for(n[o]2?Oi:Pi,c=r?Rr:Pr;return a=i(n,t,c,e),o=i(t,n,c,yr),u}function u(n){return a(n)}var a,o;return u.invert=function(n){return o(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Hr)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Xi(n,t)},u.tickFormat=function(t,e){return Zi(n,t,e)},u.nice=function(){return Ri(n,Ii),i()},u.copy=function(){return Yi(n,t,e,r)},i()}function Ui(n,t){return ua.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Ii(n){return n=Math.pow(10,Math.round(Math.log(n)/Math.LN10)-1),n&&{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}}function Vi(n,t){var e=Fi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Xi(n,t){return ua.range.apply(ua,Vi(n,t))}function Zi(n,t,e){var r=-Math.floor(Math.log(Vi(n,t)[2])/Math.LN10+.01);return ua.format(e?e.replace(no,function(n,t,e,i,u,a,o,c,l,f){return[t,e,i,u,a,o,c,l||"."+(r-2*("%"===f)),f].join("")}):",."+r+"f")}function Bi(n,t,e,r,i){function u(t){return n(e(t))}function a(){return e===$i?{floor:o,ceil:c}:{floor:function(n){return-c(-n)},ceil:function(n){return-o(-n)}}}function o(n){return Math.pow(t,Math.floor(Math.log(n)/Math.log(t)))}function c(n){return Math.pow(t,Math.ceil(Math.log(n)/Math.log(t)))}return u.invert=function(t){return r(n.invert(t))},u.domain=function(t){return arguments.length?(t[0]<0?(e=Gi,r=Ki):(e=$i,r=Ji),n.domain((i=t.map(Number)).map(e)),u):i},u.base=function(n){return arguments.length?(t=+n,u):t},u.nice=function(){return n.domain(Ri(i,a).map(e)),u},u.ticks=function(){var i=Fi(n.domain()),u=[];if(i.every(isFinite)){var a=Math.log(t),o=Math.floor(i[0]/a),c=Math.ceil(i[1]/a),l=r(i[0]),f=r(i[1]),s=t%1?2:t;if(e===Gi)for(u.push(-Math.pow(t,-o));o++0;h--)u.push(-Math.pow(t,-o)*h);else{for(;c>o;o++)for(var h=1;s>h;h++)u.push(Math.pow(t,o)*h);u.push(Math.pow(t,o))}for(o=0;u[o]f;c--);u=u.slice(o,c)}return u},u.tickFormat=function(n,i){if(arguments.length<2&&(i=Jo),!arguments.length)return i;var a,o=Math.log(t),c=Math.max(.1,n/u.ticks().length),l=e===Gi?(a=-1e-12,Math.floor):(a=1e-12,Math.ceil);return function(n){return n/r(o*l(e(n)/o+a))<=c?i(n):""}},u.copy=function(){return Bi(n.copy(),t,e,r,i)},Ui(u,n)}function $i(n){return Math.log(0>n?0:n)}function Ji(n){return Math.exp(n)}function Gi(n){return-Math.log(n>0?0:-n)}function Ki(n){return-Math.exp(-n)}function Wi(n,t,e){function r(t){return n(i(t))}var i=Qi(t),u=Qi(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Xi(e,n)},r.tickFormat=function(n,t){return Zi(e,n,t)},r.nice=function(){return r.domain(Ri(e,Ii))},r.exponent=function(a){return arguments.length?(i=Qi(t=a),u=Qi(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return Wi(n.copy(),t,e)},Ui(r,n)}function Qi(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function nu(n,t){function e(t){return a[((u.get(t)||u.set(t,n.push(t)))-1)%a.length]}function r(t,e){return ua.range(n.length).map(function(n){return t+e*n})}var u,a,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new i;for(var a,o=-1,c=r.length;++oe?l():(u.active=e,h.start.call(n,f,t),a.tween.forEach(function(e,r){(r=r.call(n,f,t))&&d.push(r)}),c(r)||ua.timer(c,0,o),1)}function c(r){if(u.active!==e)return l();for(var i=(r-g)/p,a=s(i),o=d.length;o>0;)d[--o].call(n,a);return i>=1?(l(),h.end.call(n,f,t),1):void 0}function l(){return--u.count?delete u[e]:delete n.__transition__,1}var f=n.__data__,s=a.ease,h=a.event,g=a.delay,p=a.duration,d=[];return r>=g?i(r):ua.timer(i,g,o),1},0,o),a}}function bu(n,t){n.attr("transform",function(n){return"translate("+t(n)+",0)"})}function _u(n,t){n.attr("transform",function(n){return"translate(0,"+t(n)+")"})}function wu(n,t,e){if(r=[],e&&t.length>1){for(var r,i,u,a=Fi(n.domain()),o=-1,c=t.length,l=(t[1]-t[0])/++e;++o0;)(u=+t[o]-i*l)>=a[0]&&r.push(u);for(--o,i=0;++i1?Date.UTC.apply(this,arguments):arguments[0])}function Eu(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new gc(e-1)),1),e}function u(n,e){return t(n=new gc(+n),e),n}function a(n,r,u){var a=i(n),o=[];if(u>1)for(;r>a;)e(a)%u||o.push(new Date(+a)),t(a,1);else for(;r>a;)o.push(new Date(+a)),t(a,1);return o}function o(n,t,e){try{gc=Su;var r=new Su;return r._=n,a(r,t,e)}finally{gc=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=a;var c=n.utc=ku(n);return c.floor=c,c.round=ku(r),c.ceil=ku(i),c.offset=ku(u),c.range=o,n}function ku(n){return function(t,e){try{gc=Su;var r=new Su;return r._=t,n(r,e)._}finally{gc=Date}}}function Au(n,t,e,r){for(var i,u,a=0,o=t.length,c=e.length;o>a;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(u=Cc[t.charAt(a++)],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function Nu(n){return RegExp("^(?:"+n.map(ua.requote).join("|")+")","i")}function qu(n){for(var t=new i,e=-1,r=n.length;++er?Array(e-r+1).join(t)+n:n}function Cu(n,t,e){Sc.lastIndex=0;var r=Sc.exec(t.substring(e));return r?e+=r[0].length:-1}function zu(n,t,e){wc.lastIndex=0;var r=wc.exec(t.substring(e));return r?e+=r[0].length:-1}function Du(n,t,e){Ac.lastIndex=0;var r=Ac.exec(t.substring(e));return r?(n.m=Nc.get(r[0].toLowerCase()),e+=r[0].length):-1}function ju(n,t,e){Ec.lastIndex=0;var r=Ec.exec(t.substring(e));return r?(n.m=kc.get(r[0].toLowerCase()),e+=r[0].length):-1}function Lu(n,t,e){return Au(n,""+Tc.c,t,e)}function Fu(n,t,e){return Au(n,""+Tc.x,t,e)}function Hu(n,t,e){return Au(n,""+Tc.X,t,e)}function Pu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+4));return r?(n.y=+r[0],e+=r[0].length):-1}function Ru(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.y=Ou(+r[0]),e+=r[0].length):-1}function Ou(n){return n+(n>68?1900:2e3)}function Yu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.m=r[0]-1,e+=r[0].length):-1}function Uu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.d=+r[0],e+=r[0].length):-1}function Iu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.H=+r[0],e+=r[0].length):-1}function Vu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.M=+r[0],e+=r[0].length):-1}function Xu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.S=+r[0],e+=r[0].length):-1}function Zu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+3));return r?(n.L=+r[0],e+=r[0].length):-1}function Bu(n,t,e){var r=Dc.get(t.substring(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}function $u(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return e+Tu(r,"0",2)+Tu(i,"0",2)}function Ju(n){return n.toISOString()}function Gu(n,t,e){function r(t){return n(t)}return r.invert=function(t){return Ku(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain(t),r):n.domain().map(Ku)},r.nice=function(n){return r.domain(Ri(r.domain(),function(){return n}))},r.ticks=function(e,i){var u=Fi(r.domain());if("function"!=typeof e){var a=u[1]-u[0],o=a/e,c=ua.bisect(Lc,o);if(c==Lc.length)return t.year(u,e);if(!c)return n.ticks(e).map(Ku);Math.log(o/Lc[c-1])n?-1:n>t?1:n>=t?0:0/0},ua.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ua.min=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++ir&&(e=r)}else{for(;++ir&&(e=r)}return e},ua.max=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++ie&&(e=r)}else{for(;++ie&&(e=r)}return e},ua.extent=function(n,t){var e,r,i,u=-1,a=n.length;if(arguments.length===1){for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},ua.sum=function(n,t){var e,r=0,i=n.length,u=-1;if(arguments.length===1)for(;++u1&&(t=t.map(e)),t=t.filter(n),t.length?ua.quantile(t.sort(ua.ascending),.5):void 0},ua.bisector=function(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n.call(t,t[u],u)r;){var u=r+i>>>1;er)for(;(i=n+r*++o)>t;)u.push(i/a);else for(;(i=n+r*++o)=a.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=a[c++],m=new i;++g=a.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,u={},a=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(ua.map,e,0),0)},u.key=function(n){return a.push(n),u},u.sortKeys=function(n){return o[a.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},ua.set=function(n){var t=new u;if(n)for(var e=0;e=0&&(r=n.substring(e+1),n=n.substring(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(arguments.length===2){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ua.event=null,ua.mouse=function(n){return g(n,f())};var pa=/WebKit/.test(oa.navigator.userAgent)?-1:0,da=d;try{da(aa.documentElement.childNodes)[0].nodeType}catch(ma){da=p}var va=[].__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]};ua.touches=function(n,t){return arguments.length<2&&(t=f().touches),t?da(t).map(function(t){var e=g(n,t);return e.identifier=t.identifier,e}):[]},ua.behavior.drag=function(){function n(){this.on("mousedown.drag",t).on("touchstart.drag",t)}function t(){function n(){var n=a.parentNode;return null!=f?ua.touches(n).filter(function(n){return n.identifier===f})[0]:ua.mouse(n)}function t(){if(!a.parentNode)return i();var t=n(),e=t[0]-h[0],r=t[1]-h[1];g|=e|r,h=t,l(),o({type:"drag",x:t[0]+u[0],y:t[1]+u[1],dx:e,dy:r})}function i(){o({type:"dragend"}),g&&(l(),ua.event.target===c&&s(p,"click")),p.on(null!=f?"touchmove.drag-"+f:"mousemove.drag",null).on(null!=f?"touchend.drag-"+f:"mouseup.drag",null)}var u,a=this,o=e.of(a,arguments),c=ua.event.target,f=ua.event.touches?ua.event.changedTouches[0].identifier:null,h=n(),g=0,p=ua.select(oa).on(null!=f?"touchmove.drag-"+f:"mousemove.drag",t).on(null!=f?"touchend.drag-"+f:"mouseup.drag",i,!0);r?(u=r.apply(a,arguments),u=[u.x-h[0],u.y-h[1]]):u=[0,0],null==f&&l(),o({type:"dragstart"})}var e=h(n,"drag","dragstart","dragend"),r=null;return n.origin=function(t){return arguments.length?(r=t,n):r},ua.rebind(n,e,"on")};var ya=function(n,t){return t.querySelector(n)},Ma=function(n,t){return t.querySelectorAll(n)},xa=aa.documentElement,ba=xa.matchesSelector||xa.webkitMatchesSelector||xa.mozMatchesSelector||xa.msMatchesSelector||xa.oMatchesSelector,_a=function(n,t){return ba.call(n,t)};"function"==typeof Sizzle&&(ya=function(n,t){return Sizzle(n,t)[0]||null},Ma=function(n,t){return Sizzle.uniqueSort(Sizzle(n,t))},_a=Sizzle.matchesSelector),ua.selection=function(){return Na};var wa=ua.selection.prototype=[];wa.select=function(n){var t,e,r,i,u=[];"function"!=typeof n&&(n=v(n));for(var a=-1,o=this.length;++a=0&&(e=n.substring(0,t),n=n.substring(t+1)),Sa.hasOwnProperty(e)?{space:Sa[e],local:n}:n}},wa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ua.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(M(t,n[t]));return this}return this.each(M(n,t))},ua.requote=function(n){return n.replace(Ea,"\\$&")};var Ea=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;wa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=n.trim().split(/^|\s+/g)).length,i=-1;if(t=e.classList){for(;++ir){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(S(e,n[e],t));return this}if(2>r)return oa.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(S(n,t,e))},wa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(E(t,n[t]));return this}return this.each(E(n,t))},wa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},wa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},wa.append=function(n){function t(){return this.appendChild(aa.createElementNS(this.namespaceURI,n))}function e(){return this.appendChild(aa.createElementNS(n.space,n.local))}return n=ua.ns.qualify(n),this.select(n.local?e:t)},wa.insert=function(n,t){function e(e,r){return this.insertBefore(aa.createElementNS(this.namespaceURI,n),t.call(this,e,r))}function r(e,r){return this.insertBefore(aa.createElementNS(n.space,n.local),t.call(this,e,r))}return n=ua.ns.qualify(n),"function"!=typeof t&&(t=v(t)),this.select(n.local?r:e)},wa.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},wa.data=function(n,t){function e(n,e){var r,u,a,o=n.length,s=e.length,h=Math.min(o,s),g=Array(s),p=Array(s),d=Array(o);if(t){var m,v=new i,y=new i,M=[];for(r=-1;++rr;++r)p[r]=k(e[r]);for(;o>r;++r)d[r]=n[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=n.parentNode,c.push(p),l.push(g),f.push(d)}var r,u,a=-1,o=this.length;if(!arguments.length){for(n=Array(o=(r=this[0]).length);++au;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return m(i)},wa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},wa.sort=function(n){n=N.apply(this,arguments);for(var t=-1,e=this.length;++tr){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(T(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(T(n,t,e))};var ka=ua.map({mouseenter:"mouseover",mouseleave:"mouseout"});ka.forEach(function(n){"on"+n in aa&&ka.remove(n)}),wa.each=function(n){return D(this,function(t,e,r){n.call(t,t.__data__,e,r)})},wa.call=function(n){var t=da(arguments);return n.apply(t[0]=this,t),this},wa.empty=function(){return!this.node()},wa.node=function(){for(var n=0,t=this.length;t>n;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null};var Aa=[];ua.selection.enter=j,ua.selection.enter.prototype=Aa,Aa.append=wa.append,Aa.insert=wa.insert,Aa.empty=wa.empty,Aa.node=wa.node,Aa.select=function(n){for(var t,e,r,i,u,a=[],o=-1,c=this.length;++oe-_){var u=n[0],o=t(n[0]);r(2*S),i(u,o),a(k.of(this,arguments))}_=e}}function d(){var n=ua.touches(this),t=n[0],e=m[t.identifier];if(u=n[1]){var u,o=m[u.identifier];t=[(t[0]+u[0])/2,(t[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r(ua.event.scale*v)}i(t,e),_=null,a(k.of(this,arguments))}var m,v,y,M,x,b,_,w=[0,0],S=1,E=Ta,k=h(n,"zoom");return n.translate=function(t){return arguments.length?(w=t.map(Number),u(),n):w},n.scale=function(t){return arguments.length?(S=+t,u(),n):S},n.scaleExtent=function(t){return arguments.length?(E=null==t?Ta:t.map(Number),n):E},n.x=function(t){return arguments.length?(M=t,y=t.copy(),w=[0,0],S=1,n):M},n.y=function(t){return arguments.length?(b=t,x=t.copy(),w=[0,0],S=1,n):b},ua.rebind(n,k,"on")};var qa,Ta=[0,1/0],Ca="onwheel"in aa?(qa=function(){return-ua.event.deltaY*(ua.event.deltaMode?120:1)},"wheel"):"onmousewheel"in aa?(qa=function(){return ua.event.wheelDelta},"mousewheel"):(qa=function(){return-ua.event.detail},"MozMousePixelScroll");L.prototype.toString=function(){return this.rgb()+""},ua.hsl=function(n,t,e){return arguments.length===1?n instanceof H?F(n.h,n.s,n.l):it(""+n,ut,F):F(+n,+t,+e)};var za=H.prototype=new L;za.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,this.l/n)},za.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,n*this.l)},za.rgb=function(){return P(this.h,this.s,this.l)};var Da=Math.PI,ja=1e-6,La=Da/180,Fa=180/Da;ua.hcl=function(n,t,e){return arguments.length===1?n instanceof Z?X(n.h,n.c,n.l):n instanceof J?K(n.l,n.a,n.b):K((n=at((n=ua.rgb(n)).r,n.g,n.b)).l,n.a,n.b):X(+n,+t,+e)};var Ha=Z.prototype=new L;Ha.brighter=function(n){return X(this.h,this.c,Math.min(100,this.l+Pa*(arguments.length?n:1)))},Ha.darker=function(n){return X(this.h,this.c,Math.max(0,this.l-Pa*(arguments.length?n:1)))},Ha.rgb=function(){return B(this.h,this.c,this.l).rgb()},ua.lab=function(n,t,e){return arguments.length===1?n instanceof J?$(n.l,n.a,n.b):n instanceof Z?B(n.l,n.c,n.h):at((n=ua.rgb(n)).r,n.g,n.b):$(+n,+t,+e)};var Pa=18,Ra=.95047,Oa=1,Ya=1.08883,Ua=J.prototype=new L;Ua.brighter=function(n){return $(Math.min(100,this.l+Pa*(arguments.length?n:1)),this.a,this.b)},Ua.darker=function(n){return $(Math.max(0,this.l-Pa*(arguments.length?n:1)),this.a,this.b)},Ua.rgb=function(){return G(this.l,this.a,this.b)},ua.rgb=function(n,t,e){return arguments.length===1?n instanceof et?tt(n.r,n.g,n.b):it(""+n,tt,P):tt(~~n,~~t,~~e)};var Ia=et.prototype=new L;Ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),tt(Math.min(255,Math.floor(t/n)),Math.min(255,Math.floor(e/n)),Math.min(255,Math.floor(r/n)))):tt(i,i,i)},Ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),tt(Math.floor(n*this.r),Math.floor(n*this.g),Math.floor(n*this.b))},Ia.hsl=function(){return ut(this.r,this.g,this.b)},Ia.toString=function(){return"#"+rt(this.r)+rt(this.g)+rt(this.b)};var Va=ua.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});Va.forEach(function(n,t){Va.set(n,it(t,tt,P))}),ua.functor=lt,ua.xhr=st(ft),ua.csv=pt(",","text/csv"),ua.tsv=pt(" ","text/tab-separated-values");var Xa,Za,Ba,$a;ua.timer=function(n,t,e){if(arguments.length<3){if(arguments.length<2)t=0;else if(!isFinite(t))return;e=Date.now()}var r=e+t,i={callback:n,time:r,next:null};Za?Za.next=i:Xa=i,Za=i,Ba||($a=clearTimeout($a),Ba=1,Ja(dt))},ua.timer.flush=function(){mt(),vt()};var Ja=oa.requestAnimationFrame||oa.webkitRequestAnimationFrame||oa.mozRequestAnimationFrame||oa.oRequestAnimationFrame||oa.msRequestAnimationFrame||function(n){setTimeout(n,17)},Ga=".",Ka=",",Wa=[3,3],Qa=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(yt);ua.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=ua.round(n,Mt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,Math.floor((0>=e?e+1:e-1)/3)*3))),Qa[8+e/3]},ua.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)},ua.format=function(n){var t=no.exec(n),e=t[1]||" ",r=t[2]||">",i=t[3]||"",u=t[4]||"",a=t[5],o=+t[6],c=t[7],l=t[8],f=t[9],s=1,h="",g=!1;switch(l&&(l=+l.substring(1)),(a||"0"===e&&"="===r)&&(a=e="0",r="=",c&&(o-=Math.floor((o-1)/4))),f){case"n":c=!0,f="g";break;case"%":s=100,h="%",f="f";break;case"p":s=100,h="%",f="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+f.toLowerCase());case"c":case"d":g=!0,l=0;break;case"s":s=-1,f="r"}"#"===u&&(u=""),"r"!=f||l||(f="g"),null!=l&&("g"==f?l=Math.max(1,Math.min(21,l)):("e"==f||"f"==f)&&(l=Math.max(0,Math.min(20,l)))),f=to.get(f)||xt;var p=a&&c;return function(n){if(g&&n%1)return"";var t=0>n||0===n&&0>1/n?(n=-n,"-"):i;if(0>s){var d=ua.formatPrefix(n,l);n=d.scale(n),h=d.symbol}else n*=s;n=f(n,l),!a&&c&&(n=eo(n));var m=u.length+n.length+(p?0:t.length),v=o>m?Array(m=o-m+1).join(e):"";return p&&(n=eo(v+n)),Ga&&n.replace(".",Ga),t+=u,("<"===r?t+n+v:">"===r?v+t+n:"^"===r?v.substring(0,m>>=1)+t+n+v.substring(m):t+(p?n:v+n))+h}};var no=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,to=ua.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ua.round(n,Mt(n,t))).toFixed(Math.max(0,Math.min(20,Mt(n*(1+1e-15),t))))}}),eo=ft;if(Wa){var ro=Wa.length;eo=function(n){for(var t=n.lastIndexOf("."),e=t>=0?"."+n.substring(t+1):(t=n.length,""),r=[],i=0,u=Wa[0];t>0&&u>0;)r.push(n.substring(t-=u,t+u)),u=Wa[i=(i+1)%ro];return r.reverse().join(Ka||"")+e}}ua.geo={},ua.geo.stream=function(n,t){n&&io.hasOwnProperty(n.type)?io[n.type](n,t):bt(n,t)};var io={Feature:function(n,t){bt(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*Da+n:n,co.lineStart=co.lineEnd=co.point=q}};ua.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>g&&(g=t)}function t(t,e){var r=Et([t*La,e*La]);if(v){var i=At(v,r),u=[i[1],-i[0],0],a=At(u,i);Tt(a),a=Ct(a);var c=t-p,l=c>0?1:-1,d=a[0]*Fa*l,m=Math.abs(c)>180;if(m^(d>l*p&&l*t>d)){var y=a[1]*Fa;y>g&&(g=y)}else if(d=(d+360)%360-180,m^(d>l*p&&l*t>d)){var y=-a[1]*Fa;s>y&&(s=y)}else s>e&&(s=e),e>g&&(g=e);m?p>t?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>p?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t)}else n(t,e);v=r,p=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,v=null}function i(n,e){if(v){var r=n-p;y+=Math.abs(r)>180?r+(r>0?360:-360):r}else d=n,m=e;co.point(n,e),t(n,e)}function u(){co.lineStart()}function a(){i(d,m),co.lineEnd(),Math.abs(y)>ja&&(f=-(h=180)),x[0]=f,x[1]=h,v=null}function o(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:noo?(f=-(h=180),s=-(g=90)):y>ja?g=90:-ja>y&&(s=-90),x[0]=f,x[1]=h}};return function(n){g=h=-(f=s=1/0),M=[],ua.geo.stream(n,b),M.sort(c);for(var t,e=1,r=M.length,i=M[0],u=[i];r>e;++e)t=M[e],l(t[0],i)||l(t[1],i)?(o(i[0],t[1])>o(i[0],i[1])&&(i[1]=t[1]),o(t[0],i[1])>o(i[0],i[1])&&(i[0]=t[0])):u.push(i=t);for(var a,t,p=-1/0,r=u.length-1,e=0,i=u[r];r>=e;i=t,++e)t=u[e],(a=o(i[1],t[0]))>p&&(p=a,f=t[0],h=i[1]);return M=x=null,[[f,s],[h,g]]}}(),ua.geo.centroid=function(n){lo=fo=so=ho=go=0,ua.geo.stream(n,po);var t;return fo&&Math.abs(t=Math.sqrt(so*so+ho*ho+go*go))>ja?[Math.atan2(ho,so)*Fa,Math.asin(Math.max(-1,Math.min(1,go/t)))*Fa]:void 0};var lo,fo,so,ho,go,po={sphere:function(){2>lo&&(lo=2,fo=so=ho=go=0)},point:Dt,lineStart:Lt,lineEnd:Ft,polygonStart:function(){2>lo&&(lo=2,fo=so=ho=go=0),po.lineStart=jt},polygonEnd:function(){po.lineStart=Lt}},mo=Ot(Ht,Xt,Bt),vo=1e9;ua.geo.projection=Qt,ua.geo.projectionMutator=ne,(ua.geo.equirectangular=function(){return Qt(ee)}).raw=ee.invert=ee,ua.geo.rotation=function(n){function t(t){return t=n(t[0]*La,t[1]*La),t[0]*=Fa,t[1]*=Fa,t}return n=re(n[0]%360*La,n[1]*La,n.length>2?n[2]*La:0),t.invert=function(t){return t=n.invert(t[0]*La,t[1]*La),t[0]*=Fa,t[1]*=Fa,t},t},ua.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=re(-n[0]*La,-n[1]*La,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Fa,n[1]*=Fa}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=oe((t=+r)*La,i*La),n):t},n.precision=function(r){return arguments.length?(e=oe(t*La,(i=+r)*La),n):i},n.angle(90)},ua.geo.distance=function(n,t){var e,r=(t[0]-n[0])*La,i=n[1]*La,u=t[1]*La,a=Math.sin(r),o=Math.cos(r),c=Math.sin(i),l=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*a)*e+(e=l*f-c*s*o)*e),c*f+l*s*o)},ua.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ua.range(Math.ceil(u/m)*m,i,m).map(h).concat(ua.range(Math.ceil(l/v)*v,c,v).map(g)).concat(ua.range(Math.ceil(r/p)*p,e,p).filter(function(n){return Math.abs(n%m)>ja}).map(f)).concat(ua.range(Math.ceil(o/d)*d,a,d).filter(function(n){return Math.abs(n%v)>ja}).map(s))}var e,r,i,u,a,o,c,l,f,s,h,g,p=10,d=p,m=90,v=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(g(c).slice(1),h(i).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],l=+t[0][1],c=+t[1][1],u>i&&(t=u,u=i,i=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[u,l],[i,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),n.precision(y)):[[r,o],[e,a]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(m=+t[0],v=+t[1],n):[m,v]},n.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],n):[p,d]},n.precision=function(t){return arguments.length?(y=+t,f=le(o,a,90),s=fe(r,e,y),h=le(l,c,90),g=fe(u,i,y),n):y},n.majorExtent([[-180,-90+ja],[180,90-ja]]).minorExtent([[-180,-80-ja],[180,80+ja]])},ua.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=se,i=he;return n.distance=function(){return ua.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},ua.geo.interpolate=function(n,t){return ge(n[0]*La,n[1]*La,t[0]*La,t[1]*La)},ua.geo.length=function(n){return yo=0,ua.geo.stream(n,Mo),yo};var yo,Mo={sphere:q,point:q,lineStart:pe,lineEnd:q,polygonStart:q,polygonEnd:q};(ua.geo.conicEqualArea=function(){return de(me)}).raw=me,ua.geo.albers=function(){return ua.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ua.geo.albersUsa=function(){function n(n){var u=n[0],a=n[1];return t=null,e(u,a),t||(r(u,a),t)||i(u,a),t}var t,e,r,i,u=ua.geo.albers(),a=ua.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o=ua.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?a:i>=.166&&.234>i&&r>=-.214&&-.115>r?o:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=a.stream(n),r=o.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),a.precision(t),o.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),a.scale(.35*t),o.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var l=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*l,s-.238*l],[f+.455*l,s+.238*l]]).stream(c).point,r=a.translate([f-.307*l,s+.201*l]).clipExtent([[f-.425*l+ja,s+.12*l+ja],[f-.214*l-ja,s+.234*l-ja]]).stream(c).point,i=o.translate([f-.205*l,s+.212*l]).clipExtent([[f-.214*l+ja,s+.166*l+ja],[f-.115*l-ja,s+.234*l-ja]]).stream(c).point,n},n.scale(1070)};var xo,bo,_o,wo,So,Eo,ko={point:q,lineStart:q,lineEnd:q,polygonStart:function(){bo=0,ko.lineStart=ve},polygonEnd:function(){ko.lineStart=ko.lineEnd=ko.point=q,xo+=Math.abs(bo/2)}},Ao={point:ye,lineStart:q,lineEnd:q,polygonStart:q,polygonEnd:q},No={point:be,lineStart:_e,lineEnd:we,polygonStart:function(){No.lineStart=Se},polygonEnd:function(){No.point=be,No.lineStart=_e,No.lineEnd=we}};ua.geo.path=function(){function n(n){return n&&ua.geo.stream(n,r(i.pointRadius("function"==typeof u?+u.apply(this,arguments):u))),i.result()}var t,e,r,i,u=4.5;return n.area=function(n){return xo=0,ua.geo.stream(n,r(ko)),xo},n.centroid=function(n){return lo=so=ho=go=0,ua.geo.stream(n,r(No)),go?[so/go,ho/go]:void 0},n.bounds=function(n){return So=Eo=-(_o=wo=1/0),ua.geo.stream(n,r(Ao)),[[_o,wo],[So,Eo]]},n.projection=function(e){return arguments.length?(r=(t=e)?e.stream||ke(e):ft,n):t},n.context=function(t){return arguments.length?(i=(e=t)==null?new Me:new Ee(t),n):e},n.pointRadius=function(t){return arguments.length?(u="function"==typeof t?t:+t,n):u},n.projection(ua.geo.albersUsa()).context(null)};var qo=Ae(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ua.geo.azimuthalEqualArea=function(){return Qt(qo)}).raw=qo;var To=Ae(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},ft);(ua.geo.azimuthalEquidistant=function(){return Qt(To)}).raw=To,(ua.geo.conicConformal=function(){return de(Ne)}).raw=Ne,(ua.geo.conicEquidistant=function(){return de(qe)}).raw=qe;var Co=Ae(function(n){return 1/n},Math.atan);(ua.geo.gnomonic=function(){return Qt(Co)}).raw=Co,Te.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Da/2]},(ua.geo.mercator=function(){return Ce(Te)}).raw=Te;var zo=Ae(function(){return 1},Math.asin);(ua.geo.orthographic=function(){return Qt(zo)}).raw=zo;var Do=Ae(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ua.geo.stereographic=function(){return Qt(Do)}).raw=Do,ze.invert=function(n,t){return[Math.atan2(U(n),Math.cos(t)),Y(Math.sin(t)/I(n))]},(ua.geo.transverseMercator=function(){return Ce(ze)}).raw=ze,ua.geom={},ua.svg={},ua.svg.line=function(){return De(ft)};var jo=ua.map({linear:Fe,"linear-closed":He,"step-before":Pe,"step-after":Re,basis:Xe,"basis-open":Ze,"basis-closed":Be,bundle:$e,cardinal:Ue,"cardinal-open":Oe,"cardinal-closed":Ye,monotone:nr});jo.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Lo=[0,2/3,1/3,0],Fo=[0,1/3,2/3,0],Ho=[0,1/6,2/3,1/6];ua.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i,u,a,o,c,l,f,s,h,g,p,d=lt(e),m=lt(r),v=n.length,y=v-1,M=[],x=[],b=0;if(d===je&&r===Le)t=n;else for(u=0,t=[];v>u;++u)t.push([+d.call(this,i=n[u],u),+m.call(this,i,u)]);for(u=1;v>u;++u)(t[u][1]u;++u)u!==b&&(c=t[u][1]-t[b][1],o=t[u][0]-t[b][0],M.push({angle:Math.atan2(c,o),index:u}));for(M.sort(function(n,t){return n.angle-t.angle}),g=M[0].angle,h=M[0].index,s=0,u=1;y>u;++u){if(a=M[u].index,g==M[u].angle){if(o=t[h][0]-t[b][0],c=t[h][1]-t[b][1],l=t[a][0]-t[b][0],f=t[a][1]-t[b][1],o*o+c*c>=l*l+f*f){M[u].index=-1;continue}M[s].index=-1}g=M[u].angle,s=u,h=a}for(x.push(b),u=0,a=0;2>u;++a)M[a].index>-1&&(x.push(M[a].index),u++);for(p=x.length;y>a;++a)if(!(M[a].index<0)){for(;!tr(x[p-2],x[p-1],M[a].index,t);)--p;x[p++]=M[a].index}var _=[];for(u=p-1;u>=0;--u)_.push(n[x[u]]);return _}var e=je,r=Le;return arguments.length?t(n):(t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t)},ua.geom.polygon=function(n){return n.area=function(){for(var t=0,e=n.length,r=n[e-1][1]*n[0][0]-n[e-1][0]*n[0][1];++to;o++)e.push([i,t[o],t[o+1]])}),e},ua.geom.voronoi=function(n){function t(n){var t,r,a,o=n.map(function(){return[]}),c=lt(i),l=lt(u),f=n.length,s=1e6;if(c===je&&l===Le)t=n;else for(t=[],a=0;f>a;++a)t.push([+c.call(this,r=n[a],a),+l.call(this,r,a)]);if(ir(t,function(n){var t,e,r,i,u,a;n.a===1&&n.b>=0?(t=n.ep.r,e=n.ep.l):(t=n.ep.l,e=n.ep.r),n.a===1?(u=t?t.y:-s,r=n.c-n.b*u,a=e?e.y:s,i=n.c-n.b*a):(r=t?t.x:-s,u=n.c-n.a*r,i=e?e.x:s,a=n.c-n.a*i);var c=[r,u],l=[i,a];o[n.region.l.index].push(c,l),o[n.region.r.index].push(c,l)}),o=o.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(n){return Math.atan2(n[0]-r,n[1]-i) +}),a=ua.range(n.length).sort(function(n,t){return u[n]-u[t]});return a.filter(function(n,t){return!t||u[n]-u[a[t-1]]>ja}).map(function(t){return n[t]})}),o.forEach(function(n,e){var r=n.length;if(!r)return n.push([-s,-s],[-s,s],[s,s],[s,-s]);if(!(r>2)){var i=t[e],u=n[0],a=n[1],o=i[0],c=i[1],l=u[0],f=u[1],h=a[0],g=a[1],p=Math.abs(h-l),d=g-f;if(Math.abs(d)c?-s:s;n.push([-s,m],[s,m])}else if(ja>p){var v=l>o?-s:s;n.push([v,-s],[v,s])}else{var m=(l-o)*(g-f)>(h-l)*(f-c)?s:-s,y=Math.abs(d)-p;Math.abs(y)d?m:-m,m]):(y>0&&(m*=-1),n.push([-s,m],[s,m]))}}}),e)for(a=0;f>a;++a)e(o[a]);for(a=0;f>a;++a)o[a].point=n[a];return o}var e,r=null,i=je,u=Le;return arguments.length?t(n):(t.x=function(n){return arguments.length?(i=n,t):i},t.y=function(n){return arguments.length?(u=n,t):u},t.size=function(n){return arguments.length?(null==n?e=null:(r=[+n[0],+n[1]],e=ua.geom.polygon([[0,0],[0,r[1]],r,[r[0],0]]).clip),t):r},t.links=function(n){var t,e,r,a=n.map(function(){return[]}),o=[],c=lt(i),l=lt(u),f=n.length;if(c===je&&l===Le)t=n;else for(r=0;f>r;++r)t.push([+c.call(this,e=n[r],r),+l.call(this,e,r)]);return ir(t,function(t){var e=t.region.l.index,r=t.region.r.index;a[e][r]||(a[e][r]=a[r][e]=!0,o.push({source:n[e],target:n[r]}))}),o},t.triangles=function(n){if(i===je&&u===Le)return ua.geom.delaunay(n);var t,e,r,a,o,c=lt(i),l=lt(u);for(a=0,t=[],o=n.length;o>a;++a)e=[+c.call(this,r=n[a],a),+l.call(this,r,a)],e.data=r,t.push(e);return ua.geom.delaunay(t).map(function(n){return n.map(function(n){return n.data})})},t)};var Po={l:"r",r:"l"};ua.geom.quadtree=function(n,t,e,r,i){function u(n){function u(n,t,e,r,i,u,a,o){if(!isNaN(e)&&!isNaN(r))if(n.leaf){var c=n.x,f=n.y;if(null!=c)if(Math.abs(c-e)+Math.abs(f-r)<.01)l(n,t,e,r,i,u,a,o);else{var s=n.point;n.x=n.y=n.point=null,l(n,s,c,f,i,u,a,o),l(n,t,e,r,i,u,a,o)}else n.x=e,n.y=r,n.point=t}else l(n,t,e,r,i,u,a,o)}function l(n,t,e,r,i,a,o,c){var l=.5*(i+o),f=.5*(a+c),s=e>=l,h=r>=f,g=(h<<1)+s;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=or()),s?i=l:o=l,h?a=f:c=f,u(n,t,e,r,i,a,o,c)}var f,s,h,g,p,d,m,v,y,M=lt(o),x=lt(c);if(null!=t)d=t,m=e,v=r,y=i;else if(v=y=-(d=m=1/0),s=[],h=[],p=n.length,a)for(g=0;p>g;++g)f=n[g],f.xv&&(v=f.x),f.y>y&&(y=f.y),s.push(f.x),h.push(f.y);else for(g=0;p>g;++g){var b=+M(f=n[g],g),_=+x(f,g);d>b&&(d=b),m>_&&(m=_),b>v&&(v=b),_>y&&(y=_),s.push(b),h.push(_)}var w=v-d,S=y-m;w>S?y=m+w:v=d+S;var E=or();if(E.add=function(n){u(E,n,+M(n,++g),+x(n,g),d,m,v,y)},E.visit=function(n){cr(n,E,d,m,v,y)},g=-1,null==t){for(;++g=0?n.substring(0,t):n,r=t>=0?n.substring(t+1):"in";return e=Uo.get(e)||Yo,r=Io.get(r)||ft,br(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},ua.interpolateHcl=jr,ua.interpolateHsl=Lr,ua.interpolateLab=Fr,ua.interpolateRound=Hr,ua.layout={},ua.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++e(i-e)*o){var c=t.charge*o*o;return n.px-=u*c,n.py-=a*c,!0}if(t.point&&isFinite(o)){var c=t.pointCharge*o*o;n.px-=u*c,n.py-=a*c}}return!t.charge}}function t(n){n.px=ua.event.x,n.py=ua.event.y,o.resume()}var e,r,i,u,a,o={},c=ua.dispatch("start","tick","end"),l=[1,1],f=.9,s=Vo,h=Xo,g=-30,p=.1,d=.8,m=[],v=[];return o.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,o,s,h,d,y,M,x,b=m.length,_=v.length;for(e=0;_>e;++e)o=v[e],s=o.source,h=o.target,M=h.x-s.x,x=h.y-s.y,(d=M*M+x*x)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,M*=d,x*=d,h.x-=M*(y=s.weight/(h.weight+s.weight)),h.y-=x*y,s.x+=M*(y=1-y),s.y+=x*y);if((y=r*p)&&(M=l[0]/2,x=l[1]/2,e=-1,y))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ua.timer(o.tick)),o):r},o.start=function(){function n(n,r){for(var i,u=t(e),a=-1,o=u.length;++ar;++r)c[r]=[];for(r=0;d>r;++r){var n=v[r];c[n.source.index].push(n.target),c[n.target.index].push(n.source)}}return c[e]}var e,r,c,f,p=m.length,d=v.length,y=l[0],M=l[1];for(e=0;p>e;++e)(f=m[e]).index=e,f.weight=0;for(e=0;d>e;++e)f=v[e],typeof f.source=="number"&&(f.source=m[f.source]),typeof f.target=="number"&&(f.target=m[f.target]),++f.source.weight,++f.target.weight;for(e=0;p>e;++e)f=m[e],isNaN(f.x)&&(f.x=n("x",y)),isNaN(f.y)&&(f.y=n("y",M)),isNaN(f.px)&&(f.px=f.x),isNaN(f.py)&&(f.py=f.y);if(i=[],"function"==typeof s)for(e=0;d>e;++e)i[e]=+s.call(this,v[e],e);else for(e=0;d>e;++e)i[e]=s;if(u=[],"function"==typeof h)for(e=0;d>e;++e)u[e]=+h.call(this,v[e],e);else for(e=0;d>e;++e)u[e]=h;if(a=[],"function"==typeof g)for(e=0;p>e;++e)a[e]=+g.call(this,m[e],e);else for(e=0;p>e;++e)a[e]=g;return o.resume()},o.resume=function(){return o.alpha(.1)},o.stop=function(){return o.alpha(0)},o.drag=function(){return e||(e=ua.behavior.drag().origin(ft).on("dragstart.force",Ir).on("drag.force",t).on("dragend.force",Vr)),arguments.length?(this.on("mouseover.force",Xr).on("mouseout.force",Zr).call(e),void 0):e},ua.rebind(o,c,"on")};var Vo=20,Xo=1;ua.layout.hierarchy=function(){function n(t,a,o){var c=i.call(e,t,a);if(t.depth=a,o.push(t),c&&(l=c.length)){for(var l,f,s=-1,h=t.children=[],g=0,p=a+1;++sg;++g)for(i.call(n,l[0][g],p=d[g],f[0][g][1]),h=1;m>h;++h)i.call(n,l[h][g],p+=f[h-1][g][1],f[h][g][1]);return o}var t=ft,e=ei,r=ri,i=ti,u=Qr,a=ni;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:Bo.get(t)||ei,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:$o.get(t)||ri,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(a=t,n):a},n.out=function(t){return arguments.length?(i=t,n):i},n};var Bo=ua.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(ii),u=n.map(ui),a=ua.range(r).sort(function(n,t){return i[n]-i[t]}),o=0,c=0,l=[],f=[];for(t=0;r>t;++t)e=a[t],c>o?(o+=u[e],l.push(e)):(c+=u[e],f.push(e));return f.reverse().concat(l)},reverse:function(n){return ua.range(n.length).reverse()},"default":ei}),$o=ua.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,a=[],o=0,c=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)c[e]=(o-a[e])/2;return c},wiggle:function(n){var t,e,r,i,u,a,o,c,l,f=n.length,s=n[0],h=s.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,o=s[e][0]-s[e-1][0];f>t;++t){for(r=0,a=(n[t][e][1]-n[t][e-1][1])/(2*o);t>r;++r)a+=(n[r][e][1]-n[r][e-1][1])/o;u+=a*n[t][e][1]}g[e]=c-=i?u/i*o:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,i=n.length,u=n[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:ri});ua.layout.histogram=function(){function n(n,u){for(var a,o,c=[],l=n.map(e,this),f=r.call(this,l,u),s=i.call(this,f,l,u),u=-1,h=l.length,g=s.length-1,p=t?1:1/h;++u0)for(u=-1;++u=f[0]&&o<=f[1]&&(a=c[ua.bisect(s,o,1,g)-1],a.y+=p,a.push(n[u]));return c}var t=!0,e=Number,r=li,i=oi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=lt(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return ci(n,t)}:lt(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ua.layout.tree=function(){function n(n,i){function u(n,t){var r=n.children,i=n._tree;if(r&&(a=r.length)){for(var a,c,l,f=r[0],s=f,h=-1;++h0&&(Mi(xi(o,n,r),n,i),l+=i,f+=i),s+=o._tree.mod,l+=u._tree.mod,h+=c._tree.mod,f+=a._tree.mod;o&&!hi(a)&&(a._tree.thread=o,a._tree.mod+=s-f),u&&!si(c)&&(c._tree.thread=u,c._tree.mod+=l-h,r=n)}return r}var c=t.call(this,n,i),l=c[0];vi(l,function(n,t){n._tree={ancestor:n,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),u(l),a(l,-l._tree.prelim);var f=gi(l,di),s=gi(l,pi),h=gi(l,mi),g=f.x-e(f,s)/2,p=s.x+e(s,f)/2,d=h.depth||1;return vi(l,function(n){n.x=(n.x-g)/(p-g)*r[0],n.y=n.depth/d*r[1],delete n._tree}),c}var t=ua.layout.hierarchy().sort(null).value(null),e=fi,r=[1,1];return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(r=t,n):r},$r(n,t)},ua.layout.pack=function(){function n(n,i){var u=t.call(this,n,i),a=u[0];a.x=0,a.y=0,vi(a,function(n){n.r=Math.sqrt(n.value)}),vi(a,Ei);var o=r[0],c=r[1],l=Math.max(2*a.r/o,2*a.r/c);if(e>0){var f=e*l/2;vi(a,function(n){n.r+=f}),vi(a,Ei),vi(a,function(n){n.r-=f}),l=Math.max(2*a.r/o,2*a.r/c)}return Ni(a,o/2,c/2,1/l),u}var t=ua.layout.hierarchy().sort(bi),e=0,r=[1,1];return n.size=function(t){return arguments.length?(r=t,n):r},n.padding=function(t){return arguments.length?(e=+t,n):e},$r(n,t)},ua.layout.cluster=function(){function n(n,i){var u,a=t.call(this,n,i),o=a[0],c=0;vi(o,function(n){var t=n.children;t&&t.length?(n.x=Ci(t),n.y=Ti(t)):(n.x=u?c+=e(n,u):0,n.y=0,u=n)});var l=zi(o),f=Di(o),s=l.x-e(l,f)/2,h=f.x+e(f,l)/2;return vi(o,function(n){n.x=(n.x-s)/(h-s)*r[0],n.y=(1-(o.y?n.y/o.y:1))*r[1]}),a}var t=ua.layout.hierarchy().sort(null).value(null),e=fi,r=[1,1];return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(r=t,n):r},$r(n,t)},ua.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var a,o,c,l=s(e),f=[],h=u.slice(),p=1/0,d="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?e.depth&1?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),f.area=0;(c=h.length)>0;)f.push(a=h[c-1]),f.area+=a.area,"squarify"!==g||(o=r(f,d))<=p?(h.pop(),p=o):(f.area-=f.pop().area,i(f,d,l,!1),d=Math.min(l.dx,l.dy),f.length=f.area=0,p=1/0);f.length&&(i(f,d,l,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,a=s(t),o=r.slice(),c=[];for(n(o,a.dx*a.dy/t.value),c.area=0;u=o.pop();)c.push(u),c.area+=u.area,u.z!=null&&(i(c,u.z?a.dx:a.dy,a,!o.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,a=-1,o=n.length;++ae&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*p/r,r/(t*u*p)):1/0}function i(n,t,e,r){var i,u=-1,a=n.length,o=e.x,l=e.y,f=t?c(n.area/t):0;if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=Math.random()*2-1,r=Math.random()*2-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=ua.random.normal.apply(ua,arguments);return function(){return Math.exp(n())}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t/n}}},ua.scale={},ua.scale.linear=function(){return Yi([0,1],[0,1],yr,!1)},ua.scale.log=function(){return Bi(ua.scale.linear().domain([0,Math.LN10]),10,$i,Ji,[1,10])};var Jo=ua.format(".0e");ua.scale.pow=function(){return Wi(ua.scale.linear(),1,[0,1])},ua.scale.sqrt=function(){return ua.scale.pow().exponent(.5)},ua.scale.ordinal=function(){return nu([],{t:"range",a:[[]]})},ua.scale.category10=function(){return ua.scale.ordinal().range(Go)},ua.scale.category20=function(){return ua.scale.ordinal().range(Ko)},ua.scale.category20b=function(){return ua.scale.ordinal().range(Wo)},ua.scale.category20c=function(){return ua.scale.ordinal().range(Qo)};var Go=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ko=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],Wo=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Qo=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];ua.scale.quantile=function(){return tu([],[])},ua.scale.quantize=function(){return eu(0,1,[0,1])},ua.scale.threshold=function(){return ru([.5],[0,1])},ua.scale.identity=function(){return iu([0,1])},ua.svg.arc=function(){function n(){var n=t.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+nc,o=i.apply(this,arguments)+nc,c=(a>o&&(c=a,a=o,o=c),o-a),l=Da>c?"0":"1",f=Math.cos(a),s=Math.sin(a),h=Math.cos(o),g=Math.sin(o);return c>=tc?n?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":n?"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+l+",0 "+n*f+","+n*s+"Z":"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L0,0"+"Z"}var t=uu,e=au,r=ou,i=cu;return n.innerRadius=function(e){return arguments.length?(t=lt(e),n):t},n.outerRadius=function(t){return arguments.length?(e=lt(t),n):e},n.startAngle=function(t){return arguments.length?(r=lt(t),n):r},n.endAngle=function(t){return arguments.length?(i=lt(t),n):i},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+nc;return[Math.cos(u)*n,Math.sin(u)*n]},n};var nc=-Da/2,tc=2*Da-1e-6;ua.svg.line.radial=function(){var n=De(lu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},Pe.reverse=Re,Re.reverse=Pe,ua.svg.area=function(){return fu(ft)},ua.svg.area.radial=function(){var n=fu(lu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ua.svg.chord=function(){function n(n,o){var c=t(this,u,n,o),l=t(this,a,n,o);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?i(c.r,c.p1,c.r,c.p0):i(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+i(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=o.call(n,i,r),a=c.call(n,i,r)+nc,f=l.call(n,i,r)+nc;return{r:u,a0:a,a1:f,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Da)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=se,a=he,o=su,c=ou,l=cu;return n.radius=function(t){return arguments.length?(o=lt(t),n):o},n.source=function(t){return arguments.length?(u=lt(t),n):u},n.target=function(t){return arguments.length?(a=lt(t),n):a},n.startAngle=function(t){return arguments.length?(c=lt(t),n):c},n.endAngle=function(t){return arguments.length?(l=lt(t),n):l},n},ua.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),a=e.call(this,n,i),o=(u.y+a.y)/2,c=[u,{x:u.x,y:o},{x:a.x,y:o},a];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=se,e=he,r=hu;return n.source=function(e){return arguments.length?(t=lt(e),n):t},n.target=function(t){return arguments.length?(e=lt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ua.svg.diagonal.radial=function(){var n=ua.svg.diagonal(),t=hu,e=n.projection;return n.projection=function(n){return arguments.length?e(gu(t=n)):t},n},ua.svg.symbol=function(){function n(n,r){return(ec.get(t.call(this,n,r))||mu)(e.call(this,n,r))}var t=du,e=pu;return n.type=function(e){return arguments.length?(t=lt(e),n):t},n.size=function(t){return arguments.length?(e=lt(t),n):e},n};var ec=ua.map({circle:mu,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*uc)),e=t*uc;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/ic),e=t*ic/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/ic),e=t*ic/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ua.svg.symbolTypes=ec.keys();var rc,ic=Math.sqrt(3),uc=Math.tan(30*La),ac=[],oc=0,cc={ease:kr,delay:0,duration:250};ac.call=wa.call,ac.empty=wa.empty,ac.node=wa.node,ua.transition=function(n){return arguments.length?rc?n.transition():n:Na.transition()},ua.transition.prototype=ac,ac.select=function(n){var t,e,r,i=this.id,u=[];"function"!=typeof n&&(n=v(n));for(var a=-1,o=this.length;++au;u++){i.push(t=[]);for(var e=this[u],o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return vu(i,this.id,this.time).ease(this.ease())},ac.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):D(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},ac.attr=function(n,t){function e(){this.removeAttribute(o)}function r(){this.removeAttributeNS(o.space,o.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(o);return e!==n&&(t=a(e,n),function(n){this.setAttribute(o,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(o.space,o.local);return e!==n&&(t=a(e,n),function(n){this.setAttributeNS(o.space,o.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var a=Mr(n),o=ua.ns.qualify(n);return yu(this,"attr."+n,t,o.local?u:i)},ac.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=ua.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},ac.style=function(n,t,e){function r(){this.style.removeProperty(n)}function i(t){return null==t?r:(t+="",function(){var r,i=oa.getComputedStyle(this,null).getPropertyValue(n);return i!==t&&(r=a(i,t),function(t){this.style.setProperty(n,r(t),e)})})}var u=arguments.length;if(3>u){if("string"!=typeof n){2>u&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}var a=Mr(n);return yu(this,"style."+n,t,i)},ac.styleTween=function(n,t,e){function r(r,i){var u=t.call(this,r,i,oa.getComputedStyle(this,null).getPropertyValue(n));return u&&function(t){this.style.setProperty(n,u(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},ac.text=function(n){return yu(this,"text",n,Mu)},ac.remove=function(){return this.each("end.transition",function(){var n;!this.__transition__&&(n=this.parentNode)&&n.removeChild(this)})},ac.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=ua.ease.apply(ua,arguments)),D(this,function(e){e.__transition__[t].ease=n}))},ac.delay=function(n){var t=this.id;return D(this,"function"==typeof n?function(e,r,i){e.__transition__[t].delay=n.call(e,e.__data__,r,i)|0}:(n|=0,function(e){e.__transition__[t].delay=n}))},ac.duration=function(n){var t=this.id;return D(this,"function"==typeof n?function(e,r,i){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,i)|0)}:(n=Math.max(1,0|n),function(e){e.__transition__[t].duration=n}))},ac.each=function(n,t){var e=this.id;if(arguments.length<2){var r=cc,i=rc;rc=e,D(this,function(t,r,i){cc=t.__transition__[e],n.call(t,t.__data__,r,i)}),cc=r,rc=i}else D(this,function(r){r.__transition__[e].event.on(n,t)});return this},ac.transition=function(){for(var n,t,e,r,i=this.id,u=++oc,a=[],o=0,c=this.length;c>o;o++){a.push(n=[]);for(var t=this[o],l=0,f=t.length;f>l;l++)(e=t[l])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,xu(e,l,u,r)),n.push(e)}return vu(a,u)},ua.svg.axis=function(){function n(n){n.each(function(){var n,s=ua.select(this),h=null==l?e.ticks?e.ticks.apply(e,c):e.domain():l,g=null==t?e.tickFormat?e.tickFormat.apply(e,c):String:t,p=wu(e,h,f),d=s.selectAll(".tick.minor").data(p,String),m=d.enter().insert("line",".tick").attr("class","tick minor").style("opacity",1e-6),v=ua.transition(d.exit()).style("opacity",1e-6).remove(),y=ua.transition(d).style("opacity",1),M=s.selectAll(".tick.major").data(h,String),x=M.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),b=ua.transition(M.exit()).style("opacity",1e-6).remove(),_=ua.transition(M).style("opacity",1),w=Hi(e),S=s.selectAll(".domain").data([0]),E=(S.enter().append("path").attr("class","domain"),ua.transition(S)),k=e.copy(),A=this.__chart__||k;this.__chart__=k,x.append("line"),x.append("text");var N=x.select("line"),q=_.select("line"),T=M.select("text").text(g),C=x.select("text"),z=_.select("text");switch(r){case"bottom":n=bu,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),C.attr("y",Math.max(i,0)+o),q.attr("x2",0).attr("y2",i),z.attr("x",0).attr("y",Math.max(i,0)+o),T.attr("dy",".71em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+a+"V0H"+w[1]+"V"+a);break;case"top":n=bu,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),C.attr("y",-(Math.max(i,0)+o)),q.attr("x2",0).attr("y2",-i),z.attr("x",0).attr("y",-(Math.max(i,0)+o)),T.attr("dy","0em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+-a+"V0H"+w[1]+"V"+-a);break;case"left":n=_u,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),C.attr("x",-(Math.max(i,0)+o)),q.attr("x2",-i).attr("y2",0),z.attr("x",-(Math.max(i,0)+o)).attr("y",0),T.attr("dy",".32em").style("text-anchor","end"),E.attr("d","M"+-a+","+w[0]+"H0V"+w[1]+"H"+-a);break;case"right":n=_u,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),C.attr("x",Math.max(i,0)+o),q.attr("x2",i).attr("y2",0),z.attr("x",Math.max(i,0)+o).attr("y",0),T.attr("dy",".32em").style("text-anchor","start"),E.attr("d","M"+a+","+w[0]+"H0V"+w[1]+"H"+a)}if(e.ticks)x.call(n,A),_.call(n,k),b.call(n,k),m.call(n,A),y.call(n,k),v.call(n,k);else{var D=k.rangeBand()/2,j=function(n){return k(n)+D};x.call(n,j),_.call(n,j)}})}var t,e=ua.scale.linear(),r=lc,i=6,u=6,a=6,o=3,c=[10],l=null,f=0;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in fc?t+"":lc,n):r},n.ticks=function(){return arguments.length?(c=arguments,n):c},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+t,u=r>1?+e:i,a=r>0?+arguments[r]:i,n},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(t){return arguments.length?(f=+t,n):f},n};var lc="bottom",fc={top:1,right:1,bottom:1,left:1};ua.svg.brush=function(){function n(u){u.each(function(){var u,a=ua.select(this),l=a.selectAll(".background").data([0]),s=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(f,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),l.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),s.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return sc[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",n.empty()?"none":null),h.exit().remove(),o&&(u=Hi(o),l.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),c&&(u=Hi(c),l.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),t(a)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)][0]+","+s[+/^s/.test(n)][1]+")"})}function e(n){n.select(".extent").attr("x",s[0][0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1][0]-s[0][0])}function r(n){n.select(".extent").attr("y",s[0][1]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1][1]-s[0][1])}function i(){function i(){var n=ua.event.changedTouches; +return n?ua.touches(y,n)[0]:ua.mouse(y)}function f(){ua.event.keyCode==32&&(E||(m=null,k[0]-=s[1][0],k[1]-=s[1][1],E=2),l())}function h(){ua.event.keyCode==32&&2==E&&(k[0]+=s[1][0],k[1]+=s[1][1],E=0,l())}function g(){var n=i(),u=!1;v&&(n[0]+=v[0],n[1]+=v[1]),E||(ua.event.altKey?(m||(m=[(s[0][0]+s[1][0])/2,(s[0][1]+s[1][1])/2]),k[0]=s[+(n[0]l?(i=r,r=l):i=l),s[0][e]!==r||s[1][e]!==i?(u=null,s[0][e]=r,s[1][e]=i,!0):void 0}function d(){g(),b.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ua.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),x({type:"brushend"}),l()}var m,v,y=this,M=ua.select(ua.event.target),x=a.of(y,arguments),b=ua.select(y),_=M.datum(),w=!/^(n|s)$/.test(_)&&o,S=!/^(e|w)$/.test(_)&&c,E=M.classed("extent"),k=i(),A=ua.select(oa).on("mousemove.brush",g).on("mouseup.brush",d).on("touchmove.brush",g).on("touchend.brush",d).on("keydown.brush",f).on("keyup.brush",h);if(E)k[0]=s[0][0]-k[0],k[1]=s[0][1]-k[1];else if(_){var N=+/w$/.test(_),q=+/^n/.test(_);v=[s[1-N][0]-k[0],s[1-q][1]-k[1]],k[0]=s[N][0],k[1]=s[q][1]}else ua.event.altKey&&(m=k.slice());b.style("pointer-events","none").selectAll(".resize").style("display",null),ua.select("body").style("cursor",M.style("cursor")),x({type:"brushstart"}),g(),l()}var u,a=h(n,"brushstart","brush","brushend"),o=null,c=null,f=hc[0],s=[[0,0],[0,0]];return n.x=function(t){return arguments.length?(o=t,f=hc[!o<<1|!c],n):o},n.y=function(t){return arguments.length?(c=t,f=hc[!o<<1|!c],n):c},n.extent=function(t){var e,r,i,a,l;return arguments.length?(u=[[0,0],[0,0]],o&&(e=t[0],r=t[1],c&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(l=e,e=r,r=l),s[0][0]=0|e,s[1][0]=0|r),c&&(i=t[0],a=t[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),s[0][1]=0|i,s[1][1]=0|a),n):(t=u||s,o&&(e=t[0][0],r=t[1][0],u||(e=s[0][0],r=s[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(l=e,e=r,r=l))),c&&(i=t[0][1],a=t[1][1],u||(i=s[0][1],a=s[1][1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),o&&c?[[e,i],[r,a]]:o?[e,r]:c&&[i,a])},n.clear=function(){return u=null,s[0][0]=s[0][1]=s[1][0]=s[1][1]=0,n},n.empty=function(){return o&&s[0][0]===s[1][0]||c&&s[0][1]===s[1][1]},ua.rebind(n,a,"on")};var sc={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},hc=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];ua.time={};var gc=Date,pc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Su.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){dc.setUTCDate.apply(this._,arguments)},setDay:function(){dc.setUTCDay.apply(this._,arguments)},setFullYear:function(){dc.setUTCFullYear.apply(this._,arguments)},setHours:function(){dc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){dc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){dc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){dc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){dc.setUTCSeconds.apply(this._,arguments)},setTime:function(){dc.setTime.apply(this._,arguments)}};var dc=Date.prototype,mc="%a %b %e %X %Y",vc="%m/%d/%Y",yc="%H:%M:%S",Mc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],xc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],bc=["January","February","March","April","May","June","July","August","September","October","November","December"],_c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];ua.time.year=Eu(function(n){return n=ua.time.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ua.time.years=ua.time.year.range,ua.time.years.utc=ua.time.year.utc.range,ua.time.day=Eu(function(n){var t=new gc(1970,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ua.time.days=ua.time.day.range,ua.time.days.utc=ua.time.day.utc.range,ua.time.dayOfYear=function(n){var t=ua.time.year(n);return Math.floor((n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},pc.forEach(function(n,t){n=n.toLowerCase(),t=7-t;var e=ua.time[n]=Eu(function(n){return(n=ua.time.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+Math.floor(t)*7)},function(n){var e=ua.time.year(n).getDay();return Math.floor((ua.time.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ua.time[n+"s"]=e.range,ua.time[n+"s"].utc=e.utc.range,ua.time[n+"OfYear"]=function(n){var e=ua.time.year(n).getDay();return Math.floor((ua.time.dayOfYear(n)+(e+t)%7)/7)}}),ua.time.week=ua.time.sunday,ua.time.weeks=ua.time.sunday.range,ua.time.weeks.utc=ua.time.sunday.utc.range,ua.time.weekOfYear=ua.time.sundayOfYear,ua.time.format=function(n){function t(t){for(var r,i,u,a=[],o=-1,c=0;++o=12?"PM":"AM"},S:function(n,t){return Tu(n.getSeconds(),t,2)},U:function(n,t){return Tu(ua.time.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Tu(ua.time.mondayOfYear(n),t,2)},x:ua.time.format(vc),X:ua.time.format(yc),y:function(n,t){return Tu(n.getFullYear()%100,t,2)},Y:function(n,t){return Tu(n.getFullYear()%1e4,t,4)},Z:$u,"%":function(){return"%"}},Cc={a:Cu,A:zu,b:Du,B:ju,c:Lu,d:Uu,e:Uu,H:Iu,I:Iu,L:Zu,m:Yu,M:Vu,p:Bu,S:Xu,x:Fu,X:Hu,y:Ru,Y:Pu},zc=/^\s*\d+/,Dc=ua.map({am:0,pm:1});ua.time.format.utc=function(n){function t(n){try{gc=Su;var t=new gc;return t._=n,e(t)}finally{gc=Date}}var e=ua.time.format(n);return t.parse=function(n){try{gc=Su;var t=e.parse(n);return t&&t._}finally{gc=Date}},t.toString=e.toString,t};var jc=ua.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");ua.time.format.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ju:jc,Ju.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Ju.toString=jc.toString,ua.time.second=Eu(function(n){return new gc(Math.floor(n/1e3)*1e3)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*1e3)},function(n){return n.getSeconds()}),ua.time.seconds=ua.time.second.range,ua.time.seconds.utc=ua.time.second.utc.range,ua.time.minute=Eu(function(n){return new gc(Math.floor(n/6e4)*6e4)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*6e4)},function(n){return n.getMinutes()}),ua.time.minutes=ua.time.minute.range,ua.time.minutes.utc=ua.time.minute.utc.range,ua.time.hour=Eu(function(n){var t=n.getTimezoneOffset()/60;return new gc((Math.floor(n/36e5-t)+t)*36e5)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*36e5)},function(n){return n.getHours()}),ua.time.hours=ua.time.hour.range,ua.time.hours.utc=ua.time.hour.utc.range,ua.time.month=Eu(function(n){return n=ua.time.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ua.time.months=ua.time.month.range,ua.time.months.utc=ua.time.month.utc.range;var Lc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Fc=[[ua.time.second,1],[ua.time.second,5],[ua.time.second,15],[ua.time.second,30],[ua.time.minute,1],[ua.time.minute,5],[ua.time.minute,15],[ua.time.minute,30],[ua.time.hour,1],[ua.time.hour,3],[ua.time.hour,6],[ua.time.hour,12],[ua.time.day,1],[ua.time.day,2],[ua.time.week,1],[ua.time.month,1],[ua.time.month,3],[ua.time.year,1]],Hc=[[ua.time.format("%Y"),Ht],[ua.time.format("%B"),function(n){return n.getMonth()}],[ua.time.format("%b %d"),function(n){return n.getDate()!=1}],[ua.time.format("%a %d"),function(n){return n.getDay()&&n.getDate()!=1}],[ua.time.format("%I %p"),function(n){return n.getHours()}],[ua.time.format("%I:%M"),function(n){return n.getMinutes()}],[ua.time.format(":%S"),function(n){return n.getSeconds()}],[ua.time.format(".%L"),function(n){return n.getMilliseconds()}]],Pc=ua.scale.linear(),Rc=Wu(Hc);Fc.year=function(n,t){return Pc.domain(n.map(na)).ticks(t).map(Qu)},ua.time.scale=function(){return Gu(ua.scale.linear(),Fc,Rc)};var Oc=Fc.map(function(n){return[n[0].utc,n[1]]}),Yc=[[ua.time.format.utc("%Y"),Ht],[ua.time.format.utc("%B"),function(n){return n.getUTCMonth()}],[ua.time.format.utc("%b %d"),function(n){return n.getUTCDate()!=1}],[ua.time.format.utc("%a %d"),function(n){return n.getUTCDay()&&n.getUTCDate()!=1}],[ua.time.format.utc("%I %p"),function(n){return n.getUTCHours()}],[ua.time.format.utc("%I:%M"),function(n){return n.getUTCMinutes()}],[ua.time.format.utc(":%S"),function(n){return n.getUTCSeconds()}],[ua.time.format.utc(".%L"),function(n){return n.getUTCMilliseconds()}]],Uc=Wu(Yc);return Oc.year=function(n,t){return Pc.domain(n.map(ea)).ticks(t).map(ta)},ua.time.scale.utc=function(){return Gu(ua.scale.linear(),Oc,Uc)},ua.text=st(function(n){return n.responseText}),ua.json=function(n,t){return ht(n,"application/json",ra,t)},ua.html=function(n,t){return ht(n,"text/html",ia,t)},ua.xml=st(function(n){return n.responseXML}),ua}(); +/*! Tiny Pub/Sub - v0.7.0 - 2013-01-29 +* https://github.com/cowboy/jquery-tiny-pubsub +* Copyright (c) 2013 "Cowboy" Ben Alman; Licensed MIT */ +(function(n){var u=n({});n.subscribe=function(){u.on.apply(u,arguments)},n.unsubscribe=function(){u.off.apply(u,arguments)},n.publish=function(){u.trigger.apply(u,arguments)}})(jQuery); +/*! URI.js v1.13.2 http://medialize.github.io/URI.js/ */ +/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ +(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.IPv6=n(f)})(this,function(f){var n=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var h=g.length,d=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[h-1]&&""===g[h-2]&&g.pop();h=g.length;-1!==g[h-1].indexOf(".")&&(d=7);var m;for(m=0;mf;f++)if("0"===h[0]&&1f&&(h=k,f=n)):"0"===g[m]&&(u=!0,k=m,n=1);n>f&&(h=k,f=n);1=l&&c>>10&1023|55296),a=56320|a&1023);return b+=D(a)}).join("")}function w(a, +b){return a+22+75*(26>a)-((0!=b)<<5)}function r(a,b,c){var d=0;a=c?z(a/H):a>>1;for(a+=z(a/b);a>v*t>>1;d+=p)a=z(a/v);return z(d+(v+1)*a/(a+x))}function k(b){var c=[],d=b.length,l,e=0,B=E,k=F,g,v,f,h,u;g=b.lastIndexOf(a);0>g&&(g=0);for(v=0;v=d&&n("invalid-input");h=b.charCodeAt(g++);h=10>h-48?h-22:26>h-65?h-65:26>h-97?h-97:p;(h>=p||h>z((q-e)/l))&&n("overflow");e+=h*l;u=f<=k?s:f>=k+t?t: +f-k;if(hz(q/h)&&n("overflow");l*=h}l=c.length+1;k=r(e-v,l,0==v);z(e/l)>q-B&&n("overflow");B+=z(e/l);e%=l;c.splice(e++,0,B)}return m(c)}function u(b){var c,l,e,B,g,k,v,h,f,u=[],m,y,A;b=d(b);m=b.length;c=E;l=0;g=F;for(k=0;kf&&u.push(D(f));for((e=B=u.length)&&u.push(a);e=c&&fz((q-l)/y)&&n("overflow");l+=(v-c)*y;c=v;for(k=0;kq&&n("overflow"),f==c){h=l;for(v=p;;v+=p){f=v<=g?s:v>=g+t?t:v-g; +if(h= 0x80 (not a basic code point)", +"invalid-input":"Invalid input"},v=p-s,z=Math.floor,D=String.fromCharCode,G;e={version:"1.2.3",ucs2:{decode:d,encode:m},decode:k,encode:u,toASCII:function(a){return h(a,function(a){return c.test(a)?"xn--"+u(a):a})},toUnicode:function(a){return h(a,function(a){return b.test(a)?k(a.slice(4).toLowerCase()):a})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return e});else if(y&&!y.nodeType)if(A)A.exports=e;else for(G in e)e.hasOwnProperty(G)&&(y[G]=e[G]);else f.punycode= +e})(this); +(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.SecondLevelDomains=n(f)})(this,function(f){var n=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", +bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", +cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", +et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ", +ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ", +kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ", +mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ", +pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ", +sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ", +na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", +rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", +tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", +us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(h){var d=h.lastIndexOf(".");if(0>=d||d>=h.length-1)return!1; +var f=h.lastIndexOf(".",d-1);if(0>=f||f>=d-1)return!1;var n=g.list[h.slice(d+1)];return n?0<=n.indexOf(" "+h.slice(f+1,d)+" "):!1},is:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1||0<=f.lastIndexOf(".",d-1))return!1;var m=g.list[f.slice(d+1)];return m?0<=m.indexOf(" "+f.slice(0,d)+" "):!1},get:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1)return null;var m=f.lastIndexOf(".",d-1);if(0>=m||m>=d-1)return null;var n=g.list[f.slice(d+1)];return!n||0>n.indexOf(" "+f.slice(m+ +1,d)+" ")?null:f.slice(m+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=n);return this}};return g}); +(function(f,n){"object"===typeof exports?module.exports=n(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],n):f.URI=n(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,n,g,h){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function m(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, +"\\$1")}function w(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function r(a){return"Array"===w(a)}function k(a,b){var c,d;if(r(b)){c=0;for(d=b.length;c]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters= +/[^a-zA-Z0-9\.-]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:d.domAttributes[b]}};d.encode=A;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=A;d.decode=decodeURIComponent};d.characters= +{pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}};d.encodeQuery= +function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;bd)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var l=c.start||d.findUri.start,e=c.end||d.findUri.end,f=c.trim||d.findUri.trim,k=/[a-z0-9-]=["']?$/i;for(l.lastIndex=0;;){var g=l.exec(a);if(!g)break;g=g.index;if(c.ignoreHtml){var h= +a.slice(Math.max(g-3,0),g);if(h&&k.test(h))continue}var h=g+a.slice(g).search(e),u=a.slice(g,h).replace(f,"");c.ignore&&c.ignore.test(u)||(h=g+u.length,u=b(u,g,h,a),a=a.slice(0,g)+u+a.slice(h),l.lastIndex=g+u.length)}l.lastIndex=0;return a};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+ +a+'" contains characters other than [A-Z0-9.-]');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),a;h.URI===this&&(h.URI=C);return this};e.build=function(a){if(!0===a)this._deferred_build= +!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new d(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};p={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};t=function(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}};for(s in p)e[s]=t(p[s]);p={query:"?",fragment:"#"};t=function(a, +b){return function(c,d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}};for(s in p)e[s]=t(s,p[s]);p={search:["?","query"],hash:["#","fragment"]};t=function(a,b){return function(c,d){var e=this[a](c,d);return"string"===typeof e&&e.length?b+e:e}};for(s in p)e[s]=t(p[s][1],p[s][0]);e.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}this._parts.path= +a?d.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var l=a instanceof d,e="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(e=d.getDomAttribute(a),a=a[e]||"",e=!1);!l&&e&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(l||e)for(c in l=l?a._parts:a,l)q.call(this._parts,c)&&(this._parts[c]=l[c]);else throw new TypeError("invalid input"); +this.build(!b);return this};e.is=function(a){var b=!1,c=!1,e=!1,f=!1,k=!1,h=!1,u=!1,p=!this._parts.urn;this._parts.hostname&&(p=!1,c=d.ip4_expression.test(this._parts.hostname),e=d.ip6_expression.test(this._parts.hostname),b=c||e,k=(f=!b)&&g&&g.has(this._parts.hostname),h=f&&d.idn_expression.test(this._parts.hostname),u=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return p;case "absolute":return!p;case "domain":case "name":return f;case "sld":return k; +case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return e;case "idn":return h;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return u}return null};var x=e.protocol,H=e.port,F=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return x.call(this, +a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return H.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};d.parseHost(a,c);a=c.hostname}return F.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this; +if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=d.buildUserinfo(this._parts);return c.substring(0, +c.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){var c;if(void 0===a)return this.path()+this.search()+this.hash();c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length- +1;return this._parts.hostname.substring(0,c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=RegExp("^"+m(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g); +if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=RegExp(m(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"": +this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf("."),c=this._parts.hostname.substring(c+1);return!0!==b&&g&&g.list[c.toLowerCase()]?g.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&g.is(a))c=RegExp(m(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname|| +this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=RegExp(m(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0, +c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=RegExp("^"+m(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; +var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var e=RegExp(m(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);c?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),e=c.lastIndexOf("."); +if(-1===e)return"";c=c.substring(e+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())e=a?RegExp(m(c)+"$"):RegExp(m("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}e&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!b);return this};e.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(d);void 0!==a&&"number"!==typeof a&& +(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(r(b)){e=[];a=0;for(var k=b.length;ag||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[d]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:c,modifiers:f,action:e}}function F(a,b,d,c,e){q[a+":"+d]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,d){a=a instanceof Array?a:[a];for(var c=0;c 0) { + group.push(child = remaining[n - 1]); + remaining.pop(); + } + + position(group, node.type, rect); + children.forEach(function(child, index) { + child.address = node.address.concat("." + child.type + (index + 1)); + }) + children.forEach(calculateLayout); + } + } + + // Positions the specified row of nodes. Modifies `rect`. + function position(group, groupType, rect) { + // console.log('%c\n'+' parent ' + groupType + ' rect is: ', 'background: #222; color: #EFEFEF; font-family: helvetica neue; font-size:20px; padding: 0 7px 3px 0;'); + // console.log(rect); + var i = -1, + row = (groupType === "row") ? false : true, // for ternary statements later, specifies whether that particular child is a row or not. Allows easy, centralised description of the parameter calculations that can be switched from row to column. + n = group.length, + x = rect.x, + y = rect.y, + o; + var offset = 0; + while (++i < n) { + o = group[n-(i+1)], + d = divisor(o, row, rect, group, n), + o.id = typeof o.id !== 'undefined' ? o.id : genUuid(), + o.x = row ? x : x + offset, + o.y = row ? y + offset : y, + o.dx = row ? rect.dx : rect.dx/d, + o.dy = row ? rect.dy/d : rect.dy, + offset += row ? o.dy : o.dx; + // console.log({x:o.x, y: o.y, width:o.dx, height: o.dy}); + } + } + + function divisor(node, row, rect, group, n) { + + var old = false, + dimension = row ? 'dy' : 'dx', + total = rect[dimension], + divisor; + // if not already set, divide equally. + group.forEach(function(item) { + if (!item[dimension] === undefined) { + old = true; + } + }); + + if (old) { + console.log('preserved'); + var sum = group.reduce( + function(previousValue, currentValue, index, array) { + return previousValue[dimension] + currentValue[dimension]; + }); + console.log('sum: ' + sum); + + divisor = (node[dimension]/sum)*total; + console.log("divisor: "+divisor); + return divisor; + } else { + return n; + } + } + + function isfahan(configObject) { + var nodes = hierarchy(configObject.layoutDescription), + root = nodes[0]; + size = (function(containerSelector) { + var width = jQuery(containerSelector).width(); + var height = jQuery(containerSelector).height(); + + return [width, height]; + })(configObject.containerSelector); + root.x = 0; + root.y = 0; + root.dx = containerSize(containerId)[0]; + root.dy = containerSize(containerId)[1]; + root.address = root.type + "1"; + root.id = root.id || genUuid(); + + calculateLayout(root); + isfahan.padding(padding); + nodes = nodes.map(function(node) { + return merge(node, pad(node)); + }); + + return nodes; + } + + isfahan.size = function(x) { + if (!arguments.length) return containerSize; + containerSize = x; + return isfahan; + }; + + isfahan.round = function(x) { + if (!arguments.length) return round != Number; + round = x ? Math.round : Number; + return isfahan; + }; + + isfahan.padding = function(x) { + if (!arguments.length) return padding; + + function padFunction(node) { + var p = x.call(isfahan, node, node.depth); + console.log(p); + return p == null + ? d3_layout_cellPadNull(node) + : d3_layout_cellPad(node, typeof p === "number" ? [p, p, p, p] : p); + } + + function padConstant(node) { + return d3_layout_cellPad(node, x); + } + + var type; + pad = (padding = x) == null ? d3_layout_cellPadNull + : (type = typeof x) === "function" ? padFunction + : type === "number" ? (x = [x, x, x, x], padConstant) + : padConstant; + return isfahan; + }; + + function genUuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + } + + function d3_layout_cellPadNull(node) { + return {x: node.x, y: node.y, dx: node.dx, dy: node.dy}; + } + + function d3_layout_cellPad(node, padding) { + var x = node.x + padding[3], + y = node.y + padding[0], + dx = node.dx - padding[1] - padding[3], + dy = node.dy - padding[0] - padding[2]; + if (dx < 0) { x += dx / 2; dx = 0; } + if (dy < 0) { y += dy / 2; dy = 0; } + return {x: x, y: y, dx: dx, dy: dy}; + } + + function merge(target, source) { + + /* Merges two (or more) objects, + giving the last one precedence */ + + if ( typeof target !== 'object' ) { + target = {}; + } + + for (var property in source) { + + if ( source.hasOwnProperty(property) ) { + + var sourceProperty = source[ property ]; + + if ( typeof sourceProperty === 'object' ) { + target[ property ] = util.merge( target[ property ], sourceProperty ); + continue; + } + + target[ property ] = sourceProperty; + + } + + } + + for (var a = 2, l = arguments.length; a < l; a++) { + merge(target, arguments[a]); + } + + return target; + }; + + // return d3.rebind(isfahan, hierarchy,"sort", "children", "value"); + return isfahan(configObject); +}; + +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a){function b(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function c(a,b){for(var d in b)d in a?c(a[d],b[d]):a[d]=b[d];return a}function d(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function e(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return Q[a]}):a}function f(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return T.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function g(a,b){"function"==typeof a&&(b=a,a={}),a=a||{},T.extend(P,a),delete P.fixLng,P.functions&&(delete P.functions,T.extend(T,a.functions)),"string"==typeof P.ns&&(P.ns={namespaces:[P.ns],defaultNs:P.ns}),"string"==typeof P.fallbackNS&&(P.fallbackNS=[P.fallbackNS]),("string"==typeof P.fallbackLng||"boolean"==typeof P.fallbackLng)&&(P.fallbackLng=[P.fallbackLng]),P.interpolationPrefixEscaped=T.regexEscape(P.interpolationPrefix),P.interpolationSuffixEscaped=T.regexEscape(P.interpolationSuffix),P.lng||(P.lng=T.detectLanguage()),M=T.toLanguages(P.lng),H=M[0],T.log("currentLng set to: "+H),P.useCookie&&T.cookie.read(P.cookieName)!==H&&T.cookie.create(P.cookieName,H,P.cookieExpirationTime,P.cookieDomain),P.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&T.localStorage.setItem("i18next_lng",H);var c=B;a.fixLng&&(c=function(a,b){return b=b||{},b.lng=b.lng||c.lng,B(a,b)},c.lng=H),W.setCurrentLng(H),I&&P.setJqueryExt&&u();var d;if(I&&I.Deferred&&(d=I.Deferred()),!P.resStore){var e=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var f=0,g=P.preload.length;g>f;f++)for(var h=T.toLanguages(P.preload[f]),i=0,j=h.length;j>i;i++)e.indexOf(h[i])<0&&e.push(h[i]);return J.sync.load(e,P,function(a,e){K=e,N=!0,b&&b(c),d&&d.resolve(c)}),d?d.promise():void 0}return K=P.resStore,N=!0,b&&b(c),d&&d.resolve(c),d?d.promise():void 0}function h(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)P.preload.indexOf(a[c])<0&&P.preload.push(a[c]);return g(b)}function i(a,b,c,d){"string"!=typeof b?(c=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{},d?T.deepExtend(K[a][b],c):T.extend(K[a][b],c),P.useLocalStorage&&O._storeLocal(K)}function j(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{};var c=K[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function k(a,b){return"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},T.extend({},K[a][b])}function l(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},K[a][b]={},P.useLocalStorage&&O._storeLocal(K)}function m(a,b,c,d){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{};for(var e=c.split(P.keyseparator),f=0,g=K[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;P.useLocalStorage&&O._storeLocal(K)}function n(a,b,c){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&m(a,b,d,c[d])}function o(a){P.ns.defaultNs=a}function p(a,b){q([a],b)}function q(a,b){var c={dynamicLoad:P.dynamicLoad,resGetPath:P.resGetPath,getAsync:P.getAsync,customLoad:P.customLoad,ns:{namespaces:a,defaultNs:""}},d=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var e=0,f=P.preload.length;f>e;e++)for(var g=T.toLanguages(P.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=K[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?J.sync._fetch(j,c,function(c,d){var e=a.length*j.length;T.each(a,function(a,c){P.ns.namespaces.indexOf(c)<0&&P.ns.namespaces.push(c),T.each(j,function(a,f){K[f]=K[f]||{},K[f][c]=d[f][c],e--,0===e&&b&&(P.useLocalStorage&&J.sync._storeLocal(K),b())})})}):b&&b()}function r(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,g(b,c)}function s(){return H}function t(a){K={},r(H,a)}function u(){function a(a,b,c){if(0!==b.length){var d="text";if(0===b.indexOf("[")){var e=b.split("]");b=e[1],d=e[0].substr(1,e[0].length-1)}b.indexOf(";")===b.length-1&&(b=b.substr(0,b.length-2));var f;if("html"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.html(I.t(b,f));else if("text"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.text()},c):c,a.text(I.t(b,f));else if("prepend"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.prepend(I.t(b,f));else if("append"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.append(I.t(b,f));else if(0===d.indexOf("data-")){var g=d.substr("data-".length);f=P.defaultValueFromContent?I.extend({defaultValue:a.data(g)},c):c;var h=I.t(b,f);a.data(g,h),a.attr(d,h)}else f=P.defaultValueFromContent?I.extend({defaultValue:a.attr(d)},c):c,a.attr(d,I.t(b,f))}}function b(b,c){var d=b.attr(P.selectorAttr);if(d||"undefined"==typeof d||d===!1||(d=b.text()||b.val()),d){var e=b,f=b.data("i18n-target");if(f&&(e=b.find(f)||b),c||P.useDataAttrOptions!==!0||(c=b.data("i18n-options")),c=c||{},d.indexOf(";")>=0){var g=d.split(";");I.each(g,function(b,d){""!==d&&a(e,d,c)})}else a(e,d,c);P.useDataAttrOptions===!0&&b.data("i18n-options",c)}}I.t=I.t||B,I.fn.i18n=function(a){return this.each(function(){b(I(this),a);var c=I(this).find("["+P.selectorAttr+"]");c.each(function(){b(I(this),a)})})}}function v(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||P.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?T.regexEscape(d.interpolationPrefix):P.interpolationPrefixEscaped,f=d.interpolationSuffix?T.regexEscape(d.interpolationSuffix):P.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return T.each(h,function(b,h){var i=c?c+P.keyseparator+b:b;"object"==typeof h&&null!==h?a=v(a,h,i,d):d.escapeInterpolation||P.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),T.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(T.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(h))}),a}function w(a,b){var c=",",d="{",e="}",f=T.extend({},b);for(delete f.postProcess;-1!=a.indexOf(P.reusePrefix)&&(L++,!(L>P.maxRecursion));){var g=a.lastIndexOf(P.reusePrefix),h=a.indexOf(P.reuseSuffix,g)+P.reuseSuffix.length,i=a.substring(g,h),j=i.replace(P.reusePrefix,"").replace(P.reuseSuffix,"");if(g>=h)return T.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=T.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=E(j,f);a=a.replace(i,T.regexReplacementEscape(o))}return a}function x(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function y(a){return void 0!==a.count&&"string"!=typeof a.count}function z(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function A(a,b){b=b||{};var c=C(a,b),d=F(a,b);return void 0!==d||d===c}function B(a,b){return b=b||{},N?(L=0,E.apply(null,arguments)):(T.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function C(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function D(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(P.nsseparator),i=e[0],c=e[1]),void 0===g&&P.sendMissing&&"function"==typeof P.missingKeyHandler&&(b.lng?P.missingKeyHandler(h[0],i,c,f,h):P.missingKeyHandler(P.lng,i,c,f,h));var j;j="string"==typeof P.postProcess&&""!==P.postProcess?[P.postProcess]:"array"==typeof P.postProcess||"object"==typeof P.postProcess?P.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){X[a]&&(g=X[a](g,c,b))});var k=f;if(f.indexOf(P.nsseparator)>-1&&(e=f.split(P.nsseparator),k=e[1]),k===c&&P.parseMissingKey&&(f=P.parseMissingKey(f)),void 0===g&&(f=v(f,b),f=w(f,b),j.length)){var l=C(c,b);j.forEach(function(a){X[a]&&(g=X[a](l,c,b))})}return void 0!==g?g:f}function F(a,b){b=b||{};var c,d,e=C(a,b),f=M;if(!K)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=T.toLanguages(b.lng,b.fallbackLng),!K[f[0]])){var g=P.getAsync;P.getAsync=!1,J.sync.load(f,P,function(a,b){T.extend(K,b),P.getAsync=g})}var h=b.ns||P.ns.defaultNs;if(a.indexOf(P.nsseparator)>-1){var i=a.split(P.nsseparator);h=i[0],a=i[1]}if(x(b)){c=T.extend({},b),delete c.context,c.defaultValue=P.contextNotFound;var j=h+P.nsseparator+a+"_"+b.context;if(d=B(j,c),d!=P.contextNotFound)return v(d,{context:b.context})}if(y(b,f[0])){c=T.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=P.pluralNotFound;var k;if(W.needsPlural(f[0],b.count)){k=h+P.nsseparator+a+P.pluralSuffix;var l=W.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+P.nsseparator+a)}else k=h+P.nsseparator+a;if(d=B(k,c),d!=P.pluralNotFound)return v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=B(h+P.nsseparator+a,c),v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=T.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=B(h+P.nsseparator+a,b),d!=P.pluralNotFound)return d}if(z(b)){var n=T.extend({},b);delete n.indefinite_article,n.defaultValue=P.indefiniteNotFound;var o=h+P.nsseparator+a+(b.count&&!y(b,f[0])||!b.count?P.indefiniteSuffix:"");if(d=B(o,n),d!=P.indefiniteNotFound)return d}for(var p,q=a.split(P.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],u=0,A=K[t]&&K[t][h];q[u];)A=A&&A[q[u]],u++;if(void 0!==A){var D=Object.prototype.toString.apply(A);if("string"==typeof A)A=v(A,b),A=w(A,b);else if("[object Array]"!==D||P.returnObjectTrees||b.returnObjectTrees){if(null===A&&P.fallbackOnNull===!0)A=void 0;else if(null!==A)if(P.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==D&&"[object Function]"!==D&&"[object RegExp]"!==D){var G="[object Array]"===D?[]:{};T.each(A,function(c){G[c]=E(h+P.nsseparator+a+P.keyseparator+c,b)}),A=G}}else P.objectTreeKeyHandler&&"function"==typeof P.objectTreeKeyHandler?A=P.objectTreeKeyHandler(a,A,t,h,b):(A="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",T.log(A))}else A=A.join("\n"),A=v(A,b),A=w(A,b);"string"==typeof A&&""===A.trim()&&P.fallbackOnEmpty===!0&&(A=void 0),p=A}}if(void 0===p&&!b.isFallbackLookup&&(P.fallbackToDefaultNS===!0||P.fallbackNS&&P.fallbackNS.length>0)){if(b.isFallbackLookup=!0,P.fallbackNS.length){for(var H=0,I=P.fallbackNS.length;I>H;H++)if(p=F(P.fallbackNS[H]+P.nsseparator+a,b),p||""===p&&P.fallbackOnEmpty===!1){var L=p.indexOf(P.nsseparator)>-1?p.split(P.nsseparator)[1]:p,N=e.indexOf(P.nsseparator)>-1?e.split(P.nsseparator)[1]:e;if(L!==N)break}}else p=F(a,b);b.isFallbackLookup=!1}return p}function G(){var a,b=P.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==P.detectLngQS&&c.push(b[d].substring(e+1))}}}(),P.useCookie&&"undefined"!=typeof document){var d=T.cookie.read(P.cookieName);d&&c.push(d)}if(P.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(T.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=P.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=P.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var H,I=a.jQuery||a.Zepto,J={},K={},L=0,M=[],N=!1,O={};"undefined"!=typeof module&&module.exports?module.exports=J:(I&&(I.i18n=I.i18n||J),a.i18n=a.i18n||J),O={load:function(a,b,c){b.useLocalStorage?O._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?O._fetch(f,b,function(a,b){T.extend(e,b),O._storeLocal(b),c(null,e)}):c(null,e)}):O._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;T.each(a,function(a,g){var h=T.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),T.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=v(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});T.ajax({url:g,success:function(a){T.log("loaded: "+g),f(null,a)},error:function(a,b,c){T.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;T.each(d.namespaces,function(d,f){T.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):O._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=v(c.resGetPath,{lng:a,ns:b});T.ajax({url:e,success:function(a){T.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)T.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)T.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;T.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===P.sendMissingTo&&P.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:v(P.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];T.ajax({url:l.url,type:P.sendType,data:f,success:function(){T.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=K[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){T.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:P.postAsync})}},reload:t};var P={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:O.postMissing,shortcutFunction:"sprintf"},Q={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},R={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=P.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=P.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=P.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==P.load&&f(b(a)),"current"!==P.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},W={rules:function(){var a,b={};for(a=U.length;a--;)b[U[a][0]]={name:U[a][1],numbers:U[a][2],plurals:V[U[a][3]]};return b}(),addRule:function(a,b){W.rules[a]=b},setCurrentLng:function(a){if(!W.currentRule||W.currentRule.lng!==a){var b=a.split("-");W.currentRule={lng:a,rule:W.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[d[T.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[T.getCountyIndexOfLng(a)],b)}},X={},Y=function(a,b){X[a]=b},Z=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),$=function(a,b){return b.unshift(a),Z.apply(null,b)};Y("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?$(a,c.sprintf):"object"==typeof c.sprintf?Z(a,c.sprintf):a:a}),J.init=g,J.setLng=r,J.preload=h,J.addResourceBundle=i,J.hasResourceBundle=j,J.getResourceBundle=k,J.addResource=m,J.addResources=n,J.removeResourceBundle=l,J.loadNamespace=p,J.loadNamespaces=q,J.setDefaultNamespace=o,J.t=B,J.translate=B,J.exists=A,J.detectLanguage=T.detectLanguage,J.pluralExtensions=W,J.sync=O,J.functions=T,J.lng=s,J.addPostProcessor=Y,J.applyReplacement=T.applyReplacement,J.options=P}("undefined"==typeof exports?window:exports); +window.Mirador = window.Mirador || function(config) { + + // pass the config through the save and restore process, + // returning the config that will, in fact, populate the + // application. + Mirador.saveController = new Mirador.SaveController(config); + + config = Mirador.saveController.currentConfig; + + // initialise application + Mirador.viewer = new Mirador.Viewer(config); +}; + +(function($) { + + /** + * Default values for settings + */ + $.DEFAULT_SETTINGS = { + + 'workspaceType': 'singleObject', + + 'saveSession' : true, //whether or not to store session to local storage + + 'workspaces' : { + 'singleObject': { + 'label': 'Single Object', + 'addNew': false, + 'move': false, + 'iconClass': 'image' + }, + 'compare': { + 'label': 'Compare', + 'iconClass': 'columns' + }, + 'bookReading': { + 'defaultWindowOptions': { + }, + 'label': 'Book Reading', + 'addNew': true, + 'move': false, + 'iconClass': 'book' + } + }, + + 'layout': '1x1', + + 'openManifestsPage' : false, //defaults to false, whether or not Mirador should display the manifests page, + //only valid if no windowObjects have been initialized + //if there are multiple slots, it will be bound to the first slot and the selected manifest will open in that slot + + 'windowObjects' : [ + /** within a single object, the following options: + * "loadedManifest": [manifestURI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json" + * "canvasID": [canvas URI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/canvas/canvas-12" + * + * "availableViews" : defaults to ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], any subset removes others + * "viewType" : one of [_'ThumbnailsView'_, 'ImageView', 'ScrollView', 'BookView'] - if using availableViews, must be in subset + * + * "bottomPanel" : [_true_, false] whether or not to make the bottom panel available in this window + * "bottomPanelVisible" : [_true_, false] whether or not to make the bottom panel visible in this window on load. This setting is dependent + * on bottomPanel being true + * "sidePanel" : [_true_, false] whether or not to make the side panel available in this window + * "sidePanelOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied + * { + * "toc" : [_true_, false] + * "annotations" : [true, _false_] + * } + * "sidePanelVisible" : [_true_, false] whether or not to make the side panel visible in this window on load. This setting is dependent + * on sidePanel being true + * "overlay" : [_true_, false] whether or not to make the overlay available/visible in this window + * + * "annotationLayer" : [_true_, false] whether or not to make annotation layer available in this window + * "annotationCreation" : [_true_, false] whether or not to make annotation creation available in this window, + * only valid if annotationLayer is set to True and an annotationEndpoint is defined. + * This setting does NOT affect whether or not a user can edit an individual annotation that has already been created. + * "annotationState" : [_'annoOff'_, 'annoOnCreateOff', 'annoOnCreateOn'] whether or not to turn on the annotation layer on window load + * + * "fullScreen" : [_true_, false] whether or not to make the fullScreen HUD button visible to user + * + * "displayLayout" : [_true_, false], whether or not to display all layout options, removing individual menu options is separate + * "layoutOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied + * { + * "newObject" : [_true_, false] + * "close" : [_true_, false] + * "slotRight" : [_true_, false] + * "slotLeft" : [_true_, false] + * "slotAbove" : [_true_, false] + * "slotBelow" : [_true_, false] + * } + * "windowOptions" : [data specific to the view type, such as OSD bounds and zoom level - automatically saved in SaveController] + * "id" : [unique window ID - set by application and automatically saved in SaveController] + **/ + ], + + 'defaultWindowSettings': { + + }, + + 'availableAnnotationModes': [ + + ], + + 'availableAnnotationDrawingTools': [ + + ], + + 'availableCanvasTools': [ + + ], + + // main (top) menu + //we don't actually take the height into account for the mirador-viewer div, so don't use for now + 'mainMenuSettings': { + 'show': true, + 'buttons' : { + 'bookmark' : true, + 'layout' : true, + 'options' : false, + 'fullScreenViewer': true + } + //'height': 25, + //'width': '100%' + }, + + 'workspacePanelSettings': { + 'maxRows': 5, + 'maxColumns': 5, + 'preserveWindows': true + }, + + //true or false. controls display of "Add new object from URL" on manifest listing page + 'showAddFromURLBox' : true, + + // 'buildPath' : 'build/mirador/', + 'buildPath' : '/', + + 'i18nPath' : 'locales/', + + // 'imagesPath' : 'images/', + 'imagesPath' : 'assets/', + + // 'logosPath' : 'images/logos/', + 'logosPath' : 'assets/logos/', + + 'repoImages' : { + 'other': 'iiif_logo.png' + }, + + /** + * Annotation backend that have instance-specific configuration data as a hash, e.g.: + * { + * name: 'backend name', + * module: 'NameEndpoint', + * options: + * { 'url': '', + * 'storeId': 123, + * 'APIKey': '23983hf98j3f9283jf2983fj' + * } + * } + **/ + 'annotationEndpoint': {}, + + 'jsonStorageEndpoint': { + 'name': 'JSONBlob API Endpoint', + 'module': 'JSONBlobAPI', + 'options': { + 'ssl': true, + 'port': '443', + 'host': 'jsonblob.com' + } + }, + + 'sharingEndpoint': { + 'url': '', + 'storeId': 123, + 'APIKey': '23983hf98j3f9283jf2983fj' + }, + + // linked image views configuration + 'lockController' : { + 'lockProfile' : 'lazyZoom', + 'notifyMaxMin' : true + } + }; + +}(Mirador)); + +(function($) { + + $.Viewer = function(options) { + + jQuery.extend(true, this, { + id: options.id, + hash: options.id, + data: null, + element: null, + canvas: null, + workspaceType: null, + layout: null, + workspace: null, + mainMenu: null, + workspaceAutoSave: null, + windowSize: {}, + resizeRatio: {}, + currentWorkspaceVisible: true, + overlayStates: { + 'workspacePanelVisible': false, + 'manifestsPanelVisible': false, + 'optionsPanelVisible': false, + 'bookmarkPanelVisible': false + }, + manifests: [] + }, $.DEFAULT_SETTINGS, options); + + // get initial manifests + this.element = this.element || jQuery('#' + this.id); + + if (this.data) { + this.init(); + } + }; + + $.Viewer.prototype = { + + init: function() { + var _this = this; + + //add background and positioning information on the root element that is provided in config + var backgroundImage = _this.buildPath + _this.imagesPath + 'debut_dark.png'; + this.element.css('background-color', '#333').css('background-image','url('+backgroundImage+')').css('background-position','left top') + .css('background-repeat','repeat').css('position','fixed'); + + //initialize i18next + // i18n.init({debug: false, getAsync: false, resGetPath: _this.buildPath + _this.i18nPath+'__lng__/__ns__.json'}); + + //register Handlebars helper + Handlebars.registerHelper('t', function(i18n_key) { + var result = i18n.t(i18n_key); + return new Handlebars.SafeString(result); + }); + + //check all buttons in mainMenu. If they are all set to false, then don't show mainMenu + var showMainMenu = false; + jQuery.each(this.mainMenuSettings.buttons, function(key, value) { + if (value) { showMainMenu = true; } + }); + //even if buttons are available, developer can override and set show to false + if (this.mainMenuSettings.show === false) { + showMainMenu = false; + } + + // add main menu + if (showMainMenu) { + this.mainMenu = new $.MainMenu({ parent: this, appendTo: this.element }); + } + + // add viewer area + this.canvas = jQuery('
      ') + .addClass('mirador-viewer') + .appendTo(this.element); + + if (!showMainMenu) { + this.canvas.css("top", "0px"); + } + + // add workspace configuration + this.layout = typeof this.layout !== 'string' ? JSON.stringify(this.layout) : this.layout; + this.workspace = new $.Workspace({ + layoutDescription: this.layout.charAt(0) === '{' ? JSON.parse(this.layout) : $.layoutDescriptionFromGridString(this.layout), + parent: this, + appendTo: this.element.find('.mirador-viewer') + }); + + this.workspacePanel = new $.WorkspacePanel({ + appendTo: this.element.find('.mirador-viewer'), + parent: this, + maxRows: this.workspacePanelSettings.maxRows, + maxColumns: this.workspacePanelSettings.maxColumns, + preserveWindows: this.workspacePanelSettings.preserveWindows, + workspace: this.workspace + }); + + this.manifestsPanel = new $.ManifestsPanel({ parent: this, appendTo: this.element.find('.mirador-viewer') }); + this.bookmarkPanel = new $.BookmarkPanel({ parent: this, appendTo: this.element.find('.mirador-viewer'), jsonStorageEndpoint: this.jsonStorageEndpoint }); + + // set this to be displayed + this.set('currentWorkspaceVisible', true); + + this.bindEvents(); + // retrieve manifests + this.getManifestsData(); + + if (this.windowObjects.length === 0 && this.openManifestsPage) { + this.workspace.slots[0].addItem(); + } + }, + + bindEvents: function() { + var _this = this; + // check that windows are loading first to set state of slot? + jQuery.subscribe('manifestReceived', function(event, newManifest) { + if (_this.windowObjects) { + var check = jQuery.grep(_this.windowObjects, function(object, index) { + return object.loadedManifest === newManifest.uri; + }); + jQuery.each(check, function(index, config) { + _this.loadManifestFromConfig(config); + }); + } + }); + + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + var _this = this; + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + jQuery.publish(prop + '.set', value); + }, + + // Sets state of overlays that layer over the UI state + toggleOverlay: function(state) { + var _this = this; + // first confirm all others are off + jQuery.each(this.overlayStates, function(oState, value) { + if (state !== oState) { + _this.set(oState, false, {parent: 'overlayStates'}); + } + }); + var currentState = this.get(state, 'overlayStates'); + this.set(state, !currentState, {parent: 'overlayStates'}); + }, + + toggleLoadWindow: function() { + this.toggleOverlay('manifestsPanelVisible'); + }, + + toggleWorkspacePanel: function() { + this.toggleOverlay('workspacePanelVisible'); + }, + + toggleBookmarkPanel: function() { + this.toggleOverlay('bookmarkPanelVisible'); + }, + + enterFullscreen: function() { + var el = this.element[0]; + if (el.requestFullscreen) { + el.requestFullscreen(); + } else if (el.mozRequestFullScreen) { + el.mozRequestFullScreen(); + } else if (el.webkitRequestFullscreen) { + el.webkitRequestFullscreen(); + } else if (el.msRequestFullscreen) { + el.msRequestFullscreen(); + } + }, + + exitFullscreen: function() { + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen(); + } + }, + + isFullscreen: function() { + var $fullscreen = $(fullscreenElement()); + return ($fullscreen.length > 0); + }, + + fullscreenElement: function() { + return (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement); + }, + + getManifestsData: function() { + var _this = this; + + _this.data.forEach(function(manifest) { + if (manifest.hasOwnProperty('manifestUri')) { + var url = manifest.manifestUri; + _this.addManifestFromUrl(url, manifest.location ? manifest.location : ''); + } else if (manifest.hasOwnProperty('collectionUri')) { + jQuery.getJSON(manifest.collectionUri).done(function (data, status, jqXHR) { + if (data.hasOwnProperty('manifests')){ + jQuery.each(data.manifests, function (ci, mfst) { + _this.addManifestFromUrl(mfst['@id'], ''); + }); + } + }).fail(function(jqXHR, status, error) { + console.log(jqXHR, status, error); + }); + } + }); + }, + + hasWidgets: function(collection) { + return ( + typeof collection.widgets !== 'undefined' && + collection.widgets && + !jQuery.isEmptyObject(collection.widgets) && + collection.widgets.length > 0 + ); + }, + + addManifestFromUrl: function(url, location) { + var _this = this, + manifest; + + if (!_this.manifests[url]) { + manifest = new $.Manifest(url, location); + _this.manifests[url] = manifest; + _this.manifests.push(manifest); + jQuery.publish('manifestQueued', manifest, location); + manifest.request.done(function() { + jQuery.publish('manifestReceived', manifest); + }); + } + }, + + loadManifestFromConfig: function(options) { + // check if there are available slots, otherwise don't process this object from config + //if we have more windowObjects that slots in the layout, return + var slotAddress = options.slotAddress ? options.slotAddress : this.workspace.getAvailableSlot() ? this.workspace.getAvailableSlot().layoutAddress : null; + if (!slotAddress) { + return; + } + var windowConfig = { + manifest: this.manifests[options.loadedManifest], + currentFocus : options.viewType, + focusesOriginal : options.availableViews, + currentCanvasID : options.canvasID, + id : options.id, + focusOptions : options.windowOptions, + bottomPanelAvailable : options.bottomPanel, + bottomPanelVisible : options.bottomPanelVisible, + sidePanelAvailable : options.sidePanel, + sidePanelOptions : options.sidePanelOptions, + sidePanelVisible : options.sidePanelVisible, + overlayAvailable : options.overlay, + annotationLayerAvailable : options.annotationLayer, + annotationCreationAvailable : options.annotationCreation, + annotationState : options.annotationState, + fullScreenAvailable : options.fullScreen, + slotAddress: slotAddress, + displayLayout : options.displayLayout, + layoutOptions: options.layoutOptions + }; + + this.workspace.addWindow(windowConfig); + } + }; + +}(Mirador)); + +(function($) { + + $.Workspace = function(options) { + + jQuery.extend(true, this, { + workspaceSlotCls: 'slot', + focusedSlot: null, + slots: [], + windows: [], + appendTo: null, + parent: null, + layoutDescription: null + }, options); + + this.element = this.element || jQuery('
      '); + this.init(); + + }; + + $.Workspace.prototype = { + init: function () { + this.element.appendTo(this.appendTo); + if (this.type === "none") { + this.parent.toggleSwitchWorkspace(); + return; + } + + this.calculateLayout(); + + this.bindEvents(); + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + var _this = this; + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + jQuery.publish(prop + '.set', value); + }, + + calculateLayout: function(resetting) { + var _this = this, + layout; + + _this.layout = layout = new Isfahan({ + containerId: _this.element.attr('id'), + layoutDescription: _this.layoutDescription, + configuration: null, + padding: 3 + }); + + var data = layout.filter( function(d) { + return !d.children; + }); + + // Data Join. + var divs = d3.select("#" + _this.element.attr('id')).selectAll(".layout-slot") + .data(data, function(d) { return d.id; }); + + // Implicitly updates the existing elements. + // Must come before the enter function. + divs.call(cell).each(function(d) { + _this.slots.forEach(function(slot) { + if (slot.slotID === d.id) { + slot.layoutAddress = d.address; + } + }); + }); + + // Enter + divs.enter().append("div") + .attr("class", "layout-slot") + .attr("data-layout-slot-id", function(d) { return d.id; }) + .call(cell) + .each(function(d) { + var appendTo = _this.element.children('div').filter('[data-layout-slot-id="'+ d.id+'"]')[0]; + _this.slots.push(new $.Slot({ + slotID: d.id, + layoutAddress: d.address, + focused: true, + parent: _this, + appendTo: appendTo + })); + }); + + // Exit + divs.exit() + .remove("div") + .each(function(d) { + var slotMap = _this.slots.reduce(function(map, temp_slot) { + if (d.id === temp_slot.slotID) { + map[d.id] = temp_slot; + } + return map; + }, {}), + slot = slotMap[d.id]; + + if (slot && slot.window && !resetting) { + jQuery.publish("windowRemoved", slot.window.id); + } + + _this.slots.splice(_this.slots.indexOf(slot), 1); + }); + + function cell() { + this + .style("left", function(d) { return d.x + "px"; }) + .style("top", function(d) { return d.y + "px"; }) + .style("width", function(d) { return Math.max(0, d.dx ) + "px"; }) + .style("height", function(d) { return Math.max(0, d.dy ) + "px"; }); + } + + var root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + jQuery.publish("layoutChanged", root); + }, + + split: function(targetSlot, direction) { + var _this = this, + node = jQuery.grep(_this.layout, function(node) { return node.id === targetSlot.slotID; })[0]; + nodeIndex = node.parent ? node.parent.children.indexOf(node) : 0, + nodeIsNotRoot = node.parent; + + function addSibling(node, indexDifference) { + if (nodeIsNotRoot) { + var siblingIndex = nodeIndex + indexDifference, + newSibling = _this.newNode(node.type, node); + + node.parent.children.splice(siblingIndex, 0, newSibling); + _this.layout.push(newSibling); + return newSibling; + } + + // handles the case where the root needs to be mutated. + node.type = node.type === 'row' ? 'column' : 'row'; + mutateAndAdd(node, indexDifference); + } + + function mutateAndAdd(node, indexDifference) { + // Locally mutate the tree to accomodate a + // sibling of another kind, transforming + // both the target node and its parent. + var newParent = _this.newNode(node.type, node.parent); + + // Flip its type while keeping + // the same id. + node.type = node.type === 'row' ? 'column' : 'row'; + + // Create a new node (which will be childless) + // that is also a sibling of this node. + newSibling = _this.newNode(node.type, newParent); + + // maintain array ordering. + newParent.children = []; + newParent.children.push(node); // order matters, place node first. + newParent.children.splice(indexDifference, 0, newSibling); // order matters, so put new sibling on one side or the other. + if (nodeIsNotRoot) { + newParent.parent = node.parent; + // replace the old node in its parent's child + // array with the new parent. + newParent.parent.children[nodeIndex] = newParent; + } + + node.parent = newParent; + _this.layout.push(newParent, newSibling); + } + + if (node.type === 'column') { + // Since it is a column: + // + // If adding to a side, simply + // add a sibling. + // Left means before, right means after. + if (direction === 'r' || direction === 'l') { + indexDifference = direction === 'r' ? 1 : 0; + addSibling(node, indexDifference); + } + // If adding above or below, the + // operation must be changed to mutating + // the structure. + // Up means before, Down means after. + else { + indexDifference = direction === 'd' ? 1 : 0; + mutateAndAdd(node, indexDifference); + } + } else { + // Since it is a row: + // + // If adding to a side, mutate the + // structure. + // Left means before, right means after. + if (direction === 'r' || direction === 'l') { + indexDifference = direction === 'r' ? 1 : 0; + mutateAndAdd(node, indexDifference); + } + // If adding above or below, the + // operations must be switched to adding + // a sibling. + // Up means before, Down means after. + else { + indexDifference = direction === 'd' ? 1 : 0; + addSibling(node, indexDifference); + } + } + + // Recalculate the layout. + // The original hierarchical structure is + // accessible from the root node. Passing + // it back through the layout code will + // recalculate everything else needed for + // the redraw. + var root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + _this.layoutDescription = root; + _this.calculateLayout(); + + }, + + splitRight: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'r'); + }, + + splitLeft: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'l'); + }, + + splitUp: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'u'); + }, + + splitDown: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'd'); + }, + + removeNode: function(targetSlot) { + // de-mutate the tree structure. + var _this = this, + node = jQuery.grep(_this.layout, function(node) { return node.id === targetSlot.slotID; })[0], + nodeIndex = node.parent.children.indexOf(node), + parentIndex, + remainingNode, + root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + + if (node.parent.children.length === 2) { + // de-mutate the tree without destroying + // the children of the remaining node, + // which in this case means changing their + // IDs. + node.parent.children.splice(nodeIndex,1); + remainingNode = node.parent.children[0]; + + remainingNode.parent.id = remainingNode.id; + delete node.parent; + } else if (node.parent.children.length === 1) { + } else { + // If the node is one of more than 2 siblings, + // simply splice it out of the parent's children + // array. + node.parent.children.splice(nodeIndex, 1); + } + + _this.layoutDescription = root; + _this.calculateLayout(); + }, + + newNode: function(type, parent) { + if (typeof parent === 'undefined') { + return { + type: type, + id: $.genUUID() + }; + } else { + return { + type: type, + id: $.genUUID(), + parent: parent + }; + } + }, + + getSlotFromAddress: function(address) { + var _this = this; + return _this.slots.filter(function(slot) { + return slot.layoutAddress === address; + })[0]; + }, + + resetLayout: function(layoutDescription) { + this.layoutDescription = layoutDescription; + this.calculateLayout(true); + this.placeWindows(); + }, + + placeWindows: function() { + // take the windows array and place + // as many windows into places as can + // fit. + var _this = this, + deletedWindows; + + if (_this.windows.length > _this.slots.length) { + // splice modifies the original array and + // returns the deleted items, + // so we can just perform a forEach on the + // return value, and have the saveController + // remove these windows in response to the event + // (which otherwise it would not do). + // + // The event was not called in the calculateLayout + // function because we need the other windows to remain, + // so we filter them here. + _this.windows.splice(0, _this.windows.length -_this.slots.length).forEach(function(removedWindow){ + jQuery.publish('windowRemoved', removedWindow.id); + }); + } + + _this.windows.forEach(function(window) { + var slot = _this.getAvailableSlot(); + slot.window = window; + + window.update({ + id: window.id, + slotAddress: slot.layoutAddress, + parent: slot, + appendTo: slot.element, + currentCanvasID: window.currentCanvasID, + currentFOcus: window.currentFocus + }); + }); + }, + + getAvailableSlot: function() { + return this.slots.filter(function(slot) { + return !slot.window; + })[0]; + }, + + bindEvents: function() { + var _this = this; + + d3.select(window).on('resize', function(event) { + _this.calculateLayout(); + }); + + jQuery.subscribe('resizeMirador', function(event) { + _this.calculateLayout(); + }); + + jQuery.subscribe('manifestQueued', function(event, manifestPromise) { + // Trawl windowObjects preemptively for slotAddresses and + // notify those slots to display a "loading" state. + // Similar to the operation of the manifestLoadStatusIndicator + // and its associated manifestList controller. + var targetSlot; + + if (_this.parent.windowObjects) { + var check = _this.parent.windowObjects.forEach(function(windowConfig, index) { + // windowConfig.slotAddress will give the slot; + // change the state on that slot to be "loading" + if (windowConfig.slotAddress) { + targetSlot = _this.getSlotFromAddress(windowConfig.slotAddress); + } else { + targetSlot = _this.focusedSlot || _this.slots.filter(function(slot) { + return slot.hasOwnProperty('window') ? true : false; + })[0]; + } + }); + } + }); + + jQuery.subscribe('windowRemoved', function(event, windowId) { + _this.windows = jQuery.grep(_this.windows, function(window) { + return window.id !== windowId; + }); + }); + }, + + clearSlot: function(slotId) { + if (this.slots[slodId].windowElement) { + this.slots[slotId].windowElement.remove(); + } + this.slots[slotId].window = null; + }, + + addItem: function(slot) { + this.focusedSlot = slot; + this.parent.toggleLoadWindow(); + }, + + addWindow: function(windowConfig) { + // Windows can be added from a config, + // from a saved state, (in both those cases they are in the form of "windowObjects") + // from the workspace windows list after a grid layout change, + // from the manifests panel in image mode, + // or from the manifests panel in thumbnail mode. + var _this = this, + newWindow, + targetSlot; + + jQuery.each(_this.parent.overlayStates, function(oState, value) { + // toggles the other top-level panels closed and focuses the + // workspace. For instance, after selecting an object from the + // manifestPanel. + _this.parent.set(oState, false, {parent: 'overlayStates'}); + }); + + if (windowConfig.slotAddress) { + targetSlot = _this.getSlotFromAddress(windowConfig.slotAddress); + } else { + targetSlot = _this.focusedSlot || _this.getAvailableSlot(); + } + + windowConfig.appendTo = targetSlot.element; + windowConfig.parent = targetSlot; + + if (!targetSlot.window) { + windowConfig.slotAddress = targetSlot.layoutAddress; + windowConfig.id = windowConfig.id || $.genUUID(); + + jQuery.publish("windowSlotAdded", {id: windowConfig.id, slotAddress: windowConfig.slotAddress}); + + newWindow = new $.Window(windowConfig); + _this.windows.push(newWindow); + + targetSlot.window = newWindow; + + jQuery.publish("windowAdded", {id: windowConfig.id, slotAddress: windowConfig.slotAddress}); + + jQuery.publish(('currentCanvasIDUpdated.' + windowConfig.id), windowConfig.currentCanvasID); + } else { + targetSlot.window.element.remove(); + targetSlot.window.update(windowConfig); + jQuery.publish(('currentCanvasIDUpdated.' + windowConfig.id), windowConfig.currentCanvasID); + // The target slot already has a window in it, so just update that window instead, + // using the appropriate saving functions, etc. This obviates the need changing the + // parent, slotAddress, setting a new ID, and so on. + } + } + }; +}(Mirador)); + +(function($) { + + $.BookmarkPanel = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null + }, options); + + this.init(); + + }; + + $.BookmarkPanel.prototype = { + init: function () { + this.element = jQuery(this.template()).appendTo(this.appendTo); + saveModule = this.jsonStorageEndpoint.module, + saveOptions = this.jsonStorageEndpoint.options; + this.storageModule = new $[saveModule](saveOptions); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + // handle subscribed events + jQuery.subscribe('bookmarkPanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + jQuery.subscribe('saveControllerConfigUpdated', function() { + _this.storageModule.save(Mirador.saveController.currentConfig) + .then(function(blobId) { + var bookmarkURL = window.location.href.replace(window.location.hash, '') + "?json="+blobId; + _this.element.find('#share-url').val(bookmarkURL).focus().select(); + }); + }); + }, + + hide: function() { + jQuery(this.element).hide({effect: "slide", direction: "up", duration: 300, easing: "swing"}); + }, + + show: function() { + jQuery(this.element).show({effect: "slide", direction: "up", duration: 300, easing: "swing"}); + }, + + template: Handlebars.compile([ + '
      ', + '

      {{t "bookmarkTitle"}}

      ', + '', + '{{t "url"}}: ', + '', + '', + '
      ' + ].join('')) + }; + +}(Mirador)); + +(function($) { + // Keeps track of the control context and switches out + // keyboard control mappings accordingly. + + $.ControlHarness = function(options) { + + jQuery.extend(true, this, { + contexts: null, + activeContext: null + }, options); + + this.init(); + }; + + $.ControlHarness.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + // workspace is changed: + // slot is added/removed: + // window is opened/closed: + // different top-level menus are opened (load manifest/choose workspace, etc.): + // item is selected from manifest menu. + // item is hovered over with the mouse. + // deliberately moving "up" "down" "left" and "right" through + // the command contexts. + }, + + switchActiveContext: function() { + + }, + + addContext: function(ctxId) { + + }, + + removeContext: function(ctxId) { + + } + + }; + +}(Mirador)); + + +(function($) { + + $.MainMenu = function(options) { + + jQuery.extend(true, this, { + parent: null, //viewer + element: null, + mainMenuHeight: null, + mainMenuWidth: null, + windowOptionsMenu: null, + loadWindow: null, + clearLocalStorage: '', + viewerCls: 'mirador-viewer', + mainMenuBarCls: 'mirador-main-menu-bar', + mainMenuCls: 'mirador-main-menu', + windowOptionsMenuCls: 'mirador-window-options-menu', + clearLocalStorageCls: 'clear-local-storage', + clearLocalStorageDialogCls: 'mirador-main-menu-clear-local-storage', + collectionsListingCls: 'mirador-listing-collections' + }, options); + + this.element = this.element || jQuery('
      '); + + this.init(); + + }; + + + $.MainMenu.prototype = { + + init: function() { + //this.mainMenuHeight = this.parent.mainMenuSettings.height; + //this.mainMenuWidth = this.parent.mainMenuSettings.width; + this.element + .addClass(this.mainMenuBarCls) + //.height(this.mainMenuHeight) + //.width(this.mainMenuWidth) + .appendTo(this.appendTo); + + this.element.append(this.template({ + mainMenuCls: this.mainMenuCls, + showBookmark : this.parent.mainMenuSettings.buttons.bookmark, + showLayout : this.parent.mainMenuSettings.buttons.layout, + showOptions: this.parent.mainMenuSettings.buttons.options, + showFullScreenViewer : this.parent.mainMenuSettings.buttons.fullScreenViewer, + userButtons: this.parent.mainMenuSettings.userButtons, + userLogo: this.parent.mainMenuSettings.userLogo + })); + + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + //change 'change-layout' to mouseover events rather than click? + this.element.find('.change-layout').on('click', function() { + _this.parent.toggleWorkspacePanel(); + }); + this.element.find('.bookmark-workspace').on('click', function() { _this.parent.toggleBookmarkPanel(); + }); + // when options are implemented, this will need to do something + this.element.find('.window-options').on('click', function() { }); + this.element.find('.fullscreen-viewer').on('click', function() { + _this.parent.fullscreenElement() ? _this.parent.exitFullscreen() : _this.parent.enterFullscreen(); + }); + }, + + template: Handlebars.compile([ + '{{#if userLogo}}', + '', + '{{/if}}', + '', + '{{#if userButtons}}', + '{{userbtns userButtons}}', + '{{/if}}' + ].join('')) + }; + + /* Helper methods for processing userButtons provided in configuration */ + + /* Processes userButtons configuration setting * + **************************************************** + * userButtons, if present, should be an array * + * * + * Its elements should be objects, which can * + * have the following attributes: * + * * + * label: text label assigned to the link * + * created. (required) * + * attributes: HTML attributes to add to the * + * button. If there is a "callback" * + * attribute for the button, this MUST * + * exist and MUST contain an "id" value * + * li_attributes: HTML attributes to add to the * + * list item containing the button. * + * iconClass: class or space-separated list of * + * classes. If present, an empty span with * + * these classes will be prepended to the * + * content of the link element + * sublist: Sublist of buttons, to be implemented * + * as a dropdown via CSS/JS * + * ul_attributes: HTML attributes to add to the * + * sublist UL contained in the button. * + * Ignored if button isn't representing * + * a sublist. * + * * + * NOTE: sublist dropdown functionality is not yet * + * implemented * + ****************************************************/ + var processUserButtons = function (btns) { + var output = []; + var btn; + var btns_len = btns.length; + + for (var i = 0; i < btns_len; i++){ + output.push(processUserBtn(btns[i])); + } + return output; + }; + + var processUserBtn = function (btn) { + var $li = jQuery('
    • '); + var $a = jQuery(''); + var $sub_ul; + + try { + /* Enclosing
    • for button */ + if (btn.li_attributes){ + $li.attr(btn.li_attributes); + } + + /* Link for button. */ + if (!btn.label) { + throw "userButtons must have labels"; + } + + $a.text(btn.label); + + if (btn.iconClass) { + $a.prepend(' '); + } + + if (btn.attributes){ + $a.attr(btn.attributes); + } + + $li.append($a); + + /* Sublist if present */ + if (btn.sublist) { + $sub_ul = jQuery('
        '); + if (btn.ul_attributes){ + $sub_ul.attr(btn.ul_attributes); + } + /* Recurse! */ + $sub_ul.append(processUserButtons(btn.sublist)); + + $li.append($sub_ul); + } + + return $li; + } + catch (err) { + console && console.log && console.log(err); + return jQuery(); + } + }; + + Handlebars.registerHelper('userbtns', function (userButtons) { + return new Handlebars.SafeString( + jQuery('
          ').append(processUserButtons(userButtons)).get(0).outerHTML + ); + }); + + Handlebars.registerHelper('userlogo', function (userLogo) { + return new Handlebars.SafeString( + processUserBtn(userLogo).get(0).outerHTML + ); + }); + +}(Mirador)); + +(function ($) { + $.ManifestList = function(options) { + this.appendTo = options.appendTo; + this.manifests = options.manifests; + this.init(); + }; + + $.ManifestList.prototype = { + + init: function() { + this.element = jQuery('
          ').addClass('manifest-load-status-indicator').prependTo(this.appendTo); + this.element.append('

          '); + this.bindEvents(); + }, + + render: function() { + var _this = this; + + var pending = _this.manifests.filter(function(d,i) { + return d.request.state() === 'pending'; + }), + rejected = _this.manifests.filter(function(d,i) { + return d.request.state() === 'rejected'; + }), + resolved = _this.manifests.filter(function(d,i) { + return d.request.state() === 'resolved'; + }); + + // pending, failed, or complete + var requests = d3.select(_this.element[0]) + .selectAll('div.pending') + .data(pending); + + // add new requests to the queue. + requests.enter() + .insert('div', ':nth-child(2)') + .classed('request-status-bar', true) + .classed('pending', true) + .style('left', '3000px') + .transition() + .duration(300) + .style('left', '0'); + + requests.exit() + .classed('pending', false) + .transition() + .duration(300) + .style('opacity', 0) + .remove(); + + d3.select(_this.element.find('h3')[0]) + .text(function() { + var count = pending.length; + return "Loading " + count + " Items..."; + }); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('manifestQueued', function(manifest) { + _this.render(); + }); + jQuery.subscribe('manifestReceived', function(manifest) { + _this.render(); + }); + }, + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + } + }; + +})(Mirador); + +(function($) { + + $.ManifestListItem = function(options) { + + jQuery.extend(true, this, { + element: null, + parent: null, + manifest: null, + loadStatus: null, + thumbHeight: 80, + urlHeight: 150, + resultsWidth: 0, // based on screen width + maxPreviewImagesWidth: 0, + repoWidth: 80, + metadataWidth: 450, + margin: 15, + remainingWidth: 20, + imagesTotalWidth: 0, + tplData: null, + allImages: [], + remaining: 0 + }, options); + + this.init(); + + }; + + $.ManifestListItem.prototype = { + + init: function() { + var _this = this; + //need a better way of calculating this because JS can't get width and margin of hidden elements, so must manually set that info + //ultimately use 95% of space available, since sometimes it still displays too many images + this.maxPreviewImagesWidth = this.resultsWidth - (this.repoWidth + this.margin + this.metadataWidth + this.margin + this.remainingWidth); + this.maxPreviewImagesWidth = this.maxPreviewImagesWidth * 0.95; + + Handlebars.registerHelper('pluralize', function(count, singular, plural) { + if (count === 1) { + return singular; + } else { + return plural; + } + }); + + this.fetchTplData(this.manifestId); + this.element = jQuery(this.template(this.tplData)).prependTo(this.parent.manifestListElement).hide().fadeIn('slow'); + + this.bindEvents(); + }, + + fetchTplData: function() { + var _this = this, + location = _this.manifest.location, + manifest = _this.manifest.jsonLd; + + this.tplData = { + label: manifest.label, + repository: location, + canvasCount: manifest.sequences[0].canvases.length, + images: [] + }; + + this.tplData.repoImage = (function() { + var repo = _this.tplData.repository; + if (manifest.logo) { + if (typeof manifest.logo === "string") + return manifest.logo; + if (typeof manifest.logo['@id'] !== 'undefined') + return manifest.logo['@id']; + } + if (_this.tplData.repository === '(Added from URL)') { + repo = ''; + } + var imageName = $.viewer.repoImages[repo || 'other'] || $.viewer.repoImages.other; + + return $.viewer.buildPath + $.viewer.logosPath + imageName; + })(); + + for ( var i=0; i < manifest.sequences[0].canvases.length; i++) { + var canvas = manifest.sequences[0].canvases[i]; + if (canvas.width === 0) { + continue; + } + + var aspectRatio = canvas.height/canvas.width, + width = (_this.thumbHeight/aspectRatio); + url = _this.manifest.getThumbnailForCanvas(canvas, width); + + _this.allImages.push({ + url: url, + width: width, + height: _this.thumbHeight, + id: canvas['@id'], + index: i + }); + } + + jQuery.each(_this.allImages, function(index, value) { + var width = value.width; + + _this.imagesTotalWidth += (width + _this.margin); + if (_this.imagesTotalWidth >= _this.maxPreviewImagesWidth) { + _this.imagesTotalWidth -= (width + _this.margin); + return false; + } + _this.tplData.images.push(value); + }); + + _this.remaining = this.tplData.remaining = (function() { + var remaining = _this.allImages.length - _this.tplData.images.length; + if (remaining > 0) { + return remaining; + } + })(); + + }, + + render: function() { + + }, + + bindEvents: function() { + var _this = this; + + this.element.find('img').on('load', function() { + //if img width is not equal to the width in the html, change height + jQuery(this).hide().fadeIn(600); + }); + + this.element.on('click', function() { + var windowConfig = { + manifest: _this.manifest, + currentCanvasID: null, + currentFocus: 'ThumbnailsView' + }; + $.viewer.workspace.addWindow(windowConfig); + }); + + this.element.find('.preview-image').on('click', function(e) { + e.stopPropagation(); + var windowConfig = { + manifest: _this.manifest, + currentCanvasID: jQuery(this).attr('data-image-id'), + currentFocus: 'ImageView' + }; + $.viewer.workspace.addWindow(windowConfig); + }); + + jQuery.subscribe('manifestPanelWidthChanged', function(event, newWidth){ + var newMaxPreviewWidth = newWidth - (_this.repoWidth + _this.margin + _this.metadataWidth + _this.margin + _this.remainingWidth); + newMaxPreviewWidth = newMaxPreviewWidth * 0.95; + + //width of browser window has been made smaller + if (newMaxPreviewWidth < _this.maxPreviewImagesWidth ) { + while (_this.imagesTotalWidth >= newMaxPreviewWidth) { + image = _this.tplData.images.pop(); + _this.imagesTotalWidth -= (image.width + _this.margin); + + //remove image from dom + _this.element.find('img[data-image-id="'+image.id+'"]').remove(); + } + //check if need to add ellipsis + if (_this.remaining === 0 && _this.allImages.length - _this.tplData.images.length > 0) { + _this.element.find('.preview-images').after(''); + } + _this.remaining = _this.allImages.length - _this.tplData.images.length; + + } else if (newMaxPreviewWidth > _this.maxPreviewImagesWidth) { + //width of browser window has been made larger + var currentLastImage = _this.tplData.images[_this.tplData.images.length-1], + index = currentLastImage ? currentLastImage.index+1 : 0, + image = _this.allImages[index]; + if (image) { + while (_this.imagesTotalWidth + image.width + _this.margin < newMaxPreviewWidth) { + _this.tplData.images.push(image); + _this.imagesTotalWidth += (image.width + _this.margin); + + //add image to dom + _this.element.find('.preview-images').append(''); + + //get next image + index++; + image = _this.allImages[index]; + if (!image) { + break; + } + } + //check if need to remove ellipsis + if (_this.remaining > 0 && _this.allImages.length - _this.tplData.images.length === 0) { + _this.element.find('.remaining').remove(); + } + _this.remaining = _this.allImages.length - _this.tplData.images.length; + } + } + _this.maxPreviewImagesWidth = newMaxPreviewWidth; + }); + }, + + hide: function() { + var _this = this; + }, + + show: function() { + var _this = this; + }, + + template: Handlebars.compile([ + '
        • ', + '
          ', + 'repoImg', + '
          ', + '', + '
          ', + '{{#each images}}', + '', + '{{/each}}', + '
          ', + '{{#if remaining}}', + '', + '{{/if}}', + '
        • ' + ].join('')) + }; + +}(Mirador)); + + +(function ($) { + $.ManifestLoadStatusIndicator = function(options) { + + this.appendTo = options.appendTo; + this.manifests = options.manifests; + this.init(); + }; + + $.ManifestLoadStatusIndicator.prototype = { + + init: function() { + this.element = jQuery('
          ').addClass('manifest-load-status-indicator').prependTo(this.appendTo); + this.element.append('

          '); + this.bindEvents(); + }, + + render: function() { + var _this = this; + + //console.log(_this.manifests.length); + var pending = _this.manifests.filter(function(d,i) { + return d.request.state() === 'pending'; + }), + rejected = _this.manifests.filter(function(d,i) { + return d.request.state() === 'rejected'; + }), + resolved = _this.manifests.filter(function(d,i) { + return d.request.state() === 'resolved'; + }); + + // pending, failed, or complete + var requests = d3.select(_this.element[0]) + .selectAll('div.pending') + .data(pending); + + //console.log(pending); + + // add new requests to the queue. + requests.enter() + .insert('div', ':nth-child(2)') + .classed('request-status-bar', true) + .classed('pending', true) + .style('left', '3000px') + .transition() + .duration(300) + .style('left', '0'); + + requests.exit() + .classed('pending', false) + .transition() + .duration(300) + .style('opacity', 0) + .remove(); + + d3.select(_this.element.find('h3')[0]) + .text(function() { + var count = pending.length; + return "Loading " + count + " Items..."; + }); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('manifestQueued', function(manifest) { + //console.log('queued'); + _this.render(); + }); + jQuery.subscribe('manifestReceived', function(manifest) { + //console.log('received'); + _this.render(); + }); + }, + + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + } + }; + +})(Mirador); + +(function($) { + + $.ManifestsPanel = function(options) { + + jQuery.extend(true, this, { + element: null, + listItems: null, + appendTo: null, + parent: null, + manifestListItems: [], + manifestListElement: null, + manifestLoadStatusIndicator: null, + resultsWidth: 0 + }, options); + + var _this = this; + _this.init(); + + }; + + $.ManifestsPanel.prototype = { + + init: function() { + this.element = jQuery(this.template({ + showURLBox : this.parent.showAddFromURLBox + })).appendTo(this.appendTo); + this.manifestListElement = this.element.find('ul'); + + //this code gives us the max width of the results area, used to determine how many preview images to show + //cloning the element and adjusting the display and visibility means it won't break the normal flow + var clone = this.element.clone().css("visibility","hidden").css("display", "block").appendTo(this.appendTo); + this.resultsWidth = clone.find('.select-results').outerWidth(); + this.controlsHeight = clone.find('.manifest-panel-controls').outerHeight(); + this.paddingListElement = this.controlsHeight; + this.manifestListElement.css("padding-bottom", this.paddingListElement); + clone.remove(); + + // this.manifestLoadStatusIndicator = new $.ManifestLoadStatusIndicator({ + // manifests: this.parent.manifests, + // appendTo: this.element.find('.select-results') + // }); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + // handle interface events + this.element.find('form#url-load-form').on('submit', function(event) { + event.preventDefault(); + var url = jQuery(this).find('input').val(); + _this.parent.addManifestFromUrl(url, "(Added from URL)"); + //console.log('trying to add from URL'); + }); + + this.element.find('.remove-object-option').on('click', function() { + _this.parent.toggleLoadWindow(); + }); + + // handle subscribed events + jQuery.subscribe('manifestsPanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + jQuery.subscribe('manifestReceived', function(event, newManifest) { + _this.manifestListItems.push(new $.ManifestListItem({ parent: _this, manifest: newManifest, resultsWidth: _this.resultsWidth })); + _this.element.find('#manifest-search').keyup(); + }); + + // Filter manifests based on user input + this.element.find('#manifest-search').on('keyup input', function() { + if (this.value.length > 0) { + _this.element.find('.items-listing li').show().filter(function() { + return jQuery(this).text().toLowerCase().indexOf(_this.element.find('#manifest-search').val().toLowerCase()) === -1; + }).hide(); + } else { + _this.element.find('.items-listing li').show(); + } + }); + + this.element.find('#manifest-search-form').on('submit', function(event) { + event.preventDefault(); + }); + + jQuery(window).resize($.throttle(function(){ + var clone = _this.element.clone().css("visibility","hidden").css("display", "block").appendTo(_this.appendTo); + _this.resultsWidth = clone.find('.select-results').outerWidth(); + clone.remove(); + jQuery.publish("manifestPanelWidthChanged", _this.resultsWidth); + }, 50, true)); + }, + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + }, + + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + + +(function($) { + + $.WorkspacePanel = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + workspace: null, + maxRows: null, + maxColumns: null + }, options); + + this.init(); + + }; + + $.WorkspacePanel.prototype = { + init: function () { + var _this = this, + templateData = { + rows: $.layoutDescriptionFromGridString(_this.maxColumns + 'x' + _this.maxRows).children.map(function(column, rowIndex) { + column.columns = column.children.map(function(row, columnIndex) { + row.gridString = (rowIndex+1) + 'x' + (columnIndex+1); + return row; + }); + return column; + }) + }; + + this.element = jQuery(this.template(templateData)).appendTo(this.appendTo); + var backgroundImage = _this.parent.buildPath + _this.parent.imagesPath + 'debut_dark.png'; + this.element.css('background-image','url('+backgroundImage+')').css('background-repeat','repeat'); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('workspacePanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + _this.element.find('.grid-item').on('click', function() { + var gridString = jQuery(this).data('gridstring'); + _this.onSelect(gridString); + }); + + _this.element.find('.grid-item').on('mouseover', function() { + var gridString = jQuery(this).data('gridstring'); + _this.onHover(gridString); + }); + + _this.element.find('.select-grid').on('mouseout', function() { + _this.element.find('.grid-item').removeClass('hovered'); + _this.element.find('.grid-instructions').show(); + _this.element.find('.grid-text').hide(); + }); + }, + + onSelect: function(gridString) { + var _this = this; + var layoutDescription = $.layoutDescriptionFromGridString(gridString); + _this.workspace.resetLayout(layoutDescription); + _this.parent.toggleWorkspacePanel(); + }, + + onHover: function(gridString) { + var _this = this, + highestRow = gridString.charAt(0), + highestColumn = gridString.charAt(2), + gridItems = _this.element.find('.grid-item'); + gridItems.removeClass('hovered'); + gridItems.filter(function(index) { + var element = jQuery(this); + var change = element.data('gridstring').charAt(0) <= highestRow && element.data('gridstring').charAt(2)<=highestColumn; + return change; + }).addClass('hovered'); + _this.element.find('.grid-instructions').hide(); + _this.element.find('.grid-text').text(gridString).show(); + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + }, + + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + + +(function($){ + + $.Manifest = function(manifestUri, location) { + if (manifestUri.indexOf('info.json') !== -1) { + // The following is an ugly hack. We need to finish the + // Manifesto utility library. + // See: https://github.com/IIIF/manifesto + // + // If manifestUri is not a string, then + // it's an object, namely a light-weight + // dummy manifest wrapped around the + // contents of an an info.json response. + // + // The wrapper is still going to need these + // accessor methods. We can just set the + // jsonLd directly, and the request needs to + // be a jQuery deferred object that is completed + // imediately upon creation. This allows + // components listening for this request to finish + // to react immediately without having to be + // re-written. + jQuery.extend(true, this, { + jsonLd: null, + location: location, + uri: manifestUri, + request: null + }); + + this.initFromInfoJson(manifestUri); + } else { + jQuery.extend(true, this, { + jsonLd: null, + location: location, + uri: manifestUri, + request: null + }); + + this.init(manifestUri); + } + }; + + $.Manifest.prototype = { + init: function(manifestUri) { + var _this = this; + this.request = jQuery.ajax({ + url: manifestUri, + dataType: 'json', + async: true + }); + + this.request.done(function(jsonLd) { + _this.jsonLd = jsonLd; + }); + }, + initFromInfoJson: function(infoJsonUrl) { + var _this = this; + this.request = jQuery.ajax({ + url: infoJsonUrl, + dataType: 'json', + async: true + }); + + this.request.done(function(jsonLd) { + _this.jsonLd = _this.generateInfoWrapper(jsonLd); + }); + }, + getThumbnailForCanvas : function(canvas, width) { + var version = "1.1", + service, + thumbnailUrl; + + // Ensure width is an integer... + width = parseInt(width, 10); + + // Respecting the Model... + if (canvas.hasOwnProperty('thumbnail')) { + // use the thumbnail image, prefer via a service + if (typeof(canvas.thumbnail) == 'string') { + thumbnailUrl = canvas.thumbnail; + } else if (canvas.thumbnail.hasOwnProperty('service')) { + // Get the IIIF Image API via the @context + service = canvas.thumbnail.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } else { + thumbnailUrl = canvas.thumbnail['@id']; + } + } else { + // No thumbnail, use main image + var resource = canvas.images[0].resource; + service = resource['default'] ? resource['default'].service : resource.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } + return thumbnailUrl; + }, + getCanvases : function() { + var _this = this; + return _this.jsonLd.sequences[0].canvases; + }, + getAnnotationsListUrl: function(canvasId) { + var _this = this; + var canvas = jQuery.grep(_this.getCanvases(), function(canvas, index) { + return canvas['@id'] === canvasId; + })[0]; + + if (canvas && canvas.otherContent) { + return canvas.otherContent[0]['@id']; + } else { return false; } + }, + getStructures: function() { + var _this = this; + return _this.jsonLd.structures; + }, + generateInfoWrapper: function(infoJson) { + // Takes in info.json and creates the + // dummy manifest wrapper around it + // that will allow it to behave like a + // manifest with one canvas in it, with + // one image on it. Some of the metadata + // of the image will be used as the + // label, and so on, of the manifest. + var dummyManifest = { + '@context': "http://www.shared-canvas.org/ns/context.json", + '@id': infoJson['@id'], + '@type': 'sc:Manifest', + label: infoJson['@id'].split('/')[infoJson['@id'].split('/').length -1], + sequences: [ + { + '@id': infoJson['@id'] + '/sequence/1', + '@type': 'sc:Sequence', + canvases: [ + { + '@id': infoJson['@id'] + '/sequence/1/canvas/1', + '@type': 'sc:Canvas', + width: infoJson.width, + height: infoJson.height, + images: [ + { + '@id': infoJson['@id'] + '/sequence/1/canvas/1/image/1', + '@type': 'sc:image', + 'motivation': 'sc:painting', + resource: { + '@id': infoJson, + '@type': "dctypes:Image", + format: "image/jpeg", + height: infoJson.width, + width: infoJson.height, + service: { + '@id': infoJson['@id'], + '@context': infoJson['@context'], + 'profile': infoJson.profile + } + } + } + ] + } + ] + } + ] + }; + + return dummyManifest; + } + }; + +}(Mirador)); + +(function($) { + + $.AnnotationTooltip = function(options) { + + jQuery.extend(this, { + element: null, + parent: null, + annotations: [], + windowId: "" + }, options); + + this.init(); + }; + + $.AnnotationTooltip.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + }, + + getEditor: function(annotation) { + var annoText = "", + tags = [], + _this = this; + + if (!jQuery.isEmptyObject(annotation)) { + if (jQuery.isArray(annotation.resource)) { + jQuery.each(annotation.resource, function(index, value) { + if (value['@type'] === "oa:Tag") { + tags.push(value.chars); + } else { + annoText = value.chars; + } + }); + } else { + annoText = annotation.resource.chars; + } + } + + return this.editorTemplate({content : annoText, + tags : tags.join(" "), + id : jQuery.isEmptyObject(annotation) ? "" : annotation['@id'], + windowId : _this.windowId + }); + }, + + getViewer: function(annotations) { + var annoText, + tags = [], + _this = this, + htmlAnnotations = [], + id; + + jQuery.each(annotations, function(index, annotation) { + tags = []; + if (jQuery.isArray(annotation.resource)) { + jQuery.each(annotation.resource, function(index, value) { + if (value['@type'] === "oa:Tag") { + tags.push(value.chars); + } else { + annoText = value.chars; + } + }); + } else { + annoText = annotation.resource.chars; + } + var username = ""; + if (annotation.annotatedBy && annotation.annotatedBy.name) { + username = annotation.annotatedBy.name; + } + //if it is a manifest annotation, don't allow editing or deletion + //otherwise, check annotation in endpoint + var showUpdate = false; + if (annotation.endpoint !== 'manifest') { + showUpdate = annotation.endpoint.userAuthorize('update', annotation); + } + var showDelete = false; + if (annotation.endpoint !== 'manifest') { + showDelete = annotation.endpoint.userAuthorize('delete', annotation); + } + htmlAnnotations.push({ + annoText : annoText, + tags : tags, + id : annotation['@id'], + username : username, + showUpdate : showUpdate, + showDelete : showDelete + }); + }); + + var template = this.viewerTemplate({annotations : htmlAnnotations, + windowId : _this.windowId}); + return template; + //return combination of all of them + }, + + //when this is being used to edit an existing annotation, insert them into the inputs + editorTemplate: Handlebars.compile([ + '
          ', + '', + '', + '
          ', + // need to add a delete, if permissions allow + '
          ', + '{{t "cancel"}}', + '{{t "save"}}', + '
          ', + '
          ', + '
          ' + ].join('')), + + viewerTemplate: Handlebars.compile([ + '
          ', + '{{#each annotations}}', + '
          ', + '
          ', + '{{#if showUpdate}}{{t "edit"}}{{/if}}', + '{{#if showDelete}}{{t "delete"}}{{/if}}', + '
          ', + '
          ', + '{{#if username}}

          {{username}}:

          {{/if}}', + '

          {{{annoText}}}

          ', + '
          ', + '
          ', + '{{#each tags}}', + '{{this}}', + '{{/each}}', + '
          ', + '
          ', + '{{/each}}', + '
          ' + ].join('')) + }; + +}(Mirador)); + +/* + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(options, successCallback, errorCallback) + * create(oaAnnotation, successCallback, errorCallback) + * update(oaAnnotation, successCallback, errorCallback) + * deleteAnnotation(annotationID, successCallback, errorCallback) (delete is a reserved word) + * TODO: + * read() //not currently used + * + * Optional, if endpoint is not OA compliant: + * getAnnotationInOA(endpointAnnotation) + * getAnnotationInEndpoint(oaAnnotation) + */ +(function($){ + + $.CatchEndpoint = function(options) { + + jQuery.extend(this, { + token: null, + prefix: null, + dfd: null, + context_id: "None", + collection_id: "None", + userid: "test@mirador.org", + username: "mirador-test", + annotationsList: [], //OA list for Mirador use + annotationsListCatch: null, //internal list for module use + windowID: null + }, options); + + this.init(); + }; + + $.CatchEndpoint.prototype = { + //Set up some options for catch + init: function() { + this.catchOptions = { + user: { + id: this.userid, + name: this.username + }, + permissions: { + 'read': [], + 'update': [this.userid], + 'delete': [this.userid], + 'admin': [this.userid] + } + }; + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + //Search endpoint for all annotations with a given URI + search: function(options, successCallback, errorCallback) { + var _this = this; + this.annotationsList = []; //clear out current list + + jQuery.ajax({ + url: this.prefix+"/search", + type: 'GET', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: { + uri: options.uri, + userid : options.userid ? options.userid : undefined, + username : options.username ? options.username : undefined, + text : options.text ? options.text : undefined, + tag : options.tag ? options.tag : undefined, + parentid : options.parentid ? options.parentid : undefined, + contextId: _this.context_id, + collectionId: _this.collection_id, + media: options.media ? options.media : "image", + limit: options.limit ? options.limit : -1 + }, + + contentType: "application/json; charset=utf-8", + success: function(data) { + //check if a function has been passed in, otherwise, treat it as a normal search + if (typeof successCallback === "function") { + successCallback(data); + } else { + _this.annotationsListCatch = data.rows; + jQuery.each(_this.annotationsListCatch, function(index, value) { + _this.annotationsList.push(_this.getAnnotationInOA(value)); + }); + _this.dfd.resolve(true); + jQuery.publish('catchAnnotationsLoaded.'+_this.windowID, _this.annotationsListCatch); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } else { + console.log("There was an error searching this endpoint"); + } + } + + }); + }, + + deleteAnnotation: function(annotationID, successCallback, errorCallback) { + var _this = this; + jQuery.ajax({ + url: this.prefix+"/destroy/"+annotationID, + type: 'DELETE', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + jQuery.publish('catchAnnotationDeleted.'+_this.windowID, annotationID); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + + }); + }, + + update: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation), + _this = this, + annotationID = annotation.id; + + jQuery.ajax({ + url: this.prefix+"/update/"+annotationID, + type: 'POST', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + jQuery.publish('catchAnnotationUpdated.'+_this.windowID, annotation); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //takes OA Annotation, gets Endpoint Annotation, and saves + //if successful, MUST return the OA rendering of the annotation + create: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation); + this.createCatchAnnotation(annotation, successCallback, errorCallback); + }, + + createCatchAnnotation: function(catchAnnotation, successCallback, errorCallback) { + var _this = this; + + jQuery.ajax({ + url: this.prefix+"/create", + type: 'POST', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: JSON.stringify(catchAnnotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(_this.getAnnotationInOA(data)); + } + jQuery.publish('catchAnnotationCreated.'+_this.windowID, data); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + userAuthorize: function(action, annotation) { + var token, tokens, _i, _len; + //if this is an instructor, they have access to student annotations + if (this.roles && (this.roles.indexOf('Instructor') !== -1 || this.roles.indexOf('Administrator') !== -1)){ + return true; + } + //otherwise check annotation permissions + if (annotation.permissions) { + var permissionUserIds = annotation.permissions[action] || []; + //if no userids set for a permission, it is open to everyone + if (permissionUserIds.length === 0) { + return true; + } + //otherwise compare userid of annotation to current userid + if (permissionUserIds.indexOf(this.userid) !== -1) { + return true; + } + return false; + } else if (annotation.user) { + //if no permissions, just check userids + return this.userid === annotation.user.userid; + } + //otherwise, just return true + return true; + }, + + //Convert Endpoint annotation to OA + getAnnotationInOA: function(annotation) { + var id, + motivation = [], + resource = [], + on, + annotatedBy; + //convert annotation to OA format + + id = annotation.id; //need to make URI + + if (annotation.tags.length > 0) { + motivation.push("oa:tagging"); + jQuery.each(annotation.tags, function(index, value) { + resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + if (annotation.parent && annotation.parent !== "0") { + motivation.push("oa:replying"); + on = annotation.parent; //need to make URI + } else { + motivation.push("oa:commenting"); + on = { "@type" : "oa:SpecificResource", + "source" : annotation.uri, + "selector" : { + "@type" : "oa:FragmentSelector", + "value" : "xywh="+annotation.rangePosition.x+","+annotation.rangePosition.y+","+annotation.rangePosition.width+","+annotation.rangePosition.height + }, + "scope": { + "@context" : "http://www.harvard.edu/catch/oa.json", + "@type" : "catch:Viewport", + "value" : "xywh="+annotation.bounds.x+","+annotation.bounds.y+","+annotation.bounds.width+","+annotation.bounds.height + } + }; + } + resource.push( { + "@type" : "dctypes:Text", + "format" : "text/html", + "chars" : annotation.text + }); + + annotatedBy = { "@id" : annotation.user.id, + "name" : annotation.user.name}; + + var oaAnnotation = { + "@context" : "http://iiif.io/api/presentation/2/context.json", + "@id" : String(id), + "@type" : "oa:Annotation", + "motivation" : motivation, + "resource" : resource, + "on" : on, + "annotatedBy" : annotatedBy, + "annotatedAt" : annotation.created, + "serializedAt" : annotation.updated, + "permissions" : annotation.permissions, + "endpoint" : this + }; + return oaAnnotation; + }, + + // Converts OA Annotation to endpoint format + getAnnotationInEndpoint: function(oaAnnotation) { + var annotation = {}, + tags = [], + text; + + if (oaAnnotation["@id"]) { + annotation.id = oaAnnotation["@id"]; + } + + annotation.media = "image"; + jQuery.each(oaAnnotation.resource, function(index, value) { + if (value['@type'] === 'oa:Tag') { + tags.push(value.chars); + } else if (value['@type'] === 'dctypes:Text') { + text = value.chars; + } + }); + annotation.tags = tags; + annotation.text = text; + + annotation.uri = oaAnnotation.on.source; + annotation.contextId = this.context_id; + annotation.collectionId = this.collection_id; + + var region = oaAnnotation.on.selector.value; + var regionArray = region.split('=')[1].split(','); + annotation.rangePosition = {"x":regionArray[0], "y":regionArray[1], "width":regionArray[2], "height":regionArray[3]}; + + var imageUrl = $.Iiif.getImageUrl(this.parent.imagesList[$.getImageIndexById(this.parent.imagesList, oaAnnotation.on.source)]); + imageUrl = imageUrl + "/" + regionArray.join(',') + "/full/0/native.jpg"; + annotation.thumb = imageUrl; + + region = oaAnnotation.on.scope.value; + regionArray = region.split('=')[1].split(','); + annotation.bounds = {"x":regionArray[0], "y":regionArray[1], "width":regionArray[2], "height":regionArray[3]}; + + annotation.updated = new Date().toISOString(); + if (oaAnnotation.annotatedAt) { + annotation.created = oaAnnotation.annotatedAt; + } else { + annotation.created = annotation.updated; + } + // this needs to come from LTI annotation.user.id, annotation.user.name + annotation.user = {}; + if (oaAnnotation.annotatedBy) { + annotation.user.name = oaAnnotation.annotatedBy.name; + annotation.user.id = oaAnnotation.annotatedBy['@id']; + } else { + annotation.user = this.catchOptions.user; + } + annotation.permissions = this.catchOptions.permissions; + annotation.archived = false; + annotation.ranges = []; + annotation.parent = "0"; + return annotation; + } + }; + +}(Mirador)); + +/* + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(options, successCallback, errorCallback) + * create(oaAnnotation, successCallback, errorCallback) + * update(oaAnnotation, successCallback, errorCallback) + * deleteAnnotation(annotationID, successCallback, errorCallback) (delete is a reserved word) + * TODO: + * read() //not currently used + * + * Optional, if endpoint is not OA compliant: + * getAnnotationInOA(endpointAnnotation) + * getAnnotationInEndpoint(oaAnnotation) + */ +(function($){ + + $.Endpoint = function(options) { + + jQuery.extend(this, { + dfd: null, + annotationsList: [], //OA list for Mirador use + windowID: null, + parent: null + }, options); + + this.init(); + }; + + $.Endpoint.prototype = { + init: function() { + //whatever initialization your endpoint needs + }, + + //Search endpoint for all annotations with a given URI in options + search: function(options, successCallback, errorCallback) { + var _this = this; + + //use options.uri + jQuery.ajax({ + url: '', + type: 'GET', + dataType: 'json', + headers: { }, + data: { }, + contentType: "application/json; charset=utf-8", + success: function(data) { + //check if a function has been passed in, otherwise, treat it as a normal search + if (typeof successCallback === "function") { + successCallback(data); + } else { + jQuery.each(data, function(index, value) { + _this.annotationsList.push(_this.getAnnotationInOA(value)); + }); + _this.dfd.resolve(true); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //Delete an annotation by endpoint identifier + deleteAnnotation: function(annotationID, successCallback, errorCallback) { + var _this = this; + jQuery.ajax({ + url: '', + type: 'DELETE', + dataType: 'json', + headers: { }, + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //Update an annotation given the OA version + update: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation), + _this = this; + + jQuery.ajax({ + url: '', + type: 'POST', + dataType: 'json', + headers: { }, + data: '', + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //takes OA Annotation, gets Endpoint Annotation, and saves + //if successful, MUST return the OA rendering of the annotation + create: function(oaAnnotation, successCallback, errorCallback) { + var _this = this; + + jQuery.ajax({ + url: '', + type: 'POST', + dataType: 'json', + headers: { }, + data: '', + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(_this.getAnnotationInOA(data)); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + //Convert Endpoint annotation to OA + getAnnotationInOA: function(annotation) { + }, + + // Converts OA Annotation to endpoint format + getAnnotationInEndpoint: function(oaAnnotation) { + } + }; + +}(Mirador)); + +(function($) { + + // Takes a list of oa:annotations passed + // by reference and renders their regions, + // registering updates. + + $.OsdCanvasRenderer = function(options) { + + jQuery.extend(this, { + osd: null, + osdViewer: null, + elements: null, + list: null, + parent: null, //annotationsLayer + annoTooltips: {}, + tooltips: null, + overlays: [], + inEditOrCreateMode: false + }, options); + + this.bindEvents(); + }; + + $.OsdCanvasRenderer.prototype = { + parseRegion: function(url) { + var regionString; + if (typeof url === 'object') { + regionString = url.selector.value; + } else { + regionString = url.split('#')[1]; + } + var regionArray = regionString.split('=')[1].split(','); + return regionArray; + }, + + getOsdFrame: function(region) { + var rectX = region[0], + rectY = region[1], + rectW = region[2], + rectH = region[3]; + + return this.osdViewer.viewport.imageToViewportRectangle(rectX,rectY,rectW,rectH); + + }, + + render: function() { + var _this = this; + _this.hideAll(), + this.overlays = []; + + var deferreds = jQuery.map(this.list, function(annotation) { + var deferred = jQuery.Deferred(), + region = _this.parseRegion(annotation.on), + osdOverlay = document.createElement('div'); + osdOverlay.className = 'annotation'; + osdOverlay.id = annotation['@id']; + _this.osdViewer.addHandler("add-overlay", function() { + deferred.resolve(); + }); + _this.osdViewer.addOverlay({ + element: osdOverlay, + location: _this.getOsdFrame(region) + }); + _this.overlays.push(jQuery(osdOverlay)); + return deferred; + }); + //this still doesn't take into account the actual appending of the overlays to the DOM + //so not quite there yet + jQuery.when.apply(jQuery, deferreds).done(function() { + jQuery.publish('overlaysRendered.' + _this.parent.windowId); + }); + + this.tooltips = jQuery(this.osdViewer.element).qtip({ + overwrite : false, + content: { + text : '' + }, + position : { + target : 'mouse', + my: 'bottom left', + at: 'top right', + adjust : { + mouse: false, + method: 'shift' + }, + //when the side panel is active and visible, it messes up the offset for the qtip + //which means that qtips will disappear for annotations that are on the far right side of the canvas + //so we need the container and viewport to be the element that encompasses everything, + //which can be the window or slot. we need a better way of getting this element + //because this is brittle + container: _this.parent.parent.parent.element, //window's element + viewport: _this.parent.parent.parent.element //window's element + }, + style : { + classes : 'qtip-bootstrap qtip-viewer' + }, + show: { + delay: 20, + event: false + }, + hide: { + fixed: true, + delay: 50, + event: false + }, + events: { + show: function(event, api) { + _this.setTooltipContent(event, api); + }, + visible: function(event, api) { + _this.removeAnnotationEvents(event, api); + _this.annotationEvents(event, api); + }, + move: function(event, api) { + _this.removeAnnotationEvents(event, api); + _this.annotationEvents(event, api); + _this.annotationSaveEvent(event, api); + }, + hidden: function(event, api) { + if (jQuery('.qtip:visible').length === 0) { + jQuery(_this.osdViewer.canvas).find('.annotation').removeClass('hovered');//.css('border-color', 'deepSkyBlue'); + } + } + } + }); + }, + + setTooltipContent: function(event, api) { + var overlays = this.getOverlaysFromElement(jQuery(event.originalEvent.currentTarget), event.originalEvent), + _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), //pass permissions + annotations = []; + + jQuery.each(overlays, function(index, overlay) { + annotations.push(_this.getAnnoFromRegion(overlay.id)[0]); + }); + api.set({'content.text' : annoTooltip.getViewer(annotations)}); + jQuery.publish('tooltipViewerSet.'+_this.parent.windowId); + }, + + getAnnoFromRegion: function(regionId) { + return this.list.filter(function(annotation) { + return annotation['@id'] === regionId; + }); + }, + + showTooltipsFromMousePosition: function(event) { + var overlays = this.getOverlaysFromMousePosition(event); + var api = jQuery(this.osdViewer.element).qtip('api'); + if (api) { + if (overlays.length === 0) { + api.hide(event); + } else if (api.elements.tooltip && api.elements.tooltip.is(':visible')) { + this.setTooltipContent(event, api); + api.cache.origin = event; + api.reposition(event, true); + } else { + api.show(event); + } + } + }, + + getOverlaysFromMousePosition: function(event) { + var position = OpenSeadragon.getMousePosition(event); + var _this = this, + overlays = jQuery(_this.osdViewer.canvas).find('.annotation').map(function() { + var self = jQuery(this), + offset = self.offset(), + l = offset.left, + t = offset.top, + h = self.height(), + w = self.width(), + x = position.x, + y = position.y, + maxx = l+w, + maxy = t+h; + return (y <= maxy && y >= t) && (x <= maxx && x >= l) ? this : null; + }); + return overlays; + }, + getOverlaysFromElement: function(element, event) { + var _this = this, + overlays = this.getOverlaysFromMousePosition(event); + jQuery(_this.osdViewer.canvas).find('.annotation.hovered').removeClass('hovered');//.css('border-color', 'deepSkyBlue'); + overlays.addClass('hovered'); + /*jQuery.each(overlays, function(index, value) { + jQuery(value).css('border-color', _this.getRandomColor()); + });*/ + return overlays; + }, + + getRandomColor: function() { + var colors = this.hsvToRgb(Math.random() * 360, 50, 100); + //return "#" + Math.floor(Math.random() * 0xFFFFFF).toString(16); + return 'rgb('+colors[0]+','+colors[1]+','+colors[2]+')'; + }, + + /** + * From: http://snipplr.com/view.php?codeview&id=14590 + * HSV to RGB color conversion + * + * H runs from 0 to 360 degrees + * S and V run from 0 to 100 + * + * Ported from the excellent java algorithm by Eugene Vishnevsky at: + * http://www.cs.rit.edu/~ncs/color/t_convert.html + */ + hsvToRgb: function(h, s, v) { + var r, g, b; + var i; + var f, p, q, t; + + // Make sure our arguments stay in-range + h = Math.max(0, Math.min(360, h)); + s = Math.max(0, Math.min(100, s)); + v = Math.max(0, Math.min(100, v)); + + // We accept saturation and value arguments from 0 to 100 because that's + // how Photoshop represents those values. Internally, however, the + // saturation and value are calculated from a range of 0 to 1. We make + // That conversion here. + s /= 100; + v /= 100; + + if(s === 0) { + // Achromatic (grey) + r = g = b = v; + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + } + + h /= 60; // sector 0 to 5 + i = Math.floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch(i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + default: // case 5: + r = v; + g = p; + b = q; + } + + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + }, + + bindEvents: function() { + var _this = this; + + jQuery(this.osdViewer.canvas).parent().on('mousemove', $.throttle(function(event) { + if (!_this.inEditOrCreateMode) { + _this.showTooltipsFromMousePosition(event); + } + }, 200, true)); + + this.osdViewer.addHandler('zoom', $.debounce(function(){ + _this.hideVisibleTooltips(); + }, 200, true)); + + jQuery.subscribe('removeTooltips.' + _this.parent.windowId, function() { + jQuery(_this.osdViewer.canvas).find('.annotation').qtip('destroy', true); + }); + + jQuery.subscribe('disableTooltips.' + _this.parent.windowId, function() { + _this.inEditOrCreateMode = true; + }); + + jQuery.subscribe('enableTooltips.' + _this.parent.windowId, function() { + _this.inEditOrCreateMode = false; + }); + + jQuery.subscribe('removeOverlay.' + _this.parent.windowId, function(event, annoId) { + //remove this annotation's overlay from osd + _this.osdViewer.removeOverlay(jQuery(_this.osdViewer.element).find(".annotation#"+annoId)[0]); + }); + + }, + + hideVisibleTooltips: function() { + jQuery('.qtip-viewer').qtip('hide'); + }, + + update: function() { + this.render(); + }, + + hideAll: function() { + this.osdViewer.clearOverlays(); + }, + + getElements: function() { + this.elements = this.osdViewer.currentOverlays.reduce(function(result, currentOverlay) { + currentOverlay = jQuery(currentOverlay); + return result.add(currentOverlay); + }); + return elements; + }, + + //change content of this tooltip, and disable hiding it, until user clicks save or cancel + //disable all other qtips until editing this is done + freezeQtip: function(api, oaAnno, annoTooltip) { + this.inEditOrCreateMode = true; + jQuery.publish('disableRectTool.'+this.parent.windowId); + api.set({'content.text' : annoTooltip.getEditor(oaAnno), + 'hide.event' : false}); + jQuery.publish('annotationEditorAvailable.'+this.parent.windowId); + //add rich text editor + tinymce.init({ + selector : 'form.annotation-tooltip textarea', + plugins: "image link media", + menubar: false, + statusbar: false, + toolbar_items_size: 'small', + toolbar: "bold italic | bullist numlist | link image media | removeformat", + setup : function(editor) { + editor.on('init', function(args) { + tinymce.execCommand('mceFocus', false, args.target.id); //make sure tinymce focuses on the editor after initialization + }); + } + }); + jQuery(api.elements.tooltip).removeClass("qtip-viewer"); //so it is not affected by zoom event raised in OSD + this.osdViewer.zoomPerClick = 1; + this.osdViewer.zoomPerScroll = 1; + }, + + //reenable all other qtips + //update content of this qtip to make it a viewer, not editor + //and reset hide event + unFreezeQtip: function(api, oaAnno, annoTooltip) { + this.inEditOrCreateMode = false; + jQuery.publish('enableRectTool.'+this.parent.windowId); + api.set({'content.text' : annoTooltip.getViewer([oaAnno]), + 'hide.event' : 'mouseleave'}).hide(); + jQuery(api.elements.tooltip).addClass("qtip-viewer"); //re-add class so it is affected by zoom event raised in OSD + this.osdViewer.zoomPerClick = 2; + this.osdViewer.zoomPerScroll = 1.2; + }, + + removeAnnotationEvents: function(tooltipevent, api) { + var _this = this, + editorSelector = '#annotation-editor-'+_this.parent.windowId, + viewerSelector = '#annotation-viewer-'+_this.parent.windowId; + jQuery(viewerSelector+' a.delete').off("click"); + jQuery(viewerSelector+' a.edit').off("click"); + jQuery(editorSelector+' a.save').off("click"); + jQuery(editorSelector+' a.cancel').off("click"); + }, + + annotationEvents: function(tooltipevent, api) { + var _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), + selector = '#annotation-viewer-'+_this.parent.windowId; + jQuery(selector+' a.delete').on("click", function(event) { + event.preventDefault(); + + if (!window.confirm("Do you want to delete this annotation?")) { + return false; + } + + var display = jQuery(this).parents('.annotation-display'), + id = display.attr('data-anno-id'); + //oaAnno = _this.getAnnoFromRegion(id)[0]; + jQuery.publish('annotationDeleted.'+_this.parent.windowId, [id]); + + //hide tooltip so event handlers don't get messed up + api.hide(); + display.remove(); //remove this annotation display from dom + }); + + jQuery(selector+' a.edit').on("click", function(event) { + event.preventDefault(); + + var display = jQuery(this).parents('.annotation-display'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + _this.freezeQtip(api, oaAnno, annoTooltip); + }); + }, + + annotationSaveEvent: function(event, api) { + var _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), + selector = '#annotation-editor-'+_this.parent.windowId; + + jQuery(selector).on("submit", function(event) { + event.preventDefault(); + jQuery(selector+' a.save').click(); + }); + + jQuery(selector+' a.save').on("click", function(event) { + event.preventDefault(); + + var display = jQuery(this).parents('.annotation-tooltip'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + //check if new resourceText is empty?? + var tagText = jQuery(this).parents('.annotation-editor').find('.tags-editor').val(), + resourceText = tinymce.activeEditor.getContent(), + tags = []; + tagText = $.trimString(tagText); + if (tagText) { + tags = tagText.split(/\s+/); + } + + var bounds = _this.osdViewer.viewport.getBounds(true); + var scope = _this.osdViewer.viewport.viewportToImageRectangle(bounds); + //bounds is giving negative values? + //update scope + oaAnno.on.scope.value = "xywh="+Math.round(scope.x)+","+Math.round(scope.y)+","+Math.round(scope.width)+","+Math.round(scope.height); //osd bounds + + var motivation = [], + resource = []; + + //remove all tag-related content in annotation + oaAnno.motivation = jQuery.grep(oaAnno.motivation, function(value) { + return value !== "oa:tagging"; + }); + oaAnno.resource = jQuery.grep(oaAnno.resource, function(value) { + return value["@type"] !== "oa:Tag"; + }); + //re-add tagging if we have them + if (tags.length > 0) { + oaAnno.motivation.push("oa:tagging"); + jQuery.each(tags, function(index, value) { + oaAnno.resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + jQuery.each(oaAnno.resource, function(index, value) { + if (value["@type"] === "dctypes:Text") { + value.chars = resourceText; + } + }); + //save to endpoint + jQuery.publish('annotationUpdated.'+_this.parent.windowId, [oaAnno]); + + _this.unFreezeQtip(api, oaAnno, annoTooltip); + }); + + jQuery(selector+' a.cancel').on("click", function(event) { + event.preventDefault(); + var display = jQuery(this).parents('.annotation-tooltip'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + _this.unFreezeQtip(api, oaAnno, annoTooltip); + }); + + } + }; +})(Mirador); + +(function($) { + // Takes an openSeadragon canvas and calls + // provided callbacks at different stages + // of a rectangle creation event. + + $.OsdRegionRectTool = function(options) { + jQuery.extend(this, { + osdRectTool: null, + osd: null, + osdViewer: null, + mouseStart: null, + rectangle: null, + rectClass: null, + osdOverlay: null, + dragging: false, + rectangleDrawn: false, + disableRectTool: false, + parent: null + }, options); + + this.init(); + }; + + $.OsdRegionRectTool.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + jQuery.subscribe('disableRectTool.' + _this.parent.windowId, function() { + _this.disableRectTool = true; + }); + + jQuery.subscribe('enableRectTool.' + _this.parent.windowId, function() { + _this.disableRectTool = false; + }); + }, + + reset: function(osdViewer) { + this.dragging = false; + this.osdOverlay = null; + this.rectangle = null; + this.mouseStart = null; + this.osdViewer = osdViewer; + }, + + enterEditMode: function() { + var _this = this; + this.setOsdFrozen(true); + this.osdViewer.addHandler("canvas-drag", _this.startRectangle, {recttool: _this}); + this.osdViewer.addHandler("canvas-drag-end", _this.finishRectangle, {recttool: _this}); + this.onModeEnter(); + }, + + exitEditMode: function(event) { + var _this = this; + this.setOsdFrozen(false); + this.osdViewer.removeHandler('canvas-drag', _this.startRectangle); + this.osdViewer.removeHandler('canvas-drag-end', _this.finishRectangle); + this.onModeExit(); + }, + + setOsdFrozen: function(freeze) { + if (freeze) { + // Control the openSeadragon canvas behaviour + // so that it doesn't move around while we're + // trying to edit our rectangle. + this.osdViewer.panHorizontal = false; + this.osdViewer.panVertical = false; + } else { + this.osdViewer.panHorizontal = true; + this.osdViewer.panVertical = true; + } + }, + + /* + * Here is a different way of checking if the mouse is inside the image. The response to the user feels slower + * so it doesn't feel as great. + startRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (!_this.dragging) { + _this.dragging = true; + var currentMouse = _this.osdViewer.viewport.pointFromPixel(event.position); + if (_this.isMouseInImage(currentMouse)) { + _this.mouseStart = currentMouse; + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } + } else { + var mouseNow = _this.osdViewer.viewport.pointFromPixel(event.position); + if (_this.isMouseInImage(mouseNow)) { + if (_this.mouseStart) { + _this.updateRectangle(_this.mouseStart, mouseNow); + _this.onDraw(); + } else { + _this.mouseStart = mouseNow; + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } + } + } + },*/ + + startRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (!_this.rectangleDrawn && !_this.disableRectTool) { + if (!_this.dragging) { + _this.dragging = true; + _this.mouseStart = _this.getMousePositionInImage(_this.osdViewer.viewport.pointFromPixel(event.position)); + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } else { + var mouseNow = _this.getMousePositionInImage(_this.osdViewer.viewport.pointFromPixel(event.position)); + _this.updateRectangle(_this.mouseStart, mouseNow); + _this.onDraw(); + } + } + }, + + createRectangle: function(mouseStart) { + var x = mouseStart.x, + y = mouseStart.y, + width = 0, + height = 0; + this.rectangle = new OpenSeadragon.Rect(x, y, width, height); + this.osdOverlay = document.createElement('div'); + this.osdOverlay.className = 'osd-select-rectangle'; + this.osdViewer.addOverlay({ + element: this.osdOverlay, + location: this.rectangle + }); + }, + + updateRectangle: function(mouseStart, mouseNow) { + var topLeft = { + x:Math.min(mouseStart.x, mouseNow.x), + y:Math.min(mouseStart.y, mouseNow.y) + }, + bottomRight = { + x:Math.max(mouseStart.x, mouseNow.x), + y:Math.max(mouseStart.y, mouseNow.y) + }; + + this.rectangle.x = topLeft.x; + this.rectangle.y = topLeft.y; + this.rectangle.width = bottomRight.x - topLeft.x; + this.rectangle.height = bottomRight.y - topLeft.y; + + this.osdViewer.updateOverlay(this.osdOverlay, this.rectangle); + }, + + finishRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (_this.rectangle) { + _this.dragging = false; + var osdImageRect = _this.osdViewer.viewport.viewportToImageRectangle(_this.rectangle); + var canvasRect = { + x: parseInt(osdImageRect.x, 10), + y: parseInt(osdImageRect.y, 10), + width: Math.max(parseInt(osdImageRect.width, 10), 1), //don't allow 0 pixel width or height + height: Math.max(parseInt(osdImageRect.height, 10), 1) //don't allow 0 pixel width or height + }; + _this.rectangleDrawn = true; + var tooltip = _this.onDrawFinish(canvasRect); + //show after creation so we don't have to wait for user to make sure mouse is inside overlay + tooltip.qtip('show'); + _this.rectangle = null; + _this.mouseStart = null; + } + }, + + getMousePositionInImage: function(mousePosition) { + if (mousePosition.x < 0) { + mousePosition.x = 0; + } + if (mousePosition.x > 1) { + mousePosition.x = 1; + } + if (mousePosition.y < 0) { + mousePosition.y = 0; + } + if (mousePosition.y > (1/this.osdViewer.source.aspectRatio)) { + mousePosition.y = (1/this.osdViewer.source.aspectRatio); + } + return mousePosition; + }, + + isMouseInImage: function(mousePosition) { + if (mousePosition.x < 0) { + return false; + } + if (mousePosition.x > 1) { + return false; + } + if (mousePosition.y < 0) { + return false; + } + if (mousePosition.y > (1/this.osdViewer.source.aspectRatio)) { + return false; + } + return true; + }, + + //Currently the rect is + // kept in openSeaDragon format until it is returned on "onDrawFinish". + // The intent here is to update the annotation continuously rather than + // only on the end of the draw event so rendering is always handled by + // renderer instead of only at the end of the process, since different + // rendering methods may be used. + + onDrawFinishOld: function(canvasRect) { + var parent = this.parent, + _this = this; + + var topLeftImagePoint = new OpenSeadragon.Point(canvasRect.x, canvasRect.y); + + }, + + onDrawFinish: function(canvasRect) { + var _this = this, + parent = this.parent, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}); //pass permissions + var tooltip = jQuery(this.osdOverlay).qtip({ + content: { + text : annoTooltip.getEditor({}) + }, + position : { + my: 'bottom left', + at: 'top right', + adjust : { + method: 'flipinvert' + }, + //when the side panel is active and visible, it messes up the offset for the qtip + //which means that qtips will disappear for annotations that are on the far right side of the canvas + //so we need the container and viewport to be the element that encompasses everything, + //which can be the window or slot. we need a better way of getting this element + //because this is brittle + container: _this.parent.parent.parent.element, //window's element + viewport: _this.parent.parent.parent.element //window's element + }, + style : { + classes : 'qtip-bootstrap' + }, + show: { + event: false + }, + hide: { + fixed: true, + delay: 300, + event: false + }, + events: { + render: function(event, api) { + + jQuery.publish('annotationEditorAvailable.'+parent.windowId); + + //disable all tooltips for overlays + jQuery.publish('disableTooltips.'+parent.windowId); + //disable zooming + _this.osdViewer.zoomPerClick = 1; + _this.osdViewer.zoomPerScroll = 1; + + var selector = '#annotation-editor-'+parent.windowId; + + tinymce.init({ + selector : selector+' textarea', + plugins: "image link media", + menubar: false, + statusbar: false, + toolbar_items_size: 'small', + toolbar: "bold italic | bullist numlist | link image media | removeformat", + setup : function(editor) { + editor.on('init', function(args) { + tinymce.execCommand('mceFocus', false, args.target.id); //make sure tinymce focuses on the editor after initialization + }); + } + }); + + jQuery(selector).on("submit", function(event) { + event.preventDefault(); + jQuery(selector+' a.save').click(); + }); + + jQuery(selector+' a.cancel').on("click", function(event) { + event.preventDefault(); + //add check so that dialog box only pops up if there is stuff in the editor + var content = tinymce.activeEditor.getContent(); + if (content) { + if (!window.confirm("Do you want to cancel this annotation?")) { + return false; + } + } + api.destroy(); + _this.rectangleDrawn = false; + _this.osdViewer.removeOverlay(_this.osdOverlay); + //reenable viewer tooltips + jQuery.publish('enableTooltips.'+parent.windowId); + _this.osdViewer.zoomPerClick = 2; + _this.osdViewer.zoomPerScroll = 1.2; + }); + + jQuery(selector+' a.save').on("click", function(event) { + event.preventDefault(); + var tagText = jQuery(this).parents('.annotation-editor').find('.tags-editor').val(), + resourceText = tinymce.activeEditor.getContent(), + tags = []; + tagText = $.trimString(tagText); + if (tagText) { + tags = tagText.split(/\s+/); + } + + var bounds = _this.osdViewer.viewport.getBounds(true); + var scope = _this.osdViewer.viewport.viewportToImageRectangle(bounds); + //bounds is giving negative values? + + var motivation = [], + resource = [], + on; + + if (tags && tags.length > 0) { + motivation.push("oa:tagging"); + jQuery.each(tags, function(index, value) { + resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + motivation.push("oa:commenting"); + on = { "@type" : "oa:SpecificResource", + "source" : parent.parent.canvasID, + "selector" : { + "@type" : "oa:FragmentSelector", + "value" : "xywh="+canvasRect.x+","+canvasRect.y+","+canvasRect.width+","+canvasRect.height + }, + "scope": { + "@context" : "http://www.harvard.edu/catch/oa.json", + "@type" : "catch:Viewport", + "value" : "xywh="+Math.round(scope.x)+","+Math.round(scope.y)+","+Math.round(scope.width)+","+Math.round(scope.height) //osd bounds + } + }; + resource.push( { + "@type" : "dctypes:Text", + "format" : "text/html", + "chars" : resourceText + }); + var oaAnno = { + "@context" : "http://iiif.io/api/presentation/2/context.json", + "@type" : "oa:Annotation", + "motivation" : motivation, + "resource" : resource, + "on" : on + }; + //save to endpoint + jQuery.publish('annotationCreated.'+parent.windowId, [oaAnno, _this.osdOverlay]); + + //update content of this qtip to make it a viewer, not editor + api.destroy(); + _this.rectangleDrawn = false; + //reenable viewer tooltips + jQuery.publish('enableTooltips.'+parent.windowId); + _this.osdViewer.zoomPerClick = 2; + _this.osdViewer.zoomPerScroll = 1.2; + }); + } + } + }); + return tooltip; + }, + + onDrawStart: function() { // use new $.oaAnnotation() to create new + // annotation and pass it around for updating + }, + + onModeEnter: function() { // do reasonable things to the renderer to make + // things intelligible + }, + + onModeExit: function() { + // do reasonable things to renderer to return to "normal". + }, + + onDraw: function() { + // update annotation + } + + // MIGHT BE NICE IF...: + // + // If the user is mid-drag and hits the side of the + // canvas, the canvas auto-pans and auto-zooms out + // to accomodate the rectangle. + // + // The size of the rectangle just before colliding with + // the canvas is auto-saved, so that the canvas can shrink + // back down again if the user starts shrinking it in + // mid-drag, allowing the auto-shrinking to stop when + // the original size of the rectangle is reached again. + // + // The existing rectangles should also be moveable by + // shift-clicking and dragging them, showing the + // cross-hair cursor type. + +// osdRegionRectTool = { +// enterEditMode: enterEditMode, +// exitEditMode: exitEditMode +// }; +// +// return osdRegionRectTool; + + }; +}(Mirador)); + +/* + * Edited version of https://github.com/IIIF/mirador/blob/9e3c6bbb894e044d01ad51aae1b70309939de5a9/js/src/annotations/catchEndpoint.js + * This module tries to store the annotation as is in a RDF store but some fiddeling is required. Fidles are: + * + * - delete annotation fails if id has a / in it so have to send sanatised ids to mirador + * - mirador requires an endpoint variable in the annotation pointing to this class. + * + * Note: this endpoint doesn't currently support authentication, just returns allow all + * + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(uri) + * create(oaAnnotation, returnSuccess, returnError) + * update(oaAnnotation, returnSuccess, returnError) + * deleteAnnotation(annotationID, returnSuccess, returnError) (delete is a reserved word) + * TODO: + * There is a bug in that if you create an annotation and then delete it (without moving pages) then click either the write annotation button + * or try to create a new annotation the deleted annotation re-appears. Changing pages fixes the issue as the annoation is delete from the annotation store + * + */ +(function($){ + + $.SimpleASEndpoint = function(options) { + + jQuery.extend(this, { + token: null, + // prefix: 'annotation', /**/ + uri: null, + url: options.url, + dfd: null, + annotationsList: [], //OA list for Mirador use + idMapper: {} // internal list for module use to map id to URI + }, options); + + this.init(); + }; + + $.SimpleASEndpoint.prototype = { + //Any set up for this endpoint, and triggers a search of the URI passed to object + init: function() { + this.catchOptions = { + user: { + id: this.userid, + name: this.username + }, + permissions: { + 'read': [], + 'update': [this.userid], + 'delete': [this.userid], + 'admin': [this.userid] + } + }; + this.search({ uri: this.uri }); + }, + + //Search endpoint for all annotations with a given URI + search: function(options, successCallback, errorCallback) { + var _this = this; + + this.annotationsList = []; //clear out current list + jQuery.ajax({ + url: _this.url + "/search", // this.prefix+ + type: 'GET', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: { + uri: options.uri, + media: "image", + limit: 10000 + }, + + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(data); + } else { + _this.annotationsList = data; // gmr + jQuery.each(_this.annotationsList, function(index, value) { + value.fullId = value["@id"]; + value["@id"] = $.genUUID(); + _this.idMapper[value["@id"]] = value.fullId; + value.endpoint = _this; + }); + _this.dfd.resolve(false); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } else { + console.log("The request for annotations has caused an error for endpoint: "+ options.uri); + } + } + + }); + }, + + deleteAnnotation: function(annotationID, returnSuccess, returnError) { + var _this = this; + jQuery.ajax({ + url: _this.url + "/destroy?uri=" + _this.idMapper[annotationID], // this.prefix+ + type: 'DELETE', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: { + uri: annotationID, + }, + contentType: "application/json; charset=utf-8", + success: function(data) { + returnSuccess(); + }, + error: function() { + returnError(); + } + + }); + }, + + update: function(oaAnnotation, returnSuccess, returnError) { + var annotation = oaAnnotation, + _this = this; + // slashes don't work in JQuery.find which is used for delete + // so need to switch http:// id to full id and back again for delete. + shortId = annotation["@id"]; + annotation["@id"] = annotation.fullId; + annotationID = annotation.fullId;//annotation["@id"]; + delete annotation.fullId; + delete annotation.endpoint; + jQuery.ajax({ + url: _this.url + "/update/"+annotationID, //this.prefix+ + type: 'POST', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + /* this returned data doesn't seem to be used anywhere */ + returnSuccess(); + }, + error: function() { + returnError(); + } + }); + // this is what updates the viewer + annotation.endpoint = _this; + annotation.fullId = annotation["@id"]; + annotation["@id"] = shortId; + }, + + create: function(oaAnnotation, returnSuccess, returnError) { + var annotation = oaAnnotation, + _this = this; + + jQuery.ajax({ + url: _this.url + "/create", //this.prefix+ + type: 'POST', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + data.fullId = data["@id"]; + data["@id"] = $.genUUID(); + data.endpoint = _this; + _this.idMapper[data["@id"]] = data.fullId; + + returnSuccess(data); + }, + error: function() { + returnError(); + } + }); + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + userAuthorize: function(action, annotation) { + return true; // allow all + } + }; +}(Mirador)); + +(function($) { + + $.WorkspaceLockController = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WorkspaceLockController.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.Slot = function(options) { + + jQuery.extend(true, this, { + workspaceSlotCls: 'slot', + slotID: null, + layoutAddress: null, + focused: null, + appendTo: null, + parent: null, + window: null, + windowElement: null + }, options); + + this.init(); + + }; + + $.Slot.prototype = { + init: function () { + this.element = jQuery(this.template({ + workspaceSlotCls: this.workspaceSlotCls, + slotID: this.slotId + })); + this.element.appendTo(this.appendTo); + + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this, + dropTarget = this.element.find('.dropMask'); + + this.element.find('.addItemLink').on('click', function(){ _this.addItem(); }); + this.element.find('.remove-slot-option').on('click', function(){ + _this.parent.removeNode(_this); + }); + jQuery.subscribe('windowRemoved', function(event, id) { + if (_this.window && _this.window.id === id) { + // This prevents the save controller + // from attempting to re-save the window + // after having already removed it. + _this.clearSlot(); + } + }); + this.element.on('dragover', function(e) { + e.preventDefault(); + dropTarget.show(); + }); + dropTarget.on('dragenter', function(e) { + e.preventDefault(); + _this.element.addClass('draggedOver'); + }); + dropTarget.on('dragleave', function(e) { + e.preventDefault(); + _this.element.removeClass('draggedOver'); + dropTarget.hide(); + }); + this.element.on('drop', function(e) { + _this.dropItem(e); + }); + + jQuery.subscribe('layoutChanged', function(event, layoutRoot) { + if (_this.parent.slots.length <= 1) { + _this.element.find('.remove-slot-option').hide(); + } else { + _this.element.find('.remove-slot-option').show(); + } + + // Must reset the slotAddress of the window. + if (_this.window) { + _this.window.slotAddress = _this.layoutAddress; + jQuery.publish('windowSlotAddressUpdated', { + id: _this.window.id, + slotAddress: _this.window.slotAddress + }); + } + }); + }, + + dropItem: function(e) { + var _this = this; + + e.preventDefault(); + e.originalEvent.dataTransfer.items[0].getAsString(function(url){ + var manifestUrl = $.getQueryParams(url).manifest, + canvasId = $.getQueryParams(url).canvas, + imageInfoUrl = $.getQueryParams(url).image, + windowConfig; + + if (typeof $.viewer.manifests[manifestUrl] !== 'undefined') { + windowConfig = { + manifest: $.viewer.manifests[manifestUrl], + slotAddress: _this.getAddress() + }; + + if (canvasId) { + // If the canvasID is defined, we need to both add + // it to the windowConfig and tell it to open in + // image view. If we don't specify the focus, the + // window will open in thumbnail view with the + // chosen page highlighted. + windowConfig.currentCanvasID = canvasId; + windowConfig.currentFocus = 'ImageView'; + } + + $.viewer.workspace.addWindow(windowConfig); + + } else if (typeof imageInfoUrl !== 'undefined') { + if (!$.viewer.manifests[imageInfoUrl]) { + $.viewer.addManifestFromUrl(imageInfoUrl, "(Added from URL)"); + } + } else { + if (!$.viewer.manifests[imageInfoUrl]) { + $.viewer.addManifestFromUrl(manifestUrl, "(Added from URL)"); + } + } + + jQuery.subscribe('manifestReceived', function(event, manifest) { + var windowConfig; + if (manifest.jsonLd['@id'] === manifestUrl || manifest.jsonLd['@id']+'/info.json' === imageInfoUrl) { + // There are many manifests that may be received + // while we are waiting for this one, so we + // need to make sure the event actually refers to the + // manifest we've just dropped. + + windowConfig = { + manifest: manifest, + slotAddress: _this.getAddress() + }; + + if (manifest.jsonLd['@id']+'/info.json' === imageInfoUrl) { + // If this was added from a naked info.json, pick the + // first (and only) page from the synthetic manifest. + canvasId = manifest.jsonLd.sequences[0].canvases[0]['@id']; + } + + if (canvasId) { + // If the canvasID is defined, we need to both add + // it to the windowConfig and tell it to open in + // image view. If we don't specify the focus, the + // window will open in thumbnail view with the + // chosen page highlighted. + windowConfig.currentCanvasID = canvasId; + windowConfig.currentFocus = 'ImageView'; + } + + $.viewer.workspace.addWindow(windowConfig); + } + }); + }); + }, + + clearSlot: function() { + if (this.window) { + this.window.element.remove(); + delete this.window; + } + }, + + getAddress: function() { + return this.layoutAddress; + }, + + addItem: function() { + var _this = this; + _this.focused = true; + + _this.parent.addItem(_this); + }, + + // template should be based on workspace type + template: Handlebars.compile([ + '
          ', + '
          ', + // '', + // '', + // '', + // accessbility-wise it's really bad practice to have h1 tags be used like this + // most screen reader users get a sense of where they are based on header tags + // if these are merely h1 tags for aesthetic purposes, it might be better to make them specific classes + '

          ', + '+', + '
          ', + '', + '
          ', + '

          ', + '

          {{t "addItem"}}

          ', + '

          Drop to Load Manifest

          ', + '
          ', + '', + ' {{t "close"}}', + '', + '
          ' + ].join('')) + }; + +}(Mirador)); + + +(function($) { + + $.Window = function(options) { + + jQuery.extend(this, { + element: null, + scrollImageRatio: 0.9, + manifest: null, + currentCanvasID: null, + focusImages: [], + imagesList: null, + annotationsList: [], + endpoint: null, + slotAddress: null, + currentImageMode: 'ImageView', + imageModes: ['ImageView', 'BookView'], + currentFocus: 'ThumbnailsView', + focusesOriginal: ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], + focuses: ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], + focusModules: {'ThumbnailsView': null, 'ImageView': null, 'ScrollView': null, 'BookView': null}, + focusOverlaysAvailable: { + 'ThumbnailsView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'' : false} + }, + 'ImageView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'ThumbnailsView' : true} + }, + 'ScrollView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'' : false} + }, + 'BookView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'ThumbnailsView' : true} + } + }, + focusOptions: null, + id : null, + sidePanel: null, //the actual module for the side panel + sidePanelAvailable: true, + sidePanelOptions: { + "toc" : true, + "annotations" : false + }, + sidePanelVisible: true, + annotationsAvailable: { + 'ThumbnailsView' : false, + 'ImageView' : true, + 'ScrollView' : false, + 'BookView' : false + }, + bottomPanel: null, //the actual module for the bottom panel + bottomPanelAvailable: true, + bottomPanelVisible: true, + overlay: null, + annotationLayerAvailable: true, + annotationCreationAvailable: true, + annoEndpointAvailable : false, + annotationState : 'annoOff', + fullScreenAvailable : true, + displayLayout: true, + layoutOptions : { + "newObject" : true, + "close" : true, + "slotRight" : true, + "slotLeft" : true, + "slotAbove" : true, + "slotBelow" : true + } + }, options); + + this.init(); + this.bindAnnotationEvents(); + + }; + + $.Window.prototype = { + init: function () { + var _this = this, + manifest = _this.manifest.jsonLd, + focusState = _this.currentFocus, + templateData = {}; + + //make sure annotations list is cleared out when changing objects within window + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + //unsubscribe from stale events as they will be updated with new module calls + jQuery.unsubscribe(('currentCanvasIDUpdated.' + _this.id)); + + _this.removeBookView(); + + //remove any imageModes that are not available as a focus + this.imageModes = jQuery.map(this.imageModes, function(value, index) { + if (jQuery.inArray(value, _this.focuses) === -1) return null; + return value; + }); + + _this.imagesList = _this.manifest.getCanvases(); + if (!_this.currentCanvasID) { + _this.currentCanvasID = _this.imagesList[0]['@id']; + } + + this.annoEndpointAvailable = !jQuery.isEmptyObject($.viewer.annotationEndpoint); + if (!this.annotationLayerAvailable) { + this.annotationCreationAvailable = false; + this.annoEndpointAvailable = false; + this.annotationState = 'annoOff'; + } + _this.getAnnotations(); + + //check config + if (typeof this.bottomPanelAvailable !== 'undefined' && !this.bottomPanelAvailable) { + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].bottomPanel = {'' : false}; + }); + } + + templateData.sidePanel = this.sidePanelAvailable; + if (this.sidePanelAvailable) { + templateData.sidePanel = !Object.keys(this.sidePanelOptions).every(function(element, index, array) { + return _this.sidePanelOptions[element] === false; + }); + } + if (typeof this.overlayAvailable !== 'undefined' && !this.overlayAvailable) { + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].overlay = {'' : false}; + }); + } else { + templateData.MetadataView = true; + } + + //determine if any buttons should be hidden in template + jQuery.each(this.focuses, function(index, value) { + templateData[value] = true; + }); + templateData.title = manifest.label; + templateData.displayLayout = this.displayLayout; + templateData.layoutOptions = this.layoutOptions; + // if displayLayout is true, but all individual options are set to false, set displayLayout to false + if (this.displayLayout) { + templateData.displayLayout = !Object.keys(this.layoutOptions).every(function(element, index, array) { + return _this.layoutOptions[element] === false; + }); + } + _this.element = jQuery(this.template(templateData)).appendTo(_this.appendTo); + + //clear any existing objects + _this.clearViews(); + _this.clearPanelsAndOverlay(); + + //attach view and toggle view, which triggers the attachment of panels or overlays + _this.bindNavigation(); + switch(focusState) { + case 'ThumbnailsView': + _this.toggleThumbnails(_this.currentCanvasID); + break; + case 'ImageView': + _this.toggleImageView(_this.currentCanvasID); + break; + case 'BookView': + _this.toggleBookView(_this.currentCanvasID); + break; + case 'ScrollView': + _this.toggleScrollView(_this.currentCanvasID); + break; + default: + break; + } + + if ($.viewer.workspace.slots.length <= 1) { + _this.element.find('.remove-object-option').hide(); + } + + this.bindEvents(); + + if (this.imagesList.length === 1) { + this.bottomPanelVisibility(false); + } else { + this.bottomPanelVisibility(this.bottomPanelVisible); + } + this.sidePanelVisibility(this.sidePanelVisible, '0s'); + }, + + update: function(options) { + jQuery.extend(this, options); + if (this.focusOptions) { + this.focusOptions.osdBounds = null; + this.focusOptions.zoomLevel = null; + } + this.init(); + }, + + // spawnInWorkspace: function() { + + // }, + + // reset whether BookView is available every time as a user might switch between paged and non-paged objects within a single slot/window + removeBookView: function() { + var _this = this; + this.focuses = this.focusesOriginal; + var manifest = this.manifest.jsonLd; + if (manifest.sequences[0].viewingHint) { + if (manifest.sequences[0].viewingHint.toLowerCase() !== 'paged') { + //disable bookview for this object because it's not a paged object + this.focuses = jQuery.grep(this.focuses, function(value) { + return value !== 'BookView'; + }); + } + } + }, + + bindEvents: function() { + var _this = this; + + //this event should trigger from layout + jQuery(window).resize($.debounce(function(){ + if (_this.focusModules.ScrollView) { + var containerHeight = _this.element.find('.view-container').height(); + var triggerShow = false; + if (_this.currentFocus === "ScrollView") { + triggerShow = true; + } + _this.focusModules.ScrollView.reloadImages(Math.floor(containerHeight * _this.scrollImageRatio), triggerShow); + } + }, 300)); + + jQuery.subscribe('bottomPanelSet.' + _this.id, function(event, visible) { + var panel = _this.element.find('.bottomPanel'); + if (visible === true) { + panel.css({transform: 'translateY(0)'}); + } else { + panel.css({transform: 'translateY(100%)'}); + } + }); + + jQuery.subscribe('layoutChanged', function(event, layoutRoot) { + if ($.viewer.workspace.slots.length <= 1) { + _this.element.find('.remove-object-option').hide(); + } else { + _this.element.find('.remove-object-option').show(); + } + }); + + jQuery.subscribe('sidePanelStateUpdated.' + this.id, function(event, state) { + if (state.open) { + _this.element.find('.fa-list').switchClass('fa-list', 'fa-caret-down'); + _this.element.find('.mirador-icon-toc').addClass('selected'); + _this.element.find('.view-container').removeClass('maximised'); + } else { + _this.element.find('.mirador-icon-toc').removeClass('selected'); + _this.element.find('.fa-caret-down').switchClass('fa-caret-down', 'fa-list'); + _this.element.find('.view-container').addClass('maximised'); + } + }); + + // TODO: temporary logic to minimize side panel if only tab is toc and toc is empty + jQuery.subscribe('sidePanelVisibilityByTab.' + this.id, function(event, visible) { + _this.sidePanelVisibility(visible, '0s'); + }); + + }, + + bindAnnotationEvents: function() { + var _this = this; + jQuery.subscribe('annotationCreated.'+_this.id, function(event, oaAnno, osdOverlay) { + var annoID; + //first function is success callback, second is error callback + _this.endpoint.create(oaAnno, function(data) { + //the success callback expects the OA annotation be returned + annoID = String(data['@id']); //just in case it returns a number + _this.annotationsList.push(data); + //update overlay so it can be a part of the annotationList rendering + jQuery(osdOverlay).removeClass('osd-select-rectangle').addClass('annotation').attr('id', annoID); + jQuery.publish(('annotationListLoaded.' + _this.id)); + }, + function() { + //provide useful feedback to user + console.log("There was an error saving this new annotation"); + //remove this overlay because we couldn't save annotation + jQuery(osdOverlay).remove(); + }); + }); + + jQuery.subscribe('annotationUpdated.'+_this.id, function(event, oaAnno) { + //first function is success callback, second is error callback + _this.endpoint.update(oaAnno, function() { + jQuery.each(_this.annotationsList, function(index, value) { + if (value['@id'] === oaAnno['@id']) { + _this.annotationsList[index] = oaAnno; + return false; + } + }); + jQuery.publish(('annotationListLoaded.' + _this.id)); + }, + function() { + console.log("There was an error updating this annotation"); + }); + }); + + jQuery.subscribe('annotationDeleted.'+_this.id, function(event, annoId) { + //remove from endpoint + //first function is success callback, second is error callback + _this.endpoint.deleteAnnotation(annoId, function() { + _this.annotationsList = jQuery.grep(_this.annotationsList, function(e){ return e['@id'] !== annoId; }); + jQuery.publish(('annotationListLoaded.' + _this.id)); + jQuery.publish(('removeOverlay.' + _this.id), annoId); + }, + function() { + // console.log("There was an error deleting this annotation"); + }); + }); + + jQuery.subscribe('updateAnnotationList.'+_this.id, function(event) { + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + _this.getAnnotations(); + }); + }, + + clearViews: function() { + var _this = this; + jQuery.each(_this.focusModules, function(key, value) { + _this.focusModules[key] = null; + }); + }, + + clearPanelsAndOverlay: function() { + this.sidePanel = null; + this.bottomPanel = null; + this.overlay = null; + }, + + // only panels and overlay available to this view, make rest hidden while on this view + updatePanelsAndOverlay: function(state) { + var _this = this; + + jQuery.each(this.focusOverlaysAvailable[state], function(panelType, viewOptions) { + jQuery.each(viewOptions, function(view, displayed) { + //instantiate any panels that exist for this view but are still null + if (view !== '' && _this[panelType] === null) { + _this[panelType] = new $[view]({ + manifest: _this.manifest, + appendTo: _this.element.find('.'+panelType), + parent: _this, + panel: true, + canvasID: _this.currentCanvasID, + imagesList: _this.imagesList, + thumbInfo: {thumbsHeight: 80, listingCssCls: 'panel-listing-thumbs', thumbnailCls: 'panel-thumbnail-view'} + }); + } + + //refresh displayed in case TableOfContents module changed it + displayed = _this.focusOverlaysAvailable[state][panelType][view]; + + //toggle any valid panels + if (view !== '' && displayed) { + _this.togglePanels(panelType, displayed, view, state); + } + + //hide any panels instantiated but not available to this view + if (view === '' && _this[panelType]) { + _this.togglePanels(panelType, displayed, view, state); + } + + //lastly, adjust height for non-existent panels + if (view === '') { + _this.adjustFocusSize(panelType, displayed); + } + + //update current image for all valid panels + }); + }); + + //update panels with current image + if (this.bottomPanel) { this.bottomPanel.updateFocusImages(this.focusImages); } + }, + + updateSidePanel: function() { + if (!this.sidePanelAvailable) { + return; + } + var _this = this, + tocAvailable = _this.sidePanelOptions.toc, + annotationsTabAvailable = _this.sidePanelOptions.annotations, + hasStructures = true; + + var structures = _this.manifest.getStructures(); + if (!structures || structures.length === 0) { + hasStructures = false; + } + + if (this.sidePanel === null) { + this.sidePanel = new $.SidePanel({ + parent: _this, + appendTo: _this.element.find('.sidePanel'), + manifest: _this.manifest, + canvasID: _this.currentCanvasID, + tocTabAvailable: tocAvailable, + annotationsTabAvailable: annotationsTabAvailable, + hasStructures: hasStructures + }); + } else { + this.sidePanel.update('annotations', annotationsTabAvailable); + } + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + /*setTOCBoolean: function(boolValue) { + var _this = this; + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].sidePanel.TableOfContents = boolValue; + }); + //remove thumbnail icon if not available for this object + if (!boolValue) { + this.element.find('.mirador-icon-toc').hide(); + } + },*/ + + togglePanels: function(panelType, panelState, viewType, focusState) { + //update state in focusOverlaysAvailable + this.focusOverlaysAvailable[focusState][panelType][viewType] = panelState; + this[panelType].toggle(panelState); + this.adjustFocusSize(panelType, panelState); + }, + + sidePanelVisibility: function(visible, transitionDuration) { + var _this = this; + _this.sidePanelVisible = visible, + tocIconElement = this.element.find('.mirador-icon-toc'), + sidePanelElement = this.element.find('.sidePanel'), + viewContainerElement = this.element.find('.view-container'); + + sidePanelElement.css('transition-duration', transitionDuration); + viewContainerElement.css('transition', transitionDuration); + if (visible && sidePanelElement.hasClass('minimized')) { + tocIconElement.find('.fa-list').switchClass('fa-list', 'fa-caret-down'); + tocIconElement.addClass('selected').css('background','#efefef'); + sidePanelElement.removeClass('minimized').width(280).css('border-right', '1px solid lightgray'); + viewContainerElement.css('margin-left', 280); + } else if (!visible && !sidePanelElement.hasClass('minimized')) { + tocIconElement.find('.fa-caret-down').switchClass('fa-caret-down', 'fa-list'); + tocIconElement.removeClass('selected').css('background', '#fafafa'); + viewContainerElement.css('margin-left', 0); + sidePanelElement.addClass('minimized').css('border', 'none').width(0); + } + jQuery.publish(('windowUpdated'), { + id: _this.id, + sidePanelVisible: visible + }); + }, + + bottomPanelVisibility: function(visible) { + var _this = this; + _this.bottomPanelVisible = visible; + jQuery.publish(('bottomPanelSet.' + _this.id), visible); + jQuery.publish(('windowUpdated'), { + id: _this.id, + bottomPanelVisible: visible + }); + }, + + adjustFocusSize: function(panelType, panelState) { + if (panelType === 'bottomPanel') { + this.focusModules[this.currentFocus].adjustHeight('focus-max-height', panelState); + } else if (panelType === 'sidePanel') { + this.focusModules[this.currentFocus].adjustWidth('focus-max-width', panelState); + } else {} + }, + + toggleMetadataOverlay: function(focusState) { + var _this = this; + var currentState = this.focusOverlaysAvailable[focusState].overlay.MetadataView; + if (currentState) { + this.element.find('.mirador-icon-metadata-view').removeClass('selected'); + } else { + this.element.find('.mirador-icon-metadata-view').addClass('selected'); + } + //set overlay for all focus types to same value + jQuery.each(this.focusOverlaysAvailable, function(focusType, options) { + if (focusState !== focusType) { + this.overlay.MetadataView = !currentState; + } + }); + //and then do toggling for current focus + this.togglePanels('overlay', !currentState, 'MetadataView', focusState); + }, + + toggleFocus: function(focusState, imageMode) { + var _this = this; + + this.currentFocus = focusState; + if (imageMode && jQuery.inArray(imageMode, this.imageModes) > -1) { + this.currentImageMode = imageMode; + } + //set other focusStates to false (toggle to display none) + jQuery.each(this.focusModules, function(focusKey, module) { + if (module && focusState !== focusKey) { + module.toggle(false); + } + }); + this.focusModules[focusState].toggle(true); + this.updateManifestInfo(); + this.updatePanelsAndOverlay(focusState); + this.updateSidePanel(); + jQuery.publish("focusUpdated"); + jQuery.publish("windowUpdated", { + id: _this.id, + viewType: _this.currentFocus, + canvasID: _this.currentCanvasID, + imageMode: _this.currentImageMode, + loadedManifest: _this.manifest.jsonLd['@id'], + slotAddress: _this.slotAddress + }); + }, + + toggleThumbnails: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ThumbnailsView === null) { + this.focusModules.ThumbnailsView = new $.ThumbnailsView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + canvasID: this.currentCanvasID, + imagesList: this.imagesList + }); + } else { + var view = this.focusModules.ThumbnailsView; + view.updateImage(canvasID); + } + this.toggleFocus('ThumbnailsView', ''); + }, + + toggleImageView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ImageView === null) { + this.focusModules.ImageView = new $.ImageView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + windowId: this.id, + canvasID: canvasID, + imagesList: this.imagesList, + osdOptions: this.focusOptions, + bottomPanelAvailable: this.bottomPanelAvailable, + annotationLayerAvailable: this.annotationLayerAvailable, + annotationCreationAvailable: this.annotationCreationAvailable, + annoEndpointAvailable: this.annoEndpointAvailable, + annotationState : this.annotationState, + fullScreenAvailable: this.fullScreenAvailable + }); + } else { + var view = this.focusModules.ImageView; + view.updateImage(canvasID); + } + this.toggleFocus('ImageView', 'ImageView'); + }, + + toggleBookView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.BookView === null) { + this.focusModules.BookView = new $.BookView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + windowId: this.id, + canvasID: canvasID, + imagesList: this.imagesList, + osdOptions: this.focusOptions, + bottomPanelAvailable: this.bottomPanelAvailable, + fullScreenAvailable: this.fullScreenAvailable + }); + } else { + var view = this.focusModules.BookView; + view.updateImage(canvasID); + } + this.toggleFocus('BookView', 'BookView'); + }, + + toggleScrollView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ScrollView === null) { + var containerHeight = this.element.find('.view-container').height(); + this.focusModules.ScrollView = new $.ScrollView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + canvasID: this.currentCanvasID, + imagesList: this.imagesList, + thumbInfo: {thumbsHeight: Math.floor(containerHeight * this.scrollImageRatio), listingCssCls: 'scroll-listing-thumbs', thumbnailCls: 'scroll-view'} + }); + } else { + var view = this.focusModules.ScrollView; + view.updateImage(canvasID); + } + this.toggleFocus('ScrollView', ''); + }, + + updateFocusImages: function(imageList) { + this.focusImages = imageList; + }, + + setCurrentCanvasID: function(canvasID) { + var _this = this; + this.currentCanvasID = canvasID; + jQuery.publish('removeTooltips.' + _this.id); + jQuery.unsubscribe(('annotationListLoaded.' + _this.id)); + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + this.getAnnotations(); + switch(this.currentImageMode) { + case 'ImageView': + this.toggleImageView(this.currentCanvasID); + break; + case 'BookView': + this.toggleBookView(this.currentCanvasID); + break; + default: + break; + } + jQuery.publish(('currentCanvasIDUpdated.' + _this.id), canvasID); + }, + + replaceWindow: function(newSlotAddress, newElement) { + this.slotAddress = newSlotAddress; + this.appendTo = newElement; + this.update(); + }, + + setCursorFrameStart: function(canvasID) { + }, + + updateManifestInfo: function() { + var _this = this; + this.element.find('.window-manifest-navigation').children().removeClass('selected'); + switch(_this.currentFocus) { + case 'ThumbnailsView': + //hide thumbnails button and highlight currentImageMode? + _this.element.find('.mirador-icon-thumbs-view').addClass('selected'); + break; + case 'ImageView': + //highlight Single Image View option + _this.element.find('.mirador-icon-image-view').addClass('selected'); + break; + case 'BookView': + //highlight Book View option + _this.element.find('.mirador-icon-image-view').addClass('selected'); + break; + case 'ScrollView': + //highlight Scroll View option + _this.element.find('.mirador-icon-thumbs-view').addClass('selected'); + break; + default: + break; + } + + if (this.focusOverlaysAvailable[this.currentFocus].overlay.MetadataView) { + this.element.find('.mirador-icon-metadata-view').addClass('selected'); + } + }, + + /* + Merge all annotations for current image/canvas from various sources + Pass to any widgets that will use this list + */ + getAnnotations: function() { + //first look for manifest annotations + var _this = this, + url = _this.manifest.getAnnotationsListUrl(_this.currentCanvasID); + + if (url !== false) { + jQuery.get(url, function(list) { + _this.annotationsList = _this.annotationsList.concat(list.resources); + jQuery.each(_this.annotationsList, function(index, value) { + //if there is no ID for this annotation, set a random one + if (typeof value['@id'] === 'undefined') { + value['@id'] = $.genUUID(); + } + //indicate this is a manifest annotation - which affects the UI + value.endpoint = "manifest"; + }); + jQuery.publish('annotationListLoaded.' + _this.id); + }); + } + + // next check endpoint + if (this.annoEndpointAvailable) { + var dfd = jQuery.Deferred(), + module = $.viewer.annotationEndpoint.module, + options = $.viewer.annotationEndpoint.options; //grab anything from the config that should be passed directly to the endpoint + options.name = $.viewer.annotationEndpoint.name; + // One annotation endpoint per window, the endpoint + // is a property of the instance. + if ( _this.endpoint && _this.endpoint !== null ) { + _this.endpoint.set('dfd', dfd); + } else { + options.dfd = dfd; + options.windowID = _this.id; + options.parent = _this; + _this.endpoint = new $[module](options); + } + _this.endpoint.search({ "uri" : _this.currentCanvasID}); + + dfd.done(function(loaded) { + _this.annotationsList = _this.annotationsList.concat(_this.endpoint.annotationsList); + // clear out some bad data + _this.annotationsList = jQuery.grep(_this.annotationsList, function (value, index) { + if (typeof value.on === "undefined") { + return false; + } + return true; + }); + jQuery.publish('annotationListLoaded.' + _this.id); + }); + } + }, + + // based on currentFocus + bindNavigation: function() { + var _this = this; + + this.element.find('.mirador-icon-image-view').on('mouseenter', + function() { + _this.element.find('.image-list').stop().slideFadeToggle(300); + }).on('mouseleave', + function() { + _this.element.find('.image-list').stop().slideFadeToggle(300); + }); + + this.element.find('.mirador-icon-window-menu').on('mouseenter', + function() { + _this.element.find('.slot-controls').stop().slideFadeToggle(300); + }).on('mouseleave', + function() { + _this.element.find('.slot-controls').stop().slideFadeToggle(300); + }); + + this.element.find('.single-image-option').on('click', function() { + _this.toggleImageView(_this.currentCanvasID); + }); + + this.element.find('.book-option').on('click', function() { + _this.toggleBookView(_this.currentCanvasID); + }); + + this.element.find('.scroll-option').on('click', function() { + _this.toggleScrollView(_this.currentCanvasID); + }); + + this.element.find('.thumbnails-option').on('click', function() { + _this.toggleThumbnails(_this.currentCanvasID); + }); + + this.element.find('.mirador-icon-metadata-view').on('click', function() { + _this.toggleMetadataOverlay(_this.currentFocus); + }); + + this.element.find('.mirador-icon-toc').on('click', function() { + _this.sidePanelVisibility(!_this.sidePanelVisible, '0.3s'); + }); + + this.element.find('.new-object-option').on('click', function() { + _this.parent.addItem(); + }); + + this.element.find('.remove-object-option').on('click', function() { + $.viewer.workspace.removeNode(_this.parent); + }); + + this.element.find('.add-slot-right').on('click', function() { + $.viewer.workspace.splitRight(_this.parent); + }); + + this.element.find('.add-slot-left').on('click', function() { + $.viewer.workspace.splitLeft(_this.parent); + }); + + this.element.find('.add-slot-below').on('click', function() { + $.viewer.workspace.splitDown(_this.parent); + }); + + this.element.find('.add-slot-above').on('click', function() { + $.viewer.workspace.splitUp(_this.parent); + }); + }, + + // template should be based on workspace type + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + +(function($) { + + $.AnnotationsLayer = function(options) { + + jQuery.extend(true, this, { + parent: null, + annotationsList: null, + viewer: null, + renderer: null, + rectTool: null, + selected: null, + hovered: null, + windowId: null, + mode: 'default', + element: null + }, options); + + this.init(); + }; + + $.AnnotationsLayer.prototype = { + + init: function() { + var _this = this; + jQuery.unsubscribe(('modeChange.' + _this.windowId)); + + this.createRenderer(); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + jQuery.subscribe('modeChange.' + _this.windowId, function(event, modeName) { + _this.mode = modeName; + _this.modeSwitch(); + }); + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + _this.annotationsList = _this.parent.parent.annotationsList; + _this.updateRenderer(); + }); + }, + + createRenderer: function() { + var _this = this; + this.renderer = new $.OsdCanvasRenderer({ + osd: $.OpenSeadragon, + osdViewer: _this.viewer, + list: _this.annotationsList, // must be passed by reference. + visible: false, + parent: _this + }); + this.modeSwitch(); + }, + + updateRenderer: function() { + this.renderer.list = this.annotationsList; + this.modeSwitch(); + }, + + modeSwitch: function() { + //console.log(this.mode); + if (this.mode === 'displayAnnotations') { this.enterDisplayAnnotations(); } + else if (this.mode === 'editingAnnotations') { this.enterEditAnnotations(); } + else if (this.mode === 'default') { this.enterDefault(); } + else {} + }, + + + enterDisplayAnnotations: function() { + var _this = this; + //console.log('triggering annotation loading and display'); + if (this.rectTool) { + this.rectTool.exitEditMode(); + } + this.renderer.render(); + }, + + enterEditAnnotations: function() { + var _this = this; + if (!this.rectTool) { + this.rectTool = new $.OsdRegionRectTool({ + osd: OpenSeadragon, + osdViewer: _this.viewer, + rectType: 'oa', // does not do anything yet. + parent: _this + }); + } else { + this.rectTool.reset(_this.viewer); + } + this.renderer.render(); + this.rectTool.enterEditMode(); + }, + + enterDefault: function() { + if (this.rectTool) { + this.rectTool.exitEditMode(); + } + this.renderer.hideAll(); + } + + }; + +}(Mirador)); + +(function($) { + + $.AnnotationsTab = function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + visible: null + }, options); + + this.init(); + }; + + $.AnnotationsTab.prototype = { + init: function() { + var _this = this; + this.windowId = this.parent.id; + + this.state({ + id: 'annotationsTab', + visible: this.visible, + annotationLists: [], + selectedList: null, + empty: true, + focusedList: null + }, true); + + this.listenForActions(); + this.render(this.state()); + this.loadTabComponents(); + this.bindEvents(); + }, + state: function(state, initial) { + if (!arguments.length) return this.annoTabState; + this.annoTabState = state; + + if (!initial) { + jQuery.publish('annotationsTabStateUpdated.' + this.windowId, this.annoTabState); + } + + return this.annoTabState; + }, + loadTabComponents: function() { + var _this = this; + + }, + tabStateUpdated: function(visible) { + var state = this.state(); + state.visible = state.visible ? false : true; + + this.state(state); + }, + annotationListLoaded: function() { + var _this = this, + annotationSources = [], + state = this.state(); + for(var i = 0; i < _this.parent.annotationsList.length; i++) + { + + if(typeof _this.parent.annotationsList[i].endpoint === 'string'){ + + annotationSources.push('manifest'); + + }else{ + + annotationSources.push(_this.parent.annotationsList[i].endpoint.name); + + } + + } + + // make unique + annotationSources = annotationSources.filter(function(itm,i,annotationSources){ + return i==annotationSources.indexOf(itm); + }); + + state.annotationLists = annotationSources.map(function(annotationSource) { + //var s = (annotationSource === state.selectedList ? true : false); + return { + annotationSource: annotationSource, + layer: null, + selected: (annotationSource === state.selectedList ? true : false), + focused: false + }; + }); + + if(state.annotationLists.length){ + state.empty = false; + } + + this.state(state); + }, + deselectList: function(listId) { + var _this = this; + var state = this.state(); + state.selectedList = null; + state.annotationLists.forEach(function(list){ list.selected = false; }); + this.state(state); + }, + selectList: function(listId) { + var _this = this; + var state = this.state(); + state.selectedList = listId; + state.annotationLists.forEach(function(list){ list.selected = list.annotationSource === listId ? true : false; }); + this.state(state); + }, + focusList: function(listId) { + var state = this.state(); + state.focusedList = listId; + state.annotationLists.forEach(function(list){ list.focused = list.annotationSource === listId ? true : false;}); + this.state(state); + }, + toggle: function() {}, + listenForActions: function() { + var _this = this; + + jQuery.subscribe('annotationsTabStateUpdated.' + _this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('tabStateUpdated.' + _this.windowId, function(_, data) { + _this.tabStateUpdated(data.annotationsTab); + }); + + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(_, data) { + _this.annotationListLoaded(); + }); + + jQuery.subscribe('currentCanvasIDUpdated.' + _this.windowId, function(event) { + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + _this.annotationListLoaded(); + }); + + _this.selectList(_this.state().selectedList); + + }); + + jQuery.subscribe('listSelected.' + _this.windowId, function(event, listId) { + _this.selectList(listId); + }); + + jQuery.subscribe('listDeselected.' + _this.windowId, function(event, listId) { + _this.deselectList(listId); + }); + + }, + bindEvents: function() { + var _this = this, + listItems = this.element.find('.annotationListItem'); + + listItems.on('click', function(event) { + //event.stopImmediatePropagation(); + var listClicked = jQuery(this).data('id'); + if(_this.state().selectedList === listClicked){ + //_this.deselectList(listClicked); + jQuery.publish('listDeselected.' + _this.windowId, listClicked); + }else{ + //_this.selectList(listClicked); + jQuery.publish('listSelected.' + _this.windowId, listClicked); + } + + }); + + }, + render: function(state) { + var _this = this, + templateData = { + annotationSources: state.annotationLists + }; + if (!this.element) { + this.element = jQuery(_this.template(templateData)).appendTo(_this.appendTo); + } else { + _this.appendTo.find(".annotationsPanel").remove(); + this.element = jQuery(_this.template(templateData)).appendTo(_this.appendTo); + } + _this.bindEvents(); + + + if (state.visible) { + this.element.show(); + } else { + this.element.hide(); + } + }, + template: Handlebars.compile([ + '
          ', + '
            ', + '{{#each annotationSources}}', + '
          • ', + '{{this.annotationSource}}', + '
          • ', + '{{/each}}', + '
          ', + '
          ', + ].join('')) + }; + +}(Mirador)); + +(function($) { + + $.BookView = function(options) { + + jQuery.extend(this, { + currentImg: null, + windowId: null, + currentImgIndex: 0, + stitchList: [], + canvasID: null, + imagesList: [], + element: null, + focusImages: [], + manifest: null, + viewingDirection: 'left-to-right', + viewingHint: 'paged', + osd: null, + osdCls: 'mirador-osd', + osdOptions: { + osdBounds: null, + zoomLevel: null + }, + parent: null, + stitchTileMargin: 10 + }, options); + + this.init(); + }; + + + $.BookView.prototype = { + + init: function() { + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + if (!this.osdOptions) { + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + } + + this.currentImg = this.imagesList[this.currentImgIndex]; + + this.element = jQuery(this.template()).appendTo(this.appendTo); + this.hud = new $.Hud({ + parent: this, + element: this.element, + bottomPanelAvailable: this.bottomPanelAvailable, + windowId: this.windowId, + annotationLayerAvailable: false, + fullScreenAvailable : this.fullScreenAvailable + }); + + if (this.manifest.jsonLd.sequences[0].viewingDirection) { + this.viewingDirection = this.manifest.jsonLd.sequences[0].viewingDirection.toLowerCase(); + } + if (this.manifest.jsonLd.sequences[0].viewingHint) { + this.viewingHint = this.manifest.jsonLd.sequences[0].viewingHint.toLowerCase(); + } + + this.stitchList = this.getStitchList(); + this.createOpenSeadragonInstance(); + }, + + template: Handlebars.compile([ + '
          ', + '
          ' + ].join('')), + + setBounds: function() { + var _this = this; + this.osdOptions.osdBounds = this.osd.viewport.getBounds(true); + jQuery.publish("imageBoundsUpdated", { + id: _this.parent.id, + osdBounds: { + x: _this.osdOptions.osdBounds.x, + y: _this.osdOptions.osdBounds.y, + width: _this.osdOptions.osdBounds.width, + height: _this.osdOptions.osdBounds.height + } + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + }, + + updateImage: function(canvasID) { + this.canvasID = canvasID; + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + this.currentImg = this.imagesList[this.currentImgIndex]; + var newList = this.getStitchList(); + var is_same = this.stitchList.length == newList.length && this.stitchList.every(function(element, index) { + return element === newList[index]; + }); + if (!is_same) { + this.stitchList = newList; + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + this.osd.close(); + this.createOpenSeadragonInstance(); + } + }, + + createOpenSeadragonInstance: function() { + var uniqueID = $.genUUID(), + osdId = 'mirador-osd-' + uniqueID, + osdToolBarId = osdId + '-toolbar', + elemOsd, + tileSources = [], + _this = this, + toolbarID = 'osd-toolbar-' + uniqueID, + dfd = jQuery.Deferred(); + + this.element.find('.' + this.osdCls).remove(); + + jQuery.each(this.stitchList, function(index, image) { + var imageUrl = $.Iiif.getImageUrl(image), + infoJsonUrl = imageUrl + '/info.json'; + + jQuery.getJSON(infoJsonUrl).done(function (data, status, jqXHR) { + tileSources.splice(index, 0, data); + if (tileSources.length === _this.stitchList.length ) { dfd.resolve(); } + }); + }); + + dfd.done(function () { + var aspectRatio = tileSources[0].height / tileSources[0].width; + + elemOsd = + jQuery('
          ') + .addClass(_this.osdCls) + .attr('id', osdId) + .appendTo(_this.element); + + _this.osd = $.OpenSeadragon({ + 'id': elemOsd.attr('id'), + 'toolbarID' : toolbarID + }); + + _this.osd.addHandler('open', function(){ + _this.addLayer(tileSources.slice(1), aspectRatio); + var addItemHandler = function( event ) { + _this.osd.world.removeHandler( "add-item", addItemHandler ); + if (_this.osdOptions.osdBounds) { + var rect = new OpenSeadragon.Rect(_this.osdOptions.osdBounds.x, _this.osdOptions.osdBounds.y, _this.osdOptions.osdBounds.width, _this.osdOptions.osdBounds.height); + _this.osd.viewport.fitBounds(rect, true); + } else { + _this.osd.viewport.goHome(true); + } + }; + + _this.osd.world.addHandler( "add-item", addItemHandler ); + + _this.osd.addHandler('zoom', $.debounce(function(){ + _this.setBounds(); + }, 300)); + + _this.osd.addHandler('pan', $.debounce(function(){ + _this.setBounds(); + }, 300)); + }); + + _this.osd.open(tileSources[0], {opacity:1, x:0, y:0, width:1}); + }); + + }, + + addLayer: function(tileSources, aspectRatio) { + var _this = this; + jQuery.each(tileSources, function(index, value) { + var newAR = (value.height / value.width); + var options = { + tileSource: value, + opacity: 1, + x: 1.01, + y: 0, + width: aspectRatio / newAR + }; + _this.osd.addTiledImage(options); + }); + }, + + // next two pages for paged objects + // need next single page for lining pages up + // don't need for continuous or individuals + next: function() { + var next; + if (this.currentImgIndex % 2 === 0) { + next = this.currentImgIndex + 1; + } else { + next = this.currentImgIndex + 2; + } + if (next < this.imagesList.length) { + this.parent.setCurrentCanvasID(this.imagesList[next]['@id']); + } + }, + + // previous two pages for paged objects + // need previous single page for lining things up + // don't need for continuous or individuals + previous: function() { + var prev; + if (this.currentImgIndex % 2 === 0) { + prev = this.currentImgIndex - 2; + } else { + prev = this.currentImgIndex - 1; + } + if (prev >= 0) { + this.parent.setCurrentCanvasID(this.imagesList[prev]['@id']); + } + }, + + getStitchList: function() { + // Need to check metadata for object type and viewing direction + // Default to 'paged' and 'left-to-right' + // Set index(es) for any other images to stitch with selected image + var stitchList = [], + leftIndex = [], + rightIndex = [], + topIndex = [], + bottomIndex = [], + _this = this; + + this.focusImages = []; + + if (this.viewingHint === 'individuals') { + // don't do any stitching, display like an imageView + stitchList = [this.currentImg]; + } else if (this.viewingHint === 'paged') { + // determine the other image for this pair based on index and viewingDirection + if (this.currentImgIndex === 0 || this.currentImgIndex === this.imagesList.length-1) { + //first page (front cover) or last page (back cover), display on its own + stitchList = [this.currentImg]; + } else if (this.currentImgIndex % 2 === 0) { + // even, get previous page. set order in array based on viewingDirection + switch (this.viewingDirection) { + case "left-to-right": + leftIndex[0] = this.currentImgIndex-1; + stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg]; + break; + case "right-to-left": + rightIndex[0] = this.currentImgIndex-1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]]; + break; + case "top-to-bottom": + topIndex[0] = this.currentImgIndex-1; + stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg]; + break; + case "bottom-to-top": + bottomIndex[0] = this.currentImgIndex-1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]]; + break; + default: + break; + } + } else { + // odd, get next page + switch (this.viewingDirection) { + case "left-to-right": + rightIndex[0] = this.currentImgIndex+1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]]; + break; + case "right-to-left": + leftIndex[0] = this.currentImgIndex+1; + stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg]; + break; + case "top-to-bottom": + bottomIndex[0] = this.currentImgIndex+1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]]; + break; + case "bottom-to-top": + topIndex[0] = this.currentImgIndex+1; + stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg]; + break; + default: + break; + } + } + } else if (this.viewingHint === 'continuous') { + // TODO: stitch all images together per the viewingDirection + } else { + // undefined viewingHint, don't do anything + } + + //set the focusImages for highlighting in panels + jQuery.each(stitchList, function(index, image) { + _this.focusImages.push(image['@id']); + }); + this.parent.updateFocusImages(this.focusImages); + return stitchList; + } + }; + +}(Mirador)); + +(function($) { + + $.ContextControls = function(options) { + + jQuery.extend(this, { + parent: null, //hud + element: null, + container: null, + mode: null, + windowId: null, + annoEndpointAvailable: false, + annotationCreationAvailable: true + }, options); + + this.init(); + }; + + $.ContextControls.prototype = { + + init: function() { + this.element = jQuery(this.template({ + showEdit : this.annotationCreationAvailable + })).appendTo(this.container); + this.hide(); + this.bindEvents(); + }, + + show: function() { + this.element.fadeIn("200"); + }, + + hide: function(complete) { + this.element.fadeOut("200", complete); + }, + + bindEvents: function() { + var _this = this; + + this.container.find('.mirador-osd-close').on('click', function() { + _this.parent.annoState.displayOff(); + }); + + this.container.find('.mirador-osd-back').on('click', function() { + _this.element.remove(); + _this.element = jQuery(_this.template()).appendTo(_this.container); + _this.bindEvents(); + }); + + this.container.find('.mirador-osd-edit-mode').on('click', function() { + if (_this.parent.annoState.current === 'annoOnCreateOff') { + _this.parent.annoState.createOn(); + } else if (_this.parent.annoState.current === 'annoOnCreateOn') { + _this.parent.annoState.createOff(); + } + }); + this.container.find('.mirador-osd-refresh-mode').on('click', function() { + //update annotation list from endpoint + jQuery.publish('updateAnnotationList.'+_this.windowId); + }); + + }, + + template: Handlebars.compile([ + '
          ', + '', + '', + '', + '{{#if showEdit}}', + '', + '', + '', + '{{/if}}', + '', + '', + '', + /*'', + '', + '',*/ + /*'', + '', + '',*/ + /*'', + '', + '',*/ + '
          ' + ].join('')), + + // for accessibility, make sure to add aria-labels just like above + editorTemplate: Handlebars.compile([ + '' + ].join('')) + }; +}(Mirador)); + +(function($) { + + $.Hud = function(options) { + + jQuery.extend(this, { + element: null, + parent: null, + windowId: null, + annoState: null, + showAnnotations: true, + annoEndpointAvailable: false, + fullScreenAvailable: true + }, options); + + this.init(); + }; + + $.Hud.prototype = { + + init: function() { + this.createStateMachine(); + + this.element = jQuery(this.template({ + showNextPrev : this.parent.imagesList.length !== 1, + showBottomPanel : typeof this.bottomPanelAvailable === 'undefined' ? true : this.bottomPanelAvailable, + showAnno : this.annotationLayerAvailable, + showFullScreen : this.fullScreenAvailable + })).appendTo(this.element); + + if (this.annotationLayerAvailable && this.annoEndpointAvailable) { + this.contextControls = new $.ContextControls({ + element: null, + container: this.parent.element, + mode: 'displayAnnotations', + parent: this, + windowId: this.windowId, + annotationCreationAvailable: this.annotationCreationAvailable + }); + } + + this.bindEvents(); + + if (typeof this.bottomPanelAvailable !== 'undefined' && !this.bottomPanelAvailable) { + this.parent.parent.bottomPanelVisibility(false); + } else { + this.parent.parent.bottomPanelVisibility(this.parent.parent.bottomPanelVisible); + } + }, + + bindEvents: function() { + var _this = this, + firstCanvasId = _this.parent.imagesList[0]['@id'], + lastCanvasId = _this.parent.imagesList[_this.parent.imagesList.length-1]['@id']; + + this.parent.element.find('.mirador-osd-next').on('click', function() { + _this.parent.next(); + }); + + this.parent.element.find('.mirador-osd-previous').on('click', function() { + _this.parent.previous(); + }); + + this.parent.element.find('.mirador-osd-annotations-layer').on('click', function() { + if (_this.annoState.current === 'none') { + _this.annoState.startup(this); + } + if (_this.annoState.current === 'annoOff') { + _this.annoState.displayOn(this); + } else { + _this.annoState.displayOff(this); + } + }); + + this.parent.element.find('.mirador-osd-go-home').on('click', function() { + _this.parent.osd.viewport.goHome(); + }); + + this.parent.element.find('.mirador-osd-up').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(0, -panBy.y)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-right').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(panBy.x, 0)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-down').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(0, panBy.y)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-left').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(-panBy.x, 0)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-zoom-in').on('click', function() { + var osd = _this.parent.osd; + if ( osd.viewport ) { + osd.viewport.zoomBy( + osd.zoomPerClick / 1.0 + ); + osd.viewport.applyConstraints(); + } + }); + this.parent.element.find('.mirador-osd-zoom-out').on('click', function() { + var osd = _this.parent.osd; + if ( osd.viewport ) { + osd.viewport.zoomBy( + 1.0 / osd.zoomPerClick + ); + osd.viewport.applyConstraints(); + } + }); + + this.parent.element.find('.mirador-osd-fullscreen').on('click', function() { + if (OpenSeadragon.isFullScreen()) { + OpenSeadragon.exitFullScreen(); + } else { + OpenSeadragon.requestFullScreen(_this.parent.parent.element[0]); + } + }); + + jQuery(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange", function() { + _this.fullScreen(); + }); + + this.parent.element.find('.mirador-osd-toggle-bottom-panel').on('click', function() { + var visible = !_this.parent.parent.bottomPanelVisible; + _this.parent.parent.bottomPanelVisibility(visible); + }); + + jQuery.subscribe('bottomPanelSet.' + _this.windowId, function(event, visible) { + var dodgers = _this.parent.element.find('.mirador-osd-toggle-bottom-panel, .mirador-pan-zoom-controls'); + var arrows = _this.parent.element.find('.mirador-osd-next, .mirador-osd-previous'); + if (visible === true) { + dodgers.css({transform: 'translateY(-130px)'}); + arrows.css({transform: 'translateY(-65px)'}); + } else { + dodgers.css({transform: 'translateY(0)'}); + arrows.css({transform: 'translateY(0)'}); + } + }); + + jQuery.subscribe('currentCanvasIDUpdated.' + _this.windowId, function(event, canvasId) { + // If it is the first canvas, hide the "go to previous" button, otherwise show it. + if (canvasId === firstCanvasId) { + _this.parent.element.find('.mirador-osd-previous').hide(); + _this.parent.element.find('.mirador-osd-next').show(); + } else if (canvasId === lastCanvasId) { + _this.parent.element.find('.mirador-osd-next').hide(); + _this.parent.element.find('.mirador-osd-previous').show(); + } else { + _this.parent.element.find('.mirador-osd-next').show(); + _this.parent.element.find('.mirador-osd-previous').show(); + } + // If it is the last canvas, hide the "go to previous" button, otherwise show it. + }); + }, + + createStateMachine: function() { + //add more to these as AnnoState becomes more complex + var _this = this, + duration = "200"; + //initial state is 'none' + this.annoState = StateMachine.create({ + events: [ + { name: 'startup', from: 'none', to: 'annoOff' }, + { name: 'displayOn', from: 'annoOff', to: 'annoOnCreateOff' }, + { name: 'refreshCreateOff', from: 'annoOnCreateOff', to: 'annoOnCreateOff' }, + { name: 'createOn', from: ['annoOff','annoOnCreateOff'], to: 'annoOnCreateOn' }, + { name: 'refreshCreateOn', from: 'annoOnCreateOn', to: 'annoOnCreateOn' }, + { name: 'createOff', from: 'annoOnCreateOn', to: 'annoOnCreateOff' }, + { name: 'displayOff', from: ['annoOnCreateOn','annoOnCreateOff'], to: 'annoOff' } + ], + callbacks: { + onstartup: function(event, from, to) { + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + ondisplayOn: function(event, from, to) { + if (_this.annoEndpointAvailable) { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeOut(duration, function() { + _this.contextControls.show(); + }); + } else { + _this.parent.element.find('.mirador-osd-annotations-layer').addClass("selected"); + } + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + onrefreshCreateOff: function(event, from, to) { + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + oncreateOn: function(event, from, to) { + function enableEditingAnnotations() { + _this.parent.element.find('.mirador-osd-edit-mode').addClass("selected"); + jQuery.publish('modeChange.' + _this.windowId, 'editingAnnotations'); + } + if (_this.annoEndpointAvailable) { + if (from === "annoOff") { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeOut(duration, function() { + _this.contextControls.show(); + enableEditingAnnotations(); + }); + } else { + enableEditingAnnotations(); + } + } + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + onrefreshCreateOn: function(event, from, to) { + jQuery.publish('modeChange.' + _this.windowId, 'editingAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + oncreateOff: function(event, from, to) { + _this.parent.element.find('.mirador-osd-edit-mode').removeClass("selected"); + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + ondisplayOff: function(event, from, to) { + if (_this.annoEndpointAvailable) { + _this.parent.element.find('.mirador-osd-edit-mode').removeClass("selected"); + _this.contextControls.hide(function() { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeIn(duration); + } + ); + } else { + _this.parent.element.find('.mirador-osd-annotations-layer').removeClass("selected"); + } + jQuery.publish('modeChange.' + _this.windowId, 'default'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + } + } + }); + }, + + getPanByValue: function() { + var bounds = this.parent.osd.viewport.getBounds(true); + //for now, let's keep 50% of the image on the screen + var panBy = { + "x" : bounds.width * 0.5, + "y" : bounds.height * 0.5 + }; + return panBy; + }, + + fullScreen: function() { + var replacementButton, + bottomPanelHeight = this.parent.parent.element.find('.bottomPanel').innerHeight(); + + if (!OpenSeadragon.isFullScreen()) { + replacementButton = jQuery(''); + this.parent.element.find('.mirador-osd-fullscreen').empty().append(replacementButton); + this.parent.element.find('.mirador-osd-toggle-bottom-panel').show(); + this.parent.parent.bottomPanelVisibility(true); + } else { + + replacementButton = jQuery(''); + this.parent.element.find('.mirador-osd-fullscreen').empty().append(replacementButton); + this.parent.element.find('.mirador-osd-toggle-bottom-panel').hide(); + this.parent.parent.bottomPanelVisibility(false); + } + }, + + template: Handlebars.compile([ + '{{#if showNextPrev}}', + '', + '', + '', + '{{/if}}', + '{{#if showFullScreen}}', + '', + '', + '', + '{{/if}}', + '{{#if showAnno}}', + '', + '', + '', + '{{/if}}', + '{{#if showNextPrev}}', + '', + '', + '', + '{{/if}}', + '{{#if showBottomPanel}}', + '', + '', + '', + '{{/if}}', + '' + ].join('')) + + }; + +}(Mirador)); + +(function($) { + + $.ImageView = function(options) { + + jQuery.extend(this, { + currentImg: null, + windowId: null, + currentImgIndex: 0, + canvasID: null, + imagesList: [], + element: null, + elemOsd: null, + parent: null, + manifest: null, + osd: null, + fullscreen: null, + osdOptions: { + osdBounds: null, + zoomLevel: null + }, + osdCls: 'mirador-osd', + elemAnno: null, + annoCls: 'annotation-canvas', + annotationLayerAvailable: null, + annotationsLayer: null + }, options); + + this.init(); + }; + + $.ImageView.prototype = { + + init: function() { + // check (for thumbnail view) if the canvasID is set. + // If not, make it page/item 1. + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + if (!this.osdOptions) { + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + } + this.currentImg = this.imagesList[this.currentImgIndex]; + this.element = jQuery(this.template()).appendTo(this.appendTo); + this.elemAnno = jQuery('
          ') + .addClass(this.annoCls) + .appendTo(this.element); + this.createOpenSeadragonInstance($.Iiif.getImageUrl(this.currentImg)); + this.parent.updateFocusImages([this.canvasID]); + // The hud controls are consistent + // throughout any updates to the osd canvas. + this.hud = new $.Hud({ + parent: this, + element: this.element, + bottomPanelAvailable: this.bottomPanelAvailable, + windowId: this.windowId, + annotationLayerAvailable: this.annotationLayerAvailable, + annotationCreationAvailable: this.annotationCreationAvailable, + annoEndpointAvailable: this.annoEndpointAvailable, + fullScreenAvailable : this.fullScreenAvailable + }); + + this.bindEvents(); + }, + + template: Handlebars.compile([ + '
          ', + '
          ' + ].join('')), + + bindEvents: function() { + var _this = this; + jQuery.subscribe('fitBounds.' + _this.parent.id, function(event, bounds) { + var rect = _this.osd.viewport.imageToViewportRectangle(Number(bounds.x), Number(bounds.y), Number(bounds.width), Number(bounds.height)); + _this.osd.viewport.fitBoundsWithConstraints(rect, false); + }); + + }, + + setBounds: function() { + var _this = this; + this.osdOptions.osdBounds = this.osd.viewport.getBounds(true); + jQuery.publish("imageBoundsUpdated", { + id: _this.parent.id, + osdBounds: { + x: _this.osdOptions.osdBounds.x, + y: _this.osdOptions.osdBounds.y, + width: _this.osdOptions.osdBounds.width, + height: _this.osdOptions.osdBounds.height + } + }); + var rectangle = this.osd.viewport.viewportToImageRectangle(this.osdOptions.osdBounds); + jQuery.publish("imageRectangleUpdated", { + id: _this.parent.id, + osdBounds: { + x: Math.round(rectangle.x), + y: Math.round(rectangle.y), + width: Math.round(rectangle.width), + height: Math.round(rectangle.height) + } + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + }, + + createOpenSeadragonInstance: function(imageUrl) { + var infoJsonUrl = imageUrl + '/info.json', + uniqueID = $.genUUID(), + osdID = 'mirador-osd-' + uniqueID, + infoJson, + _this = this; + + this.element.find('.' + this.osdCls).remove(); + + jQuery.getJSON(infoJsonUrl).done(function (infoJson, status, jqXHR) { + _this.elemOsd = + jQuery('
          ') + .addClass(_this.osdCls) + .attr('id', osdID) + .appendTo(_this.element); + + _this.osd = $.OpenSeadragon({ + 'id': osdID, + 'tileSources': infoJson, + 'uniqueID' : uniqueID + }); + + _this.osd.addHandler('open', function(){ + jQuery.publish('osdOpen.'+_this.windowId); + if (_this.osdOptions.osdBounds) { + var rect = new OpenSeadragon.Rect(_this.osdOptions.osdBounds.x, _this.osdOptions.osdBounds.y, _this.osdOptions.osdBounds.width, _this.osdOptions.osdBounds.height); + _this.osd.viewport.fitBounds(rect, true); + } else { + //else reset bounds for this image + _this.setBounds(); + } + + _this.addAnnotationsLayer(_this.elemAnno); + + // if current annoState is 'none' that means it has been initialized but not used + // use annotationState to choose event + if (_this.hud.annoState.current === 'none') { + _this.hud.annoState.startup(null); + if (_this.annotationState === 'annoOnCreateOff') { + _this.hud.annoState.displayOn(null); + } else if (_this.annotationState === 'annoOnCreateOn') { + _this.hud.annoState.createOn(null); + } + } else { + // if the current state is not 'none' then we need to update the annotations layer, + // with the current state, for the new canvas + if (_this.hud.annoState.current === 'annoOnCreateOff') { + _this.hud.annoState.refreshCreateOff(null); + } else if (_this.hud.annoState.current === 'annoOnCreateOn') { + _this.hud.annoState.refreshCreateOn(null); + } + } + + // A hack. Pop the osd overlays layer after the canvas so + // that annotations appear. + jQuery(_this.osd.canvas).children().first().remove().appendTo(_this.osd.canvas); + + _this.osd.addHandler('zoom', $.debounce(function() { + _this.setBounds(); + }, 500)); + + _this.osd.addHandler('pan', $.debounce(function(){ + _this.setBounds(); + }, 500)); + }); + }); + }, + + addAnnotationsLayer: function(element) { + var _this = this; + _this.annotationsLayer = new $.AnnotationsLayer({ + parent: _this, + annotationsList: _this.parent.annotationsList || [], + viewer: _this.osd, + windowId: _this.windowId, + element: element + }); + }, + + updateImage: function(canvasID) { + if (this.canvasID !== canvasID) { + this.canvasID = canvasID; + this.currentImgIndex = $.getImageIndexById(this.imagesList, canvasID); + this.currentImg = this.imagesList[this.currentImgIndex]; + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + this.osd.close(); + this.createOpenSeadragonInstance($.Iiif.getImageUrl(this.currentImg)); + this.parent.updateFocusImages([canvasID]); + } else { + this.parent.updateFocusImages([canvasID]); + } + }, + + next: function() { + var next = this.currentImgIndex + 1; + + if (next < this.imagesList.length) { + this.parent.setCurrentCanvasID(this.imagesList[next]['@id']); + } + }, + + previous: function() { + var prev = this.currentImgIndex - 1; + + if (prev >= 0) { + this.parent.setCurrentCanvasID(this.imagesList[prev]['@id']); + } + } + }; + +}(Mirador)); + +(function($) { + + $.MetadataView = function(options) { + + jQuery.extend(this, { + manifest: null, + element: null, + parent: null, + metadataTypes: null, + metadataListingCls: 'metadata-listing' + }, options); + + this.init(); + }; + + + $.MetadataView.prototype = { + + init: function() { + var _this = this, + tplData = { + metadataListingCls: this.metadataListingCls + }; + + _this.manifest = _this.manifest.jsonLd; + this.metadataTypes = {}; + + this.metadataTypes.details = _this.getMetadataDetails(_this.manifest); + this.metadataTypes.rights = _this.getMetadataRights(_this.manifest); + this.metadataTypes.links = _this.getMetadataLinks(_this.manifest); + + //vvvvv This is *not* how this should be done. + jQuery.each(this.metadataTypes, function(metadataKey, metadataValue) { + tplData[metadataKey] = []; + + jQuery.each(metadataValue, function(key, value) { + if (typeof value === 'object') { + value = _this.stringifyObject(value); + } + + if (typeof value === 'string' && value !== '') { + tplData[metadataKey].push({ + label: _this.extractLabelFromAttribute(key), + value: (metadataKey === 'links') ? value : _this.addLinksToUris(value) + }); + } + }); + }); + + if (_this.manifest.logo) { + var logo = ''; + if (typeof _this.manifest.logo === "string") { + logo = _this.manifest.logo; + } else if (typeof _this.manifest.logo['@id'] !== 'undefined') { + logo = _this.manifest.logo['@id']; + } + tplData.logo = logo; + } + + this.element = jQuery(this.template(tplData)).appendTo(this.appendTo); + this.bindEvents(); + }, + + // Base code from https://github.com/padolsey/prettyprint.js. Modified to fit Mirador needs + stringifyObject: function(obj, nestingMargin) { + var type = typeof obj, + _this = this, + str, + first = true, + increment = 15, + delimiter = '
          '; + + if (obj instanceof RegExp) { + return '/' + obj.source + '/'; + } + + if (typeof nestingMargin === 'undefined') { + nestingMargin = 0; + } + + if (obj instanceof Array) { + str = '[ '; + jQuery.each(obj, function (i, item) { + str += (i === 0 ? '' : ', ') + _this.stringifyObject(item, nestingMargin + increment); + }); + return str + ' ]'; + } + + if (typeof obj === 'object') { + str = '
          '; + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + str += (first ? '' : delimiter) + i + ': ' + _this.stringifyObject(obj[i], nestingMargin + increment); + first = false; + } + } + + return str + '
          '; + } + return obj.toString(); + }, + + stringifyRelated: function(obj) { + var _this = this, + str, + next, + label, + format; + if (obj instanceof Array) { + str = ''; + jQuery.each(obj, function (i, item) { + next = _this.stringifyRelated(item); + if (next !== '') str += (i === 0 ? '' : '
          ') + next; + }); + return str; + } + + if (typeof obj === 'object' && '@id' in obj) { + label = ('label' in obj)? obj.label : obj['@id']; + format = ('format' in obj && obj.format !== 'text/html')? '(' + obj.format + ')' : ''; + return '' + label + ' ' + format; + } + + return _this.addLinksToUris(obj.toString()); + }, + + getMetadataDetails: function(jsonLd) { + // TODO: This should not default to English + var mdList = { + 'label': '' + jsonLd.label + '' || '', + 'description': jsonLd.description || '' + }; + var value = ""; + var label = ""; + if (typeof mdList.description == "object") { + jQuery.each(mdList.description, function(index, item) { + if (typeof item == "string") { + value += item; + value += "
          "; + } else { + // {@value: ..., @language: ...} + if (item['@language'] == "en") { + value += item['@value']; + value += "
          "; + } + } + }); + mdList.description = value; + } + + if (jsonLd.metadata) { + value = ""; + label = ""; + jQuery.each(jsonLd.metadata, function(index, item) { + if (typeof item.label === "string") { + label = item.label; + } else { + jQuery.each(item.label, function(i2, what) { + // {@value: ..., @language: ...} + if (what['@language'] === "en") { + label = what['@value']; + } + }); + } + if (typeof item.value === "string") { + value = item.value; + } else { + jQuery.each(item.value, function(i3, what) { + // {@value: ..., @language: ...} + if (what['@language'] === "en") { + value = what['@value']; + } + }); + } + mdList[label] = value; + }); + } + + return mdList; + }, + + getMetadataRights: function(jsonLd) { + return { + 'license': jsonLd.license || '', + 'attribution': jsonLd.attribution || '' + }; + }, + + getMetadataLinks: function(jsonLd) { + // #414 + return { + 'related': this.stringifyRelated(jsonLd.related || ''), + 'seeAlso': this.stringifyRelated(jsonLd.seeAlso || ''), + 'within': this.stringifyObject(jsonLd.within || '') + }; + }, + + extractLabelFromAttribute: function(attr) { + var label = attr; + + label = label.replace(/^@/, ''); + label = label.replace(/([A-Z])/g, ' $1'); + label = label.replace(/\s{2,}/g, ' '); + label = label.replace(/\w\S*/g, function(txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); + + return label; + }, + + bindEvents: function() { + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + show: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.show({effect: "slide", direction: "right", duration: 300, easing: "swing"}); + }, + + hide: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.hide({effect: "slide", direction: "right", duration: 300, easing: "swing"}); + }, + + addLinksToUris: function(text) { + // http://stackoverflow.com/questions/8188645/javascript-regex-to-match-a-url-in-a-field-of-text + var regexUrl = /(http|ftp|https):\/\/[\w\-]+(\.[\w\-]+)+([\w.,@?\^=%&:\/~+#\-]*[\w@?\^=%&\/~+#\-])?/gi, + textWithLinks = text, + matches; + + if (typeof text === 'string') { + matches = text.match(regexUrl); + + if (matches) { + jQuery.each(matches, function(index, match) { + textWithLinks = textWithLinks.replace(match, '' + match + ''); + }); + } + } + + return textWithLinks; + }, + + template: Handlebars.compile([ + '
          {{t "details"}}:
          ', + '
          ', + '{{#each details}}', + '', + '{{/each}}', + '
          ', + '
          {{t "rights"}}:
          ', + '{{#if rights}}', + '
          ', + '{{#each rights}}', + '', + '{{/each}}', + '{{#if logo}}', + '', + '{{/if}}', + '
          ', + '{{else}}', + '
          ', + '', + '
          ', + '{{/if}}', + '{{#if links}}', + '
          {{t "links"}}:
          ', + '
          ', + '{{#each links}}', + '', + '{{/each}}', + // '{{#if relatedLinks}}', + // '
          {{label}}:
          {{{value}}}
          ', + // '{{/if}}', + '', + '{{/if}}' + + ].join(''), { noEscape: true }) + + }; + +}(Mirador)); + +(function($) { + + $.WidgetScale = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetScale.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.ScrollView = function(options) { + + jQuery.extend(this, { + currentImgIndex: 0, + canvasID: null, + focusImages: [], + manifest: null, + element: null, + imagesList: [], + appendTo: null, + thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'}, + parent: null, + panel: false, + lazyLoadingFactor: 1.5 //should be >= 1 + }, options); + + jQuery.extend($.ScrollView.prototype, $.ThumbnailsView.prototype); + this.init(); + }; + +}(Mirador)); + +(function($) { + + $.SidePanel= function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + panelState: {}, + tocTabAvailable: false, + annotationsTabAvailable: false, + layersTabAvailable: false, + toolsTabAvailable: false, + hasStructures: false + }, options); + + this.init(); + }; + + $.SidePanel.prototype = { + init: function() { + var _this = this; + this.windowId = this.parent.id; + + this.state({ + tabs : [ + { + name : 'toc', + options : { + available: _this.tocTabAvailable, + id:'tocTab', + label:'Index' + } + }, + /*{ + name : 'annotations', + options : { + available: _this.annotationsTabAvailable, + id:'annotationsTab', + label:'Annotations' + } + },*/ + /*{ + name : 'layers', + options : { + available: _this.layersTabAvailable, + id:'layersTab', + label:'Layers' + } + }, + { + name : 'tools', + options : { + available: _this.toolsTabAvailable, + id:'toolsTab', + label:'Tools' + } + }*/ + ], + width: 280, + open: true + }, true); + + this.listenForActions(); + this.render(this.state()); + + this.loadSidePanelComponents(); + }, + + loadSidePanelComponents: function() { + var _this = this; + + new $.Tabs({ + windowId: this.parent.id, + appendTo: this.appendTo, + tabs : this.panelState.tabs, + parent : this + }); + + if (this.tocTabAvailable) { + new $.TableOfContents({ + manifest: this.manifest, + appendTo: this.element.find('.tabContentArea'), + parent: this.parent, + panel: true, + canvasID: this.parent.currentCanvasID + }); + } + if (_this.annotationsTabAvailable) { + new $.AnnotationsTab({ + manifest: _this.manifest, + parent: this.parent, + appendTo: _this.element.find('.tabContentArea'), + tabs: _this.state.tabs + }); + } + + }, + + update: function(name, availability) { + var state = this.panelState; + jQuery.each(state.tabs, function(index, value) { + if (value.name === name) { + value.options.available = availability; + } + }); + this.state(state); + }, + + state: function(state, initial) { + if (!arguments.length) return this.panelState; + jQuery.extend(true, this.panelState, state); + + if (!initial) { + jQuery.publish('sidePanelStateUpdated.' + this.windowId, this.panelState); + } + + /*var enableSidePanel = false; + jQuery.each(this.panelState.tabs, function(index, value) { + if (value.options.available) { + enableSidePanel = true; + } + }); + + this.toggle(enableSidePanel);*/ + + return this.panelState; + }, + + panelToggled: function() { + var state = this.state(), + open = !state.open; + + state.open = open; + this.state(state); + }, + + // doesn't do anything right now + // getTemplateData: function() { + // return { + // annotationsTab: this.state().annotationsTab, + // tocTab: this.state().tocTab + // }; + // }, + + listenForActions: function() { + var _this = this; + jQuery.subscribe('sidePanelStateUpdated.' + this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('sidePanelResized', function() { + }); + + jQuery.subscribe('sidePanelToggled.' + this.windowId, function() { + _this.panelToggled(); + }); + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + if (_this.parent.annotationsAvailable[_this.parent.currentFocus]) { + if (_this.parent.annotationsList.length > 0) { + _this.update('annotations', true); + } + } + }); + + }, + + render: function(renderingData) { + var _this = this; + + if (!this.element) { + this.element = this.appendTo; + jQuery(_this.template(renderingData)).appendTo(_this.appendTo); + return; + } + + if (renderingData.open) { + this.appendTo.removeClass('minimized'); + } else { + this.appendTo.addClass('minimized'); + } + }, + + template: Handlebars.compile([ + '
          ', + '
            ', + '
          ', + '
          ' + ].join('')), + + toggle: function (enableSidePanel) { + if (!enableSidePanel) { + jQuery(this.appendTo).hide(); + this.parent.element.find('.view-container').addClass('focus-max-width'); + this.parent.element.find('.mirador-icon-toc').hide(); + } else { + jQuery(this.appendTo).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + this.parent.element.find('.view-container').removeClass('focus-max-width'); + this.parent.element.find('.mirador-icon-toc').show(); + } + } + }; + +}(Mirador)); + +(function($) { + + $.WidgetStatusBar = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetStatusBar.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.Tabs = function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + windowId: null, + tabState: {}, + tabs: [] + }, options); + + this.init(); + }; + + $.Tabs.prototype = { + init: function() { + var _this = this; + + this.state({ + tabs : this.tabs, + //tabs: [{id:'tocTab', label:'Indices'}, {id:'annotationsTab', label:'Annotations'}], + //tabs: [{id:'tocTab', label:'Indices'}], + selectedTabIndex: 0 + }, true); + this.listenForActions(); + this.render(this.state()); + this.bindEvents(); + }, + state: function(state, initial) { + if (!arguments.length) return this.tabState; + jQuery.extend(true, this.tabState, state); + + if (!initial) { + jQuery.publish('tabStateUpdated.' + this.windowId, this.tabState); + } + + return this.tabState; + }, + tabSelected: function(index) { + var state = this.state(); + state.selectedTabIndex = index; + this.state(state); + }, + getTemplateData: function() { + return { + annotationsTab: this.state().annotationsTab, + tocTab: this.state().tocTab + }; + }, + listenForActions: function() { + var _this = this; + + jQuery.subscribe('tabStateUpdated.' + this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('tabSelected.' + this.windowId, function(_, data) { + _this.tabSelected(data); + }); + + jQuery.subscribe('tabFocused.', function() { + }); + }, + bindEvents: function() { + var _this = this; + + this.element.find('.tab').on('click', function(event) { + jQuery.publish('tabSelected.' + _this.windowId, jQuery( ".tabGroup li" ).index( this )); + }); + }, + render: function(renderingData) { + var _this = this; + + if (!this.element) { + var displayLabels = false; + var tabs = jQuery.grep(renderingData.tabs, function(value, index) { + return value.options.available; + }); + renderingData.tabs = tabs; + if(renderingData.tabs.length === 1){ + // TODO: temporary logic to minimize side panel if only tab is toc and toc is empty + if (renderingData.tabs[0].name === 'toc' && !_this.parent.hasStructures) { + jQuery.publish("sidePanelVisibilityByTab." + _this.windowId, false); + } + + // don't show button if only one tab + renderingData.tabs = []; + } + //TODO: add text if there is one label or no content within this tab + this.element = jQuery(_this.template(renderingData)).prependTo(_this.appendTo); + return; + } + + this.element.find('.tab').removeClass('selected'); + var tabClass = '.' + renderingData.tabs[renderingData.selectedTabIndex].options.id; + this.element.find(tabClass).addClass('selected'); + + }, + template: Handlebars.compile([ + '
            ', + '{{#each tabs}}', + '
          • ', + '{{this.options.label}}', + '
          • ', + '{{/each}}', + '
          ', + ].join('')), + toggle: function () {} + }; + +}(Mirador)); + +(function($) { + + $.ThumbnailsView = function(options) { + + jQuery.extend(this, { + currentImgIndex: 0, + canvasID: null, + focusImages: [], + manifest: null, + element: null, + imagesList: [], + appendTo: null, + thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'}, + defaultThumbHeight: 150, + parent: null, + panel: false, + lazyLoadingFactor: 1.5 //should be >= 1 + }, options); + + this.init(); + }; + + + $.ThumbnailsView.prototype = { + + init: function() { + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + this.loadContent(); + this.bindEvents(); + }, + + loadContent: function() { + var _this = this, + tplData = { + defaultHeight: this.thumbInfo.thumbsHeight, + listingCssCls: this.thumbInfo.listingCssCls, + thumbnailCls: this.thumbInfo.thumbnailCls + }; + + tplData.thumbs = jQuery.map(this.imagesList, function(canvas, index) { + if (canvas.width === 0) { + return {}; + } + + var aspectRatio = canvas.height/canvas.width, + width = (_this.thumbInfo.thumbsHeight/aspectRatio), + thumbnailUrl = $.getThumbnailForCanvas(canvas, width); + + return { + thumbUrl: thumbnailUrl, + title: canvas.label, + id: canvas['@id'], + width: width, + highlight: _this.currentImgIndex === index ? 'highlight' : '' + }; + }); + + this.element = jQuery(_this.template(tplData)).appendTo(this.appendTo); + }, + + updateImage: function(canvasId) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, canvasId); + this.element.find('.highlight').removeClass('highlight'); + this.element.find("img[data-image-id='"+canvasId+"']").addClass('highlight'); + this.element.find("img[data-image-id='"+canvasId+"']").parent().addClass('highlight'); + }, + + updateFocusImages: function(focusList) { + var _this = this; + this.element.find('.highlight').removeClass('highlight'); + jQuery.each(focusList, function(index, canvasId) { + _this.element.find("img[data-image-id='"+canvasId+"']").addClass('highlight'); + _this.element.find("img[data-image-id='"+canvasId+"']").parent().addClass('highlight'); + }); + }, + + currentImageChanged: function() { + var _this = this, + target = _this.element.find('.highlight'), + scrollPosition; + + if (this.parent.currentFocus === 'BookView') { + scrollPosition = _this.element.scrollLeft() + (target.position().left + (target.next().width() + target.outerWidth())/2) - _this.element.width()/2; + } else { + + scrollPosition = _this.element.scrollLeft() + (target.position().left + target.width()/2) - _this.element.width()/2; + } + _this.element.scrollTo(scrollPosition, 900); + }, + + bindEvents: function() { + var _this = this; + _this.element.find('img').on('load', function() { + jQuery(this).hide().fadeIn(750); + }); + + jQuery(_this.element).scroll(function() { + _this.loadImages(); + }); + + jQuery.subscribe('windowResize', $.debounce(function(){ + _this.loadImages(); + }, 100)); + + //add any other events that would trigger thumbnail display (resize, etc) + + _this.element.find('.thumbnail-image').on('click', function() { + var canvasID = jQuery(this).attr('data-image-id'); + _this.parent.setCurrentCanvasID(canvasID); + }); + + jQuery.subscribe(('currentCanvasIDUpdated.' + _this.parent.id), function(event) { + _this.currentImageChanged(); + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + loadImages: function() { + var _this = this; + jQuery.each(_this.element.find("img"), function(key, value) { + if ($.isOnScreen(value, _this.lazyLoadingFactor) && !jQuery(value).attr("src")) { + var url = jQuery(value).attr("data"); + _this.loadImage(value, url); + } + }); + }, + + loadImage: function(imageElement, url) { + var _this = this, + imagePromise = $.createImagePromise(url); + + imagePromise.done(function(image) { + jQuery(imageElement).attr('src', image); + }); + }, + + reloadImages: function(newThumbHeight, triggerShow) { + var _this = this; + this.thumbInfo.thumbsHeight = newThumbHeight; + + jQuery.each(this.imagesList, function(index, image) { + var aspectRatio = image.height/image.width, + width = (_this.thumbInfo.thumbsHeight/aspectRatio), + newThumbURL = $.getThumbnailForCanvas(image, width), + id = image['@id']; + var imageElement = _this.element.find('img[data-image-id="'+id+'"]'); + imageElement.attr('data', newThumbURL).attr('height', _this.thumbInfo.thumbsHeight).attr('width', width).attr('src', ''); + }); + if (triggerShow) { + this.show(); + } + }, + + template: Handlebars.compile([ + '
          ', + '
            ', + '{{#thumbs}}', + '
          • ', + '', + '
            {{title}}
            ', + '
          • ', + '{{/thumbs}}', + '
          ', + '
          ' + ].join('')), + + hide: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + var _this = this; + element.show({ + effect: "fade", + duration: 300, + easing: "easeInCubic", + complete: function() { + _this.loadImages(); + } + }); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + } + + }; + + + +}(Mirador)); + +(function($) { + + $.TableOfContents = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + structures: null, + previousSelectedElements: [], + selectedElements: [], + openElements: [], + hoveredElement: [], + ranges: [], + selectContext: null, + tocData: {}, + active: null + }, options); + + this.init(); + + }; + + $.TableOfContents.prototype = { + init: function () { + var _this = this; + _this.structures = _this.manifest.getStructures(); + if (!_this.structures || _this.structures.length === 0) { + this.element = jQuery(this.emptyTemplate()).appendTo(this.appendTo); + } else { + this.ranges = this.setRanges(); + this.element = jQuery(this.template({ ranges: this.getTplData() })).appendTo(this.appendTo); + this.tocData = this.initTocData(); + this.selectedElements = $.getRangeIDByCanvasID(_this.structures, _this.parent.currentCanvasID); + this.element.find('.has-child ul').hide(); + this.render(); + } + this.bindEvents(); + }, + + setRanges: function() { + var _this = this, + ranges = []; + jQuery.each(_this.structures, function(index, range) { + if (range['@type'] === 'sc:Range') { + ranges.push({ + id: range['@id'], + canvases: range.canvases, + within: range.within, + label: range.label + }); + } + }); + + return ranges; + + }, + + tabStateUpdated: function(data) { + if (data.tabs[data.selectedTabIndex].options.id === 'tocTab') { + this.element.show(); + } else { + this.element.hide(); + } + }, + + getTplData: function() { + var _this = this, + ranges = _this.extractRangeTrees(_this.ranges); + + if (ranges.length < 2) { + ranges = ranges[0].children; + } + + return ranges; + }, + + initTocData: function() { + var _this = this, + tocData = {}; + + jQuery.each(_this.ranges, function(index, item) { + var rangeID = item.id, + attrString = '[data-rangeid="' + rangeID +'"]'; + + tocData[item.id] = { + element: _this.element.find(attrString).closest('li') //, + // open: false, + // selected: false, + // hovered: false + }; + }); + + return tocData; + }, + + extractRangeTrees: function(rangeList) { + var tree, parent; + // Recursively build tree/table of contents data structure + // Begins with the list of topmost categories + function unflatten(flatRanges, parent, tree) { + // To aid recursion, define the tree if it does not exist, + // but use the tree that is being recursively built + // by the call below. + tree = typeof tree !== 'undefined' ? tree : []; + parent = typeof parent !== 'undefined' ? parent : {id: "root", label: "Table of Contents" }; + var children = jQuery.grep(flatRanges, function(child) { if (!child.within) { child.within = 'root'; } return child.within == parent.id; }); + if ( children.length ) { + if ( parent.id === 'root') { + // If there are children and their parent's + // id is a root, bind them to the tree object. + // + // This begins the construction of the object, + // and all non-top-level children are now + // bound the these base nodes set on the tree + // object. + children.forEach(function(child) { + child.level = 0; + }); + tree = children; + } else { + // If the parent does not have a top-level id, + // bind the children to the parent node in this + // recursion level before handing it over for + // another spin. + // + // Because "child" is passed as + // the second parameter in the next call, + // in the next iteration "parent" will be the + // first child bound here. + children.forEach(function(child) { + child.level = parent.level+1; + }); + parent.children = children; + } + // The function cannot continue to the return + // statement until this line stops being called, + // which only happens when "children" is empty. + jQuery.each( children, function( index, child ){ unflatten( flatRanges, child ); } ); + } + return tree; + } + + return unflatten(rangeList); + }, + + render: function() { + var _this = this, + toDeselect = jQuery.map(_this.previousSelectedElements, function(rangeID) { + return _this.tocData[rangeID].element.toArray(); + }), + toSelect = jQuery.map(_this.selectedElements, function(rangeID) { + return _this.tocData[rangeID].element.toArray(); + }), + toOpen = jQuery.map(_this.selectedElements, function(rangeID) { + if ((jQuery.inArray(rangeID, _this.openElements) < 0) && (jQuery.inArray(rangeID, _this.previousSelectedElements) < 0)) { + return _this.tocData[rangeID].element.toArray(); + } + }), + toClose = jQuery.map(_this.previousSelectedElements, function(rangeID) { + if ((jQuery.inArray(rangeID, _this.openElements) < 0) && (jQuery.inArray(rangeID, _this.selectedElements) < 0)) { + return _this.tocData[rangeID].element.toArray(); + } + }); + + // Deselect elements + jQuery(toDeselect).removeClass('selected'); + + // Select new elements + jQuery(toSelect).addClass('selected'); + + // Scroll to new elements + scroll(); + + // Open new ones + jQuery(toOpen).toggleClass('open').find('ul:first').slideFadeToggle(); + // Close old ones (find way to keep scroll position). + jQuery(toClose).toggleClass('open').find('ul:first').slideFadeToggle(400, 'swing', scroll); + + // Get the sum of the outer height of all elements to be removed. + // Subtract from current parent height to retreive the new height. + // Scroll with respect to this. + scroll(); + + function scroll() { + var head = _this.element.find('.selected').first(); + if (head.length > 0) { + _this.element.scrollTo(head, 400); + } + } + + }, + + bindEvents: function() { + var _this = this; + // var eventString = _this.parent.id + + jQuery.subscribe('focusChanged', function(_, manifest, focusFrame) { + }); + + jQuery.subscribe('cursorFrameUpdated', function(_, manifest, cursorBounds) { + }); + + jQuery.subscribe('tabStateUpdated.' + _this.parent.id, function(_, data) { + _this.tabStateUpdated(data); + }); + + jQuery.subscribe(('currentCanvasIDUpdated.' + _this.parent.id), function(event, canvasID) { + if (!_this.structures) { return; } + _this.setSelectedElements($.getRangeIDByCanvasID(_this.structures, canvasID)); + _this.render(); + }); + + _this.element.find('.toc-link').on('click', function(event) { + event.stopPropagation(); + // The purpose of the immediate event is to update the data on the parent + // by calling its "set" function. + // + // The parent (window) then emits an event notifying all panels of + // the update, so they can respond in their own unique ways + // without window having to know anything about their DOMs or + // internal structure. + var rangeID = jQuery(this).data().rangeid, + canvasID = jQuery.grep(_this.structures, function(item) { return item['@id'] == rangeID; })[0].canvases[0], + isLeaf = jQuery(this).closest('li').hasClass('leaf-item'); + + // if ( _this.parent.currentFocus === 'ThumbnailsView' & !isLeaf) { + // _this.parent.setCursorFrameStart(canvasID); + // } else { + _this.parent.setCurrentCanvasID(canvasID); + // } + }); + + _this.element.find('.toc-caret').on('click', function(event) { + event.stopPropagation(); + + var rangeID = jQuery(this).parent().data().rangeid; + _this.setOpenItem(rangeID); + + // For now it's alright if this data gets lost in the fray. + jQuery(this).closest('li').toggleClass('open').find('ul:first').slideFadeToggle(); + + // The parent (window) then emits an event notifying all panels of + // the update, so they can respond in their own unique ways + // without window having to know anything about their DOMs or + // internal structure. + }); + + }, + + setActive: function(active) { + var _this = this; + _this.active = active; + }, + + setOpenItem: function(rangeID) { + var _this = this; + + if (jQuery.inArray(rangeID, _this.openElements)<0) { + _this.openElements.push(rangeID); + } else { + _this.openElements.splice(jQuery.inArray(rangeID, _this.openElements), 1); + } + }, + + // focusCursorFrame: function() { + // console.log('focusCursorFrame'); + // }, + + // hoverItem: function() { + // console.log('hoverItem'); + // }, + + setSelectedElements: function(rangeIDs) { + var _this = this; + + _this.previousSelectedElements = _this.selectedElements; + _this.selectedElements = rangeIDs; + }, + + // returnToPlace: function() { + // console.log('returnToPlace'); + // }, + + emptyTemplate: Handlebars.compile([ + '
            ', + '
          • ', + '

            No index available

            ', + '
          ', + ].join('')), + + template: function(tplData) { + + var template = Handlebars.compile([ + '
            ', + '{{#nestedRangeLevel ranges}}', + '
          • ', + '{{{tocLevel id label level children}}}', + '{{#if children}}', + '
              ', + '{{{nestedRangeLevel children}}}', + '
            ', + '{{/if}}', + '
          • ', + '{{/nestedRangeLevel}}', + '
          ' + ].join('')); + + var previousTemplate; + + Handlebars.registerHelper('nestedRangeLevel', function(children, options) { + var out = ''; + + if (options.fn !== undefined) { + previousTemplate = options.fn; + } + + children.forEach(function(child) { + out = out + previousTemplate(child); + }); + + return out; + }); + + Handlebars.registerHelper('tocLevel', function(id, label, level, children) { + var caret = '', + cert = ''; + return '' + caret + cert + '' + label + ''; + }); + + return template(tplData); + }, + + toggle: function(stateValue) { + if (!this.structures) { stateValue = false; } + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.appendTo).hide(); + this.parent.element.find('.view-container').addClass('focus-max-width'); + }, + + show: function() { + jQuery(this.appendTo).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + this.parent.element.find('.view-container').removeClass('focus-max-width'); + } + + }; + +}(Mirador)); + +(function($) { + + $.WidgetViewport = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetViewport.prototype = { + + }; + +}(Mirador)); + + + +(function($) { + + $.Iiif = { + + getImageUrl: function(image) { + + if (!image.images[0].resource.service) { + id = image.images[0].resource['default'].service['@id']; + id = id.replace(/\/$/, ""); + return id; + } + var id = image.images[0].resource.service['@id']; + id = id.replace(/\/$/, ""); + + return id; + }, + + getVersionFromContext: function(context) { + if (context == "http://iiif.io/api/image/2/context.json") { + return "2.0"; + } else { + return "1.1"; + } + }, + + makeUriWithWidth: function(uri, width, version) { + uri = uri.replace(/\/$/, ''); + if (version[0] == '1') { + return uri + '/full/' + width + ',/0/native.jpg'; + } else { + return uri + '/full/' + width + ',/0/default.jpg'; + } + }, + + getImageHostUrl: function(json) { + var regex, + matches = []; + + if (!json.hasOwnProperty('image_host')) { + + json.image_host = json.tilesUrl || json['@id'] || ''; + + if (json.hasOwnProperty('identifier')) { + regex = new RegExp('/?' + json.identifier + '/?$', 'i'); + json.image_host = json.image_host.replace(regex, ''); + + } else { + regex = new RegExp('(.*)\/(.*)$'); + matches = regex.exec(json.image_host); + + if (matches.length > 1) { + json.image_host = matches[1]; + json.identifier = matches[2]; + } + } + } + + return json.image_host; + } + + }; + +}(Mirador)); + + +// for scroll view +// source: http://stackoverflow.com/questions/14035083/jquery-bind-event-on-scroll-stops +jQuery.fn.scrollStop = function(callback) { + $(this).scroll(function() { + var self = this, + $this = $(self); + + if ($this.data('scrollTimeout')) { + clearTimeout($this.data('scrollTimeout')); + } + + $this.data('scrollTimeout', setTimeout(callback, 250, self)); + }); +}; + + +// for resize events +// source: https://github.com/f/jquery.resizestop +(function($) { + var slice = Array.prototype.slice; + + // Special event definition + $.extend($.event.special, { + resizestop: { + add: function(handle) { + var handler = handle.handler; + + $(this).resize(function(e) { + clearTimeout(handler._timer); + e.type = 'resizestop'; + + var _proxy = $.proxy(handler, this, e); + handler._timer = setTimeout(_proxy, handle.data || 200); + }); + } + }, + + resizestart: { + add: function(handle) { + var handler = handle.handler; + + $(this).on('resize', function(e) { + clearTimeout(handler._timer); + + if (!handler._started) { + e.type = 'resizestart'; + handler.apply(this, arguments); + handler._started = true; + } + + handler._timer = setTimeout($.proxy(function() { + handler._started = false; + }, this), handle.data || 300); + }); + } + } + }); + + // binding and currying the shortcuts. + $.extend($.fn, { + resizestop: function() { + $(this).on.apply(this, ["resizestop"].concat(slice.call(arguments))); + }, + resizestart: function() { + $(this).on.apply(this, ["resizestart"].concat(slice.call(arguments))); + } + }); +})(jQuery); +(function($){ + + var JSONBLOB_API_ENDPOINT = '/api/jsonBlob'; + + function getAPIUri(host, port, ssl, body) { + + var proto = 'http'; + port = port ? port : '80'; + + if ( ssl ) { + proto = 'https'; + port = port ? port : '443'; + } + + host = host ? host : 'jsonblob.com'; + + var path = JSONBLOB_API_ENDPOINT; + + // If the body is a string, this is a blob GET operation, + // otherwise it's a POST + if ( typeof body === 'string' || body instanceof String ){ + path += '/' + body; + } + + return proto + '://' + host + ':' + port + path; + } + + function initSettings(method, host, port, ssl, requestBody) { + + var ajaxSettings = { + type: method, + url: getAPIUri(host, port, ssl, requestBody), + contentType: 'application/json; charset=UTF-8', + accept: 'application/json', + dataType: 'json', + processData: false + }; + + // POST The data + if ( typeof requestBody !== 'string' && !(requestBody instanceof String) ) { + ajaxSettings.data = JSON.stringify(requestBody); + } + + return ajaxSettings; + } + + function syncRequest(method, host, port, ssl, requestBody) { + var result; + var settings = initSettings(method, host, port, ssl, requestBody); + settings.async = false; + settings.success = function(data, textStatus, request) { + result = data; + }; + jQuery.ajax(settings); + return result; + } + + function asyncRequest(method, host, port, ssl, requestBody, cb) { + var settings = initSettings(method, host, port, ssl, requestBody); + settings.success = cb; + jQuery.ajax(settings); + } + + $.JSONBlobAPI = function(options) { + this.options = options; + }; + + + $.JSONBlobAPI.prototype = { + readSync: function(blobId) { + return syncRequest('GET', this.options.host, this.options.port, this.options.ssl, blobId); + }, + save: function(blob) { + var deferred = jQuery.Deferred(); + asyncRequest('POST', this.options.host, this.options.port, this.options.ssl, blob, function(data, textStatus, request) { + var blobid = request.getResponseHeader('X-Jsonblob'); + deferred.resolve(blobid); + }); + return deferred.promise(); + } + }; + +}(Mirador)); + + +(function($) { + + $.OaAnnotation = function(options) { + + jQuery.extend(this, { + text: null, + tags: null, + bounds: null, // the "frame" or "cnotext" bounds, in canvas coordinates + regionFragment: null, + id: null, // the oa (canvas) @id under which to save it, preferably a uri. + oaAnnotation: null + }, options); + + this.init(); + }; + + $.OaAnnotation.prototype = { + + init: function() { + this.oaAnnotation = {}; // stub text of valid oa annotation (as + // it would appear in an oa:annotationList) + // to go here. Properties will be queried and + // twiddled by the get/set methods for each + // property below (as the annotation is + // passed through the annotation creation process). + }, + + chars: function(chars) { + // getter and setter for text of annotation. + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + if (!arguments.length) return _this.oa.resource.chars; // not sure if this is the right "path"? + _this.oa.resource.chars = chars; + return this; // allow chaining? + }, + + tags: function(tags) { + if (!arguments.length) return _this.oa.resource.chars; // not sure if this is the right "path"? + _this.oa.resource.chars = chars; + return this; // allow chaining? + // getter and setter for tag field (only the part that can be changed by user). + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + }, + + regionFragment: function() { + if (!arguments.length) return _this.oa.on; // not sure if this is the right "path"? + _this.oa.on = chars; // not exactly, parse the "on" field to add the new context after hash. + return this; // allow chaining? + // getter and setter for tag field (only the part that can be changed by user). + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + } + }; +}(Mirador)); + +(function($) { + + $.OpenSeadragon = function(options) { + + var osd = OpenSeadragon( + + jQuery.extend({ + preserveViewport: true, + visibilityRatio: 1, + minZoomLevel: 0, + defaultZoomLevel: 0, + blendTime: 0.1, + alwaysBlend: false, + prefixUrl: 'images/openseadragon/', + showNavigationControl: false + }, options) + + ); + + return osd; + + }; + +}(Mirador)); + +(function($) { + + $.SaveController = function(config) { + + jQuery.extend(true, this, { + currentConfig: null, + originalConfig: null, // Don't know if we really need this. + shareEndpoint: null, // the place where POST requests for new saved sessions will go + historySize: null, // wishful thinking for later. + sessionID: null + }); + + this.init(jQuery.extend(false, $.DEFAULT_SETTINGS, config)); + + }; + + $.SaveController.prototype = { + + init: function(config) { + var _this = this; + + // Don't want to save session, therefore don't set up save controller + if (config.saveSession === false) { + this.currentConfig = config; + return false; + } + + saveModule = config.jsonStorageEndpoint.module, + saveOptions = config.jsonStorageEndpoint.options; + _this.storageModule = new $[saveModule](saveOptions); + + var sessionID = window.location.hash.substring(1); // will return empty string if none exists, causing the or statement below to evaluate to false, generating a new sesssionID. + + if (sessionID) { + this.sessionID = sessionID; + } else { + this.sessionID = $.genUUID(); // might want a cleaner thing for the url. + } + + if (localStorage.getItem(this.sessionID)) { + this.currentConfig = JSON.parse(localStorage.getItem(sessionID)); + } else { + var paramURL = window.location.search.substring(1); + if (paramURL) { + //get json from JSON storage and set currentConfig to it + var params = paramURL.split('='); + var jsonblob = params[1]; + this.currentConfig = this.storageModule.readSync(jsonblob); + } else { + this.currentConfig = config; + } + } + //remove empty hashes from config + this.currentConfig.windowObjects = jQuery.map(this.currentConfig.windowObjects, function(value, index) { + if (Object.keys(value).length === 0) return null; + return value; + }); + + //add UUIDs to parts of config that need them + if (this.currentConfig.windowObjects) { + jQuery.each(this.currentConfig.windowObjects, function(index, window) { + if (!window.id) { + window.id = $.genUUID(); + } + }); + } + // see: http://html5demos.com/history and http://diveintohtml5.info/history.html + // put history stuff here, for a great cross-browser demo, see: http://browserstate.github.io/history.js/demo/ + //http://stackoverflow.com/questions/17801614/popstate-passing-popped-state-to-event-handler + + //also remove ?json bit so it's a clean URL + var cleanURL = window.location.href.replace(window.location.search, ""); + if (window.location.hash) { + history.replaceState(this.currentConfig, "Mirador Session", cleanURL); + } else { + history.replaceState(this.currentConfig, "Mirador Session", cleanURL+"#"+this.sessionID); + } + + this.bindEvents(); + + }, + + set: function(prop, value, options) { + // when a property of the config is updated, + // save it to localStore. + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + this.save(); + jQuery.publish("saveControllerConfigUpdated"); + }, + + bindEvents: function() { + var _this = this; + // listen to existing events and use the + // available data to update the appropriate + // field in the stored config. + + jQuery.subscribe('windowUpdated', function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + jQuery.extend(windowObjects[index], options); + } + }); + } else { + windowObjects = [options]; + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe("imageBoundsUpdated", function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + if (!windowObjects[index].windowOptions) { + windowObjects[index].windowOptions = {}; + } + windowObjects[index].windowOptions.osdBounds = options.osdBounds; + } + }); + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('windowSlotAddressUpdated', function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + jQuery.extend(windowObjects[index], options); + } + }); + } else { + windowObjects = [options]; + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('manifestQueued', function(event, manifestObject, repository) { + var data = _this.currentConfig.data, + objectInConfig = false, + url = manifestObject.uri; + + jQuery.each(data, function(index, manifestObject){ + if (manifestObject.manifestUri === url) { + objectInConfig = true; + } + }); + if (!objectInConfig) { + data.push({"manifestUri":url, "location":repository}); + _this.set("data", data, {parent: "currentConfig"}); + } + }); + + jQuery.subscribe("layoutChanged", function(event, layoutDescription) { + // string parents to prevent invalid circular representation. + var serialisedLayout = JSON.stringify(layoutDescription, function(key, value) { + if (key === 'parent') return undefined; + return value; + }); + _this.set('layout', serialisedLayout, {parent: "currentConfig"} ); + }); + + jQuery.subscribe("windowSlotAdded", function(event, options) { + var windowObjects = _this.currentConfig.windowObjects, + inArray = jQuery.grep(windowObjects, function(windowObj) { + return windowObj.id === options.id; + }); + if (inArray.length === 0) { + windowObjects.push({ + 'id' : options.id, + 'slotAddress': options.slotAddress + }); + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + } + }); + + jQuery.subscribe("windowsRemoved", function(event) { + _this.set("windowObjects", [], {parent: "currentConfig"} ); + }); + + jQuery.subscribe("windowRemoved", function(event, windowID) { + var windowObjects = jQuery.grep(_this.currentConfig.windowObjects, function(window, index) { + return window.id !== windowID; + }); + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('etc...', function(junk) { + // handle adding the property in the appropriate place + // in this.currentConfig by passing to the _this.set(), + // which "saves" to localstore as a side effect. + + }); + + // We could have simply listened to the 'set' event that + // would have been emitted by objects when their models were + // updated and sent the results to a parser function that + // would extract the calling object's properties in the config + // and updated them if they were different, but we can't + // currently do that the way the app is written, since we + // didn't actually follow that patttern almost anywhere. + // + // jQuery.subscribe('set', function(junk) { + // // 1.) send the junk to a parser function + // // 2.) use this.set(parsedJunk) to update + // // this.currentConfig, with the side effect of + // // saving to localStorage. + // + // }); + + // you may need to bind another event here that responds to the + // user navigating history, for the purpose of popping the + // history entry back off. + + }, + + save: function() { + var _this = this; + + // the hash must be stringified because + // localStorage is a key:value store that + // only accepts strings. + + localStorage.setItem(_this.sessionID, JSON.stringify(_this.currentConfig)); + } + + }; + +}(Mirador)); + +(function($) { + + $.trimString = function(str) { + return str.replace(/^\s+|\s+$/g, ''); + }; + + /* -------------------------------------------------------------------------- + Methods related to manifest data + -------------------------------------------------------------------------- */ + + $.getImageIndexById = function(imagesList, id) { + var imgIndex = 0; + + jQuery.each(imagesList, function(index, img) { + if ($.trimString(img['@id']) === $.trimString(id)) { + imgIndex = index; + } + }); + + return imgIndex; + }; + + $.getThumbnailForCanvas = function(canvas, width) { + var version = "1.1", + service, + thumbnailUrl; + + // Ensure width is an integer... + width = parseInt(width, 10); + + // Respecting the Model... + if (canvas.hasOwnProperty('thumbnail')) { + // use the thumbnail image, prefer via a service + if (typeof(canvas.thumbnail) == 'string') { + thumbnailUrl = canvas.thumbnail; + } else if (canvas.thumbnail.hasOwnProperty('service')) { + // Get the IIIF Image API via the @context + service = canvas.thumbnail.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + console.log('version'); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } else { + thumbnailUrl = canvas.thumbnail['@id']; + } + } else { + // No thumbnail, use main image + var resource = canvas.images[0].resource; + service = resource['default'] ? resource['default'].service : resource.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } + return thumbnailUrl; + }; + + $.getImagesListByManifest = function(manifest) { + return manifest.sequences[0].canvases; + }; + + $.getCollectionTitle = function(metadata) { + return metadata.details.label || ''; + }; + + /* + miscellaneous utilities + */ + + $.getQueryParams = function(url) { + var assoc = {}; + var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); }; + var queryString = url.split('?')[1]; + var keyValues = queryString.split('&'); + + for(var i in keyValues) { + var key = keyValues[i].split('='); + if (key.length > 1) { + assoc[decode(key[0])] = decode(key[1]); + } + } + + return assoc; + }; + + $.genUUID = function() { + var idNum = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + + return idNum; + }; + + jQuery.fn.slideFadeToggle = function(speed, easing, callback) { + return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); + }; + + $.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + + if (typeof options !== 'undefined') { + options = {}; + } + + var later = function() { + previous = options.leading === false ? 0 : new Date(); + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date(); + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + $.debounce = function(func, wait, immediate) { + var timeout, args, context, timestamp, result; + return function() { + context = this; + args = arguments; + timestamp = new Date(); + var later = function() { + var last = (new Date()) - timestamp; + if (last < wait) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + } + }; + var callNow = immediate && !timeout; + if (!timeout) { + timeout = setTimeout(later, wait); + } + if (callNow) result = func.apply(context, args); + return result; + }; + }; + + $.parseRegion = function(url) { + url = new URI(url); + var regionString = url.hash(); + regionArray = regionString.split('=')[1].split(','); + return regionArray; + }; + + $.getOsdFrame = function(region, currentImg) { + var imgWidth = currentImg.width, + imgHeight = currentImg.height, + canvasWidth = currentImg.canvasWidth, + canvasHeight = currentImg.canvasHeight, + widthNormaliser = imgWidth/canvasWidth, + heightNormaliser = imgHeight/canvasHeight, + rectX = (region[0]*widthNormaliser)/imgWidth, + rectY = (region[1]*heightNormaliser)/imgWidth, + rectW = (region[2]*widthNormaliser)/imgWidth, + rectH = (region[3]*heightNormaliser)/imgWidth; + + var osdFrame = new OpenSeadragon.Rect(rectX,rectY,rectW,rectH); + + return osdFrame; + }; + + // http://upshots.org/javascript/jquery-test-if-element-is-in-viewport-visible-on-screen + $.isOnScreen = function(elem, outsideViewportFactor) { + var factor = 1; + if (outsideViewportFactor) { + factor = outsideViewportFactor; + } + var win = jQuery(window); + var viewport = { + top : (win.scrollTop() * factor), + left : (win.scrollLeft() * factor) + }; + viewport.bottom = (viewport.top + win.outerHeight()) * factor; + viewport.right = (viewport.left + win.outerWidth()) * factor; + + var el = jQuery(elem); + var bounds = el.offset(); + bounds.bottom = bounds.top + el.height(); + bounds.right = bounds.left + el.width(); + + return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); + }; + + $.getRangeIDByCanvasID = function(structures, canvasID /*, [given parent range] (for multiple ranges, later) */) { + var ranges = jQuery.grep(structures, function(range) { return jQuery.inArray(canvasID, range.canvases) > -1; }), + rangeIDs = jQuery.map(ranges, function(range) { return range['@id']; }); + + return rangeIDs; + }; + + $.layoutDescriptionFromGridString = function (gridString) { + var columns = parseInt(gridString.substring(gridString.indexOf("x") + 1, gridString.length),10), + rowsPerColumn = parseInt(gridString.substring(0, gridString.indexOf("x")),10), + layoutDescription = { + type:'row' + }; + + if (gridString === "1x1") return layoutDescription; + + layoutDescription.children = []; + + // Javascript does not have range expansions quite yet, + // long live the humble for loop. + // Use a closure to contain the column and row variables. + for (var i = 0, c = columns; i < c; i++) { + var column = { type: 'column'}; + + if (rowsPerColumn > 1) { + column.children = []; + for (var j = 0, r = rowsPerColumn; j < r; j++) { + column.children.push({ + type: 'row' + }); + } + } + + layoutDescription.children.push(column); + } + + return layoutDescription; + }; + + $.generateRange = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = step || 1; + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + }; + + // Configurable Promises + $.createImagePromise = function(imageUrl) { + var img = new Image(), + dfd = jQuery.Deferred(); + + img.onload = function() { + dfd.resolve(img.src); + }; + + img.onerror = function() { + dfd.reject(img.src); + }; + + dfd.fail(function() { + console.log('image failed to load: ' + img.src); + }); + + img.src = imageUrl; + return dfd.promise(); + }; + +}(Mirador)); diff --git a/vendor/assets/javascripts/mirador.js.erb b/vendor/assets/javascripts/mirador.js.erb new file mode 100644 index 0000000..0d044f2 --- /dev/null +++ b/vendor/assets/javascripts/mirador.js.erb @@ -0,0 +1,11461 @@ +//! Mirador 2.0.0 +//! Built on 2015-12-31 +/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license +*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
          a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
          t
          ",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
          ",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; +return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
          ",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
          ","
          "],area:[1,"",""],param:[1,"",""],thead:[1,"","
          "],tr:[2,"","
          "],col:[2,"","
          "],td:[3,"","
          "],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
          ","
          "]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) +}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("':""),e._keyEvent=!1,F},_generateMonthYearHeader:function(e,t,i,a,s,n,r,o){var h=this._get(e,"changeMonth"),l=this._get(e,"changeYear"),u=this._get(e,"showMonthAfterYear"),d='
          ',c="";if(n||!h)c+=''+r[t]+"";else{var p=a&&a.getFullYear()==i,m=s&&s.getFullYear()==i;c+='"}if(u||(d+=c+(!n&&h&&l?"":" ")),!e.yearshtml)if(e.yearshtml="",n||!l)d+=''+i+"";else{var g=this._get(e,"yearRange").split(":"),v=(new Date).getFullYear(),y=function(e){var t=e.match(/c[+-].*/)?i+parseInt(e.substring(1),10):e.match(/[+-].*/)?v+parseInt(e,10):parseInt(e,10);return isNaN(t)?v:t},b=y(g[0]),_=Math.max(b,y(g[1]||""));for(b=a?Math.max(b,a.getFullYear()):b,_=s?Math.min(_,s.getFullYear()):_,e.yearshtml+='",d+=e.yearshtml,e.yearshtml=null}return d+=this._get(e,"yearSuffix"),u&&(d+=(!n&&h&&l?"":" ")+c),d+="
          "},_adjustInstDate:function(e,t,i){var a=e.drawYear+("Y"==i?t:0),s=e.drawMonth+("M"==i?t:0),n=Math.min(e.selectedDay,this._getDaysInMonth(a,s))+("D"==i?t:0),r=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(a,s,n)));e.selectedDay=r.getDate(),e.drawMonth=e.selectedMonth=r.getMonth(),e.drawYear=e.selectedYear=r.getFullYear(),("M"==i||"Y"==i)&&this._notifyChange(e)},_restrictMinMax:function(e,t){var i=this._getMinMaxDate(e,"min"),a=this._getMinMaxDate(e,"max"),s=i&&i>t?i:t;return s=a&&s>a?a:s},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,i,a){var s=this._getNumberOfMonths(e),n=this._daylightSavingAdjust(new Date(i,a+(0>t?t:s[0]*s[1]),1));return 0>t&&n.setDate(this._getDaysInMonth(n.getFullYear(),n.getMonth())),this._isInRange(e,n)},_isInRange:function(e,t){var i=this._getMinMaxDate(e,"min"),a=this._getMinMaxDate(e,"max");return(!i||t.getTime()>=i.getTime())&&(!a||t.getTime()<=a.getTime())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t="string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,i,a){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var s=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(a,i,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),s,this._getFormatConfig(e))}}),$.fn.datepicker=function(e){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv),$.datepicker.initialized=!0);var t=Array.prototype.slice.call(arguments,1);return"string"!=typeof e||"isDisabled"!=e&&"getDate"!=e&&"widget"!=e?"option"==e&&2==arguments.length&&"string"==typeof arguments[1]?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t)):this.each(function(){"string"==typeof e?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this].concat(t)):$.datepicker._attachDatepicker(this,e)}):$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.9.2",window["DP_jQuery_"+dpuuid]=$})(jQuery);(function(e,t){var i="ui-dialog ui-widget ui-widget-content ui-corner-all ",a={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},s={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.2",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var i=e(this).css(t).offset().top;0>i&&e(this).css("top",t.top-i)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),"string"!=typeof this.originalTitle&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var a,s,n,r,o,h=this,l=this.options,u=l.title||" ";a=(this.uiDialog=e("
          ")).addClass(i+l.dialogClass).css({display:"none",outline:0,zIndex:l.zIndex}).attr("tabIndex",-1).keydown(function(t){l.closeOnEscape&&!t.isDefaultPrevented()&&t.keyCode&&t.keyCode===e.ui.keyCode.ESCAPE&&(h.close(t),t.preventDefault())}).mousedown(function(e){h.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(a),s=(this.uiDialogTitlebar=e("
          ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").bind("mousedown",function(){a.focus()}).prependTo(a),n=e("").addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),h.close(e)}).appendTo(s),(this.uiDialogTitlebarCloseText=e("")).addClass("ui-icon ui-icon-closethick").text(l.closeText).appendTo(n),r=e("").uniqueId().addClass("ui-dialog-title").html(u).prependTo(s),o=(this.uiDialogButtonPane=e("
          ")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("
          ")).addClass("ui-dialog-buttonset").appendTo(o),a.attr({role:"dialog","aria-labelledby":r.attr("id")}),s.find("*").add(s).disableSelection(),this._hoverable(n),this._focusable(n),l.draggable&&e.fn.draggable&&this._makeDraggable(),l.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(l.buttons),this._isOpen=!1,e.fn.bgiframe&&a.bgiframe(),this._on(a,{keydown:function(i){if(l.modal&&i.keyCode===e.ui.keyCode.TAB){var s=e(":tabbable",a),n=s.filter(":first"),r=s.filter(":last");return i.target!==r[0]||i.shiftKey?i.target===n[0]&&i.shiftKey?(r.focus(1),!1):t:(n.focus(1),!1)}}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var i,a,s=this;if(this._isOpen&&!1!==this._trigger("beforeClose",t))return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){s._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(i=0,e(".ui-dialog").each(function(){this!==s.uiDialog[0]&&(a=e(this).css("z-index"),isNaN(a)||(i=Math.max(i,a)))}),e.ui.dialog.maxZ=i),this},isOpen:function(){return this._isOpen},moveToTop:function(t,i){var a,s=this.options;return s.modal&&!t||!s.stack&&!s.modal?this._trigger("focus",i):(s.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=s.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),a={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(a),this._trigger("focus",i),this)},open:function(){if(!this._isOpen){var t,i=this.options,a=this.uiDialog;return this._size(),this._position(i.position),a.show(i.show),this.overlay=i.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=a)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this}},_createButtons:function(t){var i=this,a=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),"object"==typeof t&&null!==t&&e.each(t,function(){return!(a=!0)}),a?(e.each(t,function(t,a){var s,n;a=e.isFunction(a)?{click:a,text:t}:a,a=e.extend({type:"button"},a),n=a.click,a.click=function(){n.apply(i.element[0],arguments)},s=e("",a).appendTo(i.uiButtonSet),e.fn.button&&s.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function t(e){return{position:e.position,offset:e.offset}}var i=this,a=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(a,s){e(this).addClass("ui-dialog-dragging"),i._trigger("dragStart",a,t(s))},drag:function(e,a){i._trigger("drag",e,t(a))},stop:function(s,n){a.position=[n.position.left-i.document.scrollLeft(),n.position.top-i.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),i._trigger("dragStop",s,t(n)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(i){function a(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}i=i===t?this.options.resizable:i;var s=this,n=this.options,r=this.uiDialog.css("position"),o="string"==typeof i?i:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:n.maxWidth,maxHeight:n.maxHeight,minWidth:n.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,i){e(this).addClass("ui-dialog-resizing"),s._trigger("resizeStart",t,a(i))},resize:function(e,t){s._trigger("resize",e,a(t))},stop:function(t,i){e(this).removeClass("ui-dialog-resizing"),n.height=e(this).height(),n.width=e(this).width(),s._trigger("resizeStop",t,a(i)),e.ui.dialog.overlay.resize()}}).css("position",r).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return"auto"===e.height?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var i,a=[],s=[0,0];t?(("string"==typeof t||"object"==typeof t&&"0"in t)&&(a=t.split?t.split(" "):[t[0],t[1]],1===a.length&&(a[1]=a[0]),e.each(["left","top"],function(e,t){+a[e]===a[e]&&(s[e]=a[e],a[e]=t)}),t={my:a[0]+(0>s[0]?s[0]:"+"+s[0])+" "+a[1]+(0>s[1]?s[1]:"+"+s[1]),at:a.join(" ")}),t=e.extend({},e.ui.dialog.prototype.options.position,t)):t=e.ui.dialog.prototype.options.position,i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var i=this,n={},r=!1;e.each(t,function(e,t){i._setOption(e,t),e in a&&(r=!0),e in s&&(n[e]=t)}),r&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(t,a){var s,n,r=this.uiDialog;switch(t){case"buttons":this._createButtons(a);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+a);break;case"dialogClass":r.removeClass(this.options.dialogClass).addClass(i+a);break;case"disabled":a?r.addClass("ui-dialog-disabled"):r.removeClass("ui-dialog-disabled");break;case"draggable":s=r.is(":data(draggable)"),s&&!a&&r.draggable("destroy"),!s&&a&&this._makeDraggable();break;case"position":this._position(a);break;case"resizable":n=r.is(":data(resizable)"),n&&!a&&r.resizable("destroy"),n&&"string"==typeof a&&r.resizable("option","handles",a),n||a===!1||this._makeResizable(a);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(a||" "))}this._super(t,a)},_size:function(){var t,i,a,s=this.options,n=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),s.minWidth>s.width&&(s.width=s.minWidth),t=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),i=Math.max(0,s.minHeight-t),"auto"===s.height?e.support.minHeight?this.element.css({minHeight:i,height:"auto"}):(this.uiDialog.show(),a=this.element.css("height","auto").height(),n||this.uiDialog.hide(),this.element.height(Math.max(a,i))):this.element.height(Math.max(s.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(i){0===this.instances.length&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(i){return e(i.target).zIndex()").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(t){var s=e.ui.dialog.overlay.instances;0!==s.length&&s[s.length-1]===a&&i.options.closeOnEscape&&!t.isDefaultPrevented()&&t.keyCode&&t.keyCode===e.ui.keyCode.ESCAPE&&(i.close(t),t.preventDefault())}),a.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&a.bgiframe(),this.instances.push(a),a},destroy:function(t){var i=e.inArray(t,this.instances),a=0;-1!==i&&this.oldInstances.push(this.instances.splice(i,1)[0]),0===this.instances.length&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){a=Math.max(a,this.css("z-index"))}),this.maxZ=a},height:function(){var t,i;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),i=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),i>t?e(window).height()+"px":t+"px"):e(document).height()+"px"},width:function(){var t,i;return e.ui.ie?(t=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),i=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),i>t?e(window).width()+"px":t+"px"):e(document).width()+"px"},resize:function(){var t=e([]);e.each(e.ui.dialog.overlay.instances,function(){t=t.add(this)}),t.css({width:0,height:0}).css({width:e.ui.dialog.overlay.width(),height:e.ui.dialog.overlay.height()})}}),e.extend(e.ui.dialog.overlay.prototype,{destroy:function(){e.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);(function(e){e.widget("ui.draggable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){"original"!=this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var i=this.options;return this.helper||i.disabled||e(t.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(t),this.handle?(e(i.iframeFix===!0?"iframe":i.iframeFix).each(function(){e('
          ').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),i.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,i){if(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),!i){var a=this._uiHash();if(this._trigger("drag",t,a)===!1)return this._mouseUp({}),!1;this.position=a.position}return this.options.axis&&"y"==this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"==this.options.axis||(this.helper[0].style.top=this.position.top+"px"),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(i=e.ui.ddmanager.drop(this,t)),this.dropped&&(i=this.dropped,this.dropped=!1);for(var a=this.element[0],s=!1;a&&(a=a.parentNode);)a==document&&(s=!0);if(!s&&"original"===this.options.helper)return!1;if("invalid"==this.options.revert&&!i||"valid"==this.options.revert&&i||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,i)){var n=this;e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){n._trigger("stop",t)!==!1&&n._clear()})}else this._trigger("stop",t)!==!1&&this._clear();return!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){var i=this.options.handle&&e(this.options.handle,this.element).length?!1:!0;return e(this.options.handle,this.element).find("*").andSelf().each(function(){this==t.target&&(i=!0)}),i},_createHelper:function(t){var i=this.options,a=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t])):"clone"==i.helper?this.element.clone().removeAttr("id"):this.element;return a.parents("body").length||a.appendTo("parent"==i.appendTo?this.element[0].parentNode:i.appendTo),a[0]==this.element[0]||/(fixed|absolute)/.test(a.css("position"))||a.css("position","absolute"),a},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"==this.cssPosition&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;if("parent"==t.containment&&(t.containment=this.helper[0].parentNode),("document"==t.containment||"window"==t.containment)&&(this.containment=["document"==t.containment?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,"document"==t.containment?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,("document"==t.containment?0:e(window).scrollLeft())+e("document"==t.containment?document:window).width()-this.helperProportions.width-this.margins.left,("document"==t.containment?0:e(window).scrollTop())+(e("document"==t.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(t.containment)||t.containment.constructor==Array)t.containment.constructor==Array&&(this.containment=t.containment);else{var i=e(t.containment),a=i[0];if(!a)return;i.offset();var s="hidden"!=e(a).css("overflow");this.containment=[(parseInt(e(a).css("borderLeftWidth"),10)||0)+(parseInt(e(a).css("paddingLeft"),10)||0),(parseInt(e(a).css("borderTopWidth"),10)||0)+(parseInt(e(a).css("paddingTop"),10)||0),(s?Math.max(a.scrollWidth,a.offsetWidth):a.offsetWidth)-(parseInt(e(a).css("borderLeftWidth"),10)||0)-(parseInt(e(a).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(s?Math.max(a.scrollHeight,a.offsetHeight):a.offsetHeight)-(parseInt(e(a).css("borderTopWidth"),10)||0)-(parseInt(e(a).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=i}},_convertPositionTo:function(t,i){i||(i=this.position);var a="absolute"==t?1:-1,s=(this.options,"absolute"!=this.cssPosition||this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent),n=/(html|body)/i.test(s[0].tagName);return{top:i.top+this.offset.relative.top*a+this.offset.parent.top*a-("fixed"==this.cssPosition?-this.scrollParent.scrollTop():n?0:s.scrollTop())*a,left:i.left+this.offset.relative.left*a+this.offset.parent.left*a-("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():n?0:s.scrollLeft())*a}},_generatePosition:function(t){var i=this.options,a="absolute"!=this.cssPosition||this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(a[0].tagName),n=t.pageX,r=t.pageY;if(this.originalPosition){var o;if(this.containment){if(this.relative_container){var l=this.relative_container.offset();o=[this.containment[0]+l.left,this.containment[1]+l.top,this.containment[2]+l.left,this.containment[3]+l.top]}else o=this.containment;t.pageX-this.offset.click.lefto[2]&&(n=o[2]+this.offset.click.left),t.pageY-this.offset.click.top>o[3]&&(r=o[3]+this.offset.click.top)}if(i.grid){var h=i.grid[1]?this.originalPageY+Math.round((r-this.originalPageY)/i.grid[1])*i.grid[1]:this.originalPageY;r=o?h-this.offset.click.topo[3]?h-this.offset.click.topo[2]?u-this.offset.click.left=0;u--){var d=a.snapElements[u].left,c=d+a.snapElements[u].width,p=a.snapElements[u].top,m=p+a.snapElements[u].height;if(r>d-n&&c+n>r&&l>p-n&&m+n>l||r>d-n&&c+n>r&&h>p-n&&m+n>h||o>d-n&&c+n>o&&l>p-n&&m+n>l||o>d-n&&c+n>o&&h>p-n&&m+n>h){if("inner"!=s.snapMode){var f=n>=Math.abs(p-h),g=n>=Math.abs(m-l),v=n>=Math.abs(d-o),y=n>=Math.abs(c-r);f&&(i.position.top=a._convertPositionTo("relative",{top:p-a.helperProportions.height,left:0}).top-a.margins.top),g&&(i.position.top=a._convertPositionTo("relative",{top:m,left:0}).top-a.margins.top),v&&(i.position.left=a._convertPositionTo("relative",{top:0,left:d-a.helperProportions.width}).left-a.margins.left),y&&(i.position.left=a._convertPositionTo("relative",{top:0,left:c}).left-a.margins.left)}var b=f||g||v||y;if("outer"!=s.snapMode){var f=n>=Math.abs(p-l),g=n>=Math.abs(m-h),v=n>=Math.abs(d-r),y=n>=Math.abs(c-o);f&&(i.position.top=a._convertPositionTo("relative",{top:p,left:0}).top-a.margins.top),g&&(i.position.top=a._convertPositionTo("relative",{top:m-a.helperProportions.height,left:0}).top-a.margins.top),v&&(i.position.left=a._convertPositionTo("relative",{top:0,left:d}).left-a.margins.left),y&&(i.position.left=a._convertPositionTo("relative",{top:0,left:c-a.helperProportions.width}).left-a.margins.left)}!a.snapElements[u].snapping&&(f||g||v||y||b)&&a.options.snap.snap&&a.options.snap.snap.call(a.element,t,e.extend(a._uiHash(),{snapItem:a.snapElements[u].item})),a.snapElements[u].snapping=f||g||v||y||b}else a.snapElements[u].snapping&&a.options.snap.release&&a.options.snap.release.call(a.element,t,e.extend(a._uiHash(),{snapItem:a.snapElements[u].item})),a.snapElements[u].snapping=!1}}}),e.ui.plugin.add("draggable","stack",{start:function(){var t=e(this).data("draggable").options,i=e.makeArray(e(t.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});if(i.length){var a=parseInt(i[0].style.zIndex)||0;e(i).each(function(e){this.style.zIndex=a+e}),this[0].style.zIndex=a+i.length}}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i){var a=e(i.helper),s=e(this).data("draggable").options;a.css("zIndex")&&(s._zIndex=a.css("zIndex")),a.css("zIndex",s.zIndex)},stop:function(t,i){var a=e(this).data("draggable").options;a._zIndex&&e(i.helper).css("zIndex",a._zIndex)}})})(jQuery);(function(e){e.widget("ui.droppable",{version:"1.9.2",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var t=this.options,i=t.accept;this.isover=0,this.isout=1,this.accept=e.isFunction(i)?i:function(e){return e.is(i)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){for(var t=e.ui.ddmanager.droppables[this.options.scope],i=0;t.length>i;i++)t[i]==this&&t.splice(i,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,i){"accept"==t&&(this.accept=e.isFunction(i)?i:function(e){return e.is(i)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",t,this.ui(i))},_deactivate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",t,this.ui(i))},_over:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!=this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(i)))},_out:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!=this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(i)))},_drop:function(t,i){var a=i||e.ui.ddmanager.current;if(!a||(a.currentItem||a.element)[0]==this.element[0])return!1;var s=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"droppable");return t.options.greedy&&!t.options.disabled&&t.options.scope==a.options.scope&&t.accept.call(t.element[0],a.currentItem||a.element)&&e.ui.intersect(a,e.extend(t,{offset:t.element.offset()}),t.options.tolerance)?(s=!0,!1):undefined}),s?!1:this.accept.call(this.element[0],a.currentItem||a.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(a)),this.element):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(t,i,a){if(!i.offset)return!1;var s=(t.positionAbs||t.position.absolute).left,n=s+t.helperProportions.width,r=(t.positionAbs||t.position.absolute).top,o=r+t.helperProportions.height,l=i.offset.left,h=l+i.proportions.width,u=i.offset.top,d=u+i.proportions.height;switch(a){case"fit":return s>=l&&h>=n&&r>=u&&d>=o;case"intersect":return s+t.helperProportions.width/2>l&&h>n-t.helperProportions.width/2&&r+t.helperProportions.height/2>u&&d>o-t.helperProportions.height/2;case"pointer":var c=(t.positionAbs||t.position.absolute).left+(t.clickOffset||t.offset.click).left,p=(t.positionAbs||t.position.absolute).top+(t.clickOffset||t.offset.click).top,m=e.ui.isOver(p,c,u,l,i.proportions.height,i.proportions.width);return m;case"touch":return(r>=u&&d>=r||o>=u&&d>=o||u>r&&o>d)&&(s>=l&&h>=s||n>=l&&h>=n||l>s&&n>h);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,i){var a=e.ui.ddmanager.droppables[t.options.scope]||[],s=i?i.type:null,n=(t.currentItem||t.element).find(":data(droppable)").andSelf();e:for(var r=0;a.length>r;r++)if(!(a[r].options.disabled||t&&!a[r].accept.call(a[r].element[0],t.currentItem||t.element))){for(var o=0;n.length>o;o++)if(n[o]==a[r].element[0]){a[r].proportions.height=0;continue e}a[r].visible="none"!=a[r].element.css("display"),a[r].visible&&("mousedown"==s&&a[r]._activate.call(a[r],i),a[r].offset=a[r].element.offset(),a[r].proportions={width:a[r].element[0].offsetWidth,height:a[r].element[0].offsetHeight})}},drop:function(t,i){var a=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){this.options&&(!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(a=this._drop.call(this,i)||a),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,i)))}),a},dragStart:function(t,i){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)})},drag:function(t,i){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,i),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var a=e.ui.intersect(t,this,this.options.tolerance),s=a||1!=this.isover?a&&0==this.isover?"isover":null:"isout";if(s){var n;if(this.options.greedy){var r=this.options.scope,o=this.element.parents(":data(droppable)").filter(function(){return e.data(this,"droppable").options.scope===r});o.length&&(n=e.data(o[0],"droppable"),n.greedyChild="isover"==s?1:0)}n&&"isover"==s&&(n.isover=0,n.isout=1,n._out.call(n,i)),this[s]=1,this["isout"==s?"isover":"isout"]=0,this["isover"==s?"_over":"_out"].call(this,i),n&&"isout"==s&&(n.isout=0,n.isover=1,n._over.call(n,i))}}})},dragStop:function(t,i){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)}}})(jQuery);jQuery.effects||function(e,t){var i=e.uiBackCompat!==!1,a="ui-effects-";e.effects={effect:{}},function(t,i){function a(e,t,i){var a=c[t.type]||{};return null==e?i||!t.def?null:t.def:(e=a.floor?~~e:parseFloat(e),isNaN(e)?t.def:a.mod?(e+a.mod)%a.mod:0>e?0:e>a.max?a.max:e)}function s(e){var a=u(),s=a._rgba=[];return e=e.toLowerCase(),m(l,function(t,n){var r,o=n.re.exec(e),h=o&&n.parse(o),l=n.space||"rgba";return h?(r=a[l](h),a[d[l].cache]=r[d[l].cache],s=a._rgba=r._rgba,!1):i}),s.length?("0,0,0,0"===s.join()&&t.extend(s,r.transparent),a):r[e]}function n(e,t,i){return i=(i+1)%1,1>6*i?e+6*(t-e)*i:1>2*i?t:2>3*i?e+6*(t-e)*(2/3-i):e}var r,o="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),h=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[2.55*e[1],2.55*e[2],2.55*e[3],e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],u=t.Color=function(e,i,a,s){return new t.Color.fn.parse(e,i,a,s)},d={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},c={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},p=u.support={},f=t("

          ")[0],m=t.each;f.style.cssText="background-color:rgba(1,1,1,.5)",p.rgba=f.style.backgroundColor.indexOf("rgba")>-1,m(d,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),u.fn=t.extend(u.prototype,{parse:function(n,o,h,l){if(n===i)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(o),o=i);var c=this,p=t.type(n),f=this._rgba=[];return o!==i&&(n=[n,o,h,l],p="array"),"string"===p?this.parse(s(n)||r._default):"array"===p?(m(d.rgba.props,function(e,t){f[t.idx]=a(n[t.idx],t)}),this):"object"===p?(n instanceof u?m(d,function(e,t){n[t.cache]&&(c[t.cache]=n[t.cache].slice())}):m(d,function(t,i){var s=i.cache;m(i.props,function(e,t){if(!c[s]&&i.to){if("alpha"===e||null==n[e])return;c[s]=i.to(c._rgba)}c[s][t.idx]=a(n[e],t,!0)}),c[s]&&0>e.inArray(null,c[s].slice(0,3))&&(c[s][3]=1,i.from&&(c._rgba=i.from(c[s])))}),this):i},is:function(e){var t=u(e),a=!0,s=this;return m(d,function(e,n){var r,o=t[n.cache];return o&&(r=s[n.cache]||n.to&&n.to(s._rgba)||[],m(n.props,function(e,t){return null!=o[t.idx]?a=o[t.idx]===r[t.idx]:i})),a}),a},_space:function(){var e=[],t=this;return m(d,function(i,a){t[a.cache]&&e.push(i)}),e.pop()},transition:function(e,t){var i=u(e),s=i._space(),n=d[s],r=0===this.alpha()?u("transparent"):this,o=r[n.cache]||n.to(r._rgba),h=o.slice();return i=i[n.cache],m(n.props,function(e,s){var n=s.idx,r=o[n],l=i[n],u=c[s.type]||{};null!==l&&(null===r?h[n]=l:(u.mod&&(l-r>u.mod/2?r+=u.mod:r-l>u.mod/2&&(r-=u.mod)),h[n]=a((l-r)*t+r,s)))}),this[s](h)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),a=i.pop(),s=u(e)._rgba;return u(t.map(i,function(e,t){return(1-a)*s[t]+a*e}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(e,t){return null==e?t>2?1:0:e});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(e,t){return null==e&&(e=t>2?1:0),t&&3>t&&(e=Math.round(100*e)+"%"),e});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),a=i.pop();return e&&i.push(~~(255*a)),"#"+t.map(i,function(e){return e=(e||0).toString(16),1===e.length?"0"+e:e}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),u.fn.parse.prototype=u.fn,d.hsla.to=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t,i,a=e[0]/255,s=e[1]/255,n=e[2]/255,r=e[3],o=Math.max(a,s,n),h=Math.min(a,s,n),l=o-h,u=o+h,d=.5*u;return t=h===o?0:a===o?60*(s-n)/l+360:s===o?60*(n-a)/l+120:60*(a-s)/l+240,i=0===d||1===d?d:.5>=d?l/u:l/(2-u),[Math.round(t)%360,i,d,null==r?1:r]},d.hsla.from=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t=e[0]/360,i=e[1],a=e[2],s=e[3],r=.5>=a?a*(1+i):a+i-a*i,o=2*a-r;return[Math.round(255*n(o,r,t+1/3)),Math.round(255*n(o,r,t)),Math.round(255*n(o,r,t-1/3)),s]},m(d,function(e,s){var n=s.props,r=s.cache,o=s.to,l=s.from;u.fn[e]=function(e){if(o&&!this[r]&&(this[r]=o(this._rgba)),e===i)return this[r].slice();var s,h=t.type(e),d="array"===h||"object"===h?e:arguments,c=this[r].slice();return m(n,function(e,t){var i=d["object"===h?e:t.idx];null==i&&(i=c[t.idx]),c[t.idx]=a(i,t)}),l?(s=u(l(c)),s[r]=c,s):u(c)},m(n,function(i,a){u.fn[i]||(u.fn[i]=function(s){var n,r=t.type(s),o="alpha"===i?this._hsla?"hsla":"rgba":e,l=this[o](),u=l[a.idx];return"undefined"===r?u:("function"===r&&(s=s.call(this,u),r=t.type(s)),null==s&&a.empty?this:("string"===r&&(n=h.exec(s),n&&(s=u+parseFloat(n[2])*("+"===n[1]?1:-1))),l[a.idx]=s,this[o](l)))})})}),m(o,function(e,i){t.cssHooks[i]={set:function(e,a){var n,r,o="";if("string"!==t.type(a)||(n=s(a))){if(a=u(n||a),!p.rgba&&1!==a._rgba[3]){for(r="backgroundColor"===i?e.parentNode:e;(""===o||"transparent"===o)&&r&&r.style;)try{o=t.css(r,"backgroundColor"),r=r.parentNode}catch(h){}a=a.blend(o&&"transparent"!==o?o:"_default")}a=a.toRgbaString()}try{e.style[i]=a}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=u(e.elem,i),e.end=u(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}}),t.cssHooks.borderColor={expand:function(e){var t={};return m(["Top","Right","Bottom","Left"],function(i,a){t["border"+a+"Color"]=e}),t}},r=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(){var t,i,a=this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this,null):this.currentStyle,s={};if(a&&a.length&&a[0]&&a[a[0]])for(i=a.length;i--;)t=a[i],"string"==typeof a[t]&&(s[e.camelCase(t)]=a[t]);else for(t in a)"string"==typeof a[t]&&(s[t]=a[t]);return s}function a(t,i){var a,s,r={};for(a in i)s=i[a],t[a]!==s&&(n[a]||(e.fx.step[a]||!isNaN(parseFloat(s)))&&(r[a]=s));return r}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,i){e.fx.step[i]=function(e){("none"!==e.end&&!e.setAttr||1===e.pos&&!e.setAttr)&&(jQuery.style(e.elem,i,e.end),e.setAttr=!0)}}),e.effects.animateClass=function(t,n,r,o){var h=e.speed(n,r,o);return this.queue(function(){var n,r=e(this),o=r.attr("class")||"",l=h.children?r.find("*").andSelf():r;l=l.map(function(){var t=e(this);return{el:t,start:i.call(this)}}),n=function(){e.each(s,function(e,i){t[i]&&r[i+"Class"](t[i])})},n(),l=l.map(function(){return this.end=i.call(this.el[0]),this.diff=a(this.start,this.end),this}),r.attr("class",o),l=l.map(function(){var t=this,i=e.Deferred(),a=jQuery.extend({},h,{queue:!1,complete:function(){i.resolve(t)}});return this.el.animate(this.diff,a),i.promise()}),e.when.apply(e,l.get()).done(function(){n(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),h.complete.call(r[0])})})},e.fn.extend({_addClass:e.fn.addClass,addClass:function(t,i,a,s){return i?e.effects.animateClass.call(this,{add:t},i,a,s):this._addClass(t)},_removeClass:e.fn.removeClass,removeClass:function(t,i,a,s){return i?e.effects.animateClass.call(this,{remove:t},i,a,s):this._removeClass(t)},_toggleClass:e.fn.toggleClass,toggleClass:function(i,a,s,n,r){return"boolean"==typeof a||a===t?s?e.effects.animateClass.call(this,a?{add:i}:{remove:i},s,n,r):this._toggleClass(i,a):e.effects.animateClass.call(this,{toggle:i},a,s,n)},switchClass:function(t,i,a,s,n){return e.effects.animateClass.call(this,{add:i,remove:t},a,s,n)}})}(),function(){function s(t,i,a,s){return e.isPlainObject(t)&&(i=t,t=t.effect),t={effect:t},null==i&&(i={}),e.isFunction(i)&&(s=i,a=null,i={}),("number"==typeof i||e.fx.speeds[i])&&(s=a,a=i,i={}),e.isFunction(a)&&(s=a,a=null),i&&e.extend(t,i),a=a||i.duration,t.duration=e.fx.off?0:"number"==typeof a?a:a in e.fx.speeds?e.fx.speeds[a]:e.fx.speeds._default,t.complete=s||i.complete,t}function n(t){return!t||"number"==typeof t||e.fx.speeds[t]?!0:"string"!=typeof t||e.effects.effect[t]?!1:i&&e.effects[t]?!1:!0}e.extend(e.effects,{version:"1.9.2",save:function(e,t){for(var i=0;t.length>i;i++)null!==t[i]&&e.data(a+t[i],e[0].style[t[i]])},restore:function(e,i){var s,n;for(n=0;i.length>n;n++)null!==i[n]&&(s=e.data(a+i[n]),s===t&&(s=""),e.css(i[n],s))},setMode:function(e,t){return"toggle"===t&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var i,a;switch(e[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=e[0]/t.height}switch(e[1]){case"left":a=0;break;case"center":a=.5;break;case"right":a=1;break;default:a=e[1]/t.width}return{x:a,y:i}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var i={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},a=e("

          ").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),s={width:t.width(),height:t.height()},n=document.activeElement;try{n.id}catch(r){n=document.body}return t.wrap(a),(t[0]===n||e.contains(t[0],n))&&e(n).focus(),a=t.parent(),"static"===t.css("position")?(a.css({position:"relative"}),t.css({position:"relative"})):(e.extend(i,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,a){i[a]=t.css(a),isNaN(parseInt(i[a],10))&&(i[a]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(s),a.css(i).show()},removeWrapper:function(t){var i=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===i||e.contains(t[0],i))&&e(i).focus()),t},setTransition:function(t,i,a,s){return s=s||{},e.each(i,function(e,i){var n=t.cssUnit(i);n[0]>0&&(s[i]=n[0]*a+n[1])}),s}}),e.fn.extend({effect:function(){function t(t){function i(){e.isFunction(n)&&n.call(s[0]),e.isFunction(t)&&t()}var s=e(this),n=a.complete,r=a.mode;(s.is(":hidden")?"hide"===r:"show"===r)?i():o.call(s[0],a,i)}var a=s.apply(this,arguments),n=a.mode,r=a.queue,o=e.effects.effect[a.effect],h=!o&&i&&e.effects[a.effect];return e.fx.off||!o&&!h?n?this[n](a.duration,a.complete):this.each(function(){a.complete&&a.complete.call(this)}):o?r===!1?this.each(t):this.queue(r||"fx",t):h.call(this,{options:a,duration:a.duration,callback:a.complete,mode:a.mode})},_show:e.fn.show,show:function(e){if(n(e))return this._show.apply(this,arguments);var t=s.apply(this,arguments);return t.mode="show",this.effect.call(this,t)},_hide:e.fn.hide,hide:function(e){if(n(e))return this._hide.apply(this,arguments);var t=s.apply(this,arguments);return t.mode="hide",this.effect.call(this,t)},__toggle:e.fn.toggle,toggle:function(t){if(n(t)||"boolean"==typeof t||e.isFunction(t))return this.__toggle.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="toggle",this.effect.call(this,i)},cssUnit:function(t){var i=this.css(t),a=[];return e.each(["em","px","%","pt"],function(e,t){i.indexOf(t)>0&&(a=[parseFloat(i),t])}),a}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,i){t[i]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return 0===e||1===e?e:-Math.pow(2,8*(e-1))*Math.sin((80*(e-1)-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){for(var t,i=4;((t=Math.pow(2,--i))-1)/11>e;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*t-2)/22-e,2)}}),e.each(t,function(t,i){e.easing["easeIn"+t]=i,e.easing["easeOut"+t]=function(e){return 1-i(1-e)},e.easing["easeInOut"+t]=function(e){return.5>e?i(2*e)/2:1-i(-2*e+2)/2}})}()}(jQuery);(function(e){var t=/up|down|vertical/,i=/up|left|vertical|horizontal/;e.effects.effect.blind=function(a,s){var n,r,o,l=e(this),h=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(l,a.mode||"hide"),d=a.direction||"up",c=t.test(d),p=c?"height":"width",m=c?"top":"left",f=i.test(d),g={},v="show"===u;l.parent().is(".ui-effects-wrapper")?e.effects.save(l.parent(),h):e.effects.save(l,h),l.show(),n=e.effects.createWrapper(l).css({overflow:"hidden"}),r=n[p](),o=parseFloat(n.css(m))||0,g[p]=v?r:0,f||(l.css(c?"bottom":"right",0).css(c?"top":"left","auto").css({position:"absolute"}),g[m]=v?o:r+o),v&&(n.css(p,0),f||n.css(m,o+r)),n.animate(g,{duration:a.duration,easing:a.easing,queue:!1,complete:function(){"hide"===u&&l.hide(),e.effects.restore(l,h),e.effects.removeWrapper(l),s()}})}})(jQuery);(function(e){e.effects.effect.bounce=function(t,i){var a,s,n,r=e(this),o=["position","top","bottom","left","right","height","width"],l=e.effects.setMode(r,t.mode||"effect"),h="hide"===l,u="show"===l,d=t.direction||"up",c=t.distance,p=t.times||5,m=2*p+(u||h?1:0),f=t.duration/m,g=t.easing,v="up"===d||"down"===d?"top":"left",y="up"===d||"left"===d,b=r.queue(),_=b.length;for((u||h)&&o.push("opacity"),e.effects.save(r,o),r.show(),e.effects.createWrapper(r),c||(c=r["top"===v?"outerHeight":"outerWidth"]()/3),u&&(n={opacity:1},n[v]=0,r.css("opacity",0).css(v,y?2*-c:2*c).animate(n,f,g)),h&&(c/=Math.pow(2,p-1)),n={},n[v]=0,a=0;p>a;a++)s={},s[v]=(y?"-=":"+=")+c,r.animate(s,f,g).animate(n,f,g),c=h?2*c:c/2;h&&(s={opacity:0},s[v]=(y?"-=":"+=")+c,r.animate(s,f,g)),r.queue(function(){h&&r.hide(),e.effects.restore(r,o),e.effects.removeWrapper(r),i()}),_>1&&b.splice.apply(b,[1,0].concat(b.splice(_,m+1))),r.dequeue()}})(jQuery);(function(e){e.effects.effect.clip=function(t,i){var a,s,n,r=e(this),o=["position","top","bottom","left","right","height","width"],l=e.effects.setMode(r,t.mode||"hide"),h="show"===l,u=t.direction||"vertical",d="vertical"===u,c=d?"height":"width",p=d?"top":"left",m={};e.effects.save(r,o),r.show(),a=e.effects.createWrapper(r).css({overflow:"hidden"}),s="IMG"===r[0].tagName?a:r,n=s[c](),h&&(s.css(c,0),s.css(p,n/2)),m[c]=h?n:0,m[p]=h?0:n/2,s.animate(m,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){h||r.hide(),e.effects.restore(r,o),e.effects.removeWrapper(r),i()}})}})(jQuery);(function(e){e.effects.effect.drop=function(t,i){var a,s=e(this),n=["position","top","bottom","left","right","opacity","height","width"],r=e.effects.setMode(s,t.mode||"hide"),o="show"===r,l=t.direction||"left",h="up"===l||"down"===l?"top":"left",u="up"===l||"left"===l?"pos":"neg",d={opacity:o?1:0};e.effects.save(s,n),s.show(),e.effects.createWrapper(s),a=t.distance||s["top"===h?"outerHeight":"outerWidth"](!0)/2,o&&s.css("opacity",0).css(h,"pos"===u?-a:a),d[h]=(o?"pos"===u?"+=":"-=":"pos"===u?"-=":"+=")+a,s.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===r&&s.hide(),e.effects.restore(s,n),e.effects.removeWrapper(s),i()}})}})(jQuery);(function(e){e.effects.effect.explode=function(t,i){function a(){b.push(this),b.length===d*c&&s()}function s(){p.css({visibility:"visible"}),e(b).remove(),f||p.hide(),i()}var n,r,o,l,h,u,d=t.pieces?Math.round(Math.sqrt(t.pieces)):3,c=d,p=e(this),m=e.effects.setMode(p,t.mode||"hide"),f="show"===m,g=p.show().css("visibility","hidden").offset(),v=Math.ceil(p.outerWidth()/c),y=Math.ceil(p.outerHeight()/d),b=[];for(n=0;d>n;n++)for(l=g.top+n*y,u=n-(d-1)/2,r=0;c>r;r++)o=g.left+r*v,h=r-(c-1)/2,p.clone().appendTo("body").wrap("
          ").css({position:"absolute",visibility:"visible",left:-r*v,top:-n*y}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:v,height:y,left:o+(f?h*v:0),top:l+(f?u*y:0),opacity:f?0:1}).animate({left:o+(f?0:h*v),top:l+(f?0:u*y),opacity:f?1:0},t.duration||500,t.easing,a)}})(jQuery);(function(e){e.effects.effect.fade=function(t,i){var a=e(this),s=e.effects.setMode(a,t.mode||"toggle");a.animate({opacity:s},{queue:!1,duration:t.duration,easing:t.easing,complete:i})}})(jQuery);(function(e){e.effects.effect.fold=function(t,i){var a,s,n=e(this),r=["position","top","bottom","left","right","height","width"],o=e.effects.setMode(n,t.mode||"hide"),l="show"===o,h="hide"===o,u=t.size||15,d=/([0-9]+)%/.exec(u),c=!!t.horizFirst,p=l!==c,m=p?["width","height"]:["height","width"],f=t.duration/2,g={},v={};e.effects.save(n,r),n.show(),a=e.effects.createWrapper(n).css({overflow:"hidden"}),s=p?[a.width(),a.height()]:[a.height(),a.width()],d&&(u=parseInt(d[1],10)/100*s[h?0:1]),l&&a.css(c?{height:0,width:u}:{height:u,width:0}),g[m[0]]=l?s[0]:u,v[m[1]]=l?s[1]:0,a.animate(g,f,t.easing).animate(v,f,t.easing,function(){h&&n.hide(),e.effects.restore(n,r),e.effects.removeWrapper(n),i()})}})(jQuery);(function(e){e.effects.effect.highlight=function(t,i){var a=e(this),s=["backgroundImage","backgroundColor","opacity"],n=e.effects.setMode(a,t.mode||"show"),r={backgroundColor:a.css("backgroundColor")};"hide"===n&&(r.opacity=0),e.effects.save(a,s),a.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(r,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===n&&a.hide(),e.effects.restore(a,s),i()}})}})(jQuery);(function(e){e.effects.effect.pulsate=function(t,i){var a,s=e(this),n=e.effects.setMode(s,t.mode||"show"),r="show"===n,o="hide"===n,l=r||"hide"===n,h=2*(t.times||5)+(l?1:0),u=t.duration/h,d=0,c=s.queue(),p=c.length;for((r||!s.is(":visible"))&&(s.css("opacity",0).show(),d=1),a=1;h>a;a++)s.animate({opacity:d},u,t.easing),d=1-d;s.animate({opacity:d},u,t.easing),s.queue(function(){o&&s.hide(),i()}),p>1&&c.splice.apply(c,[1,0].concat(c.splice(p,h+1))),s.dequeue()}})(jQuery);(function(e){e.effects.effect.puff=function(t,i){var a=e(this),s=e.effects.setMode(a,t.mode||"hide"),n="hide"===s,r=parseInt(t.percent,10)||150,o=r/100,h={height:a.height(),width:a.width(),outerHeight:a.outerHeight(),outerWidth:a.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:s,complete:i,percent:n?r:100,from:n?h:{height:h.height*o,width:h.width*o,outerHeight:h.outerHeight*o,outerWidth:h.outerWidth*o}}),a.effect(t)},e.effects.effect.scale=function(t,i){var a=e(this),s=e.extend(!0,{},t),n=e.effects.setMode(a,t.mode||"effect"),r=parseInt(t.percent,10)||(0===parseInt(t.percent,10)?0:"hide"===n?0:100),o=t.direction||"both",h=t.origin,l={height:a.height(),width:a.width(),outerHeight:a.outerHeight(),outerWidth:a.outerWidth()},u={y:"horizontal"!==o?r/100:1,x:"vertical"!==o?r/100:1};s.effect="size",s.queue=!1,s.complete=i,"effect"!==n&&(s.origin=h||["middle","center"],s.restore=!0),s.from=t.from||("show"===n?{height:0,width:0,outerHeight:0,outerWidth:0}:l),s.to={height:l.height*u.y,width:l.width*u.x,outerHeight:l.outerHeight*u.y,outerWidth:l.outerWidth*u.x},s.fade&&("show"===n&&(s.from.opacity=0,s.to.opacity=1),"hide"===n&&(s.from.opacity=1,s.to.opacity=0)),a.effect(s)},e.effects.effect.size=function(t,i){var a,s,n,r=e(this),o=["position","top","bottom","left","right","width","height","overflow","opacity"],h=["position","top","bottom","left","right","overflow","opacity"],l=["width","height","overflow"],u=["fontSize"],d=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],c=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(r,t.mode||"effect"),f=t.restore||"effect"!==p,m=t.scale||"both",g=t.origin||["middle","center"],v=r.css("position"),y=f?o:h,b={height:0,width:0,outerHeight:0,outerWidth:0};"show"===p&&r.show(),a={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()},"toggle"===t.mode&&"show"===p?(r.from=t.to||b,r.to=t.from||a):(r.from=t.from||("show"===p?b:a),r.to=t.to||("hide"===p?b:a)),n={from:{y:r.from.height/a.height,x:r.from.width/a.width},to:{y:r.to.height/a.height,x:r.to.width/a.width}},("box"===m||"both"===m)&&(n.from.y!==n.to.y&&(y=y.concat(d),r.from=e.effects.setTransition(r,d,n.from.y,r.from),r.to=e.effects.setTransition(r,d,n.to.y,r.to)),n.from.x!==n.to.x&&(y=y.concat(c),r.from=e.effects.setTransition(r,c,n.from.x,r.from),r.to=e.effects.setTransition(r,c,n.to.x,r.to))),("content"===m||"both"===m)&&n.from.y!==n.to.y&&(y=y.concat(u).concat(l),r.from=e.effects.setTransition(r,u,n.from.y,r.from),r.to=e.effects.setTransition(r,u,n.to.y,r.to)),e.effects.save(r,y),r.show(),e.effects.createWrapper(r),r.css("overflow","hidden").css(r.from),g&&(s=e.effects.getBaseline(g,a),r.from.top=(a.outerHeight-r.outerHeight())*s.y,r.from.left=(a.outerWidth-r.outerWidth())*s.x,r.to.top=(a.outerHeight-r.to.outerHeight)*s.y,r.to.left=(a.outerWidth-r.to.outerWidth)*s.x),r.css(r.from),("content"===m||"both"===m)&&(d=d.concat(["marginTop","marginBottom"]).concat(u),c=c.concat(["marginLeft","marginRight"]),l=o.concat(d).concat(c),r.find("*[width]").each(function(){var i=e(this),a={height:i.height(),width:i.width(),outerHeight:i.outerHeight(),outerWidth:i.outerWidth()};f&&e.effects.save(i,l),i.from={height:a.height*n.from.y,width:a.width*n.from.x,outerHeight:a.outerHeight*n.from.y,outerWidth:a.outerWidth*n.from.x},i.to={height:a.height*n.to.y,width:a.width*n.to.x,outerHeight:a.height*n.to.y,outerWidth:a.width*n.to.x},n.from.y!==n.to.y&&(i.from=e.effects.setTransition(i,d,n.from.y,i.from),i.to=e.effects.setTransition(i,d,n.to.y,i.to)),n.from.x!==n.to.x&&(i.from=e.effects.setTransition(i,c,n.from.x,i.from),i.to=e.effects.setTransition(i,c,n.to.x,i.to)),i.css(i.from),i.animate(i.to,t.duration,t.easing,function(){f&&e.effects.restore(i,l)})})),r.animate(r.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){0===r.to.opacity&&r.css("opacity",r.from.opacity),"hide"===p&&r.hide(),e.effects.restore(r,y),f||("static"===v?r.css({position:"relative",top:r.to.top,left:r.to.left}):e.each(["top","left"],function(e,t){r.css(t,function(t,i){var a=parseInt(i,10),s=e?r.to.left:r.to.top;return"auto"===i?s+"px":a+s+"px"})})),e.effects.removeWrapper(r),i()}})}})(jQuery);(function(e){e.effects.effect.shake=function(t,i){var a,s=e(this),n=["position","top","bottom","left","right","height","width"],r=e.effects.setMode(s,t.mode||"effect"),o=t.direction||"left",h=t.distance||20,l=t.times||3,u=2*l+1,d=Math.round(t.duration/u),c="up"===o||"down"===o?"top":"left",p="up"===o||"left"===o,f={},m={},g={},v=s.queue(),y=v.length;for(e.effects.save(s,n),s.show(),e.effects.createWrapper(s),f[c]=(p?"-=":"+=")+h,m[c]=(p?"+=":"-=")+2*h,g[c]=(p?"-=":"+=")+2*h,s.animate(f,d,t.easing),a=1;l>a;a++)s.animate(m,d,t.easing).animate(g,d,t.easing);s.animate(m,d,t.easing).animate(f,d/2,t.easing).queue(function(){"hide"===r&&s.hide(),e.effects.restore(s,n),e.effects.removeWrapper(s),i()}),y>1&&v.splice.apply(v,[1,0].concat(v.splice(y,u+1))),s.dequeue()}})(jQuery);(function(e){e.effects.effect.slide=function(t,i){var a,s=e(this),n=["position","top","bottom","left","right","width","height"],r=e.effects.setMode(s,t.mode||"show"),o="show"===r,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h,d={};e.effects.save(s,n),s.show(),a=t.distance||s["top"===l?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(s).css({overflow:"hidden"}),o&&s.css(l,u?isNaN(a)?"-"+a:-a:a),d[l]=(o?u?"+=":"-=":u?"-=":"+=")+a,s.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===r&&s.hide(),e.effects.restore(s,n),e.effects.removeWrapper(s),i()}})}})(jQuery);(function(e){e.effects.effect.transfer=function(t,i){var a=e(this),s=e(t.to),n="fixed"===s.css("position"),r=e("body"),o=n?r.scrollTop():0,h=n?r.scrollLeft():0,l=s.offset(),u={top:l.top-o,left:l.left-h,height:s.innerHeight(),width:s.innerWidth()},d=a.offset(),c=e('
          ').appendTo(document.body).addClass(t.className).css({top:d.top-o,left:d.left-h,height:a.innerHeight(),width:a.innerWidth(),position:n?"fixed":"absolute"}).animate(u,t.duration,t.easing,function(){c.remove(),i()})}})(jQuery);(function(e){var t=!1;e.widget("ui.menu",{version:"1.9.2",defaultElement:"
            ",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(i){var s=e(i.target).closest(".ui-menu-item");!t&&s.not(".ui-state-disabled").length&&(t=!0,this.select(i),s.has(".ui-menu").length?this.expand(i):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var i=e(t.currentTarget);i.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(i){e(i.target).closest(".ui-menu").length||this.collapseAll(i),t=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function i(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var s,a,n,r,o,h=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:h=!1,a=this.previousFilter||"",n=String.fromCharCode(t.keyCode),r=!1,clearTimeout(this.filterTimer),n===a?r=!0:n=a+n,o=RegExp("^"+i(n),"i"),s=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),s=r&&-1!==s.index(this.active.next())?this.active.nextAll(".ui-menu-item"):s,s.length||(n=String.fromCharCode(t.keyCode),o=RegExp("^"+i(n),"i"),s=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),s.length?(this.focus(t,s),s.length>1?(this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}h&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},refresh:function(){var t,i=this.options.icons.submenu,s=this.element.find(this.options.menus);s.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),s=t.prev("a"),a=e("").addClass("ui-menu-icon ui-icon "+i).data("ui-menu-submenu-carat",!0);s.attr("aria-haspopup","true").prepend(a),t.attr("aria-labelledby",s.attr("id"))}),t=s.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-—–\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},focus:function(e,t){var i,s;this.blur(e,e&&"focus"===e.type),this._scrollIntoView(t),this.active=t.first(),s=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&"keydown"===e.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=t.children(".ui-menu"),i.length&&/^mouse/.test(e.type)&&this._startOpening(i),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var i,s,a,n,r,o;this._hasScroll()&&(i=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,a=t.offset().top-this.activeMenu.offset().top-i-s,n=this.activeMenu.scrollTop(),r=this.activeMenu.height(),o=t.height(),0>a?this.activeMenu.scrollTop(n+a):a+o>r&&this.activeMenu.scrollTop(n+a-r+o))},blur:function(e,t){t||clearTimeout(this.timer),this.active&&(this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active}))},_startOpening:function(e){clearTimeout(this.timer),"true"===e.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(e)},this.delay))},_open:function(t){var i=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(t,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(t),this.activeMenu=s},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,i){var s;this.active&&(s="first"===e||"last"===e?this.active["first"===e?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[e+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.children(".ui-menu-item")[t]()),this.focus(i,s)},nextPage:function(t){var i,s,a;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,a=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=e(this),0>i.offset().top-s-a}),this.focus(t,i)):this.focus(t,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())),undefined):(this.next(t),undefined)},previousPage:function(t){var i,s,a;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,a=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=e(this),i.offset().top-s+a>0}),this.focus(t,i)):this.focus(t,this.activeMenu.children(".ui-menu-item").first())),undefined):(this.next(t),undefined)},_hasScroll:function(){return this.element.outerHeight()
          ").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return e===t?this._value():(this._setOption("value",e),this)},_setOption:function(e,t){"value"===e&&(this.options.value=t,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),this._super(e,t)},_value:function(){var e=this.options.value;return"number"!=typeof e&&(e=0),Math.min(this.options.max,Math.max(this.min,e))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var e=this.value(),t=this._percentage();this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),this.valueDiv.toggle(e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(t.toFixed(0)+"%"),this.element.attr("aria-valuenow",e)}})})(jQuery);(function(e){e.widget("ui.resizable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var t=this,i=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e('
          ').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=i.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor==String){"all"==this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw");var s=this.handles.split(",");this.handles={};for(var a=0;s.length>a;a++){var n=e.trim(s[a]),r="ui-resizable-"+n,o=e('
          ');o.css({zIndex:i.zIndex}),"se"==n&&o.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[n]=".ui-resizable-"+n,this.element.append(o)}}this._renderAxis=function(t){t=t||this.element;for(var i in this.handles){if(this.handles[i].constructor==String&&(this.handles[i]=e(this.handles[i],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var s=e(this.handles[i],this.element),a=0;a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth();var n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");t.css(n,a),this._proportionallyResize()}e(this.handles[i]).length}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!t.resizing){if(this.className)var e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);t.axis=e&&e[1]?e[1]:"se"}}),i.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){i.disabled||(e(this).removeClass("ui-resizable-autohide"),t._handles.show())}).mouseleave(function(){i.disabled||t.resizing||(e(this).addClass("ui-resizable-autohide"),t._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){t(this.element);var i=this.element;this.originalElement.css({position:i.css("position"),width:i.outerWidth(),height:i.outerHeight(),top:i.css("top"),left:i.css("left")}).insertAfter(i),i.remove()}return this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_mouseCapture:function(t){var i=!1;for(var s in this.handles)e(this.handles[s])[0]==t.target&&(i=!0);return!this.options.disabled&&i},_mouseStart:function(i){var s=this.options,a=this.element.position(),n=this.element;this.resizing=!0,this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()},(n.is(".ui-draggable")||/absolute/.test(n.css("position")))&&n.css({position:"absolute",top:a.top,left:a.left}),this._renderProxy();var r=t(this.helper.css("left")),o=t(this.helper.css("top"));s.containment&&(r+=e(s.containment).scrollLeft()||0,o+=e(s.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:r,top:o},this.size=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()},this.originalSize=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()},this.originalPosition={left:r,top:o},this.sizeDiff={width:n.outerWidth()-n.width(),height:n.outerHeight()-n.height()},this.originalMousePosition={left:i.pageX,top:i.pageY},this.aspectRatio="number"==typeof s.aspectRatio?s.aspectRatio:this.originalSize.width/this.originalSize.height||1;var h=e(".ui-resizable-"+this.axis).css("cursor");return e("body").css("cursor","auto"==h?this.axis+"-resize":h),n.addClass("ui-resizable-resizing"),this._propagate("start",i),!0},_mouseDrag:function(e){var t=this.helper,i=(this.options,this.originalMousePosition),s=this.axis,a=e.pageX-i.left||0,n=e.pageY-i.top||0,r=this._change[s];if(!r)return!1;var o=r.apply(this,[e,a,n]);return this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(o=this._updateRatio(o,e)),o=this._respectSize(o,e),this._propagate("resize",e),t.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(o),this._trigger("resize",e,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var i=this.options,s=this;if(this._helper){var a=this._proportionallyResizeElements,n=a.length&&/textarea/i.test(a[0].nodeName),r=n&&e.ui.hasScroll(a[0],"left")?0:s.sizeDiff.height,o=n?0:s.sizeDiff.width,h={width:s.helper.width()-o,height:s.helper.height()-r},l=parseInt(s.element.css("left"),10)+(s.position.left-s.originalPosition.left)||null,u=parseInt(s.element.css("top"),10)+(s.position.top-s.originalPosition.top)||null;i.animate||this.element.css(e.extend(h,{top:u,left:l})),s.helper.height(s.size.height),s.helper.width(s.size.width),this._helper&&!i.animate&&this._proportionallyResize()}return e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t,s,a,n,r,o=this.options;r={minWidth:i(o.minWidth)?o.minWidth:0,maxWidth:i(o.maxWidth)?o.maxWidth:1/0,minHeight:i(o.minHeight)?o.minHeight:0,maxHeight:i(o.maxHeight)?o.maxHeight:1/0},(this._aspectRatio||e)&&(t=r.minHeight*this.aspectRatio,a=r.minWidth/this.aspectRatio,s=r.maxHeight*this.aspectRatio,n=r.maxWidth/this.aspectRatio,t>r.minWidth&&(r.minWidth=t),a>r.minHeight&&(r.minHeight=a),r.maxWidth>s&&(r.maxWidth=s),r.maxHeight>n&&(r.maxHeight=n)),this._vBoundaries=r},_updateCache:function(e){this.options,this.offset=this.helper.offset(),i(e.left)&&(this.position.left=e.left),i(e.top)&&(this.position.top=e.top),i(e.height)&&(this.size.height=e.height),i(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=(this.options,this.position),s=this.size,a=this.axis;return i(e.height)?e.width=e.height*this.aspectRatio:i(e.width)&&(e.height=e.width/this.aspectRatio),"sw"==a&&(e.left=t.left+(s.width-e.width),e.top=null),"nw"==a&&(e.top=t.top+(s.height-e.height),e.left=t.left+(s.width-e.width)),e},_respectSize:function(e,t){var s=(this.helper,this._vBoundaries),a=(this._aspectRatio||t.shiftKey,this.axis),n=i(e.width)&&s.maxWidth&&s.maxWidthe.width,h=i(e.height)&&s.minHeight&&s.minHeight>e.height;o&&(e.width=s.minWidth),h&&(e.height=s.minHeight),n&&(e.width=s.maxWidth),r&&(e.height=s.maxHeight);var l=this.originalPosition.left+this.originalSize.width,u=this.position.top+this.size.height,d=/sw|nw|w/.test(a),c=/nw|ne|n/.test(a);o&&d&&(e.left=l-s.minWidth),n&&d&&(e.left=l-s.maxWidth),h&&c&&(e.top=u-s.minHeight),r&&c&&(e.top=u-s.maxHeight);var p=!e.width&&!e.height;return p&&!e.left&&e.top?e.top=null:p&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){if(this.options,this._proportionallyResizeElements.length)for(var t=this.helper||this.element,i=0;this._proportionallyResizeElements.length>i;i++){var s=this._proportionallyResizeElements[i];if(!this.borderDif){var a=[s.css("borderTopWidth"),s.css("borderRightWidth"),s.css("borderBottomWidth"),s.css("borderLeftWidth")],n=[s.css("paddingTop"),s.css("paddingRight"),s.css("paddingBottom"),s.css("paddingLeft")];this.borderDif=e.map(a,function(e,t){var i=parseInt(e,10)||0,s=parseInt(n[t],10)||0;return i+s})}s.css({height:t.height()-this.borderDif[0]-this.borderDif[2]||0,width:t.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,i=this.options;if(this.elementOffset=t.offset(),this._helper){this.helper=this.helper||e('
          ');var s=e.ui.ie6?1:0,a=e.ui.ie6?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-s+"px",top:this.elementOffset.top-s+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=(this.options,this.originalSize),s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=(this.options,this.originalSize),a=this.originalPosition;return{top:a.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!=t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).data("resizable"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).data("resizable"),a=s.options,n=s.originalSize,r=s.originalPosition,o={height:s.size.height-n.height||0,width:s.size.width-n.width||0,top:s.position.top-r.top||0,left:s.position.left-r.left||0},h=function(t,s){e(t).each(function(){var t=e(this),a=e(this).data("resizable-alsoresize"),n={},r=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(e,t){var i=(a[t]||0)+(o[t]||0);i&&i>=0&&(n[t]=i||null)}),t.css(n)})};"object"!=typeof a.alsoResize||a.alsoResize.nodeType?h(a.alsoResize):e.each(a.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).data("resizable"),s=i.options,a=i._proportionallyResizeElements,n=a.length&&/textarea/i.test(a[0].nodeName),r=n&&e.ui.hasScroll(a[0],"left")?0:i.sizeDiff.height,o=n?0:i.sizeDiff.width,h={width:i.size.width-o,height:i.size.height-r},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};a&&a.length&&e(a[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var i=e(this).data("resizable"),s=i.options,a=i.element,n=s.containment,r=n instanceof e?n.get(0):/parent/.test(n)?a.parent().get(0):n;if(r)if(i.containerElement=e(r),/document/.test(n)||n==document)i.containerOffset={left:0,top:0},i.containerPosition={left:0,top:0},i.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight};else{var o=e(r),h=[];e(["Top","Right","Left","Bottom"]).each(function(e,i){h[e]=t(o.css("padding"+i))}),i.containerOffset=o.offset(),i.containerPosition=o.position(),i.containerSize={height:o.innerHeight()-h[3],width:o.innerWidth()-h[1]};var l=i.containerOffset,u=i.containerSize.height,d=i.containerSize.width,c=e.ui.hasScroll(r,"left")?r.scrollWidth:d,p=e.ui.hasScroll(r)?r.scrollHeight:u;i.parentData={element:r,left:l.left,top:l.top,width:c,height:p}}},resize:function(t){var i=e(this).data("resizable"),s=i.options,a=(i.containerSize,i.containerOffset),n=(i.size,i.position),r=i._aspectRatio||t.shiftKey,o={top:0,left:0},h=i.containerElement;h[0]!=document&&/static/.test(h.css("position"))&&(o=a),n.left<(i._helper?a.left:0)&&(i.size.width=i.size.width+(i._helper?i.position.left-a.left:i.position.left-o.left),r&&(i.size.height=i.size.width/i.aspectRatio),i.position.left=s.helper?a.left:0),n.top<(i._helper?a.top:0)&&(i.size.height=i.size.height+(i._helper?i.position.top-a.top:i.position.top),r&&(i.size.width=i.size.height*i.aspectRatio),i.position.top=i._helper?a.top:0),i.offset.left=i.parentData.left+i.position.left,i.offset.top=i.parentData.top+i.position.top;var l=Math.abs((i._helper?i.offset.left-o.left:i.offset.left-o.left)+i.sizeDiff.width),u=Math.abs((i._helper?i.offset.top-o.top:i.offset.top-a.top)+i.sizeDiff.height),d=i.containerElement.get(0)==i.element.parent().get(0),c=/relative|absolute/.test(i.containerElement.css("position"));d&&c&&(l-=i.parentData.left),l+i.size.width>=i.parentData.width&&(i.size.width=i.parentData.width-l,r&&(i.size.height=i.size.width/i.aspectRatio)),u+i.size.height>=i.parentData.height&&(i.size.height=i.parentData.height-u,r&&(i.size.width=i.size.height*i.aspectRatio))},stop:function(){var t=e(this).data("resizable"),i=t.options,s=(t.position,t.containerOffset),a=t.containerPosition,n=t.containerElement,r=e(t.helper),o=r.offset(),h=r.outerWidth()-t.sizeDiff.width,l=r.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(n.css("position"))&&e(this).css({left:o.left-a.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(n.css("position"))&&e(this).css({left:o.left-a.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).data("resizable"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).data("resizable");t.options,t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).data("resizable");t.options,t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(t){var i=e(this).data("resizable"),s=i.options,a=i.size,n=i.originalSize,r=i.originalPosition,o=i.axis;s._aspectRatio||t.shiftKey,s.grid="number"==typeof s.grid?[s.grid,s.grid]:s.grid;var h=Math.round((a.width-n.width)/(s.grid[0]||1))*(s.grid[0]||1),l=Math.round((a.height-n.height)/(s.grid[1]||1))*(s.grid[1]||1);/^(se|s|e)$/.test(o)?(i.size.width=n.width+h,i.size.height=n.height+l):/^(ne)$/.test(o)?(i.size.width=n.width+h,i.size.height=n.height+l,i.position.top=r.top-l):/^(sw)$/.test(o)?(i.size.width=n.width+h,i.size.height=n.height+l,i.position.left=r.left-h):(i.size.width=n.width+h,i.size.height=n.height+l,i.position.top=r.top-l,i.position.left=r.left-h)}});var t=function(e){return parseInt(e,10)||0},i=function(e){return!isNaN(parseInt(e,10))}})(jQuery);(function(e){e.widget("ui.selectable",e.ui.mouse,{version:"1.9.2",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var t=this;this.element.addClass("ui-selectable"),this.dragged=!1;var i;this.refresh=function(){i=e(t.options.filter,t.element[0]),i.addClass("ui-selectee"),i.each(function(){var t=e(this),i=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:i.left,top:i.top,right:i.left+t.outerWidth(),bottom:i.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=i.addClass("ui-selectee"),this._mouseInit(),this.helper=e("
          ")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var i=this;if(this.opos=[t.pageX,t.pageY],!this.options.disabled){var s=this.options;this.selectees=e(s.filter,this.element[0]),this._trigger("start",t),e(s.appendTo).append(this.helper),this.helper.css({left:t.clientX,top:t.clientY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=e.data(this,"selectable-item");s.startselected=!0,t.metaKey||t.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",t,{unselecting:s.element}))}),e(t.target).parents().andSelf().each(function(){var s=e.data(this,"selectable-item");if(s){var a=!t.metaKey&&!t.ctrlKey||!s.$element.hasClass("ui-selected");return s.$element.removeClass(a?"ui-unselecting":"ui-selected").addClass(a?"ui-selecting":"ui-unselecting"),s.unselecting=!a,s.selecting=a,s.selected=a,a?i._trigger("selecting",t,{selecting:s.element}):i._trigger("unselecting",t,{unselecting:s.element}),!1}})}},_mouseDrag:function(t){var i=this;if(this.dragged=!0,!this.options.disabled){var s=this.options,a=this.opos[0],n=this.opos[1],r=t.pageX,o=t.pageY;if(a>r){var h=r;r=a,a=h}if(n>o){var h=o;o=n,n=h}return this.helper.css({left:a,top:n,width:r-a,height:o-n}),this.selectees.each(function(){var h=e.data(this,"selectable-item");if(h&&h.element!=i.element[0]){var l=!1;"touch"==s.tolerance?l=!(h.left>r||a>h.right||h.top>o||n>h.bottom):"fit"==s.tolerance&&(l=h.left>a&&r>h.right&&h.top>n&&o>h.bottom),l?(h.selected&&(h.$element.removeClass("ui-selected"),h.selected=!1),h.unselecting&&(h.$element.removeClass("ui-unselecting"),h.unselecting=!1),h.selecting||(h.$element.addClass("ui-selecting"),h.selecting=!0,i._trigger("selecting",t,{selecting:h.element}))):(h.selecting&&((t.metaKey||t.ctrlKey)&&h.startselected?(h.$element.removeClass("ui-selecting"),h.selecting=!1,h.$element.addClass("ui-selected"),h.selected=!0):(h.$element.removeClass("ui-selecting"),h.selecting=!1,h.startselected&&(h.$element.addClass("ui-unselecting"),h.unselecting=!0),i._trigger("unselecting",t,{unselecting:h.element}))),h.selected&&(t.metaKey||t.ctrlKey||h.startselected||(h.$element.removeClass("ui-selected"),h.selected=!1,h.$element.addClass("ui-unselecting"),h.unselecting=!0,i._trigger("unselecting",t,{unselecting:h.element}))))}}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,this.options,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);(function(e){var t=5;e.widget("ui.slider",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var i,s,a=this.options,n=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),r="",o=[];for(this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(a.disabled?" ui-slider-disabled ui-disabled":"")),this.range=e([]),a.range&&(a.range===!0&&(a.values||(a.values=[this._valueMin(),this._valueMin()]),a.values.length&&2!==a.values.length&&(a.values=[a.values[0],a.values[0]])),this.range=e("
          ").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+("min"===a.range||"max"===a.range?" ui-slider-range-"+a.range:""))),s=a.values&&a.values.length||1,i=n.length;s>i;i++)o.push(r);this.handles=n.add(e(o.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).mouseenter(function(){a.disabled||e(this).addClass("ui-state-hover")}).mouseleave(function(){e(this).removeClass("ui-state-hover")}).focus(function(){a.disabled?e(this).blur():(e(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),e(this).addClass("ui-state-focus"))}).blur(function(){e(this).removeClass("ui-state-focus")}),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)}),this._on(this.handles,{keydown:function(i){var s,a,n,r,o=e(i.target).data("ui-slider-handle-index");switch(i.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(i.preventDefault(),!this._keySliding&&(this._keySliding=!0,e(i.target).addClass("ui-state-active"),s=this._start(i,o),s===!1))return}switch(r=this.options.step,a=n=this.options.values&&this.options.values.length?this.values(o):this.value(),i.keyCode){case e.ui.keyCode.HOME:n=this._valueMin();break;case e.ui.keyCode.END:n=this._valueMax();break;case e.ui.keyCode.PAGE_UP:n=this._trimAlignValue(a+(this._valueMax()-this._valueMin())/t);break;case e.ui.keyCode.PAGE_DOWN:n=this._trimAlignValue(a-(this._valueMax()-this._valueMin())/t);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(a===this._valueMax())return;n=this._trimAlignValue(a+r);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(a===this._valueMin())return;n=this._trimAlignValue(a-r)}this._slide(i,o,n)},keyup:function(t){var i=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,i),this._change(t,i),e(t.target).removeClass("ui-state-active"))}}),this._refreshValue(),this._animateOff=!1},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var i,s,a,n,r,o,h,l,u=this,d=this.options;return d.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),i={x:t.pageX,y:t.pageY},s=this._normValueFromMouse(i),a=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var i=Math.abs(s-u.values(t));a>i&&(a=i,n=e(this),r=t)}),d.range===!0&&this.values(1)===d.min&&(r+=1,n=e(this.handles[r])),o=this._start(t,r),o===!1?!1:(this._mouseSliding=!0,this._handleIndex=r,n.addClass("ui-state-active").focus(),h=n.offset(),l=!e(t.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:t.pageX-h.left-n.width()/2,top:t.pageY-h.top-n.height()/2-(parseInt(n.css("borderTopWidth"),10)||0)-(parseInt(n.css("borderBottomWidth"),10)||0)+(parseInt(n.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,r,s),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},i=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,i),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,i,s,a,n;return"horizontal"===this.orientation?(t=this.elementSize.width,i=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,i=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),s=i/t,s>1&&(s=1),0>s&&(s=0),"vertical"===this.orientation&&(s=1-s),a=this._valueMax()-this._valueMin(),n=this._valueMin()+s*a,this._trimAlignValue(n)},_start:function(e,t){var i={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._trigger("start",e,i)},_slide:function(e,t,i){var s,a,n;this.options.values&&this.options.values.length?(s=this.values(t?0:1),2===this.options.values.length&&this.options.range===!0&&(0===t&&i>s||1===t&&s>i)&&(i=s),i!==this.values(t)&&(a=this.values(),a[t]=i,n=this._trigger("slide",e,{handle:this.handles[t],value:i,values:a}),s=this.values(t?0:1),n!==!1&&this.values(t,i,!0))):i!==this.value()&&(n=this._trigger("slide",e,{handle:this.handles[t],value:i}),n!==!1&&this.value(i))},_stop:function(e,t){var i={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._trigger("stop",e,i)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var i={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._trigger("change",e,i)}},value:function(e){return arguments.length?(this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0),undefined):this._value()},values:function(t,i){var s,a,n;if(arguments.length>1)return this.options.values[t]=this._trimAlignValue(i),this._refreshValue(),this._change(null,t),undefined;if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();for(s=this.options.values,a=arguments[0],n=0;s.length>n;n+=1)s[n]=this._trimAlignValue(a[n]),this._change(null,n);this._refreshValue()},_setOption:function(t,i){var s,a=0;switch(e.isArray(this.options.values)&&(a=this.options.values.length),e.Widget.prototype._setOption.apply(this,arguments),t){case"disabled":i?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.prop("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.prop("disabled",!1),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),s=0;a>s;s+=1)this._change(null,s);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e)},_values:function(e){var t,i,s;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t);for(i=this.options.values.slice(),s=0;i.length>s;s+=1)i[s]=this._trimAlignValue(i[s]);return i},_trimAlignValue:function(e){if(this._valueMin()>=e)return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,i=(e-this._valueMin())%t,s=e-i;return 2*Math.abs(i)>=t&&(s+=i>0?t:-t),parseFloat(s.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,i,s,a,n,r=this.options.range,o=this.options,h=this,l=this._animateOff?!1:o.animate,u={};this.options.values&&this.options.values.length?this.handles.each(function(s){i=100*((h.values(s)-h._valueMin())/(h._valueMax()-h._valueMin())),u["horizontal"===h.orientation?"left":"bottom"]=i+"%",e(this).stop(1,1)[l?"animate":"css"](u,o.animate),h.options.range===!0&&("horizontal"===h.orientation?(0===s&&h.range.stop(1,1)[l?"animate":"css"]({left:i+"%"},o.animate),1===s&&h.range[l?"animate":"css"]({width:i-t+"%"},{queue:!1,duration:o.animate})):(0===s&&h.range.stop(1,1)[l?"animate":"css"]({bottom:i+"%"},o.animate),1===s&&h.range[l?"animate":"css"]({height:i-t+"%"},{queue:!1,duration:o.animate}))),t=i}):(s=this.value(),a=this._valueMin(),n=this._valueMax(),i=n!==a?100*((s-a)/(n-a)):0,u["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[l?"animate":"css"](u,o.animate),"min"===r&&"horizontal"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({width:i+"%"},o.animate),"max"===r&&"horizontal"===this.orientation&&this.range[l?"animate":"css"]({width:100-i+"%"},{queue:!1,duration:o.animate}),"min"===r&&"vertical"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({height:i+"%"},o.animate),"max"===r&&"vertical"===this.orientation&&this.range[l?"animate":"css"]({height:100-i+"%"},{queue:!1,duration:o.animate}))}})})(jQuery);(function(e){e.widget("ui.sortable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===e.axis||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,i){"disabled"===t?(this.options[t]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,i){var s=this;if(this.reverting)return!1;if(this.options.disabled||"static"==this.options.type)return!1;this._refreshItems(t);var a=null;if(e(t.target).parents().each(function(){return e.data(this,s.widgetName+"-item")==s?(a=e(this),!1):undefined}),e.data(t.target,s.widgetName+"-item")==s&&(a=e(t.target)),!a)return!1;if(this.options.handle&&!i){var n=!1;if(e(this.options.handle,a).find("*").andSelf().each(function(){this==t.target&&(n=!0)}),!n)return!1}return this.currentItem=a,this._removeCurrentsFromItems(),!0},_mouseStart:function(t,i,s){var a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&(e("body").css("cursor")&&(this._storedCursor=e("body").css("cursor")),e("body").css("cursor",a.cursor)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(var n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!a.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){if(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll){var i=this.options,s=!1;this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY=0;a--){var n=this.items[a],r=n.item[0],o=this._intersectsWithPointer(n);if(o&&n.instance===this.currentContainer&&r!=this.currentItem[0]&&this.placeholder[1==o?"next":"prev"]()[0]!=r&&!e.contains(this.placeholder[0],r)&&("semi-dynamic"==this.options.type?!e.contains(this.element[0],r):!0)){if(this.direction=1==o?"down":"up","pointer"!=this.options.tolerance&&!this._intersectsWithSides(n))break;this._rearrange(t,n),this._trigger("change",t,this._uiHash());break}}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,i){if(t){if(e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t),this.options.revert){var s=this,a=this.placeholder.offset();this.reverting=!0,e(this.helper).animate({left:a.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:a.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){s._clear(t)})}else this._clear(t,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"==this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!=this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var i=this._getItemsAsjQuery(t&&t.connected),s=[];return t=t||{},e(i).each(function(){var i=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[-=_](.+)/);i&&s.push((t.key||i[1]+"[]")+"="+(t.key&&t.expression?i[1]:i[2]))}),!s.length&&t.key&&s.push(t.key+"="),s.join("&")},toArray:function(t){var i=this._getItemsAsjQuery(t&&t.connected),s=[];return t=t||{},i.each(function(){s.push(e(t.item||this).attr(t.attribute||"id")||"")}),s},_intersectsWith:function(e){var t=this.positionAbs.left,i=t+this.helperProportions.width,s=this.positionAbs.top,a=s+this.helperProportions.height,n=e.left,r=n+e.width,o=e.top,h=o+e.height,l=this.offset.click.top,u=this.offset.click.left,c=s+l>o&&h>s+l&&t+u>n&&r>t+u;return"pointer"==this.options.tolerance||this.options.forcePointerForContainers||"pointer"!=this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:t+this.helperProportions.width/2>n&&r>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>o&&h>a-this.helperProportions.height/2},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),s="y"===this.options.axis||e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),a=i&&s,n=this._getDragVerticalDirection(),r=this._getDragHorizontalDirection();return a?this.floating?r&&"right"==r||"down"==n?2:1:n&&("down"==n?2:1):!1},_intersectsWithSides:function(t){var i=e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),s=e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),a=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"==n&&s||"left"==n&&!s:a&&("down"==a&&i||"up"==a&&!i)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return 0!=e&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return 0!=e&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor==String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var i=[],s=[],a=this._connectWith();if(a&&t)for(var n=a.length-1;n>=0;n--)for(var r=e(a[n]),o=r.length-1;o>=0;o--){var h=e.data(r[o],this.widgetName);h&&h!=this&&!h.options.disabled&&s.push([e.isFunction(h.options.items)?h.options.items.call(h.element):e(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}s.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var n=s.length-1;n>=0;n--)s[n][0].each(function(){i.push(this)});return e(i)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var i=0;t.length>i;i++)if(t[i]==e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var i=this.items,s=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],a=this._connectWith();if(a&&this.ready)for(var n=a.length-1;n>=0;n--)for(var r=e(a[n]),o=r.length-1;o>=0;o--){var h=e.data(r[o],this.widgetName);h&&h!=this&&!h.options.disabled&&(s.push([e.isFunction(h.options.items)?h.options.items.call(h.element[0],t,{item:this.currentItem}):e(h.options.items,h.element),h]),this.containers.push(h))}for(var n=s.length-1;n>=0;n--)for(var l=s[n][1],u=s[n][0],o=0,c=u.length;c>o;o++){var d=e(u[o]);d.data(this.widgetName+"-item",l),i.push({item:d,instance:l,width:0,height:0,left:0,top:0})}},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var i=this.items.length-1;i>=0;i--){var s=this.items[i];if(s.instance==this.currentContainer||!this.currentContainer||s.item[0]==this.currentItem[0]){var a=this.options.toleranceElement?e(this.options.toleranceElement,s.item):s.item;t||(s.width=a.outerWidth(),s.height=a.outerHeight());var n=a.offset();s.left=n.left,s.top=n.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var i=this.containers.length-1;i>=0;i--){var n=this.containers[i].element.offset();this.containers[i].containerCache.left=n.left,this.containers[i].containerCache.top=n.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight()}return this},_createPlaceholder:function(t){t=t||this;var i=t.options;if(!i.placeholder||i.placeholder.constructor==String){var s=i.placeholder;i.placeholder={element:function(){var i=e(document.createElement(t.currentItem[0].nodeName)).addClass(s||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return s||(i.style.visibility="hidden"),i},update:function(e,a){(!s||i.forcePlaceholderSize)&&(a.height()||a.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),a.width()||a.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10)))}}}t.placeholder=e(i.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),i.placeholder.update(t,t.placeholder)},_contactContainers:function(t){for(var i=null,s=null,a=this.containers.length-1;a>=0;a--)if(!e.contains(this.currentItem[0],this.containers[a].element[0]))if(this._intersectsWith(this.containers[a].containerCache)){if(i&&e.contains(this.containers[a].element[0],i.element[0]))continue;i=this.containers[a],s=a}else this.containers[a].containerCache.over&&(this.containers[a]._trigger("out",t,this._uiHash(this)),this.containers[a].containerCache.over=0);if(i)if(1===this.containers.length)this.containers[s]._trigger("over",t,this._uiHash(this)),this.containers[s].containerCache.over=1;else{for(var n=1e4,r=null,o=this.containers[s].floating?"left":"top",h=this.containers[s].floating?"width":"height",l=this.positionAbs[o]+this.offset.click[o],u=this.items.length-1;u>=0;u--)if(e.contains(this.containers[s].element[0],this.items[u].item[0])&&this.items[u].item[0]!=this.currentItem[0]){var c=this.items[u].item.offset()[o],d=!1;Math.abs(c-l)>Math.abs(c+this.items[u][h]-l)&&(d=!0,c+=this.items[u][h]),n>Math.abs(c-l)&&(n=Math.abs(c-l),r=this.items[u],this.direction=d?"up":"down")}if(!r&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[s],r?this._rearrange(t,r,null,!0):this._rearrange(t,null,this.containers[s].element,!0),this._trigger("change",t,this._uiHash()),this.containers[s]._trigger("change",t,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[s]._trigger("over",t,this._uiHash(this)),this.containers[s].containerCache.over=1}},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t,this.currentItem])):"clone"==i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||e("parent"!=i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(""==s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(""==s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"==this.cssPosition&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;if("parent"==t.containment&&(t.containment=this.helper[0].parentNode),("document"==t.containment||"window"==t.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e("document"==t.containment?document:window).width()-this.helperProportions.width-this.margins.left,(e("document"==t.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),!/^(document|window|parent)$/.test(t.containment)){var i=e(t.containment)[0],s=e(t.containment).offset(),a="hidden"!=e(i).css("overflow");this.containment=[s.left+(parseInt(e(i).css("borderLeftWidth"),10)||0)+(parseInt(e(i).css("paddingLeft"),10)||0)-this.margins.left,s.top+(parseInt(e(i).css("borderTopWidth"),10)||0)+(parseInt(e(i).css("paddingTop"),10)||0)-this.margins.top,s.left+(a?Math.max(i.scrollWidth,i.offsetWidth):i.offsetWidth)-(parseInt(e(i).css("borderLeftWidth"),10)||0)-(parseInt(e(i).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,s.top+(a?Math.max(i.scrollHeight,i.offsetHeight):i.offsetHeight)-(parseInt(e(i).css("borderTopWidth"),10)||0)-(parseInt(e(i).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(t,i){i||(i=this.position);var s="absolute"==t?1:-1,a=(this.options,"absolute"!=this.cssPosition||this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent),n=/(html|body)/i.test(a[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"==this.cssPosition?-this.scrollParent.scrollTop():n?0:a.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():n?0:a.scrollLeft())*s}},_generatePosition:function(t){var i=this.options,s="absolute"!=this.cssPosition||this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(s[0].tagName);"relative"!=this.cssPosition||this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset());var n=t.pageX,r=t.pageY;if(this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.leftthis.containment[2]&&(n=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),i.grid)){var o=this.originalPageY+Math.round((r-this.originalPageY)/i.grid[1])*i.grid[1];r=this.containment?o-this.offset.click.topthis.containment[3]?o-this.offset.click.topthis.containment[2]?h-this.offset.click.left=0;a--)i||s.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[a])),this.containers[a].containerCache.over&&(s.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[a])),this.containers[a].containerCache.over=0);if(this._storedCursor&&e("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"==this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!i){this._trigger("beforeStop",t,this._uiHash());for(var a=0;s.length>a;a++)s[a].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(i||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null,!i){for(var a=0;s.length>a;a++)s[a].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var i=t||this;return{helper:i.helper,placeholder:i.placeholder||e([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:t?t.element:null}}})})(jQuery);(function(e){function t(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.widget("ui.spinner",{version:"1.9.2",defaultElement:"",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},i=this.element;return e.each(["min","max","step"],function(e,s){var a=i.attr(s);void 0!==a&&a.length&&(t[s]=a)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e),void 0)},mousewheel:function(e,t){if(t){if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()}},"mousedown .ui-spinner-button":function(t){function i(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s}))}var s;s=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),this._start(t)!==!1&&this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){return e(t.currentTarget).hasClass("ui-state-active")?this._start(t)===!1?!1:(this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t),void 0):void 0},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(.5*e.height())&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var i=this.options,s=e.ui.keyCode;switch(t.keyCode){case s.UP:return this._repeat(null,1,t),!0;case s.DOWN:return this._repeat(null,-1,t),!0;case s.PAGE_UP:return this._repeat(null,i.page,t),!0;case s.PAGE_DOWN:return this._repeat(null,-i.page,t),!0}return!1},_uiSpinnerHtml:function(){return""},_buttonHtml:function(){return""+""+""+""+""},_start:function(e){return this.spinning||this._trigger("start",e)!==!1?(this.counter||(this.counter=1),this.spinning=!0,!0):!1},_repeat:function(e,t,i){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,i)},e),this._spin(t*this.options.step,i)},_spin:function(e,t){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+e*this._increment(this.counter)),this.spinning&&this._trigger("spin",t,{value:i})===!1||(this._value(i),this.counter++)},_increment:function(t){var i=this.options.incremental;return i?e.isFunction(i)?i(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return null!==this.options.min&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=""+e,i=t.indexOf(".");return-1===i?0:t.length-i-1},_adjustValue:function(e){var t,i,s=this.options;return t=null!==s.min?s.min:0,i=e-t,i=Math.round(i/s.step)*s.step,e=t+i,e=parseFloat(e.toFixed(this._precision())),null!==s.max&&e>s.max?s.max:null!==s.min&&s.min>e?s.min:e},_stop:function(e){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",e))},_setOption:function(e,t){if("culture"===e||"numberFormat"===e){var i=this._parse(this.element.val());return this.options[e]=t,this.element.val(this._format(i)),void 0}("max"===e||"min"===e||"step"===e)&&"string"==typeof t&&(t=this._parse(t)),this._super(e,t),"disabled"===e&&(t?(this.element.prop("disabled",!0),this.buttons.button("disable")):(this.element.prop("disabled",!1),this.buttons.button("enable")))},_setOptions:t(function(e){this._super(e),this._value(this.element.val())}),_parse:function(e){return"string"==typeof e&&""!==e&&(e=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(e,10,this.options.culture):+e),""===e||isNaN(e)?null:e},_format:function(e){return""===e?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},_value:function(e,t){var i;""!==e&&(i=this._parse(e),null!==i&&(t||(i=this._adjustValue(i)),e=this._format(i))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:t(function(e){this._stepUp(e)}),_stepUp:function(e){this._spin((e||1)*this.options.step)},stepDown:t(function(e){this._stepDown(e)}),_stepDown:function(e){this._spin((e||1)*-this.options.step)},pageUp:t(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:t(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){return arguments.length?(t(this._value).call(this,e),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}})})(jQuery);(function(e,t){function i(){return++a}function s(e){return e.hash.length>1&&e.href.replace(n,"")===location.href.replace(n,"").replace(/\s/g,"%20")}var a=0,n=/#.*$/;e.widget("ui.tabs",{version:"1.9.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var i=this,s=this.options,a=s.active,n=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",s.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),null===a&&(n&&this.tabs.each(function(i,s){return e(s).attr("aria-controls")===n?(a=i,!1):t}),null===a&&(a=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===a||-1===a)&&(a=this.tabs.length?0:!1)),a!==!1&&(a=this.tabs.index(this.tabs.eq(a)),-1===a&&(a=s.collapsible?!1:0)),s.active=a,!s.collapsible&&s.active===!1&&this.anchors.length&&(s.active=0),e.isArray(s.disabled)&&(s.disabled=e.unique(s.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return i.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(this.options.active):e(),this._refresh(),this.active.length&&this.load(s.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(i){var s=e(this.document[0].activeElement).closest("li"),a=this.tabs.index(s),n=!0;if(!this._handlePageNav(i)){switch(i.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:a++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:n=!1,a--;break;case e.ui.keyCode.END:a=this.anchors.length-1;break;case e.ui.keyCode.HOME:a=0;break;case e.ui.keyCode.SPACE:return i.preventDefault(),clearTimeout(this.activating),this._activate(a),t;case e.ui.keyCode.ENTER:return i.preventDefault(),clearTimeout(this.activating),this._activate(a===this.options.active?!1:a),t;default:return}i.preventDefault(),clearTimeout(this.activating),a=this._focusNextTab(a,n),i.ctrlKey||(s.attr("aria-selected","false"),this.tabs.eq(a).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",a)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(i){return i.altKey&&i.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):i.altKey&&i.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):t},_findNextTab:function(t,i){function s(){return t>a&&(t=0),0>t&&(t=a),t}for(var a=this.tabs.length-1;-1!==e.inArray(s(),this.options.disabled);)t=i?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,i){return"active"===e?(this._activate(i),t):"disabled"===e?(this._setupDisabled(i),t):(this._super(e,i),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",i),i||this.options.active!==!1||this._activate(0)),"event"===e&&this._setupEvents(i),"heightStyle"===e&&this._setupHeightStyle(i),t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,i=this.tablist.children(":has(a[href])");t.disabled=e.map(i.filter(".ui-state-disabled"),function(e){return i.index(e)}),this._processTabs(),t.active!==!1&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(i,a){var n,r,o,h=e(a).uniqueId().attr("id"),l=e(a).closest("li"),u=l.attr("aria-controls");s(a)?(n=a.hash,r=t.element.find(t._sanitizeSelector(n))):(o=t._tabId(l),n="#"+o,r=t.element.find(n),r.length||(r=t._createPanel(o),r.insertAfter(t.panels[i-1]||t.tablist)),r.attr("aria-live","polite")),r.length&&(t.panels=t.panels.add(r)),u&&l.data("ui-tabs-aria-controls",u),l.attr({"aria-controls":n.substring(1),"aria-labelledby":h}),r.attr("aria-labelledby",h)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("
          ").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var i,s=0;i=this.tabs[s];s++)t===!0||-1!==e.inArray(s,t)?e(i).addClass("ui-state-disabled").attr("aria-disabled","true"):e(i).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var i={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var i,s,a=this.element.parent();"fill"===t?(e.support.minHeight||(s=a.css("overflow"),a.css("overflow","hidden")),i=a.height(),this.element.siblings(":visible").each(function(){var t=e(this),s=t.css("position");"absolute"!==s&&"fixed"!==s&&(i-=t.outerHeight(!0))}),s&&a.css("overflow",s),this.element.children().not(this.panels).each(function(){i-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,i-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===t&&(i=0,this.panels.each(function(){i=Math.max(i,e(this).height("").height())}).height(i))},_eventHandler:function(t){var i=this.options,s=this.active,a=e(t.currentTarget),n=a.closest("li"),r=n[0]===s[0],o=r&&i.collapsible,h=o?e():this._getPanelForTab(n),l=s.length?this._getPanelForTab(s):e(),u={oldTab:s,oldPanel:l,newTab:o?e():n,newPanel:h};t.preventDefault(),n.hasClass("ui-state-disabled")||n.hasClass("ui-tabs-loading")||this.running||r&&!i.collapsible||this._trigger("beforeActivate",t,u)===!1||(i.active=o?!1:this.tabs.index(n),this.active=r?e():n,this.xhr&&this.xhr.abort(),l.length||h.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(n),t),this._toggle(t,u))},_toggle:function(t,i){function s(){n.running=!1,n._trigger("activate",t,i)}function a(){i.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&n.options.show?n._show(r,n.options.show,s):(r.show(),s())}var n=this,r=i.newPanel,o=i.oldPanel;this.running=!0,o.length&&this.options.hide?this._hide(o,this.options.hide,function(){i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),a()}):(i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),o.hide(),a()),o.attr({"aria-expanded":"false","aria-hidden":"true"}),i.oldTab.attr("aria-selected","false"),r.length&&o.length?i.oldTab.attr("tabIndex",-1):r.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),r.attr({"aria-expanded":"true","aria-hidden":"false"}),i.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var i,s=this._findActive(t);s[0]!==this.active[0]&&(s.length||(s=this.active),i=s.find(".ui-tabs-anchor")[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),i=t.data("ui-tabs-aria-controls");i?t.attr("aria-controls",i):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(i){var s=this.options.disabled;s!==!1&&(i===t?s=!1:(i=this._getIndex(i),s=e.isArray(s)?e.map(s,function(e){return e!==i?e:null}):e.map(this.tabs,function(e,t){return t!==i?t:null})),this._setupDisabled(s))},disable:function(i){var s=this.options.disabled;if(s!==!0){if(i===t)s=!0;else{if(i=this._getIndex(i),-1!==e.inArray(i,s))return;s=e.isArray(s)?e.merge([i],s).sort():[i]}this._setupDisabled(s)}},load:function(t,i){t=this._getIndex(t);var a=this,n=this.tabs.eq(t),r=n.find(".ui-tabs-anchor"),o=this._getPanelForTab(n),h={tab:n,panel:o};s(r[0])||(this.xhr=e.ajax(this._ajaxSettings(r,i,h)),this.xhr&&"canceled"!==this.xhr.statusText&&(n.addClass("ui-tabs-loading"),o.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){o.html(e),a._trigger("load",i,h)},1)}).complete(function(e,t){setTimeout(function(){"abort"===t&&a.panels.stop(!1,!0),n.removeClass("ui-tabs-loading"),o.removeAttr("aria-busy"),e===a.xhr&&delete a.xhr},1)})))},_ajaxSettings:function(t,i,s){var a=this;return{url:t.attr("href"),beforeSend:function(t,n){return a._trigger("beforeLoad",i,e.extend({jqXHR:t,ajaxSettings:n},s))}}},_getPanelForTab:function(t){var i=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+i))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var i=this;this._on({tabsbeforeload:function(s,a){return e.data(a.tab[0],"cache.tabs")?(s.preventDefault(),t):(a.jqXHR.success(function(){i.options.cache&&e.data(a.tab[0],"cache.tabs",!0)}),t)}})},_ajaxSettings:function(t,i,s){var a=this.options.ajaxOptions;return e.extend({},a,{error:function(e,t){try{a.error(e,t,s.tab.closest("li").index(),s.tab[0])}catch(i){}}},this._superApply(arguments))},_setOption:function(e,t){"cache"===e&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"Loading…"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target===this.element[0]&&this.options.spinner){var i=t.tab.find("span"),s=i.html();i.html(this.options.spinner),t.jqXHR.complete(function(){i.html(s)})}}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var i,s=this.options;(t&&s.disabled===!0||e.isArray(s.disabled)&&-1!==e.inArray(t,s.disabled))&&(i=!0),this._superApply(arguments),i&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var i,s=this.options;(t&&s.disabled===!1||e.isArray(s.disabled)&&-1===e.inArray(t,s.disabled))&&(i=!0),this._superApply(arguments),i&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"
        • #{label}
        • "},add:function(i,s,a){a===t&&(a=this.anchors.length);var n,r,o=this.options,h=e(o.tabTemplate.replace(/#\{href\}/g,i).replace(/#\{label\}/g,s)),l=i.indexOf("#")?this._tabId(h):i.replace("#","");return h.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),h.attr("aria-controls",l),n=a>=this.tabs.length,r=this.element.find("#"+l),r.length||(r=this._createPanel(l),n?a>0?r.insertAfter(this.panels.eq(-1)):r.appendTo(this.element):r.insertBefore(this.panels[a])),r.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),n?h.appendTo(this.tablist):h.insertBefore(this.tabs[a]),o.disabled=e.map(o.disabled,function(e){return e>=a?++e:e}),this.refresh(),1===this.tabs.length&&o.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[a],this.panels[a])),this},remove:function(t){t=this._getIndex(t);var i=this.options,s=this.tabs.eq(t).remove(),a=this._getPanelForTab(s).remove();return s.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(this.anchors.length>t+1?1:-1)),i.disabled=e.map(e.grep(i.disabled,function(e){return e!==t}),function(e){return e>=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(s.find("a")[0],a[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var s=t.is("li")?t.find("a[href]"):t;return s=s[0],e(s).closest("li").attr("aria-controls")||s.title&&s.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"
          "},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;null===e.active&&e.selected!==t&&(e.active=-1===e.selected?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if("selected"!==e)return this._super(e,t);var i=this.options;this._super("active",-1===t?!1:t),i.selected=i.active,i.selected===!1&&(i.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,i){var s,a,n=this._superApply(arguments);return n?("beforeActivate"===e?(s=i.newTab.length?i.newTab:i.oldTab,a=i.newPanel.length?i.newPanel:i.oldPanel,n=this._super("select",t,{tab:s.find(".ui-tabs-anchor")[0],panel:a[0],index:s.closest("li").index()})):"activate"===e&&i.newTab.length&&(n=this._super("show",t,{tab:i.newTab.find(".ui-tabs-anchor")[0],panel:i.newPanel[0],index:i.newTab.closest("li").index()})),n):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){if(e=this._getIndex(e),-1===e){if(!this.options.collapsible||-1===this.options.selected)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e,t=this.options;null==t.active&&t.cookie&&(e=parseInt(this._cookie(),10),-1===e&&(e=!1),t.active=e),this._super()},_cookie:function(i){var s=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(s.push(i===!1?-1:i),s.push(this.options.cookie)),e.cookie.apply(null,s)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,i,s){var a=e.extend({},s);return"load"===t&&(a.panel=a.panel[0],a.tab=a.tab.find(".ui-tabs-anchor")[0]),this._super(t,i,a)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,i,s=this.options.fx;return s&&(e.isArray(s)?(t=s[0],i=s[1]):t=i=s),s?{show:i,hide:t}:null},_toggle:function(e,i){function s(){n.running=!1,n._trigger("activate",e,i)}function a(){i.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&h.show?r.animate(h.show,h.show.duration,function(){s()}):(r.show(),s())}var n=this,r=i.newPanel,o=i.oldPanel,h=this._getFx();return h?(n.running=!0,o.length&&h.hide?o.animate(h.hide,h.hide.duration,function(){i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),a()}):(i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),o.hide(),a()),t):this._super(e,i)}}))})(jQuery);(function(e){function t(t,i){var s=(t.attr("aria-describedby")||"").split(/\s+/);s.push(i),t.data("ui-tooltip-id",i).attr("aria-describedby",e.trim(s.join(" ")))}function i(t){var i=t.data("ui-tooltip-id"),s=(t.attr("aria-describedby")||"").split(/\s+/),a=e.inArray(i,s);-1!==a&&s.splice(a,1),t.removeData("ui-tooltip-id"),s=e.trim(s.join(" ")),s?t.attr("aria-describedby",s):t.removeAttr("aria-describedby")}var s=0;e.widget("ui.tooltip",{version:"1.9.2",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,i){var s=this;return"disabled"===t?(this[i?"_disable":"_enable"](),this.options[t]=i,void 0):(this._super(t,i),"content"===t&&e.each(this.tooltips,function(e,t){s._updateContent(t)}),void 0)},_disable:function(){var t=this;e.each(this.tooltips,function(i,s){var a=e.Event("blur");a.target=a.currentTarget=s[0],t.close(a,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var i=this,s=e(t?t.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),t&&"mouseover"===t.type&&s.parents().each(function(){var t,s=e(this);s.data("ui-tooltip-open")&&(t=e.Event("blur"),t.target=t.currentTarget=this,i.close(t,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._updateContent(s,t))},_updateContent:function(e,t){var i,s=this.options.content,a=this,n=t?t.type:null;return"string"==typeof s?this._open(t,e,s):(i=s.call(e[0],function(i){e.data("ui-tooltip-open")&&a._delay(function(){t&&(t.type=n),this._open(t,e,i)})}),i&&this._open(t,e,i),void 0)},_open:function(i,s,a){function n(e){l.of=e,r.is(":hidden")||r.position(l)}var r,o,h,l=e.extend({},this.options.position);if(a){if(r=this._find(s),r.length)return r.find(".ui-tooltip-content").html(a),void 0;s.is("[title]")&&(i&&"mouseover"===i.type?s.attr("title",""):s.removeAttr("title")),r=this._tooltip(s),t(s,r.attr("id")),r.find(".ui-tooltip-content").html(a),this.options.track&&i&&/^mouse/.test(i.type)?(this._on(this.document,{mousemove:n}),n(i)):r.position(e.extend({of:s},this.options.position)),r.hide(),this._show(r,this.options.show),this.options.show&&this.options.show.delay&&(h=setInterval(function(){r.is(":visible")&&(n(l.of),clearInterval(h))},e.fx.interval)),this._trigger("open",i,{tooltip:r}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var i=e.Event(t);i.currentTarget=s[0],this.close(i,!0)}},remove:function(){this._removeTooltip(r)}},i&&"mouseover"!==i.type||(o.mouseleave="close"),i&&"focusin"!==i.type||(o.focusout="close"),this._on(!0,s,o)}},close:function(t){var s=this,a=e(t?t.currentTarget:this.element),n=this._find(a);this.closing||(a.data("ui-tooltip-title")&&a.attr("title",a.data("ui-tooltip-title")),i(a),n.stop(!0),this._hide(n,this.options.hide,function(){s._removeTooltip(e(this))}),a.removeData("ui-tooltip-open"),this._off(a,"mouseleave focusout keyup"),a[0]!==this.element[0]&&this._off(a,"remove"),this._off(this.document,"mousemove"),t&&"mouseleave"===t.type&&e.each(this.parents,function(t,i){e(i.element).attr("title",i.title),delete s.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:n}),this.closing=!1)},_tooltip:function(t){var i="ui-tooltip-"+s++,a=e("
          ").attr({id:i,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("
          ").addClass("ui-tooltip-content").appendTo(a),a.appendTo(this.document[0].body),e.fn.bgiframe&&a.bgiframe(),this.tooltips[i]=t,a},_find:function(t){var i=t.data("ui-tooltip-id");return i?e("#"+i):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(i,s){var a=e.Event("blur");a.target=a.currentTarget=s[0],t.close(a,!0),e("#"+i).remove(),s.data("ui-tooltip-title")&&(s.attr("title",s.data("ui-tooltip-title")),s.removeData("ui-tooltip-title"))})}})})(jQuery); +/** + * Copyright (c) 2007-2014 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com + * Licensed under MIT + * @author Ariel Flesler + * @version 1.4.12 + */ +;(function(a){if(typeof define==='function'&&define.amd){define(['jquery'],a)}else{a(jQuery)}}(function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};j.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(f,g,h){if(typeof g=='object'){h=g;g=0}if(typeof h=='function')h={onAfter:h};if(f=='max')f=9e9;h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue)g/=2;h.offset=both(h.offset);h.over=both(h.over);return this._scrollable().each(function(){if(f==null)return;var d=this,$elem=$(d),targ=f,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=win?$(targ):$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}var e=$.isFunction(h.offset)&&h.offset(d,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=j.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=e[pos]||0;if(h.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*h.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&h.queue){if(old!=attr[key])animate(h.onAfterFirst);delete attr[key]}});animate(h.onAfter);function animate(a){$elem.animate(attr,g,h.easing,a&&function(){a.call(this,targ,h)})}}).end()};j.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||typeof a=='object'?a:{top:a,left:a}};return j})); + +/* qTip2 @@vVERSION | Plugins: @@PLUGINS | Styles: @@STYLES | qtip2.com | Licensed MIT | Wed Feb 11 2015 19:36:40 */ + +!function(a,b,c){!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.qtip&&a(jQuery)}(function(d){"use strict";function e(a,b,c,e){this.id=c,this.target=a,this.tooltip=F,this.elements={target:a},this._id=S+"-"+c,this.timers={img:{}},this.options=b,this.plugins={},this.cache={event:{},target:d(),disabled:E,attr:e,onTooltip:E,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=E}function f(a){return a===F||"object"!==d.type(a)}function g(a){return!(d.isFunction(a)||a&&a.attr||a.length||"object"===d.type(a)&&(a.jquery||a.then))}function h(a){var b,c,e,h;return f(a)?E:(f(a.metadata)&&(a.metadata={type:a.metadata}),"content"in a&&(b=a.content,f(b)||b.jquery||b.done?b=a.content={text:c=g(b)?E:b}:c=b.text,"ajax"in b&&(e=b.ajax,h=e&&e.once!==E,delete b.ajax,b.text=function(a,b){var f=c||d(this).attr(b.options.content.attr)||"Loading...",g=d.ajax(d.extend({},e,{context:b})).then(e.success,F,e.error).then(function(a){return a&&h&&b.set("content.text",a),a},function(a,c,d){b.destroyed||0===a.status||b.set("content.text",c+": "+d)});return h?f:(b.set("content.text",f),g)}),"title"in b&&(d.isPlainObject(b.title)&&(b.button=b.title.button,b.title=b.title.text),g(b.title||E)&&(b.title=E))),"position"in a&&f(a.position)&&(a.position={my:a.position,at:a.position}),"show"in a&&f(a.show)&&(a.show=a.show.jquery?{target:a.show}:a.show===D?{ready:D}:{event:a.show}),"hide"in a&&f(a.hide)&&(a.hide=a.hide.jquery?{target:a.hide}:{event:a.hide}),"style"in a&&f(a.style)&&(a.style={classes:a.style}),d.each(R,function(){this.sanitize&&this.sanitize(a)}),a)}function i(a,b){for(var c,d=0,e=a,f=b.split(".");e=e[f[d++]];)d0?setTimeout(d.proxy(a,this),b):void a.call(this)}function m(a){this.tooltip.hasClass(ab)||(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=l.call(this,function(){this.toggle(D,a)},this.options.show.delay))}function n(a){if(!this.tooltip.hasClass(ab)&&!this.destroyed){var b=d(a.relatedTarget),c=b.closest(W)[0]===this.tooltip[0],e=b[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==b[0]&&"mouse"===this.options.position.target&&c||this.options.hide.fixed&&/mouse(out|leave|move)/.test(a.type)&&(c||e))try{a.preventDefault(),a.stopImmediatePropagation()}catch(f){}else this.timers.hide=l.call(this,function(){this.toggle(E,a)},this.options.hide.delay,this)}}function o(a){!this.tooltip.hasClass(ab)&&this.options.hide.inactive&&(clearTimeout(this.timers.inactive),this.timers.inactive=l.call(this,function(){this.hide(a)},this.options.hide.inactive))}function p(a){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(a)}function q(a,c,e){d(b.body).delegate(a,(c.split?c:c.join("."+S+" "))+"."+S,function(){var a=y.api[d.attr(this,U)];a&&!a.disabled&&e.apply(a,arguments)})}function r(a,c,f){var g,i,j,k,l,m=d(b.body),n=a[0]===b?m:a,o=a.metadata?a.metadata(f.metadata):F,p="html5"===f.metadata.type&&o?o[f.metadata.name]:F,q=a.data(f.metadata.name||"qtipopts");try{q="string"==typeof q?d.parseJSON(q):q}catch(r){}if(k=d.extend(D,{},y.defaults,f,"object"==typeof q?h(q):F,h(p||o)),i=k.position,k.id=c,"boolean"==typeof k.content.text){if(j=a.attr(k.content.attr),k.content.attr===E||!j)return E;k.content.text=j}if(i.container.length||(i.container=m),i.target===E&&(i.target=n),k.show.target===E&&(k.show.target=n),k.show.solo===D&&(k.show.solo=i.container.closest("body")),k.hide.target===E&&(k.hide.target=n),k.position.viewport===D&&(k.position.viewport=i.container),i.container=i.container.eq(0),i.at=new A(i.at,D),i.my=new A(i.my),a.data(S))if(k.overwrite)a.qtip("destroy",!0);else if(k.overwrite===E)return E;return a.attr(T,c),k.suppress&&(l=a.attr("title"))&&a.removeAttr("title").attr(cb,l).attr("title",""),g=new e(a,k,c,!!j),a.data(S,g),g}function s(a){return a.charAt(0).toUpperCase()+a.slice(1)}function t(a,b){var d,e,f=b.charAt(0).toUpperCase()+b.slice(1),g=(b+" "+rb.join(f+" ")+f).split(" "),h=0;if(qb[b])return a.css(qb[b]);for(;d=g[h++];)if((e=a.css(d))!==c)return qb[b]=d,e}function u(a,b){return Math.ceil(parseFloat(t(a,b)))}function v(a,b){this._ns="tip",this.options=b,this.offset=b.offset,this.size=[b.width,b.height],this.init(this.qtip=a)}function w(a,b){this.options=b,this._ns="-modal",this.init(this.qtip=a)}function x(a){this._ns="ie6",this.init(this.qtip=a)}var y,z,A,B,C,D=!0,E=!1,F=null,G="x",H="y",I="width",J="height",K="top",L="left",M="bottom",N="right",O="center",P="flipinvert",Q="shift",R={},S="qtip",T="data-hasqtip",U="data-qtip-id",V=["ui-widget","ui-tooltip"],W="."+S,X="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),Y=S+"-fixed",Z=S+"-default",$=S+"-focus",_=S+"-hover",ab=S+"-disabled",bb="_replacedByqTip",cb="oldtitle",db={ie:function(){for(var a=4,c=b.createElement("div");(c.innerHTML="")&&c.getElementsByTagName("i")[0];a+=1);return a>4?a:0/0}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||E};z=e.prototype,z._when=function(a){return d.when.apply(d,a)},z.render=function(a){if(this.rendered||this.destroyed)return this;var b,c=this,e=this.options,f=this.cache,g=this.elements,h=e.content.text,i=e.content.title,j=e.content.button,k=e.position,l=("."+this._id+" ",[]);return d.attr(this.target[0],"aria-describedby",this._id),f.posClass=this._createPosClass((this.position={my:k.my,at:k.at}).my),this.tooltip=g.tooltip=b=d("
          ",{id:this._id,"class":[S,Z,e.style.classes,f.posClass].join(" "),width:e.style.width||"",height:e.style.height||"",tracking:"mouse"===k.target&&k.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":E,"aria-describedby":this._id+"-content","aria-hidden":D}).toggleClass(ab,this.disabled).attr(U,this.id).data(S,this).appendTo(k.container).append(g.content=d("
          ",{"class":S+"-content",id:this._id+"-content","aria-atomic":D})),this.rendered=-1,this.positioning=D,i&&(this._createTitle(),d.isFunction(i)||l.push(this._updateTitle(i,E))),j&&this._createButton(),d.isFunction(h)||l.push(this._updateContent(h,E)),this.rendered=D,this._setWidget(),d.each(R,function(a){var b;"render"===this.initialize&&(b=this(c))&&(c.plugins[a]=b)}),this._unassignEvents(),this._assignEvents(),this._when(l).then(function(){c._trigger("render"),c.positioning=E,c.hiddenDuringWait||!e.show.ready&&!a||c.toggle(D,f.event,E),c.hiddenDuringWait=E}),y.api[this.id]=this,this},z.destroy=function(a){function b(){if(!this.destroyed){this.destroyed=D;var a,b=this.target,c=b.attr(cb);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),d.each(this.plugins,function(){this.destroy&&this.destroy()});for(a in this.timers)clearTimeout(this.timers[a]);b.removeData(S).removeAttr(U).removeAttr(T).removeAttr("aria-describedby"),this.options.suppress&&c&&b.attr("title",c).removeAttr(cb),this._unassignEvents(),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=F,delete y.api[this.id]}}return this.destroyed?this.target:(a===D&&"hide"!==this.triggering||!this.rendered?b.call(this):(this.tooltip.one("tooltiphidden",d.proxy(b,this)),!this.triggering&&this.hide()),this.target)},B=z.checks={builtin:{"^id$":function(a,b,c,e){var f=c===D?y.nextid:c,g=S+"-"+f;f!==E&&f.length>0&&!d("#"+g).length?(this._id=g,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):a[b]=e},"^prerender":function(a,b,c){c&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(a,b,c){this._updateContent(c)},"^content.attr$":function(a,b,c,d){this.options.content.text===this.target.attr(d)&&this._updateContent(this.target.attr(c))},"^content.title$":function(a,b,c){return c?(c&&!this.elements.title&&this._createTitle(),void this._updateTitle(c)):this._removeTitle()},"^content.button$":function(a,b,c){this._updateButton(c)},"^content.title.(text|button)$":function(a,b,c){this.set("content."+b,c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(this.position[b]=a[b]=new A(c,"at"===b))},"^position.container$":function(a,b,c){this.rendered&&this.tooltip.appendTo(c)},"^show.ready$":function(a,b,c){c&&(!this.rendered&&this.render(D)||this.toggle(D))},"^style.classes$":function(a,b,c,d){this.rendered&&this.tooltip.removeClass(d).addClass(c)},"^style.(width|height)":function(a,b,c){this.rendered&&this.tooltip.css(b,c)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(a,b,c){this.rendered&&this.tooltip.toggleClass(Z,!!c)},"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){this.rendered&&this.tooltip[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var a=this.options.position;this.tooltip.attr("tracking","mouse"===a.target&&a.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},z.get=function(a){if(this.destroyed)return this;var b=i(this.options,a.toLowerCase()),c=b[0][b[1]];return c.precedance?c.string():c};var eb=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,fb=/^prerender|show\.ready/i;z.set=function(a,b){if(this.destroyed)return this;{var c,e=this.rendered,f=E,g=this.options;this.checks}return"string"==typeof a?(c=a,a={},a[c]=b):a=d.extend({},a),d.each(a,function(b,c){if(e&&fb.test(b))return void delete a[b];var h,j=i(g,b.toLowerCase());h=j[0][j[1]],j[0][j[1]]=c&&c.nodeType?d(c):c,f=eb.test(b)||f,a[b]=[j[0],j[1],c,h]}),h(g),this.positioning=D,d.each(a,d.proxy(j,this)),this.positioning=E,this.rendered&&this.tooltip[0].offsetWidth>0&&f&&this.reposition("mouse"===g.position.target?F:this.cache.event),this},z._update=function(a,b){var c=this,e=this.cache;return this.rendered&&a?(d.isFunction(a)&&(a=a.call(this.elements.target,e.event,this)||""),d.isFunction(a.then)?(e.waiting=D,a.then(function(a){return e.waiting=E,c._update(a,b)},F,function(a){return c._update(a,b)})):a===E||!a&&""!==a?E:(a.jquery&&a.length>0?b.empty().append(a.css({display:"block",visibility:"visible"})):b.html(a),this._waitForContent(b).then(function(a){c.rendered&&c.tooltip[0].offsetWidth>0&&c.reposition(e.event,!a.length)}))):E},z._waitForContent=function(a){var b=this.cache;return b.waiting=D,(d.fn.imagesLoaded?a.imagesLoaded():d.Deferred().resolve([])).done(function(){b.waiting=E}).promise()},z._updateContent=function(a,b){this._update(a,this.elements.content,b)},z._updateTitle=function(a,b){this._update(a,this.elements.title,b)===E&&this._removeTitle(E)},z._createTitle=function(){var a=this.elements,b=this._id+"-title";a.titlebar&&this._removeTitle(),a.titlebar=d("
          ",{"class":S+"-titlebar "+(this.options.style.widget?k("header"):"")}).append(a.title=d("
          ",{id:b,"class":S+"-title","aria-atomic":D})).insertBefore(a.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus","down"===a.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover","mouseover"===a.type)}),this.options.content.button&&this._createButton()},z._removeTitle=function(a){var b=this.elements;b.title&&(b.titlebar.remove(),b.titlebar=b.title=b.button=F,a!==E&&this.reposition())},z._createPosClass=function(a){return S+"-pos-"+(a||this.options.position.my).abbrev()},z.reposition=function(c,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=D;var f,g,h,i,j=this.cache,k=this.tooltip,l=this.options.position,m=l.target,n=l.my,o=l.at,p=l.viewport,q=l.container,r=l.adjust,s=r.method.split(" "),t=k.outerWidth(E),u=k.outerHeight(E),v=0,w=0,x=k.css("position"),y={left:0,top:0},z=k[0].offsetWidth>0,A=c&&"scroll"===c.type,B=d(a),C=q[0].ownerDocument,F=this.mouse;if(d.isArray(m)&&2===m.length)o={x:L,y:K},y={left:m[0],top:m[1]};else if("mouse"===m)o={x:L,y:K},(!r.mouse||this.options.hide.distance)&&j.origin&&j.origin.pageX?c=j.origin:!c||c&&("resize"===c.type||"scroll"===c.type)?c=j.event:F&&F.pageX&&(c=F),"static"!==x&&(y=q.offset()),C.body.offsetWidth!==(a.innerWidth||C.documentElement.clientWidth)&&(g=d(b.body).offset()),y={left:c.pageX-y.left+(g&&g.left||0),top:c.pageY-y.top+(g&&g.top||0)},r.mouse&&A&&F&&(y.left-=(F.scrollX||0)-B.scrollLeft(),y.top-=(F.scrollY||0)-B.scrollTop());else{if("event"===m?c&&c.target&&"scroll"!==c.type&&"resize"!==c.type?j.target=d(c.target):c.target||(j.target=this.elements.target):"event"!==m&&(j.target=d(m.jquery?m:this.elements.target)),m=j.target,m=d(m).eq(0),0===m.length)return this;m[0]===b||m[0]===a?(v=db.iOS?a.innerWidth:m.width(),w=db.iOS?a.innerHeight:m.height(),m[0]===a&&(y={top:(p||m).scrollTop(),left:(p||m).scrollLeft()})):R.imagemap&&m.is("area")?f=R.imagemap(this,m,o,R.viewport?s:E):R.svg&&m&&m[0].ownerSVGElement?f=R.svg(this,m,o,R.viewport?s:E):(v=m.outerWidth(E),w=m.outerHeight(E),y=m.offset()),f&&(v=f.width,w=f.height,g=f.offset,y=f.position),y=this.reposition.offset(m,y,q),(db.iOS>3.1&&db.iOS<4.1||db.iOS>=4.3&&db.iOS<4.33||!db.iOS&&"fixed"===x)&&(y.left-=B.scrollLeft(),y.top-=B.scrollTop()),(!f||f&&f.adjustable!==E)&&(y.left+=o.x===N?v:o.x===O?v/2:0,y.top+=o.y===M?w:o.y===O?w/2:0)}return y.left+=r.x+(n.x===N?-t:n.x===O?-t/2:0),y.top+=r.y+(n.y===M?-u:n.y===O?-u/2:0),R.viewport?(h=y.adjusted=R.viewport(this,y,l,v,w,t,u),g&&h.left&&(y.left+=g.left),g&&h.top&&(y.top+=g.top),h.my&&(this.position.my=h.my)):y.adjusted={left:0,top:0},j.posClass!==(i=this._createPosClass(this.position.my))&&k.removeClass(j.posClass).addClass(j.posClass=i),this._trigger("move",[y,p.elem||p],c)?(delete y.adjusted,e===E||!z||isNaN(y.left)||isNaN(y.top)||"mouse"===m||!d.isFunction(l.effect)?k.css(y):d.isFunction(l.effect)&&(l.effect.call(k,this,d.extend({},y)),k.queue(function(a){d(this).css({opacity:"",height:""}),db.ie&&this.style.removeAttribute("filter"),a()})),this.positioning=E,this):this},z.reposition.offset=function(a,c,e){function f(a,b){c.left+=b*a.scrollLeft(),c.top+=b*a.scrollTop()}if(!e[0])return c;var g,h,i,j,k=d(a[0].ownerDocument),l=!!db.ie&&"CSS1Compat"!==b.compatMode,m=e[0];do"static"!==(h=d.css(m,"position"))&&("fixed"===h?(i=m.getBoundingClientRect(),f(k,-1)):(i=d(m).position(),i.left+=parseFloat(d.css(m,"borderLeftWidth"))||0,i.top+=parseFloat(d.css(m,"borderTopWidth"))||0),c.left-=i.left+(parseFloat(d.css(m,"marginLeft"))||0),c.top-=i.top+(parseFloat(d.css(m,"marginTop"))||0),g||"hidden"===(j=d.css(m,"overflow"))||"visible"===j||(g=d(m)));while(m=m.offsetParent);return g&&(g[0]!==k[0]||l)&&f(g,1),c};var gb=(A=z.reposition.Corner=function(a,b){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,O).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!b;var c=a.charAt(0);this.precedance="t"===c||"b"===c?H:G}).prototype;gb.invert=function(a,b){this[a]=this[a]===L?N:this[a]===N?L:b||this[a]},gb.string=function(a){var b=this.x,c=this.y,d=b!==c?"center"===b||"center"!==c&&(this.precedance===H||this.forceY)?[c,b]:[b,c]:[b];return a!==!1?d.join(" "):d},gb.abbrev=function(){var a=this.string(!1);return a[0].charAt(0)+(a[1]&&a[1].charAt(0)||"")},gb.clone=function(){return new A(this.string(),this.forceY)},z.toggle=function(a,c){var e=this.cache,f=this.options,g=this.tooltip;if(c){if(/over|enter/.test(c.type)&&e.event&&/out|leave/.test(e.event.type)&&f.show.target.add(c.target).length===f.show.target.length&&g.has(c.relatedTarget).length)return this;e.event=d.event.fix(c)}if(this.waiting&&!a&&(this.hiddenDuringWait=D),!this.rendered)return a?this.render(1):this;if(this.destroyed||this.disabled)return this;var h,i,j,k=a?"show":"hide",l=this.options[k],m=(this.options[a?"hide":"show"],this.options.position),n=this.options.content,o=this.tooltip.css("width"),p=this.tooltip.is(":visible"),q=a||1===l.target.length,r=!c||l.target.length<2||e.target[0]===c.target;return(typeof a).search("boolean|number")&&(a=!p),h=!g.is(":animated")&&p===a&&r,i=h?F:!!this._trigger(k,[90]),this.destroyed?this:(i!==E&&a&&this.focus(c),!i||h?this:(d.attr(g[0],"aria-hidden",!a),a?(this.mouse&&(e.origin=d.event.fix(this.mouse)),d.isFunction(n.text)&&this._updateContent(n.text,E),d.isFunction(n.title)&&this._updateTitle(n.title,E),!C&&"mouse"===m.target&&m.adjust.mouse&&(d(b).bind("mousemove."+S,this._storeMouse),C=D),o||g.css("width",g.outerWidth(E)),this.reposition(c,arguments[2]),o||g.css("width",""),l.solo&&("string"==typeof l.solo?d(l.solo):d(W,l.solo)).not(g).not(l.target).qtip("hide",d.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete e.origin,C&&!d(W+'[tracking="true"]:visible',l.solo).not(g).length&&(d(b).unbind("mousemove."+S),C=E),this.blur(c)),j=d.proxy(function(){a?(db.ie&&g[0].style.removeAttribute("filter"),g.css("overflow",""),"string"==typeof l.autofocus&&d(this.options.show.autofocus,g).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):g.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(a?"visible":"hidden")},this),l.effect===E||q===E?(g[k](),j()):d.isFunction(l.effect)?(g.stop(1,1),l.effect.call(g,this),g.queue("fx",function(a){j(),a()})):g.fadeTo(90,a?1:0,j),a&&l.target.trigger("qtip-"+this.id+"-inactive"),this))},z.show=function(a){return this.toggle(D,a)},z.hide=function(a){return this.toggle(E,a)},z.focus=function(a){if(!this.rendered||this.destroyed)return this;var b=d(W),c=this.tooltip,e=parseInt(c[0].style.zIndex,10),f=y.zindex+b.length;return c.hasClass($)||this._trigger("focus",[f],a)&&(e!==f&&(b.each(function(){this.style.zIndex>e&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+$).qtip("blur",a)),c.addClass($)[0].style.zIndex=f),this},z.blur=function(a){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass($),this._trigger("blur",[this.tooltip.css("zIndex")],a),this)},z.disable=function(a){return this.destroyed?this:("toggle"===a?a=!(this.rendered?this.tooltip.hasClass(ab):this.disabled):"boolean"!=typeof a&&(a=D),this.rendered&&this.tooltip.toggleClass(ab,a).attr("aria-disabled",a),this.disabled=!!a,this)},z.enable=function(){return this.disable(E)},z._createButton=function(){var a=this,b=this.elements,c=b.tooltip,e=this.options.content.button,f="string"==typeof e,g=f?e:"Close tooltip";b.button&&b.button.remove(),b.button=e.jquery?e:d("",{"class":"qtip-close "+(this.options.style.widget?"":S+"-icon"),title:g,"aria-label":g}).prepend(d("",{"class":"ui-icon ui-icon-close",html:"×"})),b.button.appendTo(b.titlebar||c).attr("role","button").click(function(b){return c.hasClass(ab)||a.hide(b),E})},z._updateButton=function(a){if(!this.rendered)return E;var b=this.elements.button;a?this._createButton():b.remove()},z._setWidget=function(){var a=this.options.style.widget,b=this.elements,c=b.tooltip,d=c.hasClass(ab);c.removeClass(ab),ab=a?"ui-state-disabled":"qtip-disabled",c.toggleClass(ab,d),c.toggleClass("ui-helper-reset "+k(),a).toggleClass(Z,this.options.style.def&&!a),b.content&&b.content.toggleClass(k("content"),a),b.titlebar&&b.titlebar.toggleClass(k("header"),a),b.button&&b.button.toggleClass(S+"-icon",!a)},z._storeMouse=function(a){return(this.mouse=d.event.fix(a)).type="mousemove",this},z._bind=function(a,b,c,e,f){if(a&&c&&b.length){var g="."+this._id+(e?"-"+e:"");return d(a).bind((b.split?b:b.join(g+" "))+g,d.proxy(c,f||this)),this}},z._unbind=function(a,b){return a&&d(a).unbind("."+this._id+(b?"-"+b:"")),this},z._trigger=function(a,b,c){var e=d.Event("tooltip"+a);return e.originalEvent=c&&d.extend({},c)||this.cache.event||F,this.triggering=a,this.tooltip.trigger(e,[this].concat(b||[])),this.triggering=E,!e.isDefaultPrevented()},z._bindEvents=function(a,b,c,e,f,g){var h=c.filter(e).add(e.filter(c)),i=[];h.length&&(d.each(b,function(b,c){var e=d.inArray(c,a);e>-1&&i.push(a.splice(e,1)[0])}),i.length&&(this._bind(h,i,function(a){var b=this.rendered?this.tooltip[0].offsetWidth>0:!1;(b?g:f).call(this,a)}),c=c.not(h),e=e.not(h))),this._bind(c,a,f),this._bind(e,b,g)},z._assignInitialEvents=function(a){function b(a){return this.disabled||this.destroyed?E:(this.cache.event=a&&d.event.fix(a),this.cache.target=a&&d(a.target),clearTimeout(this.timers.show),void(this.timers.show=l.call(this,function(){this.render("object"==typeof a||c.show.ready)},c.prerender?0:c.show.delay)))}var c=this.options,e=c.show.target,f=c.hide.target,g=c.show.event?d.trim(""+c.show.event).split(" "):[],h=c.hide.event?d.trim(""+c.hide.event).split(" "):[];this._bind(this.elements.target,["remove","removeqtip"],function(){this.destroy(!0)},"destroy"),/mouse(over|enter)/i.test(c.show.event)&&!/mouse(out|leave)/i.test(c.hide.event)&&h.push("mouseleave"),this._bind(e,"mousemove",function(a){this._storeMouse(a),this.cache.onTarget=D}),this._bindEvents(g,h,e,f,b,function(){return this.timers?void clearTimeout(this.timers.show):E}),(c.show.ready||c.prerender)&&b.call(this,a)},z._assignEvents=function(){var c=this,e=this.options,f=e.position,g=this.tooltip,h=e.show.target,i=e.hide.target,j=f.container,k=f.viewport,l=d(b),q=(d(b.body),d(a)),r=e.show.event?d.trim(""+e.show.event).split(" "):[],s=e.hide.event?d.trim(""+e.hide.event).split(" "):[];d.each(e.events,function(a,b){c._bind(g,"toggle"===a?["tooltipshow","tooltiphide"]:["tooltip"+a],b,null,g)}),/mouse(out|leave)/i.test(e.hide.event)&&"window"===e.hide.leave&&this._bind(l,["mouseout","blur"],function(a){/select|option/.test(a.target.nodeName)||a.relatedTarget||this.hide(a)}),e.hide.fixed?i=i.add(g.addClass(Y)):/mouse(over|enter)/i.test(e.show.event)&&this._bind(i,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+e.hide.event).indexOf("unfocus")>-1&&this._bind(j.closest("html"),["mousedown","touchstart"],function(a){var b=d(a.target),c=this.rendered&&!this.tooltip.hasClass(ab)&&this.tooltip[0].offsetWidth>0,e=b.parents(W).filter(this.tooltip[0]).length>0;b[0]===this.target[0]||b[0]===this.tooltip[0]||e||this.target.has(b[0]).length||!c||this.hide(a)}),"number"==typeof e.hide.inactive&&(this._bind(h,"qtip-"+this.id+"-inactive",o,"inactive"),this._bind(i.add(g),y.inactiveEvents,o)),this._bindEvents(r,s,h,i,m,n),this._bind(h.add(g),"mousemove",function(a){if("number"==typeof e.hide.distance){var b=this.cache.origin||{},c=this.options.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&this.hide(a)}this._storeMouse(a)}),"mouse"===f.target&&f.adjust.mouse&&(e.hide.event&&this._bind(h,["mouseenter","mouseleave"],function(a){return this.cache?void(this.cache.onTarget="mouseenter"===a.type):E}),this._bind(l,"mousemove",function(a){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(ab)&&this.tooltip[0].offsetWidth>0&&this.reposition(a)})),(f.adjust.resize||k.length)&&this._bind(d.event.special.resize?k:q,"resize",p),f.adjust.scroll&&this._bind(q.add(f.container),"scroll",p)},z._unassignEvents=function(){var c=this.options,e=c.show.target,f=c.hide.target,g=d.grep([this.elements.target[0],this.rendered&&this.tooltip[0],c.position.container[0],c.position.viewport[0],c.position.container.closest("html")[0],a,b],function(a){return"object"==typeof a});e&&e.toArray&&(g=g.concat(e.toArray())),f&&f.toArray&&(g=g.concat(f.toArray())),this._unbind(g)._unbind(g,"destroy")._unbind(g,"inactive")},d(function(){q(W,["mouseenter","mouseleave"],function(a){var b="mouseenter"===a.type,c=d(a.currentTarget),e=d(a.relatedTarget||a.target),f=this.options;b?(this.focus(a),c.hasClass(Y)&&!c.hasClass(ab)&&clearTimeout(this.timers.hide)):"mouse"===f.position.target&&f.position.adjust.mouse&&f.hide.event&&f.show.target&&!e.closest(f.show.target[0]).length&&this.hide(a),c.toggleClass(_,b)}),q("["+U+"]",X,o)}),y=d.fn.qtip=function(a,b,e){var f=(""+a).toLowerCase(),g=F,i=d.makeArray(arguments).slice(1),j=i[i.length-1],k=this[0]?d.data(this[0],S):F;return!arguments.length&&k||"api"===f?k:"string"==typeof a?(this.each(function(){var a=d.data(this,S);if(!a)return D;if(j&&j.timeStamp&&(a.cache.event=j),!b||"option"!==f&&"options"!==f)a[f]&&a[f].apply(a,i);else{if(e===c&&!d.isPlainObject(b))return g=a.get(b),E;a.set(b,e)}}),g!==F?g:this):"object"!=typeof a&&arguments.length?void 0:(k=h(d.extend(D,{},a)),this.each(function(a){var b,c;return c=d.isArray(k.id)?k.id[a]:k.id,c=!c||c===E||c.length<1||y.api[c]?y.nextid++:c,b=r(d(this),c,k),b===E?D:(y.api[c]=b,d.each(R,function(){"initialize"===this.initialize&&this(b)}),void b._assignInitialEvents(j))}))},d.qtip=e,y.api={},d.each({attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&"object"==typeof f&&f.options.suppress)return arguments.length<2?d.attr(c,cb):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(cb,b))}return d.fn["attr"+bb].apply(this,arguments)},clone:function(a){var b=(d([]),d.fn["clone"+bb].apply(this,arguments));return a||b.filter("["+cb+"]").attr("title",function(){return d.attr(this,cb)}).removeAttr(cb),b}},function(a,b){if(!b||d.fn[a+bb])return D;var c=d.fn[a+bb]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+bb]=d.cleanData,d.cleanData=function(a){for(var b,c=0;(b=d(a[c])).length;c++)if(b.attr(T))try{b.triggerHandler("removeqtip")}catch(e){}d["cleanData"+bb].apply(this,arguments)}),y.version="@@VERSION",y.nextid=0,y.inactiveEvents=X,y.zindex=15e3,y.defaults={prerender:E,id:E,overwrite:D,suppress:D,content:{text:D,attr:"title",title:E,button:E},position:{my:"top left",at:"bottom right",target:E,container:E,viewport:E,adjust:{x:0,y:0,mouse:D,scroll:D,resize:D,method:"flipinvert flipinvert"},effect:function(a,b){d(this).animate(b,{duration:200,queue:E})}},show:{target:E,event:"mouseenter",effect:D,delay:90,solo:E,ready:E,autofocus:E},hide:{target:E,event:"mouseleave",effect:D,delay:0,fixed:E,inactive:E,leave:"window",distance:E},style:{classes:"",widget:E,width:E,height:E,def:D},events:{render:F,move:F,show:F,hide:F,toggle:F,visible:F,hidden:F,focus:F,blur:F}};var hb,ib="margin",jb="border",kb="color",lb="background-color",mb="transparent",nb=" !important",ob=!!b.createElement("canvas").getContext,pb=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,qb={},rb=["Webkit","O","Moz","ms"];if(ob)var sb=a.devicePixelRatio||1,tb=function(){var a=b.createElement("canvas").getContext("2d");return a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||1}(),ub=sb/tb;else var vb=function(a,b,c){return"'};d.extend(v.prototype,{init:function(a){var b,c;c=this.element=a.elements.tip=d("
          ",{"class":S+"-tip"}).prependTo(a.tooltip),ob?(b=d("").appendTo(this.element)[0].getContext("2d"),b.lineJoin="miter",b.miterLimit=1e5,b.save()):(b=vb("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(b+b),a._bind(d("*",c).add(c),["click","mousedown"],function(a){a.stopPropagation()},this._ns)),a._bind(a.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(a){var b=this.qtip.elements.titlebar;return b&&(a.y===K||a.y===O&&this.element.position().top+this.size[1]/2+this.options.offsetl&&!pb.test(e[1])&&(e[0]=e[1]),this.border=l=p.border!==D?p.border:l):this.border=l=0,k=this.size=this._calculateSize(b),n.css({width:k[0],height:k[1],lineHeight:k[1]+"px"}),j=b.precedance===H?[s(r.x===L?l:r.x===N?k[0]-q[0]-l:(k[0]-q[0])/2),s(r.y===K?k[1]-q[1]:0)]:[s(r.x===L?k[0]-q[0]:0),s(r.y===K?l:r.y===M?k[1]-q[1]-l:(k[1]-q[1])/2)],ob?(g=o[0].getContext("2d"),g.restore(),g.save(),g.clearRect(0,0,6e3,6e3),h=this._calculateTip(r,q,ub),i=this._calculateTip(r,this.size,ub),o.attr(I,k[0]*ub).attr(J,k[1]*ub),o.css(I,k[0]).css(J,k[1]),this._drawCoords(g,i),g.fillStyle=e[1],g.fill(),g.translate(j[0]*ub,j[1]*ub),this._drawCoords(g,h),g.fillStyle=e[0],g.fill()):(h=this._calculateTip(r),h="m"+h[0]+","+h[1]+" l"+h[2]+","+h[3]+" "+h[4]+","+h[5]+" xe",j[2]=l&&/^(r|b)/i.test(b.string())?8===db.ie?2:1:0,o.css({coordsize:k[0]+l+" "+(k[1]+l),antialias:""+(r.string().indexOf(O)>-1),left:j[0]-j[2]*Number(f===G),top:j[1]-j[2]*Number(f===H),width:k[0]+l,height:k[1]+l}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k[0]+l+" "+(k[1]+l),path:h,fillcolor:e[0],filled:!!a,stroked:!a}).toggle(!(!l&&!a)),!a&&b.html(vb("stroke",'weight="'+2*l+'px" color="'+e[1]+'" miterlimit="1000" joinstyle="miter"'))})),a.opera&&setTimeout(function(){m.tip.css({display:"inline-block",visibility:"visible"})},1),c!==E&&this.calculate(b,k)},calculate:function(a,b){if(!this.enabled)return E;var c,e,f=this,g=this.qtip.elements,h=this.element,i=this.options.offset,j=(g.tooltip.hasClass("ui-widget"),{});return a=a||this.corner,c=a.precedance,b=b||this._calculateSize(a),e=[a.x,a.y],c===G&&e.reverse(),d.each(e,function(d,e){var h,k,l; +e===O?(h=c===H?L:K,j[h]="50%",j[ib+"-"+h]=-Math.round(b[c===H?0:1]/2)+i):(h=f._parseWidth(a,e,g.tooltip),k=f._parseWidth(a,e,g.content),l=f._parseRadius(a),j[e]=Math.max(-f.border,d?k:i+(l>h?l:-h)))}),j[a[c]]-=b[c===G?0:1],h.css({margin:"",top:"",bottom:"",left:"",right:""}).css(j),j},reposition:function(a,b,d){function e(a,b,c,d,e){a===Q&&j.precedance===b&&k[d]&&j[c]!==O?j.precedance=j.precedance===G?H:G:a!==Q&&k[d]&&(j[b]=j[b]===O?k[d]>0?d:e:j[b]===d?e:d)}function f(a,b,e){j[a]===O?p[ib+"-"+b]=o[a]=g[ib+"-"+b]-k[b]:(h=g[e]!==c?[k[b],-g[b]]:[-k[b],g[b]],(o[a]=Math.max(h[0],h[1]))>h[0]&&(d[b]-=k[b],o[b]=E),p[g[e]!==c?e:b]=o[a])}if(this.enabled){var g,h,i=b.cache,j=this.corner.clone(),k=d.adjusted,l=b.options.position.adjust.method.split(" "),m=l[0],n=l[1]||l[0],o={left:E,top:E,x:0,y:0},p={};this.corner.fixed!==D&&(e(m,G,H,L,N),e(n,H,G,K,M),(j.string()!==i.corner.string()||i.cornerTop!==k.top||i.cornerLeft!==k.left)&&this.update(j,E)),g=this.calculate(j),g.right!==c&&(g.left=-g.right),g.bottom!==c&&(g.top=-g.bottom),g.user=this.offset,(o.left=m===Q&&!!k.left)&&f(G,L,N),(o.top=n===Q&&!!k.top)&&f(H,K,M),this.element.css(p).toggle(!(o.x&&o.y||j.x===O&&o.y||j.y===O&&o.x)),d.left-=g.left.charAt?g.user:m!==Q||o.top||!o.left&&!o.top?g.left+this.border:0,d.top-=g.top.charAt?g.user:n!==Q||o.left||!o.left&&!o.top?g.top+this.border:0,i.cornerLeft=k.left,i.cornerTop=k.top,i.corner=j.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),hb=R.tip=function(a){return new v(a,a.options.style.tip)},hb.initialize="render",hb.sanitize=function(a){if(a.style&&"tip"in a.style){var b=a.style.tip;"object"!=typeof b&&(b=a.style.tip={corner:b}),/string|boolean/i.test(typeof b.corner)||(b.corner=D)}},B.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(a){this.size=[a.width,a.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},d.extend(D,y.defaults,{style:{tip:{corner:D,mimic:E,width:6,height:6,border:D,offset:0}}});var wb,xb,yb="qtip-modal",zb="."+yb;xb=function(){function a(a){if(d.expr[":"].focusable)return d.expr[":"].focusable;var b,c,e,f=!isNaN(d.attr(a,"tabindex")),g=a.nodeName&&a.nodeName.toLowerCase();return"area"===g?(b=a.parentNode,c=b.name,a.href&&c&&"map"===b.nodeName.toLowerCase()?(e=d("img[usemap=#"+c+"]")[0],!!e&&e.is(":visible")):!1):/input|select|textarea|button|object/.test(g)?!a.disabled:"a"===g?a.href||f:f}function c(a){k.length<1&&a.length?a.not("body").blur():k.first().focus()}function e(a){if(i.is(":visible")){var b,e=d(a.target),h=f.tooltip,j=e.closest(W);b=j.length<1?E:parseInt(j[0].style.zIndex,10)>parseInt(h[0].style.zIndex,10),b||e.closest(W)[0]===h[0]||c(e),g=a.target===k[k.length-1]}}var f,g,h,i,j=this,k={};d.extend(j,{init:function(){return i=j.elem=d("
          ",{id:"qtip-overlay",html:"
          ",mousedown:function(){return E}}).hide(),d(b.body).bind("focusin"+zb,e),d(b).bind("keydown"+zb,function(a){f&&f.options.show.modal.escape&&27===a.keyCode&&f.hide(a)}),i.bind("click"+zb,function(a){f&&f.options.show.modal.blur&&f.hide(a)}),j},update:function(b){f=b,k=b.options.show.modal.stealfocus!==E?b.tooltip.find("*").filter(function(){return a(this)}):[]},toggle:function(a,e,g){var k=(d(b.body),a.tooltip),l=a.options.show.modal,m=l.effect,n=e?"show":"hide",o=i.is(":visible"),p=d(zb).filter(":visible:not(:animated)").not(k);return j.update(a),e&&l.stealfocus!==E&&c(d(":focus")),i.toggleClass("blurs",l.blur),e&&i.appendTo(b.body),i.is(":animated")&&o===e&&h!==E||!e&&p.length?j:(i.stop(D,E),d.isFunction(m)?m.call(i,e):m===E?i[n]():i.fadeTo(parseInt(g,10)||90,e?1:0,function(){e||i.hide()}),e||i.queue(function(a){i.css({left:"",top:""}),d(zb).length||i.detach(),a()}),h=e,f.destroyed&&(f=F),j)}}),j.init()},xb=new xb,d.extend(w.prototype,{init:function(a){var b=a.tooltip;return this.options.on?(a.elements.overlay=xb.elem,b.addClass(yb).css("z-index",y.modal_zindex+d(zb).length),a._bind(b,["tooltipshow","tooltiphide"],function(a,c,e){var f=a.originalEvent;if(a.target===b[0])if(f&&"tooltiphide"===a.type&&/mouse(leave|enter)/.test(f.type)&&d(f.relatedTarget).closest(xb.elem[0]).length)try{a.preventDefault()}catch(g){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(a,"tooltipshow"===a.type,e)},this._ns,this),a._bind(b,"tooltipfocus",function(a,c){if(!a.isDefaultPrevented()&&a.target===b[0]){var e=d(zb),f=y.modal_zindex+e.length,g=parseInt(b[0].style.zIndex,10);xb.elem[0].style.zIndex=f-1,e.each(function(){this.style.zIndex>g&&(this.style.zIndex-=1)}),e.filter("."+$).qtip("blur",a.originalEvent),b.addClass($)[0].style.zIndex=f,xb.update(c);try{a.preventDefault()}catch(h){}}},this._ns,this),void a._bind(b,"tooltiphide",function(a){a.target===b[0]&&d(zb).filter(":visible").not(b).last().qtip("focus",a)},this._ns,this)):this},toggle:function(a,b,c){return a&&a.isDefaultPrevented()?this:void xb.toggle(this.qtip,!!b,c)},destroy:function(){this.qtip.tooltip.removeClass(yb),this.qtip._unbind(this.qtip.tooltip,this._ns),xb.toggle(this.qtip,E),delete this.qtip.elements.overlay}}),wb=R.modal=function(a){return new w(a,a.options.show.modal)},wb.sanitize=function(a){a.show&&("object"!=typeof a.show.modal?a.show.modal={on:!!a.show.modal}:"undefined"==typeof a.show.modal.on&&(a.show.modal.on=D))},y.modal_zindex=y.zindex-200,wb.initialize="render",B.modal={"^show.modal.(on|blur)$":function(){this.destroy(),this.init(),this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}},d.extend(D,y.defaults,{show:{modal:{on:E,effect:D,blur:D,stealfocus:D,escape:D}}}),R.viewport=function(c,d,e,f,g,h,i){function j(a,b,c,e,f,g,h,i,j){var k=d[f],s=u[a],t=v[a],w=c===Q,x=s===f?j:s===g?-j:-j/2,y=t===f?i:t===g?-i:-i/2,z=q[f]+r[f]-(n?0:m[f]),A=z-k,B=k+j-(h===I?o:p)-z,C=x-(u.precedance===a||s===u[b]?y:0)-(t===O?i/2:0);return w?(C=(s===f?1:-1)*x,d[f]+=A>0?A:B>0?-B:0,d[f]=Math.max(-m[f]+r[f],k-C,Math.min(Math.max(-m[f]+r[f]+(h===I?o:p),k+C),d[f],"center"===s?k-x:1e9))):(e*=c===P?2:0,A>0&&(s!==f||B>0)?(d[f]-=C+e,l.invert(a,f)):B>0&&(s!==g||A>0)&&(d[f]-=(s===O?-C:C)+e,l.invert(a,g)),d[f]B&&(d[f]=k,l=u.clone())),d[f]-k}var k,l,m,n,o,p,q,r,s=e.target,t=c.elements.tooltip,u=e.my,v=e.at,w=e.adjust,x=w.method.split(" "),y=x[0],z=x[1]||x[0],A=e.viewport,B=e.container,C=(c.cache,{left:0,top:0});return A.jquery&&s[0]!==a&&s[0]!==b.body&&"none"!==w.method?(m=B.offset()||C,n="static"===B.css("position"),k="fixed"===t.css("position"),o=A[0]===a?A.width():A.outerWidth(E),p=A[0]===a?A.height():A.outerHeight(E),q={left:k?0:A.scrollLeft(),top:k?0:A.scrollTop()},r=A.offset()||C,("shift"!==y||"shift"!==z)&&(l=u.clone()),C={left:"none"!==y?j(G,H,y,w.x,L,N,I,f,h):0,top:"none"!==z?j(H,G,z,w.y,K,M,J,g,i):0,my:l}):C},R.polys={polygon:function(a,b){var c,d,e,f={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:E},g=0,h=[],i=1,j=1,k=0,l=0;for(g=a.length;g--;)c=[parseInt(a[--g],10),parseInt(a[g+1],10)],c[0]>f.position.right&&(f.position.right=c[0]),c[0]f.position.bottom&&(f.position.bottom=c[1]),c[1]0&&e>0&&i>0&&j>0;)for(d=Math.floor(d/2),e=Math.floor(e/2),b.x===L?i=d:b.x===N?i=f.width-d:i+=Math.floor(d/2),b.y===K?j=e:b.y===M?j=f.height-e:j+=Math.floor(e/2),g=h.length;g--&&!(h.length<2);)k=h[g][0]-f.position.left,l=h[g][1]-f.position.top,(b.x===L&&k>=i||b.x===N&&i>=k||b.x===O&&(i>k||k>f.width-i)||b.y===K&&l>=j||b.y===M&&j>=l||b.y===O&&(j>l||l>f.height-j))&&h.splice(g,1);f.position={left:h[0][0],top:h[0][1]}}return f},rect:function(a,b,c,d){return{width:Math.abs(c-a),height:Math.abs(d-b),position:{left:Math.min(a,c),top:Math.min(b,d)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(a,b,c,d,e){var f=R.polys._angles[e.abbrev()],g=0===f?0:c*Math.cos(f*Math.PI),h=d*Math.sin(f*Math.PI);return{width:2*c-Math.abs(g),height:2*d-Math.abs(h),position:{left:a+g,top:b+h},adjustable:E}},circle:function(a,b,c,d){return R.polys.ellipse(a,b,c,c,d)}},R.svg=function(a,c,e){for(var f,g,h,i,j,k,l,m,n,o=(d(b),c[0]),p=d(o.ownerSVGElement),q=o.ownerDocument,r=(parseInt(c.css("stroke-width"),10)||0)/2;!o.getBBox;)o=o.parentNode;if(!o.getBBox||!o.parentNode)return E;switch(o.nodeName){case"ellipse":case"circle":m=R.polys.ellipse(o.cx.baseVal.value,o.cy.baseVal.value,(o.rx||o.r).baseVal.value+r,(o.ry||o.r).baseVal.value+r,e);break;case"line":case"polygon":case"polyline":for(l=o.points||[{x:o.x1.baseVal.value,y:o.y1.baseVal.value},{x:o.x2.baseVal.value,y:o.y2.baseVal.value}],m=[],k=-1,i=l.numberOfItems||l.length;++k';d.extend(x.prototype,{_scroll:function(){var b=this.qtip.elements.overlay;b&&(b[0].style.top=d(a).scrollTop()+"px")},init:function(c){var e=c.tooltip;d("select, object").length<1&&(this.bgiframe=c.elements.bgiframe=d(Bb).appendTo(e),c._bind(e,"tooltipmove",this.adjustBGIFrame,this._ns,this)),this.redrawContainer=d("
          ",{id:S+"-rcontainer"}).appendTo(b.body),c.elements.overlay&&c.elements.overlay.addClass("qtipmodal-ie6fix")&&(c._bind(a,["scroll","resize"],this._scroll,this._ns,this),c._bind(e,["tooltipshow"],this._scroll,this._ns,this)),this.redraw()},adjustBGIFrame:function(){var a,b,c=this.qtip.tooltip,d={height:c.outerHeight(E),width:c.outerWidth(E)},e=this.qtip.plugins.tip,f=this.qtip.elements.tip;b=parseInt(c.css("borderLeftWidth"),10)||0,b={left:-b,top:-b},e&&f&&(a="x"===e.corner.precedance?[I,L]:[J,K],b[a[1]]-=f[a[0]]()),this.bgiframe.css(b).css(d)},redraw:function(){if(this.qtip.rendered<1||this.drawing)return this;var a,b,c,d,e=this.qtip.tooltip,f=this.qtip.options.style,g=this.qtip.options.position.container;return this.qtip.drawing=1,f.height&&e.css(J,f.height),f.width?e.css(I,f.width):(e.css(I,"").appendTo(this.redrawContainer),b=e.width(),1>b%2&&(b+=1),c=e.css("maxWidth")||"",d=e.css("minWidth")||"",a=(c+d).indexOf("%")>-1?g.width()/100:0,c=(c.indexOf("%")>-1?a:1)*parseInt(c,10)||b,d=(d.indexOf("%")>-1?a:1)*parseInt(d,10)||0,b=c+d?Math.min(Math.max(b,d),c):b,e.css(I,Math.round(b)).appendTo(g)),this.drawing=0,this},destroy:function(){this.bgiframe&&this.bgiframe.remove(),this.qtip._unbind([a,this.qtip.tooltip],this._ns)}}),Ab=R.ie6=function(a){return 6===db.ie?new x(a):E},Ab.initialize="render",B.ie6={"^content|style$":function(){this.redraw()}}})}(window,document); +//# sourceMappingURL=jquery.qtip.min.js.map +(function(){var a={VERSION:"2.3.3",Result:{SUCCEEDED:1,NOTRANSITION:2,CANCELLED:3,PENDING:4},Error:{INVALID_TRANSITION:100,PENDING_TRANSITION:200,INVALID_CALLBACK:300},WILDCARD:"*",ASYNC:"async",create:function(g,h){var j=(typeof g.initial=="string")?{state:g.initial}:g.initial;var f=g.terminal||g["final"];var e=h||g.target||{};var l=g.events||[];var i=g.callbacks||{};var c={};var k=function(m){var p=(m.from instanceof Array)?m.from:(m.from?[m.from]:[a.WILDCARD]);c[m.name]=c[m.name]||{};for(var o=0;o=0):(this.current===m)};e.can=function(m){return !this.transition&&(c[m].hasOwnProperty(this.current)||c[m].hasOwnProperty(a.WILDCARD))};e.cannot=function(m){return !this.can(m)};e.error=g.error||function(o,s,r,n,m,q,p){throw p||q};e.isFinished=function(){return this.is(f)};if(j&&!j.defer){e[j.event]()}return e},doCallback:function(g,d,c,i,h,b){if(d){try{return d.apply(g,[c,i,h].concat(b))}catch(f){return g.error(c,i,h,b,a.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",f)}}},beforeAnyEvent:function(d,c,f,e,b){return a.doCallback(d,d.onbeforeevent,c,f,e,b)},afterAnyEvent:function(d,c,f,e,b){return a.doCallback(d,d.onafterevent||d.onevent,c,f,e,b)},leaveAnyState:function(d,c,f,e,b){return a.doCallback(d,d.onleavestate,c,f,e,b)},enterAnyState:function(d,c,f,e,b){return a.doCallback(d,d.onenterstate||d.onstate,c,f,e,b)},changeState:function(d,c,f,e,b){return a.doCallback(d,d.onchangestate,c,f,e,b)},beforeThisEvent:function(d,c,f,e,b){return a.doCallback(d,d["onbefore"+c],c,f,e,b)},afterThisEvent:function(d,c,f,e,b){return a.doCallback(d,d["onafter"+c]||d["on"+c],c,f,e,b)},leaveThisState:function(d,c,f,e,b){return a.doCallback(d,d["onleave"+f],c,f,e,b)},enterThisState:function(d,c,f,e,b){return a.doCallback(d,d["onenter"+e]||d["on"+e],c,f,e,b)},beforeEvent:function(d,c,f,e,b){if((false===a.beforeThisEvent(d,c,f,e,b))||(false===a.beforeAnyEvent(d,c,f,e,b))){return false}},afterEvent:function(d,c,f,e,b){a.afterThisEvent(d,c,f,e,b);a.afterAnyEvent(d,c,f,e,b)},leaveState:function(f,e,h,g,d){var c=a.leaveThisState(f,e,h,g,d),b=a.leaveAnyState(f,e,h,g,d);if((false===c)||(false===b)){return false}else{if((a.ASYNC===c)||(a.ASYNC===b)){return a.ASYNC}}},enterState:function(d,c,f,e,b){a.enterThisState(d,c,f,e,b);a.enterAnyState(d,c,f,e,b)},buildEvent:function(b,c){return function(){var h=this.current;var g=c[h]||c[a.WILDCARD]||h;var e=Array.prototype.slice.call(arguments);if(this.transition){return this.error(b,h,g,e,a.Error.PENDING_TRANSITION,"event "+b+" inappropriate because previous transition did not complete")}if(this.cannot(b)){return this.error(b,h,g,e,a.Error.INVALID_TRANSITION,"event "+b+" inappropriate in current state "+this.current)}if(false===a.beforeEvent(this,b,h,g,e)){return a.Result.CANCELLED}if(h===g){a.afterEvent(this,b,h,g,e);return a.Result.NOTRANSITION}var f=this;this.transition=function(){f.transition=null;f.current=g;a.enterState(f,b,h,g,e);a.changeState(f,b,h,g,e);a.afterEvent(f,b,h,g,e);return a.Result.SUCCEEDED};this.transition.cancel=function(){f.transition=null;a.afterEvent(f,b,h,g,e)};var d=a.leaveState(this,b,h,g,e);if(false===d){this.transition=null;return a.Result.CANCELLED}else{if(a.ASYNC===d){return a.Result.PENDING}else{if(this.transition){return this.transition()}}}}}};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports){exports=module.exports=a}exports.StateMachine=a}else{if(typeof define==="function"&&define.amd){define(function(b){return a})}else{if(typeof window!=="undefined"){window.StateMachine=a}else{if(typeof self!=="undefined"){self.StateMachine=a}}}}}()); +// 4.1.7 (2014-11-27) +!function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;ir;r++)if(o=n[r],o&&o.func.call(o.scope,e)===!1&&e.preventDefault(),e.isImmediatePropagationStopped())return}var a=this,s={},l,c,u,d,f;c=o+(+new Date).toString(32),d="onmouseenter"in document.documentElement,u="onfocusin"in document.documentElement,f={mouseenter:"mouseover",mouseleave:"mouseout"},l=1,a.domLoaded=!1,a.events=s,a.bind=function(t,o,p,h){function m(e){i(n(e||_.event),g)}var g,v,y,b,C,x,w,_=window;if(t&&3!==t.nodeType&&8!==t.nodeType){for(t[c]?g=t[c]:(g=l++,t[c]=g,s[g]={}),h=h||t,o=o.split(" "),y=o.length;y--;)b=o[y],x=m,C=w=!1,"DOMContentLoaded"===b&&(b="ready"),a.domLoaded&&"ready"===b&&"complete"==t.readyState?p.call(h,n({type:b})):(d||(C=f[b],C&&(x=function(e){var t,r;if(t=e.currentTarget,r=e.relatedTarget,r&&t.contains)r=t.contains(r);else for(;r&&r!==t;)r=r.parentNode;r||(e=n(e||_.event),e.type="mouseout"===e.type?"mouseleave":"mouseenter",e.target=t,i(e,g))})),u||"focusin"!==b&&"focusout"!==b||(w=!0,C="focusin"===b?"focus":"blur",x=function(e){e=n(e||_.event),e.type="focus"===e.type?"focusin":"focusout",i(e,g)}),v=s[g][b],v?"ready"===b&&a.domLoaded?p({type:b}):v.push({func:p,scope:h}):(s[g][b]=v=[{func:p,scope:h}],v.fakeName=C,v.capture=w,v.nativeHandler=x,"ready"===b?r(t,x,a):e(t,C||b,x,w)));return t=v=0,p}},a.unbind=function(e,n,r){var i,o,l,u,d,f;if(!e||3===e.nodeType||8===e.nodeType)return a;if(i=e[c]){if(f=s[i],n){for(n=n.split(" "),l=n.length;l--;)if(d=n[l],o=f[d]){if(r)for(u=o.length;u--;)if(o[u].func===r){var p=o.nativeHandler,h=o.fakeName,m=o.capture;o=o.slice(0,u).concat(o.slice(u+1)),o.nativeHandler=p,o.fakeName=h,o.capture=m,f[d]=o}r&&0!==o.length||(delete f[d],t(e,o.fakeName||d,o.nativeHandler,o.capture))}}else{for(d in f)o=f[d],t(e,o.fakeName||d,o.nativeHandler,o.capture);f={}}for(d in f)return a;delete s[i];try{delete e[c]}catch(g){e[c]=null}}return a},a.fire=function(e,t,r){var o;if(!e||3===e.nodeType||8===e.nodeType)return a;r=n(null,r),r.type=t,r.target=e;do o=e[c],o&&i(r,o),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow;while(e&&!r.isPropagationStopped());return a},a.clean=function(e){var t,n,r=a.unbind;if(!e||3===e.nodeType||8===e.nodeType)return a;if(e[c]&&r(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName)for(r(e),n=e.getElementsByTagName("*"),t=n.length;t--;)e=n[t],e[c]&&r(e);return a},a.destroy=function(){s={}},a.cancel=function(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}}var o="mce-data-",a=/^(?:mouse|contextmenu)|click/,s={keyLocation:1,layerX:1,layerY:1,returnValue:1};return i.Event=new i,i.Event.bind(window,"ready",function(){}),i}),r(c,[],function(){function e(e,t,n,r){var i,o,a,s,l,c,d,p,h,m;if((t?t.ownerDocument||t:z)!==D&&B(t),t=t||D,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(H&&!r){if(i=vt.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&I(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return Z.apply(n,t.getElementsByTagName(e)),n;if((a=i[3])&&x.getElementsByClassName)return Z.apply(n,t.getElementsByClassName(a)),n}if(x.qsa&&(!M||!M.test(e))){if(p=d=F,h=t,m=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){for(c=N(e),(d=t.getAttribute("id"))?p=d.replace(bt,"\\$&"):t.setAttribute("id",p),p="[id='"+p+"'] ",l=c.length;l--;)c[l]=p+f(c[l]);h=yt.test(e)&&u(t.parentNode)||t,m=c.join(",")}if(m)try{return Z.apply(n,h.querySelectorAll(m)),n}catch(g){}finally{d||t.removeAttribute("id")}}}return S(e.replace(st,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[F]=!0,e}function i(e){var t=D.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=e.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||K)-(~e.sourceIndex||K);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function l(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function c(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function u(e){return e&&typeof e.getElementsByTagName!==Y&&e}function d(){}function f(e){for(var t=0,n=e.length,r="";n>t;t++)r+=e[t].value;return r}function p(e,t,n){var r=t.dir,i=n&&"parentNode"===r,o=V++;return t.first?function(t,n,o){for(;t=t[r];)if(1===t.nodeType||i)return e(t,n,o)}:function(t,n,a){var s,l,c=[W,o];if(a){for(;t=t[r];)if((1===t.nodeType||i)&&e(t,n,a))return!0}else for(;t=t[r];)if(1===t.nodeType||i){if(l=t[F]||(t[F]={}),(s=l[r])&&s[0]===W&&s[1]===o)return c[2]=s[2];if(l[r]=c,c[2]=e(t,n,a))return!0}}}function h(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function m(t,n,r){for(var i=0,o=n.length;o>i;i++)e(t,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,l=e.length,c=null!=t;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),c&&t.push(s));return a}function v(e,t,n,i,o,a){return i&&!i[F]&&(i=v(i)),o&&!o[F]&&(o=v(o,a)),r(function(r,a,s,l){var c,u,d,f=[],p=[],h=a.length,v=r||m(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?v:g(v,f,e,s,l),b=n?o||(r?e:h||i)?[]:a:y;if(n&&n(y,b,s,l),i)for(c=g(b,p),i(c,[],s,l),u=c.length;u--;)(d=c[u])&&(b[p[u]]=!(y[p[u]]=d));if(r){if(o||e){if(o){for(c=[],u=b.length;u--;)(d=b[u])&&c.push(y[u]=d);o(null,b=[],c,l)}for(u=b.length;u--;)(d=b[u])&&(c=o?tt.call(r,d):f[u])>-1&&(r[c]=!(a[c]=d))}}else b=g(b===a?b.splice(h,b.length):b),o?o(null,a,b,l):Z.apply(a,b)})}function y(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,l=p(function(e){return e===t},a,!0),c=p(function(e){return tt.call(t,e)>-1},a,!0),u=[function(e,n,r){return!o&&(r||n!==T)||((t=n).nodeType?l(e,n,r):c(e,n,r))}];i>s;s++)if(n=w.relative[e[s].type])u=[p(h(u),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[F]){for(r=++s;i>r&&!w.relative[e[r].type];r++);return v(s>1&&h(u),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(st,"$1"),n,r>s&&y(e.slice(s,r)),i>r&&y(e=e.slice(r)),i>r&&f(e))}u.push(n)}return h(u)}function b(t,n){var i=n.length>0,o=t.length>0,a=function(r,a,s,l,c){var u,d,f,p=0,h="0",m=r&&[],v=[],y=T,b=r||o&&w.find.TAG("*",c),C=W+=null==y?1:Math.random()||.1,x=b.length;for(c&&(T=a!==D&&a);h!==x&&null!=(u=b[h]);h++){if(o&&u){for(d=0;f=t[d++];)if(f(u,a,s)){l.push(u);break}c&&(W=C)}i&&((u=!f&&u)&&p--,r&&m.push(u))}if(p+=h,i&&h!==p){for(d=0;f=n[d++];)f(m,v,a,s);if(r){if(p>0)for(;h--;)m[h]||v[h]||(v[h]=J.call(l));v=g(v)}Z.apply(l,v),c&&!r&&v.length>0&&p+n.length>1&&e.uniqueSort(l)}return c&&(W=C,T=y),m};return i?r(a):a}var C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F="sizzle"+-new Date,z=window.document,W=0,V=0,U=n(),$=n(),q=n(),j=function(e,t){return e===t&&(A=!0),0},Y=typeof t,K=1<<31,G={}.hasOwnProperty,X=[],J=X.pop,Q=X.push,Z=X.push,et=X.slice,tt=X.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},nt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",rt="[\\x20\\t\\r\\n\\f]",it="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",ot="\\["+rt+"*("+it+")(?:"+rt+"*([*^$|!~]?=)"+rt+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+it+"))|)"+rt+"*\\]",at=":("+it+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ot+")*)|.*)\\)|)",st=new RegExp("^"+rt+"+|((?:^|[^\\\\])(?:\\\\.)*)"+rt+"+$","g"),lt=new RegExp("^"+rt+"*,"+rt+"*"),ct=new RegExp("^"+rt+"*([>+~]|"+rt+")"+rt+"*"),ut=new RegExp("="+rt+"*([^\\]'\"]*?)"+rt+"*\\]","g"),dt=new RegExp(at),ft=new RegExp("^"+it+"$"),pt={ID:new RegExp("^#("+it+")"),CLASS:new RegExp("^\\.("+it+")"),TAG:new RegExp("^("+it+"|[*])"),ATTR:new RegExp("^"+ot),PSEUDO:new RegExp("^"+at),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+rt+"*(even|odd|(([+-]|)(\\d*)n|)"+rt+"*(?:([+-]|)"+rt+"*(\\d+)|))"+rt+"*\\)|)","i"),bool:new RegExp("^(?:"+nt+")$","i"),needsContext:new RegExp("^"+rt+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+rt+"*((?:-\\d)?\\d*)"+rt+"*\\)|)(?=[^-]|$)","i")},ht=/^(?:input|select|textarea|button)$/i,mt=/^h\d$/i,gt=/^[^{]+\{\s*\[native \w/,vt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,yt=/[+~]/,bt=/'|\\/g,Ct=new RegExp("\\\\([\\da-f]{1,6}"+rt+"?|("+rt+")|.)","ig"),xt=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)};try{Z.apply(X=et.call(z.childNodes),z.childNodes),X[z.childNodes.length].nodeType}catch(wt){Z={apply:X.length?function(e,t){Q.apply(e,et.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}x=e.support={},E=e.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},B=e.setDocument=function(e){var t,n=e?e.ownerDocument||e:z,r=n.defaultView;return n!==D&&9===n.nodeType&&n.documentElement?(D=n,L=n.documentElement,H=!E(n),r&&r!==r.top&&(r.addEventListener?r.addEventListener("unload",function(){B()},!1):r.attachEvent&&r.attachEvent("onunload",function(){B()})),x.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),x.getElementsByTagName=i(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),x.getElementsByClassName=gt.test(n.getElementsByClassName),x.getById=i(function(e){return L.appendChild(e).id=F,!n.getElementsByName||!n.getElementsByName(F).length}),x.getById?(w.find.ID=function(e,t){if(typeof t.getElementById!==Y&&H){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},w.filter.ID=function(e){var t=e.replace(Ct,xt);return function(e){return e.getAttribute("id")===t}}):(delete w.find.ID,w.filter.ID=function(e){var t=e.replace(Ct,xt);return function(e){var n=typeof e.getAttributeNode!==Y&&e.getAttributeNode("id");return n&&n.value===t}}),w.find.TAG=x.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==Y?t.getElementsByTagName(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=x.getElementsByClassName&&function(e,t){return H?t.getElementsByClassName(e):void 0},P=[],M=[],(x.qsa=gt.test(n.querySelectorAll))&&(i(function(e){e.innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&M.push("[*^$]="+rt+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||M.push("\\["+rt+"*(?:value|"+nt+")"),e.querySelectorAll(":checked").length||M.push(":checked")}),i(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&M.push("name"+rt+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||M.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),M.push(",.*:")})),(x.matchesSelector=gt.test(O=L.matches||L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&i(function(e){x.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),P.push("!=",at)}),M=M.length&&new RegExp(M.join("|")),P=P.length&&new RegExp(P.join("|")),t=gt.test(L.compareDocumentPosition),I=t||gt.test(L.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return A=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r?r:(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&r||!x.sortDetached&&t.compareDocumentPosition(e)===r?e===n||e.ownerDocument===z&&I(z,e)?-1:t===n||t.ownerDocument===z&&I(z,t)?1:R?tt.call(R,e)-tt.call(R,t):0:4&r?-1:1)}:function(e,t){if(e===t)return A=!0,0;var r,i=0,o=e.parentNode,s=t.parentNode,l=[e],c=[t];if(!o||!s)return e===n?-1:t===n?1:o?-1:s?1:R?tt.call(R,e)-tt.call(R,t):0;if(o===s)return a(e,t);for(r=e;r=r.parentNode;)l.unshift(r);for(r=t;r=r.parentNode;)c.unshift(r);for(;l[i]===c[i];)i++;return i?a(l[i],c[i]):l[i]===z?-1:c[i]===z?1:0},n):D},e.matches=function(t,n){return e(t,null,null,n)},e.matchesSelector=function(t,n){if((t.ownerDocument||t)!==D&&B(t),n=n.replace(ut,"='$1']"),!(!x.matchesSelector||!H||P&&P.test(n)||M&&M.test(n)))try{var r=O.call(t,n);if(r||x.disconnectedMatch||t.document&&11!==t.document.nodeType)return r}catch(i){}return e(n,D,null,[t]).length>0},e.contains=function(e,t){return(e.ownerDocument||e)!==D&&B(e),I(e,t)},e.attr=function(e,n){(e.ownerDocument||e)!==D&&B(e);var r=w.attrHandle[n.toLowerCase()],i=r&&G.call(w.attrHandle,n.toLowerCase())?r(e,n,!H):t;return i!==t?i:x.attributes||!H?e.getAttribute(n):(i=e.getAttributeNode(n))&&i.specified?i.value:null},e.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},e.uniqueSort=function(e){var t,n=[],r=0,i=0;if(A=!x.detectDuplicates,R=!x.sortStable&&e.slice(0),e.sort(j),A){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return R=null,e},_=e.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=_(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=_(t);return n},w=e.selectors={cacheLength:50,createPseudo:r,match:pt,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Ct,xt),e[3]=(e[3]||e[4]||e[5]||"").replace(Ct,xt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pt.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&dt.test(n)&&(t=N(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Ct,xt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=U[e+" "];return t||(t=new RegExp("(^|"+rt+")"+e+"("+rt+"|$)"))&&U(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==Y&&e.getAttribute("class")||"")})},ATTR:function(t,n,r){return function(i){var o=e.attr(i,t);return null==o?"!="===n:n?(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o+" ").indexOf(r)>-1:"|="===n?o===r||o.slice(0,r.length+1)===r+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var c,u,d,f,p,h,m=o!==a?"nextSibling":"previousSibling",g=t.parentNode,v=s&&t.nodeName.toLowerCase(),y=!l&&!s;if(g){if(o){for(;m;){for(d=t;d=d[m];)if(s?d.nodeName.toLowerCase()===v:1===d.nodeType)return!1;h=m="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?g.firstChild:g.lastChild],a&&y){for(u=g[F]||(g[F]={}),c=u[e]||[],p=c[0]===W&&c[1],f=c[0]===W&&c[2],d=p&&g.childNodes[p];d=++p&&d&&d[m]||(f=p=0)||h.pop();)if(1===d.nodeType&&++f&&d===t){u[e]=[W,p,f];break}}else if(y&&(c=(t[F]||(t[F]={}))[e])&&c[0]===W)f=c[1];else for(;(d=++p&&d&&d[m]||(f=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==v:1!==d.nodeType)||!++f||(y&&((d[F]||(d[F]={}))[e]=[W,f]),d!==t)););return f-=i,f===r||f%r===0&&f/r>=0}}},PSEUDO:function(t,n){var i,o=w.pseudos[t]||w.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return o[F]?o(n):o.length>1?(i=[t,t,"",n],w.setFilters.hasOwnProperty(t.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=tt.call(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(st,"$1"));return i[F]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),!n.pop()}}),has:r(function(t){return function(n){return e(t,n).length>0}}),contains:r(function(e){return e=e.replace(Ct,xt),function(t){return(t.textContent||t.innerText||_(t)).indexOf(e)>-1}}),lang:r(function(t){return ft.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(Ct,xt).toLowerCase(),function(e){var n;do if(n=H?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return n=n.toLowerCase(),n===t||0===n.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=window.location&&window.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===L},focus:function(e){return e===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return mt.test(e.nodeName)},input:function(e){return ht.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:c(function(){return[0]}),last:c(function(e,t){return[t-1]}),eq:c(function(e,t,n){return[0>n?n+t:n]}),even:c(function(e,t){for(var n=0;t>n;n+=2)e.push(n);return e}),odd:c(function(e,t){for(var n=1;t>n;n+=2)e.push(n);return e}),lt:c(function(e,t,n){for(var r=0>n?n+t:n;--r>=0;)e.push(r);return e}),gt:c(function(e,t,n){for(var r=0>n?n+t:n;++r2&&"ID"===(a=o[0]).type&&x.getById&&9===t.nodeType&&H&&w.relative[o[1].type]){if(t=(w.find.ID(a.matches[0].replace(Ct,xt),t)||[])[0],!t)return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=pt.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((l=w.find[s])&&(r=l(a.matches[0].replace(Ct,xt),yt.test(o[0].type)&&u(t.parentNode)||t))){if(o.splice(i,1),e=r.length&&f(o),!e)return Z.apply(n,r),n;break}}return(c||k(e,d))(r,t,!H,n,yt.test(e)&&u(t.parentNode)||t),n},x.sortStable=F.split("").sort(j).join("")===F,x.detectDuplicates=!!A,B(),x.sortDetached=i(function(e){return 1&e.compareDocumentPosition(D.createElement("div"))}),i(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){return n?void 0:e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),x.attributes&&i(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){return n||"input"!==e.nodeName.toLowerCase()?void 0:e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(nt,function(e,t,n){var r;return n?void 0:e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),e}),r(u,[],function(){var e=navigator,t=e.userAgent,n,r,i,o,a,s,l;n=window.opera&&window.opera.buildNumber,r=/WebKit/.test(t),i=!r&&!n&&/MSIE/gi.test(t)&&/Explorer/gi.test(e.appName),i=i&&/MSIE (\w+)\./.exec(t)[1],o=-1==t.indexOf("Trident/")||-1==t.indexOf("rv:")&&-1==e.appName.indexOf("Netscape")?!1:11,i=i||o,a=!r&&!o&&/Gecko/.test(t),s=-1!=t.indexOf("Mac"),l=/(iPad|iPhone)/.test(t);var c=!l||t.match(/AppleWebKit\/(\d*)/)[1]>=534;return{opera:n,webkit:r,ie:i,gecko:a,mac:s,iOS:l,contentEditable:c,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:8!=i,range:window.getSelection&&"Range"in window,documentMode:i?document.documentMode||7:10}}),r(d,[u],function(e){function n(e){return null===e||e===t?"":(""+e).replace(v,"")}function r(e,n){return n?"array"==n&&y(e)?!0:typeof e==n:e!==t}function i(e){var t=e,n,r;if(!y(e))for(t=[],n=0,r=e.length;r>n;n++)t[n]=e[n];return t}function o(e,t,n){var r;for(e=e||[],t=t||",","string"==typeof e&&(e=e.split(t)),n=n||{},r=e.length;r--;)n[e[r]]={};return n}function a(e,n,r){var i,o;if(!e)return 0;if(r=r||e,e.length!==t){for(i=0,o=e.length;o>i;i++)if(n.call(r,e[i],i,e)===!1)return 0}else for(i in e)if(e.hasOwnProperty(i)&&n.call(r,e[i],i,e)===!1)return 0;return 1}function s(e,t){var n=[];return a(e,function(e){n.push(t(e))}),n}function l(e,t){var n=[];return a(e,function(e){(!t||t(e))&&n.push(e)}),n}function c(e,t,n){var r=this,i,o,a,s,l,c=0;if(e=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(e),a=e[3].match(/(^|\.)(\w+)$/i)[2],o=r.createNS(e[3].replace(/\.\w+$/,""),n),!o[a]){if("static"==e[2])return o[a]=t,void(this.onCreate&&this.onCreate(e[2],e[3],o[a]));t[a]||(t[a]=function(){},c=1),o[a]=t[a],r.extend(o[a].prototype,t),e[5]&&(i=r.resolve(e[5]).prototype,s=e[5].match(/\.(\w+)$/i)[1],l=o[a],o[a]=c?function(){return i[s].apply(this,arguments)}:function(){return this.parent=i[s],l.apply(this,arguments)},o[a].prototype[a]=o[a],r.each(i,function(e,t){o[a].prototype[t]=i[t]}),r.each(t,function(e,t){i[t]?o[a].prototype[t]=function(){return this.parent=i[t],e.apply(this,arguments)}:t!=a&&(o[a].prototype[t]=e)})),r.each(t["static"],function(e,t){o[a][t]=e})}}function u(e,t){var n,r;if(e)for(n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}function d(e,n){var r,i,o,a=arguments,s;for(r=1,i=a.length;i>r;r++){n=a[r];for(o in n)n.hasOwnProperty(o)&&(s=n[o],s!==t&&(e[o]=s))}return e}function f(e,t,n,r){r=r||this,e&&(n&&(e=e[n]),a(e,function(e,i){return t.call(r,e,i,n)===!1?!1:void f(e,t,n,r)}))}function p(e,t){var n,r;for(t=t||window,e=e.split("."),n=0;nn&&(t=t[e[n]],t);n++);return t}function m(e,t){return!e||r(e,"array")?e:s(e.split(t||","),n)}function g(t){var n=e.cacheSuffix;return n&&(t+=(-1===t.indexOf("?")?"?":"&")+n),t}var v=/^\s*|\s*$/g,y=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};return{trim:n,isArray:y,is:r,toArray:i,makeMap:o,each:a,map:s,grep:l,inArray:u,extend:d,create:c,walk:f,createNS:p,resolve:h,explode:m,_addCacheSuffix:g}}),r(f,[l,c,d,u],function(e,n,r,i){function o(e){return"undefined"!=typeof e}function a(e){return"string"==typeof e}function s(e){return e&&e==e.window}function l(e,t){var n,r,i;for(t=t||w,i=t.createElement("div"),n=t.createDocumentFragment(),i.innerHTML=e;r=i.firstChild;)n.appendChild(r);return n}function c(e,t,n,r){var i;if(a(t))t=l(t,v(e[0]));else if(t.length&&!t.nodeType){if(t=f.makeArray(t),r)for(i=t.length-1;i>=0;i--)c(e,t[i],n,r);else for(i=0;ii&&(a=e[i],t.call(a,i,a)!==!1);i++);return e}function g(e,t){var n=[];return m(e,function(e,r){t(r,e)&&n.push(r)}),n}function v(e){return e?9==e.nodeType?e:e.ownerDocument:w}function y(e,n,r){var i=[],o=e[n];for("string"!=typeof r&&r instanceof f&&(r=r[0]);o&&9!==o.nodeType;){if(r!==t){if(o===r)break;if("string"==typeof r&&f(o).is(r))break}1===o.nodeType&&i.push(o),o=o[n]}return i}function b(e,n,r,i){var o=[];for(i instanceof f&&(i=i[0]);e;e=e[n])if(!r||e.nodeType===r){if(i!==t){if(e===i)break;if("string"==typeof i&&f(e).is(i))break}o.push(e)}return o}function C(e,t,n){for(e=e[t];e;e=e[t])if(e.nodeType==n)return e;return null}function x(e,t,n){m(n,function(n,r){e[n]=e[n]||{},e[n][t]=r})}var w=document,_=Array.prototype.push,E=Array.prototype.slice,N=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,k=e.Event,S,T=r.makeMap("fillOpacity fontWeight lineHeight opacity orphans widows zIndex zoom"," "),R=r.makeMap("checked compact declare defer disabled ismap multiple nohref noshade nowrap readonly selected"," "),A={"for":"htmlFor","class":"className",readonly:"readOnly"},B={"float":"cssFloat"},D={},L={},H=/^\s*|\s*$/g;return f.fn=f.prototype={constructor:f,selector:"",context:null,length:0,init:function(e,t){var n=this,r,i;if(!e)return n;if(e.nodeType)return n.context=n[0]=e,n.length=1,n;if(t&&t.nodeType)n.context=t;else{if(t)return f(e).attr(t);n.context=t=document}if(a(e)){if(n.selector=e,r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!r)return f(t).find(e);if(r[1])for(i=l(e,v(t)).firstChild;i;)_.call(n,i),i=i.nextSibling;else{if(i=v(t).getElementById(r[2]),!i)return n;if(i.id!==r[2])return n.find(e);n.length=1,n[0]=i}}else this.add(e,!1);return n},toArray:function(){return r.toArray(this)},add:function(e,t){var n=this,r,i;if(a(e))return n.add(f(e));if(t!==!1)for(r=f.unique(n.toArray().concat(f.makeArray(e))),n.length=r.length,i=0;it;t++)f.find(e,this[t],r);return f(r)},filter:function(e){return f("function"==typeof e?g(this.toArray(),function(t,n){return e(n,t)}):f.filter(e,this.toArray()))},closest:function(e){var t=[];return e instanceof f&&(e=e[0]),this.each(function(n,r){for(;r;){if("string"==typeof e&&f(r).is(e)){t.push(r);break}if(r==e){t.push(r);break}r=r.parentNode}}),f(t)},offset:function(e){var t,n,r,i=0,o=0,a;return e?this.css(e):(t=this[0],t&&(n=t.ownerDocument,r=n.documentElement,t.getBoundingClientRect&&(a=t.getBoundingClientRect(),i=a.left+(r.scrollLeft||n.body.scrollLeft)-r.clientLeft,o=a.top+(r.scrollTop||n.body.scrollTop)-r.clientTop)),{left:i,top:o})},push:_,sort:[].sort,splice:[].splice},r.extend(f,{extend:r.extend,makeArray:function(e){return s(e)||e.nodeType?[e]:r.toArray(e)},inArray:p,isArray:r.isArray,each:m,trim:h,grep:g,find:n,expr:n.selectors,unique:n.uniqueSort,text:n.getText,contains:n.contains,filter:function(e,t,n){var r=t.length;for(n&&(e=":not("+e+")");r--;)1!=t[r].nodeType&&t.splice(r,1);return t=1===t.length?f.find.matchesSelector(t[0],e)?[t[0]]:[]:f.find.matches(e,t)}}),m({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return y(e,"parentNode")},next:function(e){return C(e,"nextSibling",1)},prev:function(e){return C(e,"previousSibling",1)},children:function(e){return b(e.firstChild,"nextSibling",1)},contents:function(e){return r.toArray(("iframe"===e.nodeName?e.contentDocument||e.contentWindow.document:e).childNodes)}},function(e,t){f.fn[e]=function(n){var r=this,i=[];return r.each(function(){var e=t.call(i,this,n,i);e&&(f.isArray(e)?i.push.apply(i,e):i.push(e))}),this.length>1&&(i=f.unique(i),0===e.indexOf("parents")&&(i=i.reverse())),i=f(i),n?i.filter(n):i}}),m({parentsUntil:function(e,t){return y(e,"parentNode",t)},nextUntil:function(e,t){return b(e,"nextSibling",1,t).slice(1)},prevUntil:function(e,t){return b(e,"previousSibling",1,t).slice(1)}},function(e,t){f.fn[e]=function(n,r){var i=this,o=[];return i.each(function(){var e=t.call(o,this,n,o);e&&(f.isArray(e)?o.push.apply(o,e):o.push(e))}),this.length>1&&(o=f.unique(o),(0===e.indexOf("parents")||"prevUntil"===e)&&(o=o.reverse())),o=f(o),r?o.filter(r):o}}),f.fn.is=function(e){return!!e&&this.filter(e).length>0},f.fn.init.prototype=f.fn,f.overrideDefaults=function(e){function t(r,i){return n=n||e(),0===arguments.length&&(r=n.element),i||(i=n.context),new t.fn.init(r,i)}var n;return f.extend(t,this),t},i.ie&&i.ie<8&&(x(D,"get",{maxlength:function(e){var t=e.maxLength;return 2147483647===t?S:t},size:function(e){var t=e.size;return 20===t?S:t},"class":function(e){return e.className},style:function(e){var t=e.style.cssText;return 0===t.length?S:t}}),x(D,"set",{"class":function(e,t){e.className=t},style:function(e,t){e.style.cssText=t}})),i.ie&&i.ie<9&&(B["float"]="styleFloat",x(L,"set",{opacity:function(e,t){var n=e.style;null===t||""===t?n.removeAttribute("filter"):(n.zoom=1,n.filter="alpha(opacity="+100*t+")")}})),f.attrHooks=D,f.cssHooks=L,f}),r(p,[],function(){return function(e,t){function n(e,t,n,r){function i(e){return e=parseInt(e,10).toString(16),e.length>1?e:"0"+e}return"#"+i(t)+i(n)+i(r)}var r=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,i=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,o=/\s*([^:]+):\s*([^;]+);?/g,a=/\s+$/,s,l,c={},u,d,f,p="\ufeff";for(e=e||{},t&&(d=t.getValidStyles(),f=t.getInvalidStyles()),u=("\\\" \\' \\; \\: ; : "+p).split(" "),l=0;l-1&&n||(m[e+t]=-1==l?s[0]:s.join(" "),delete m[e+"-top"+t],delete m[e+"-right"+t],delete m[e+"-bottom"+t],delete m[e+"-left"+t])}}function u(e){var t=m[e],n;if(t){for(t=t.split(" "),n=t.length;n--;)if(t[n]!==t[0])return!1;return m[e]=t[0],!0}}function d(e,t,n,r){u(t)&&u(n)&&u(r)&&(m[e]=m[t]+" "+m[n]+" "+m[r],delete m[t],delete m[n],delete m[r])}function f(e){return b=!0,c[e]}function p(e,t){return b&&(e=e.replace(/\uFEFF[0-9]/g,function(e){return c[e]})),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e}function h(t,n,r,i,o,a){if(o=o||a)return o=p(o),"'"+o.replace(/\'/g,"\\'")+"'";if(n=p(n||r||i),!e.allow_script_urls){var s=n.replace(/[\s\r\n]+/,"");if(/(java|vb)script:/i.test(s))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(s))return""}return C&&(n=C.call(x,n,"style")),"url('"+n.replace(/\'/g,"\\'")+"')"}var m={},g,v,y,b,C=e.url_converter,x=e.url_converter_scope||this;if(t){for(t=t.replace(/[\u0000-\u001F]/g,""),t=t.replace(/\\[\"\';:\uFEFF]/g,f).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(e){return e.replace(/[;:]/g,f)});g=o.exec(t);){if(v=g[1].replace(a,"").toLowerCase(),y=g[2].replace(a,""),y=y.replace(/\\[0-9a-f]+/g,function(e){return String.fromCharCode(parseInt(e.substr(1),16))}),v&&y.length>0){if(!e.allow_script_urls&&("behavior"==v||/expression\s*\(|\/\*|\*\//.test(y)))continue;"font-weight"===v&&"700"===y?y="bold":("color"===v||"background-color"===v)&&(y=y.toLowerCase()),y=y.replace(r,n),y=y.replace(i,h),m[v]=b?p(y,!0):y}o.lastIndex=g.index+g[0].length}s("border","",!0),s("border","-width"),s("border","-color"),s("border","-style"),s("padding",""),s("margin",""),d("border","border-width","border-style","border-color"),"medium none"===m.border&&delete m.border,"none"===m["border-image"]&&delete m["border-image"]}return m},serialize:function(e,t){function n(t){var n,r,o,a;if(n=d[t])for(r=0,o=n.length;o>r;r++)t=n[r],a=e[t],a!==s&&a.length>0&&(i+=(i.length>0?" ":"")+t+": "+a+";")}function r(e,t){var n;return n=f["*"],n&&n[e]?!1:(n=f[t],n&&n[e]?!1:!0)}var i="",o,a;if(t&&d)n("*"),n(t);else for(o in e)a=e[o],a!==s&&a.length>0&&(!f||r(o,t))&&(i+=(i.length>0?" ":"")+o+": "+a+";");return i}}}}),r(h,[],function(){return function(e,t){function n(e,n,r,i){var o,a;if(e){if(!i&&e[n])return e[n];if(e!=t){if(o=e[r])return o;for(a=e.parentNode;a&&a!=t;a=a.parentNode)if(o=a[r])return o}}}var r=e;this.current=function(){return r},this.next=function(e){return r=n(r,"firstChild","nextSibling",e)},this.prev=function(e){return r=n(r,"lastChild","previousSibling",e)}}}),r(m,[d],function(e){function t(n){function r(){return M.createDocumentFragment()}function i(e,t){_(F,e,t)}function o(e,t){_(z,e,t)}function a(e){i(e.parentNode,j(e))}function s(e){i(e.parentNode,j(e)+1)}function l(e){o(e.parentNode,j(e))}function c(e){o(e.parentNode,j(e)+1)}function u(e){e?(H[U]=H[V],H[$]=H[W]):(H[V]=H[U],H[W]=H[$]),H.collapsed=F}function d(e){a(e),c(e)}function f(e){i(e,0),o(e,1===e.nodeType?e.childNodes.length:e.nodeValue.length)}function p(e,t){var n=H[V],r=H[W],i=H[U],o=H[$],a=t.startContainer,s=t.startOffset,l=t.endContainer,c=t.endOffset;return 0===e?w(n,r,a,s):1===e?w(i,o,a,s):2===e?w(i,o,l,c):3===e?w(n,r,l,c):void 0}function h(){E(I)}function m(){return E(P)}function g(){return E(O)}function v(e){var t=this[V],r=this[W],i,o;3!==t.nodeType&&4!==t.nodeType||!t.nodeValue?(t.childNodes.length>0&&(o=t.childNodes[r]),o?t.insertBefore(e,o):3==t.nodeType?n.insertAfter(e,t):t.appendChild(e)):r?r>=t.nodeValue.length?n.insertAfter(e,t):(i=t.splitText(r),t.parentNode.insertBefore(e,i)):t.parentNode.insertBefore(e,t)}function y(e){var t=H.extractContents();H.insertNode(e),e.appendChild(t),H.selectNode(e)}function b(){return q(new t(n),{startContainer:H[V],startOffset:H[W],endContainer:H[U],endOffset:H[$],collapsed:H.collapsed,commonAncestorContainer:H.commonAncestorContainer})}function C(e,t){var n;if(3==e.nodeType)return e;if(0>t)return e;for(n=e.firstChild;n&&t>0;)--t,n=n.nextSibling;return n?n:e}function x(){return H[V]==H[U]&&H[W]==H[$]}function w(e,t,r,i){var o,a,s,l,c,u;if(e==r)return t==i?0:i>t?-1:1;for(o=r;o&&o.parentNode!=e;)o=o.parentNode;if(o){for(a=0,s=e.firstChild;s!=o&&t>a;)a++,s=s.nextSibling;return a>=t?-1:1}for(o=e;o&&o.parentNode!=r;)o=o.parentNode;if(o){for(a=0,s=r.firstChild;s!=o&&i>a;)a++,s=s.nextSibling;return i>a?-1:1}for(l=n.findCommonAncestor(e,r),c=e;c&&c.parentNode!=l;)c=c.parentNode;for(c||(c=l),u=r;u&&u.parentNode!=l;)u=u.parentNode;if(u||(u=l),c==u)return 0;for(s=l.firstChild;s;){if(s==c)return-1;if(s==u)return 1;s=s.nextSibling}}function _(e,t,r){var i,o;for(e?(H[V]=t,H[W]=r):(H[U]=t,H[$]=r),i=H[U];i.parentNode;)i=i.parentNode;for(o=H[V];o.parentNode;)o=o.parentNode;o==i?w(H[V],H[W],H[U],H[$])>0&&H.collapse(e):H.collapse(e),H.collapsed=x(),H.commonAncestorContainer=n.findCommonAncestor(H[V],H[U])}function E(e){var t,n=0,r=0,i,o,a,s,l,c;if(H[V]==H[U])return N(e);for(t=H[U],i=t.parentNode;i;t=i,i=i.parentNode){if(i==H[V])return k(t,e);++n}for(t=H[V],i=t.parentNode;i;t=i,i=i.parentNode){if(i==H[U])return S(t,e);++r}for(o=r-n,a=H[V];o>0;)a=a.parentNode,o--;for(s=H[U];0>o;)s=s.parentNode,o++;for(l=a.parentNode,c=s.parentNode;l!=c;l=l.parentNode,c=c.parentNode)a=l,s=c;return T(a,s,e)}function N(e){var t,n,i,o,a,s,l,c,u;if(e!=I&&(t=r()),H[W]==H[$])return t;if(3==H[V].nodeType){if(n=H[V].nodeValue,i=n.substring(H[W],H[$]),e!=O&&(o=H[V],c=H[W],u=H[$]-H[W],0===c&&u>=o.nodeValue.length-1?o.parentNode.removeChild(o):o.deleteData(c,u),H.collapse(F)),e==I)return;return i.length>0&&t.appendChild(M.createTextNode(i)),t}for(o=C(H[V],H[W]),a=H[$]-H[W];o&&a>0;)s=o.nextSibling,l=D(o,e),t&&t.appendChild(l),--a,o=s;return e!=O&&H.collapse(F),t}function k(e,t){var n,i,o,a,s,l;if(t!=I&&(n=r()),i=R(e,t),n&&n.appendChild(i),o=j(e),a=o-H[W],0>=a)return t!=O&&(H.setEndBefore(e),H.collapse(z)),n;for(i=e.previousSibling;a>0;)s=i.previousSibling,l=D(i,t),n&&n.insertBefore(l,n.firstChild),--a,i=s;return t!=O&&(H.setEndBefore(e),H.collapse(z)),n}function S(e,t){var n,i,o,a,s,l;for(t!=I&&(n=r()),o=A(e,t),n&&n.appendChild(o),i=j(e),++i,a=H[$]-i,o=e.nextSibling;o&&a>0;)s=o.nextSibling,l=D(o,t),n&&n.appendChild(l),--a,o=s;return t!=O&&(H.setStartAfter(e),H.collapse(F)),n}function T(e,t,n){var i,o,a,s,l,c,u;for(n!=I&&(o=r()),i=A(e,n),o&&o.appendChild(i),a=j(e),s=j(t),++a,l=s-a,c=e.nextSibling;l>0;)u=c.nextSibling,i=D(c,n),o&&o.appendChild(i),c=u,--l;return i=R(t,n),o&&o.appendChild(i),n!=O&&(H.setStartAfter(e),H.collapse(F)),o}function R(e,t){var n=C(H[U],H[$]-1),r,i,o,a,s,l=n!=H[U];if(n==e)return B(n,l,z,t);for(r=n.parentNode,i=B(r,z,z,t);r;){for(;n;)o=n.previousSibling,a=B(n,l,z,t),t!=I&&i.insertBefore(a,i.firstChild),l=F,n=o;if(r==e)return i;n=r.previousSibling,r=r.parentNode,s=B(r,z,z,t),t!=I&&s.appendChild(i),i=s}}function A(e,t){var n=C(H[V],H[W]),r=n!=H[V],i,o,a,s,l;if(n==e)return B(n,r,F,t);for(i=n.parentNode,o=B(i,z,F,t);i;){for(;n;)a=n.nextSibling,s=B(n,r,F,t),t!=I&&o.appendChild(s),r=F,n=a;if(i==e)return o;n=i.nextSibling,i=i.parentNode,l=B(i,z,F,t),t!=I&&l.appendChild(o),o=l}}function B(e,t,r,i){var o,a,s,l,c;if(t)return D(e,i);if(3==e.nodeType){if(o=e.nodeValue,r?(l=H[W],a=o.substring(l),s=o.substring(0,l)):(l=H[$],a=o.substring(0,l),s=o.substring(l)),i!=O&&(e.nodeValue=s),i==I)return;return c=n.clone(e,z),c.nodeValue=a,c}if(i!=I)return n.clone(e,z)}function D(e,t){return t!=I?t==O?n.clone(e,F):e:void e.parentNode.removeChild(e)}function L(){return n.create("body",null,g()).outerText}var H=this,M=n.doc,P=0,O=1,I=2,F=!0,z=!1,W="startOffset",V="startContainer",U="endContainer",$="endOffset",q=e.extend,j=n.nodeIndex;return q(H,{startContainer:M,startOffset:0,endContainer:M,endOffset:0,collapsed:F,commonAncestorContainer:M,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:i,setEnd:o,setStartBefore:a,setStartAfter:s,setEndBefore:l,setEndAfter:c,collapse:u,selectNode:d,selectNodeContents:f,compareBoundaryPoints:p,deleteContents:h,extractContents:m,cloneContents:g,insertNode:v,surroundContents:y,cloneRange:b,toStringIE:L}),H}return t.prototype.toString=function(){return this.toStringIE()},t}),r(g,[d],function(e){function t(e){var t;return t=document.createElement("div"),t.innerHTML=e,t.textContent||t.innerText||e}function n(e,t){var n,r,i,a={};if(e){for(e=e.split(","),t=t||10,n=0;n\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,l=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,c=/[<>&\"\']/g,u=/&(#x|#)?([\w]+);/g,d={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"};o={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},a={"<":"<",">":">","&":"&",""":'"',"'":"'"},i=n("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32);var f={encodeRaw:function(e,t){return e.replace(t?s:l,function(e){return o[e]||e})},encodeAllRaw:function(e){return(""+e).replace(c,function(e){return o[e]||e})},encodeNumeric:function(e,t){return e.replace(t?s:l,function(e){return e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":o[e]||"&#"+e.charCodeAt(0)+";"})},encodeNamed:function(e,t,n){return n=n||i,e.replace(t?s:l,function(e){return o[e]||n[e]||e})},getEncodeFunc:function(e,t){function a(e,n){return e.replace(n?s:l,function(e){return o[e]||t[e]||"&#"+e.charCodeAt(0)+";"||e})}function c(e,n){return f.encodeNamed(e,n,t)}return t=n(t)||i,e=r(e.replace(/\+/g,",")),e.named&&e.numeric?a:e.named?t?c:f.encodeNamed:e.numeric?f.encodeNumeric:f.encodeRaw},decode:function(e){return e.replace(u,function(e,n,r){return n?(r=parseInt(r,2===n.length?16:10),r>65535?(r-=65536,String.fromCharCode(55296+(r>>10),56320+(1023&r))):d[r]||String.fromCharCode(r)):a[e]||i[e]||t(e)})}};return f}),r(v,[d],function(e){return function(t,n){function r(e){t.getElementsByTagName("head")[0].appendChild(e)}function i(n,i,l){function c(){for(var e=y.passed,t=e.length;t--;)e[t]();y.status=2,y.passed=[],y.failed=[]}function u(){for(var e=y.failed,t=e.length;t--;)e[t]();y.status=3,y.passed=[],y.failed=[]}function d(){var e=navigator.userAgent.match(/WebKit\/(\d*)/);return!!(e&&e[1]<536)}function f(e,t){e()||((new Date).getTime()-v0)return g=t.createElement("style"),g.textContent='@import "'+n+'"',h(),void r(g);p()}r(m),m.href=n}}var o=0,a={},s;n=n||{},s=n.maxLoadTime||5e3,this.load=i}}),r(y,[c,f,p,l,h,m,g,u,d,v],function(e,n,r,i,o,a,s,l,c,u){function d(e,t){var n={},r=t.keep_values,i;return i={set:function(n,r,i){t.url_converter&&(r=t.url_converter.call(t.url_converter_scope||e,r,i,n[0])),n.attr("data-mce-"+i,r).attr(i,r)},get:function(e,t){return e.attr("data-mce-"+t)||e.attr(t)}},n={style:{set:function(e,t){return null!==t&&"object"==typeof t?void e.css(t):(r&&e.attr("data-mce-style",t),void e.attr("style",t))},get:function(t){var n=t.attr("data-mce-style")||t.attr("style");return n=e.serializeStyle(e.parseStyle(n),t[0].nodeName)}}},r&&(n.href=n.src=i),n}function f(e,t){var o=this,a;o.doc=e,o.win=window,o.files={},o.counter=0,o.stdMode=!v||e.documentMode>=8,o.boxModel=!v||"CSS1Compat"==e.compatMode||o.stdMode,o.styleSheetLoader=new u(e),o.boundEvents=[],o.settings=t=t||{},o.schema=t.schema,o.styles=new r({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema),o.fixDoc(e),o.events=t.ownEvents?new i(t.proxy):i.Event,o.attrHooks=d(o,t),a=t.schema?t.schema.getBlockElements():{},o.$=n.overrideDefaults(function(){return{context:e,element:o.getRoot()}}),o.isBlock=function(e){if(!e)return!1;var t=e.nodeType;return t?!(1!==t||!a[e.nodeName]):!!a[e]}}var p=c.each,h=c.is,m=c.grep,g=c.trim,v=l.ie,y=/^([a-z0-9],?)+$/i,b=/^[ \t\r\n]*$/;return f.prototype={$$:function(e){return"string"==typeof e&&(e=this.get(e)),this.$(e)},root:null,fixDoc:function(e){var t=this.settings,n;if(v&&t.schema){"abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video".replace(/\w+/g,function(t){e.createElement(t)});for(n in t.schema.getCustomElements())e.createElement(n)}},clone:function(e,t){var n=this,r,i;return!v||1!==e.nodeType||t?e.cloneNode(t):(i=n.doc,t?r.firstChild:(r=i.createElement(e.nodeName),p(n.getAttribs(e),function(t){n.setAttrib(r,t.nodeName,n.getAttrib(e,t.nodeName))}),r))},getRoot:function(){var e=this;return e.settings.root_element||e.doc.body},getViewPort:function(e){var t,n;return e=e?e:this.win,t=e.document,n=this.boxModel?t.documentElement:t.body,{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop,w:e.innerWidth||n.clientWidth,h:e.innerHeight||n.clientHeight}},getRect:function(e){var t=this,n,r;return e=t.get(e),n=t.getPos(e),r=t.getSize(e),{x:n.x,y:n.y,w:r.w,h:r.h}},getSize:function(e){var t=this,n,r;return e=t.get(e),n=t.getStyle(e,"width"),r=t.getStyle(e,"height"),-1===n.indexOf("px")&&(n=0),-1===r.indexOf("px")&&(r=0),{w:parseInt(n,10)||e.offsetWidth||e.clientWidth,h:parseInt(r,10)||e.offsetHeight||e.clientHeight}},getParent:function(e,t,n){return this.getParents(e,t,n,!1)},getParents:function(e,n,r,i){var o=this,a,s=[];for(e=o.get(e),i=i===t,r=r||("BODY"!=o.getRoot().nodeName?o.getRoot().parentNode:null),h(n,"string")&&(a=n,n="*"===n?function(e){return 1==e.nodeType}:function(e){return o.is(e,a)});e&&e!=r&&e.nodeType&&9!==e.nodeType;){if(!n||n(e)){if(!i)return e;s.push(e)}e=e.parentNode}return i?s:null},get:function(e){var t;return e&&this.doc&&"string"==typeof e&&(t=e,e=this.doc.getElementById(e),e&&e.id!==t)?this.doc.getElementsByName(t)[1]:e},getNext:function(e,t){return this._findSib(e,t,"nextSibling")},getPrev:function(e,t){return this._findSib(e,t,"previousSibling")},select:function(t,n){var r=this;return e(t,r.get(n)||r.settings.root_element||r.doc,[])},is:function(n,r){var i;if(n.length===t){if("*"===r)return 1==n.nodeType;if(y.test(r)){for(r=r.toLowerCase().split(/,/),n=n.nodeName.toLowerCase(),i=r.length-1;i>=0;i--)if(r[i]==n)return!0;return!1}}if(n.nodeType&&1!=n.nodeType)return!1;var o=n.nodeType?[n]:n;return e(r,o[0].ownerDocument||o[0],null,o).length>0},add:function(e,t,n,r,i){var o=this;return this.run(e,function(e){var a;return a=h(t,"string")?o.doc.createElement(t):t,o.setAttribs(a,n),r&&(r.nodeType?a.appendChild(r):o.setHTML(a,r)),i?a:e.appendChild(a)})},create:function(e,t,n){return this.add(this.doc.createElement(e),e,t,n,1)},createHTML:function(e,t,n){var r="",i;r+="<"+e;for(i in t)t.hasOwnProperty(i)&&null!==t[i]&&"undefined"!=typeof t[i]&&(r+=" "+i+'="'+this.encode(t[i])+'"');return"undefined"!=typeof n?r+">"+n+"":r+" />"},createFragment:function(e){var t,n,r=this.doc,i;for(i=r.createElement("div"),t=r.createDocumentFragment(),e&&(i.innerHTML=e);n=i.firstChild;)t.appendChild(n);return t},remove:function(e,t){return e=this.$$(e),t?e.each(function(){for(var e;e=this.firstChild;)3==e.nodeType&&0===e.data.length?this.removeChild(e):this.parentNode.insertBefore(e,this)}).remove():e.remove(),e.length>1?e.toArray():e[0]},setStyle:function(e,t,n){e=this.$$(e).css(t,n),this.settings.update_styles&&e.attr("data-mce-style",null)},getStyle:function(e,n,r){return e=this.$$(e),r?e.css(n):(n=n.replace(/-(\D)/g,function(e,t){return t.toUpperCase()}),"float"==n&&(n=v?"styleFloat":"cssFloat"),e[0]&&e[0].style?e[0].style[n]:t)},setStyles:function(e,t){e=this.$$(e).css(t),this.settings.update_styles&&e.attr("data-mce-style",null)},removeAllAttribs:function(e){return this.run(e,function(e){var t,n=e.attributes;for(t=n.length-1;t>=0;t--)e.removeAttributeNode(n.item(t))})},setAttrib:function(e,t,n){var r=this,i,o,a=r.settings;""===n&&(n=null),e=r.$$(e),i=e.attr(t),e.length&&(o=r.attrHooks[t],o&&o.set?o.set(e,n,t):e.attr(t,n),i!=n&&a.onSetAttrib&&a.onSetAttrib({attrElm:e,attrName:t,attrValue:n}))},setAttribs:function(e,t){var n=this;n.$$(e).each(function(e,r){p(t,function(e,t){n.setAttrib(r,t,e)})})},getAttrib:function(e,t,n){var r=this,i,o;return e=r.$$(e),e.length&&(i=r.attrHooks[t],o=i&&i.get?i.get(e,t):e.attr(t)),"undefined"==typeof o&&(o=n||""),o},getPos:function(e,t){var r=this,i=0,o=0,a,s=r.doc,l=s.body,c;if(e=r.get(e),t=t||l,e){if(t===l&&e.getBoundingClientRect&&"static"===n(l).css("position"))return c=e.getBoundingClientRect(),t=r.boxModel?s.documentElement:l,i=c.left+(s.documentElement.scrollLeft||l.scrollLeft)-t.clientLeft,o=c.top+(s.documentElement.scrollTop||l.scrollTop)-t.clientTop,{x:i,y:o};for(a=e;a&&a!=t&&a.nodeType;)i+=a.offsetLeft||0,o+=a.offsetTop||0,a=a.offsetParent;for(a=e.parentNode;a&&a!=t&&a.nodeType;)i-=a.scrollLeft||0,o-=a.scrollTop||0,a=a.parentNode}return{x:i,y:o}},parseStyle:function(e){return this.styles.parse(e)},serializeStyle:function(e,t){return this.styles.serialize(e,t)},addStyle:function(e){var t=this,n=t.doc,r,i;if(t!==f.DOM&&n===document){var o=f.DOM.addedStyles;if(o=o||[],o[e])return;o[e]=!0,f.DOM.addedStyles=o}i=n.getElementById("mceDefaultStyles"),i||(i=n.createElement("style"),i.id="mceDefaultStyles",i.type="text/css",r=n.getElementsByTagName("head")[0],r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i)),i.styleSheet?i.styleSheet.cssText+=e:i.appendChild(n.createTextNode(e))},loadCSS:function(e){var t=this,n=t.doc,r;return t!==f.DOM&&n===document?void f.DOM.loadCSS(e):(e||(e=""),r=n.getElementsByTagName("head")[0],void p(e.split(","),function(e){var i;e=c._addCacheSuffix(e),t.files[e]||(t.files[e]=!0,i=t.create("link",{rel:"stylesheet",href:e}),v&&n.documentMode&&n.recalc&&(i.onload=function(){n.recalc&&n.recalc(),i.onload=null}),r.appendChild(i))}))},addClass:function(e,t){this.$$(e).addClass(t)},removeClass:function(e,t){this.toggleClass(e,t,!1)},hasClass:function(e,t){return this.$$(e).hasClass(t)},toggleClass:function(e,t,r){this.$$(e).toggleClass(t,r).each(function(){""===this.className&&n(this).attr("class",null)})},show:function(e){this.$$(e).show()},hide:function(e){this.$$(e).hide()},isHidden:function(e){return"none"==this.$$(e).css("display")},uniqueId:function(e){return(e?e:"mce_")+this.counter++},setHTML:function(e,t){e=this.$$(e),v?e.each(function(e,r){if(r.canHaveHTML!==!1){for(;r.firstChild;)r.removeChild(r.firstChild);try{r.innerHTML="
          "+t,r.removeChild(r.firstChild)}catch(i){n("
          ").html("
          "+t).contents().slice(1).appendTo(r)}return t}}):e.html(t)},getOuterHTML:function(e){return e=this.get(e),1==e.nodeType?e.outerHTML:n("
          ").append(n(e).clone()).html()},setOuterHTML:function(e,t){var r=this;r.$$(e).each(function(){try{this.outerHTML=t}catch(e){r.remove(n(this).html(t),!0)}})},decode:s.decode,encode:s.encodeAllRaw,insertAfter:function(e,t){return t=this.get(t),this.run(e,function(e){var n,r;return n=t.parentNode,r=t.nextSibling,r?n.insertBefore(e,r):n.appendChild(e),e})},replace:function(e,t,n){var r=this;return r.run(t,function(t){return h(t,"array")&&(e=e.cloneNode(!0)),n&&p(m(t.childNodes),function(t){e.appendChild(t)}),t.parentNode.replaceChild(e,t)})},rename:function(e,t){var n=this,r;return e.nodeName!=t.toUpperCase()&&(r=n.create(t),p(n.getAttribs(e),function(t){n.setAttrib(r,t.nodeName,n.getAttrib(e,t.nodeName))}),n.replace(r,e,1)),r||e},findCommonAncestor:function(e,t){for(var n=e,r;n;){for(r=t;r&&n!=r;)r=r.parentNode;if(n==r)break;n=n.parentNode}return!n&&e.ownerDocument?e.ownerDocument.documentElement:n},toHex:function(e){return this.styles.toHex(c.trim(e))},run:function(e,t,n){var r=this,i;return"string"==typeof e&&(e=r.get(e)),e?(n=n||this,e.nodeType||!e.length&&0!==e.length?t.call(n,e):(i=[],p(e,function(e,o){e&&("string"==typeof e&&(e=r.get(e)),i.push(t.call(n,e,o)))}),i)):!1},getAttribs:function(e){var t;if(e=this.get(e),!e)return[];if(v){if(t=[],"OBJECT"==e.nodeName)return e.attributes;"OPTION"===e.nodeName&&this.getAttrib(e,"selected")&&t.push({specified:1,nodeName:"selected"});var n=/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi;return e.cloneNode(!1).outerHTML.replace(n,"").replace(/[\w:\-]+/gi,function(e){t.push({specified:1,nodeName:e})}),t}return e.attributes},isEmpty:function(e,t){var n=this,r,i,a,s,l,c=0;if(e=e.firstChild){s=new o(e,e.parentNode),t=t||(n.schema?n.schema.getNonEmptyElements():null);do{if(a=e.nodeType,1===a){if(e.getAttribute("data-mce-bogus"))continue;if(l=e.nodeName.toLowerCase(),t&&t[l]){if("br"===l){c++;continue}return!1}for(i=n.getAttribs(e),r=i.length;r--;)if(l=i[r].nodeName,"name"===l||"data-mce-bookmark"===l)return!1}if(8==a)return!1;if(3===a&&!b.test(e.nodeValue))return!1}while(e=s.next())}return 1>=c},createRng:function(){var e=this.doc;return e.createRange?e.createRange():new a(this)},nodeIndex:function(e,t){var n=0,r,i;if(e)for(r=e.nodeType,e=e.previousSibling;e;e=e.previousSibling)i=e.nodeType,(!t||3!=i||i!=r&&e.nodeValue.length)&&(n++,r=i);return n},split:function(e,t,n){function r(e){function t(e){var t=e.previousSibling&&"SPAN"==e.previousSibling.nodeName,n=e.nextSibling&&"SPAN"==e.nextSibling.nodeName;return t&&n}var n,o=e.childNodes,a=e.nodeType;if(1!=a||"bookmark"!=e.getAttribute("data-mce-type")){for(n=o.length-1;n>=0;n--)r(o[n]);if(9!=a){if(3==a&&e.nodeValue.length>0){var s=g(e.nodeValue).length;if(!i.isBlock(e.parentNode)||s>0||0===s&&t(e))return +}else if(1==a&&(o=e.childNodes,1==o.length&&o[0]&&1==o[0].nodeType&&"bookmark"==o[0].getAttribute("data-mce-type")&&e.parentNode.insertBefore(o[0],e),o.length||/^(br|hr|input|img)$/i.test(e.nodeName)))return;i.remove(e)}return e}}var i=this,o=i.createRng(),a,s,l;return e&&t?(o.setStart(e.parentNode,i.nodeIndex(e)),o.setEnd(t.parentNode,i.nodeIndex(t)),a=o.extractContents(),o=i.createRng(),o.setStart(t.parentNode,i.nodeIndex(t)+1),o.setEnd(e.parentNode,i.nodeIndex(e)+1),s=o.extractContents(),l=e.parentNode,l.insertBefore(r(a),e),n?l.replaceChild(n,t):l.insertBefore(t,e),l.insertBefore(r(s),e),i.remove(e),n||t):void 0},bind:function(e,t,n,r){var i=this;if(c.isArray(e)){for(var o=e.length;o--;)e[o]=i.bind(e[o],t,n,r);return e}return!i.settings.collect||e!==i.doc&&e!==i.win||i.boundEvents.push([e,t,n,r]),i.events.bind(e,t,n,r||i)},unbind:function(e,t,n){var r=this,i;if(c.isArray(e)){for(i=e.length;i--;)e[i]=r.unbind(e[i],t,n);return e}if(r.boundEvents&&(e===r.doc||e===r.win))for(i=r.boundEvents.length;i--;){var o=r.boundEvents[i];e!=o[0]||t&&t!=o[1]||n&&n!=o[2]||this.events.unbind(o[0],o[1],o[2])}return this.events.unbind(e,t,n)},fire:function(e,t,n){return this.events.fire(e,t,n)},getContentEditable:function(e){var t;return e&&1==e.nodeType?(t=e.getAttribute("data-mce-contenteditable"),t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null):null},getContentEditableParent:function(e){for(var t=this.getRoot(),n=null;e&&e!==t&&(n=this.getContentEditable(e),null===n);e=e.parentNode);return n},destroy:function(){var t=this;if(t.boundEvents){for(var n=t.boundEvents.length;n--;){var r=t.boundEvents[n];this.events.unbind(r[0],r[1],r[2])}t.boundEvents=null}e.setDocument&&e.setDocument(),t.win=t.doc=t.root=t.events=t.frag=null},isChildOf:function(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1},dumpRng:function(e){return"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},_findSib:function(e,t,n){var r=this,i=t;if(e)for("string"==typeof i&&(i=function(e){return r.is(e,t)}),e=e[n];e;e=e[n])if(i(e))return e;return null}},f.DOM=new f(document),f}),r(b,[y,d],function(e,t){function n(){function e(e,n){function i(){a.remove(l),s&&(s.onreadystatechange=s.onload=s=null),n()}function o(){"undefined"!=typeof console&&console.log&&console.log("Failed to load: "+e)}var a=r,s,l;l=a.uniqueId(),s=document.createElement("script"),s.id=l,s.type="text/javascript",s.src=t._addCacheSuffix(e),"onreadystatechange"in s?s.onreadystatechange=function(){/loaded|complete/.test(s.readyState)&&i()}:s.onload=i,s.onerror=o,(document.getElementsByTagName("head")[0]||document.body).appendChild(s)}var n=0,a=1,s=2,l={},c=[],u={},d=[],f=0,p;this.isDone=function(e){return l[e]==s},this.markDone=function(e){l[e]=s},this.add=this.load=function(e,t,r){var i=l[e];i==p&&(c.push(e),l[e]=n),t&&(u[e]||(u[e]=[]),u[e].push({func:t,scope:r||this}))},this.loadQueue=function(e,t){this.loadScripts(c,e,t)},this.loadScripts=function(t,n,r){function c(e){i(u[e],function(e){e.func.call(e.scope)}),u[e]=p}var h;d.push({func:n,scope:r||this}),(h=function(){var n=o(t);t.length=0,i(n,function(t){return l[t]==s?void c(t):void(l[t]!=a&&(l[t]=a,f++,e(t,function(){l[t]=s,f--,c(t),h()})))}),f||(i(d,function(e){e.func.call(e.scope)}),d.length=0)})()}}var r=e.DOM,i=t.each,o=t.grep;return n.ScriptLoader=new n,n}),r(C,[b,d],function(e,n){function r(){var e=this;e.items=[],e.urls={},e.lookup={}}var i=n.each;return r.prototype={get:function(e){return this.lookup[e]?this.lookup[e].instance:t},dependencies:function(e){var t;return this.lookup[e]&&(t=this.lookup[e].dependencies),t||[]},requireLangPack:function(t,n){var i=r.language;if(i&&r.languageLoad!==!1){if(n)if(n=","+n+",",-1!=n.indexOf(","+i.substr(0,2)+","))i=i.substr(0,2);else if(-1==n.indexOf(","+i+","))return;e.ScriptLoader.add(this.urls[t]+"/langs/"+i+".js")}},add:function(e,t,n){return this.items.push(t),this.lookup[e]={instance:t,dependencies:n},t},createUrl:function(e,t){return"object"==typeof t?t:{prefix:e.prefix,resource:t,suffix:e.suffix}},addComponents:function(t,n){var r=this.urls[t];i(n,function(t){e.ScriptLoader.add(r+"/"+t)})},load:function(n,o,a,s){function l(){var r=c.dependencies(n);i(r,function(e){var n=c.createUrl(o,e);c.load(n.resource,n,t,t)}),a&&a.call(s?s:e)}var c=this,u=o;c.urls[n]||("object"==typeof o&&(u=o.prefix+o.resource+o.suffix),0!==u.indexOf("/")&&-1==u.indexOf("://")&&(u=r.baseURL+"/"+u),c.urls[n]=u.substring(0,u.lastIndexOf("/")),c.lookup[n]?l():e.ScriptLoader.add(u,l,s))}},r.PluginManager=new r,r.ThemeManager=new r,r}),r(x,[d,h],function(e,t){function n(e,t){var n=e.childNodes;return t--,t>n.length-1?t=n.length-1:0>t&&(t=0),n[t]||e}function r(e){this.walk=function(t,r){function o(e){var t;return t=e[0],3===t.nodeType&&t===c&&u>=t.nodeValue.length&&e.splice(0,1),t=e[e.length-1],0===f&&e.length>0&&t===d&&3===t.nodeType&&e.splice(e.length-1,1),e}function a(e,t,n){for(var r=[];e&&e!=n;e=e[t])r.push(e);return r}function s(e,t){do{if(e.parentNode==t)return e;e=e.parentNode}while(e)}function l(e,t,n){var i=n?"nextSibling":"previousSibling";for(g=e,v=g.parentNode;g&&g!=t;g=v)v=g.parentNode,y=a(g==e?g:g[i],i),y.length&&(n||y.reverse(),r(o(y)))}var c=t.startContainer,u=t.startOffset,d=t.endContainer,f=t.endOffset,p,h,m,g,v,y,b;if(b=e.select("td.mce-item-selected,th.mce-item-selected"),b.length>0)return void i(b,function(e){r([e])});if(1==c.nodeType&&c.hasChildNodes()&&(c=c.childNodes[u]),1==d.nodeType&&d.hasChildNodes()&&(d=n(d,f)),c==d)return r(o([c]));for(p=e.findCommonAncestor(c,d),g=c;g;g=g.parentNode){if(g===d)return l(c,p,!0);if(g===p)break}for(g=d;g;g=g.parentNode){if(g===c)return l(d,p);if(g===p)break}h=s(c,p)||c,m=s(d,p)||d,l(c,h,!0),y=a(h==c?h:h.nextSibling,"nextSibling",m==d?m.nextSibling:m),y.length&&r(o(y)),l(d,m)},this.split=function(e){function t(e,t){return e.splitText(t)}var n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset;return n==i&&3==n.nodeType?r>0&&rr?(o-=r,n=i=t(i,o).previousSibling,o=i.nodeValue.length,r=0):o=0):(3==n.nodeType&&r>0&&r0&&o0)return c=p,u=n?p.nodeValue.length:0,void(i=!0);if(e.isBlock(p)||h[p.nodeName.toLowerCase()])return;s=p}o&&s&&(c=s,i=!0,u=0)}var c,u,d,f=e.getRoot(),p,h,m,g;if(c=n[(r?"start":"end")+"Container"],u=n[(r?"start":"end")+"Offset"],g=1==c.nodeType&&u===c.childNodes.length,h=e.schema.getNonEmptyElements(),m=r,1==c.nodeType&&u>c.childNodes.length-1&&(m=!1),9===c.nodeType&&(c=e.getRoot(),u=0),c===f){if(m&&(p=c.childNodes[u>0?u-1:0],p&&(h[p.nodeName]||"TABLE"==p.nodeName)))return;if(c.hasChildNodes()&&(u=Math.min(!m&&u>0?u-1:u,c.childNodes.length-1),c=c.childNodes[u],u=0,c.hasChildNodes()&&!/TABLE/.test(c.nodeName))){p=c,d=new t(c,f);do{if(3===p.nodeType&&p.nodeValue.length>0){u=m?0:p.nodeValue.length,c=p,i=!0;break}if(h[p.nodeName.toLowerCase()]){u=e.nodeIndex(p),c=p.parentNode,"IMG"!=p.nodeName||m||u++,i=!0;break}}while(p=m?d.next():d.prev())}}o&&(3===c.nodeType&&0===u&&l(!0),1===c.nodeType&&(p=c.childNodes[u],p||(p=c.childNodes[u-1]),!p||"BR"!==p.nodeName||s(p,"A")||a(p)||a(p,!0)||l(!0,p))),m&&!o&&3===c.nodeType&&u===c.nodeValue.length&&l(!1),i&&n["set"+(r?"Start":"End")](c,u)}var i,o;return o=n.collapsed,r(!0),o||r(),i&&o&&n.collapse(!0),i}}var i=e.each;return r.compareRanges=function(e,t){if(e&&t){if(!e.item&&!e.duplicate)return e.startContainer==t.startContainer&&e.startOffset==t.startOffset;if(e.item&&t.item&&e.item(0)===t.item(0))return!0;if(e.isEqual&&t.isEqual&&t.isEqual(e))return!0}return!1},r}),r(w,[x],function(e){return function(t){function n(e){var n,r;if(r=t.$(e).parentsUntil(t.getBody()).add(e),r.length===i.length){for(n=r.length;n>=0&&r[n]===i[n];n--);if(-1===n)return i=r,!0}return i=r,!1}var r,i=[];"onselectionchange"in t.getDoc()||t.on("NodeChange Click MouseUp KeyUp Focus",function(n){var i,o;i=t.selection.getRng(),o={startContainer:i.startContainer,startOffset:i.startOffset,endContainer:i.endContainer,endOffset:i.endOffset},"nodechange"!=n.type&&e.compareRanges(o,r)||t.fire("SelectionChange"),r=o}),t.on("contextmenu",function(){t.fire("SelectionChange")}),t.on("SelectionChange",function(){var e=t.selection.getStart(!0);t.selection.isCollapsed()||n(e)||!t.dom.isChildOf(e,t.getBody())||t.nodeChanged({selectionChange:!0})}),t.on("MouseUp",function(e){e.isDefaultPrevented()||setTimeout(function(){t.nodeChanged()},0)}),this.nodeChanged=function(e){var n=t.selection,r,i,o;t.initialized&&n&&!t.settings.disable_nodechange&&!t.settings.readonly&&(o=t.getBody(),r=n.getStart()||o,r=r.ownerDocument!=t.getDoc()?t.getBody():r,"IMG"==r.nodeName&&n.isCollapsed()&&(r=r.parentNode),i=[],t.dom.getParent(r,function(e){return e===o?!0:void i.push(e)}),e=e||{},e.element=r,e.parents=i,t.fire("NodeChange",e))}}}),r(_,[],function(){function e(e,t,n){var r,i,o=n?"lastChild":"firstChild",a=n?"prev":"next";if(e[o])return e[o];if(e!==t){if(r=e[a])return r;for(i=e.parent;i&&i!==t;i=i.parent)if(r=i[a])return r}}function t(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}var n=/^[ \t\r\n]*$/,r={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11};return t.prototype={replace:function(e){var t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t},attr:function(e,t){var n=this,r,i,o;if("string"!=typeof e){for(i in e)n.attr(i,e[i]);return n}if(r=n.attributes){if(t!==o){if(null===t){if(e in r.map)for(delete r.map[e],i=r.length;i--;)if(r[i].name===e)return r=r.splice(i,1),n;return n}if(e in r.map){for(i=r.length;i--;)if(r[i].name===e){r[i].value=t;break}}else r.push({name:e,value:t});return r.map[e]=t,n}return r.map[e]}},clone:function(){var e=this,n=new t(e.name,e.type),r,i,o,a,s;if(o=e.attributes){for(s=[],s.map={},r=0,i=o.length;i>r;r++)a=o[r],"id"!==a.name&&(s[s.length]={name:a.name,value:a.value},s.map[a.name]=a.value);n.attributes=s}return n.value=e.value,n.shortEnded=e.shortEnded,n},wrap:function(e){var t=this;return t.parent.insert(e,t),e.append(t),t},unwrap:function(){var e=this,t,n;for(t=e.firstChild;t;)n=t.next,e.insert(t,e,!0),t=n;e.remove()},remove:function(){var e=this,t=e.parent,n=e.next,r=e.prev;return t&&(t.firstChild===e?(t.firstChild=n,n&&(n.prev=null)):r.next=n,t.lastChild===e?(t.lastChild=r,r&&(r.next=null)):n.prev=r,e.parent=e.next=e.prev=null),e},append:function(e){var t=this,n;return e.parent&&e.remove(),n=t.lastChild,n?(n.next=e,e.prev=n,t.lastChild=e):t.lastChild=t.firstChild=e,e.parent=t,e},insert:function(e,t,n){var r;return e.parent&&e.remove(),r=t.parent||this,n?(t===r.firstChild?r.firstChild=e:t.prev.next=e,e.prev=t.prev,e.next=t,t.prev=e):(t===r.lastChild?r.lastChild=e:t.next.prev=e,e.next=t.next,e.prev=t,t.next=e),e.parent=r,e},getAll:function(t){var n=this,r,i=[];for(r=n.firstChild;r;r=e(r,n))r.name===t&&i.push(r);return i},empty:function(){var t=this,n,r,i;if(t.firstChild){for(n=[],i=t.firstChild;i;i=e(i,t))n.push(i);for(r=n.length;r--;)i=n[r],i.parent=i.firstChild=i.lastChild=i.next=i.prev=null}return t.firstChild=t.lastChild=null,t},isEmpty:function(t){var r=this,i=r.firstChild,o,a;if(i)do{if(1===i.type){if(i.attributes.map["data-mce-bogus"])continue;if(t[i.name])return!1;for(o=i.attributes.length;o--;)if(a=i.attributes[o].name,"name"===a||0===a.indexOf("data-mce-bookmark"))return!1}if(8===i.type)return!1;if(3===i.type&&!n.test(i.value))return!1}while(i=e(i,r));return!0},walk:function(t){return e(this,null,t)}},t.create=function(e,n){var i,o;if(i=new t(e,r[e]||1),n)for(o in n)i.attr(o,n[o]);return i},t}),r(E,[d],function(e){function t(e,t){return e?e.split(t||" "):[]}function n(e){function n(e,n,r){function i(e,t){var n={},r,i;for(r=0,i=e.length;i>r;r++)n[e[r]]=t||{};return n}var s,c,u,d=arguments;for(r=r||[],n=n||"","string"==typeof r&&(r=t(r)),c=3;co;o++)i.attributes[n[o]]={},i.attributesOrder.push(n[o])}var a={},l,c,u,d,f,p;return i[e]?i[e]:(l=t("id accesskey class dir lang style tabindex title"),c=t("address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul"),u=t("a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment"),"html4"!=e&&(l.push.apply(l,t("contenteditable contextmenu draggable dropzone hidden spellcheck translate")),c.push.apply(c,t("article aside details dialog figure header footer hgroup section nav")),u.push.apply(u,t("audio canvas command datalist mark meter output progress time wbr video ruby bdi keygen"))),"html5-strict"!=e&&(l.push("xml:lang"),p=t("acronym applet basefont big font strike tt"),u.push.apply(u,p),s(p,function(e){n(e,"",u)}),f=t("center dir isindex noframes"),c.push.apply(c,f),d=[].concat(c,u),s(f,function(e){n(e,"",d)})),d=d||[].concat(c,u),n("html","manifest","head body"),n("head","","base command link meta noscript script style title"),n("title hr noscript br"),n("base","href target"),n("link","href rel media hreflang type sizes hreflang"),n("meta","name http-equiv content charset"),n("style","media type scoped"),n("script","src async defer type charset"),n("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",d),n("address dt dd div caption","",d),n("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",u),n("blockquote","cite",d),n("ol","reversed start type","li"),n("ul","","li"),n("li","value",d),n("dl","","dt dd"),n("a","href target rel media hreflang type",u),n("q","cite",u),n("ins del","cite datetime",d),n("img","src srcset alt usemap ismap width height"),n("iframe","src name width height",d),n("embed","src type width height"),n("object","data type typemustmatch name usemap form width height",d,"param"),n("param","name value"),n("map","name",d,"area"),n("area","alt coords shape href target rel media hreflang type"),n("table","border","caption colgroup thead tfoot tbody tr"+("html4"==e?" col":"")),n("colgroup","span","col"),n("col","span"),n("tbody thead tfoot","","tr"),n("tr","","td th"),n("td","colspan rowspan headers",d),n("th","colspan rowspan headers scope abbr",d),n("form","accept-charset action autocomplete enctype method name novalidate target",d),n("fieldset","disabled form name",d,"legend"),n("label","form for",u),n("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),n("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"==e?d:u),n("select","disabled form multiple name required size","option optgroup"),n("optgroup","disabled label","option"),n("option","disabled label selected value"),n("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),n("menu","type label",d,"li"),n("noscript","",d),"html4"!=e&&(n("wbr"),n("ruby","",u,"rt rp"),n("figcaption","",d),n("mark rt rp summary bdi","",u),n("canvas","width height",d),n("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",d,"track source"),n("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",d,"track source"),n("picture","","img source"),n("source","src srcset type media sizes"),n("track","kind src srclang label default"),n("datalist","",u,"option"),n("article section nav aside header footer","",d),n("hgroup","","h1 h2 h3 h4 h5 h6"),n("figure","",d,"figcaption"),n("time","datetime",u),n("dialog","open",d),n("command","type label icon disabled checked radiogroup command"),n("output","for form name",u),n("progress","value max",u),n("meter","value min max low high optimum",u),n("details","open",d,"summary"),n("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!=e&&(r("script","language xml:space"),r("style","xml:space"),r("object","declare classid code codebase codetype archive standby align border hspace vspace"),r("embed","align name hspace vspace"),r("param","valuetype type"),r("a","charset name rev shape coords"),r("br","clear"),r("applet","codebase archive code object alt name width height align hspace vspace"),r("img","name longdesc align border hspace vspace"),r("iframe","longdesc frameborder marginwidth marginheight scrolling align"),r("font basefont","size color face"),r("input","usemap align"),r("select","onchange"),r("textarea"),r("h1 h2 h3 h4 h5 h6 div p legend caption","align"),r("ul","type compact"),r("li","type"),r("ol dl menu dir","compact"),r("pre","width xml:space"),r("hr","align noshade size width"),r("isindex","prompt"),r("table","summary width frame rules cellspacing cellpadding align bgcolor"),r("col","width align char charoff valign"),r("colgroup","width align char charoff valign"),r("thead","align char charoff valign"),r("tr","align char charoff valign bgcolor"),r("th","axis align char charoff valign nowrap bgcolor width height"),r("form","accept"),r("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),r("tfoot","align char charoff valign"),r("tbody","align char charoff valign"),r("area","nohref"),r("body","background bgcolor text link vlink alink")),"html4"!=e&&(r("input button select textarea","autofocus"),r("input textarea","placeholder"),r("a","download"),r("link script img","crossorigin"),r("iframe","sandbox seamless allowfullscreen")),s(t("a form meter progress dfn"),function(e){a[e]&&delete a[e].children[e]}),delete a.caption.children.table,i[e]=a,a)}function r(e,t){var n;return e&&(n={},"string"==typeof e&&(e={"*":e}),s(e,function(e,r){n[r]="map"==t?a(e,/[, ]/):c(e,/[, ]/)})),n}var i={},o={},a=e.makeMap,s=e.each,l=e.extend,c=e.explode,u=e.inArray;return function(e){function o(t,n,r){var o=e[t];return o?o=a(o,/[, ]/,a(o.toUpperCase(),/[, ]/)):(o=i[t],o||(o=a(n," ",a(n.toUpperCase()," ")),o=l(o,r),i[t]=o)),o}function d(e){return new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$")}function f(e){var n,r,i,o,s,l,c,f,p,h,m,g,v,b,x,w,_,E,N,k=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,S=/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,T=/[*?+]/;if(e)for(e=t(e,","),y["@"]&&(w=y["@"].attributes,_=y["@"].attributesOrder),n=0,r=e.length;r>n;n++)if(s=k.exec(e[n])){if(b=s[1],p=s[2],x=s[3],f=s[5],g={},v=[],l={attributes:g,attributesOrder:v},"#"===b&&(l.paddEmpty=!0),"-"===b&&(l.removeEmpty=!0),"!"===s[4]&&(l.removeEmptyAttrs=!0),w){for(E in w)g[E]=w[E];v.push.apply(v,_)}if(f)for(f=t(f,"|"),i=0,o=f.length;o>i;i++)if(s=S.exec(f[i])){if(c={},m=s[1],h=s[2].replace(/::/g,":"),b=s[3],N=s[4],"!"===m&&(l.attributesRequired=l.attributesRequired||[],l.attributesRequired.push(h),c.required=!0),"-"===m){delete g[h],v.splice(u(v,h),1);continue}b&&("="===b&&(l.attributesDefault=l.attributesDefault||[],l.attributesDefault.push({name:h,value:N}),c.defaultValue=N),":"===b&&(l.attributesForced=l.attributesForced||[],l.attributesForced.push({name:h,value:N}),c.forcedValue=N),"<"===b&&(c.validValues=a(N,"?"))),T.test(h)?(l.attributePatterns=l.attributePatterns||[],c.pattern=d(h),l.attributePatterns.push(c)):(g[h]||v.push(h),g[h]=c)}w||"@"!=p||(w=g,_=v),x&&(l.outputName=p,y[x]=l),T.test(p)?(l.pattern=d(p),C.push(l)):y[p]=l}}function p(e){y={},C=[],f(e),s(_,function(e,t){b[t]=e.children})}function h(e){var n=/^(~)?(.+)$/;e&&(i.text_block_elements=i.block_elements=null,s(t(e,","),function(e){var t=n.exec(e),r="~"===t[1],i=r?"span":"div",o=t[2];if(b[o]=b[i],L[o]=i,r||(R[o.toUpperCase()]={},R[o]={}),!y[o]){var a=y[i];a=l({},a),delete a.removeEmptyAttrs,delete a.removeEmpty,y[o]=a}s(b,function(e,t){e[i]&&(b[t]=e=l({},b[t]),e[o]=e[i])})}))}function m(e){var n=/^([+\-]?)(\w+)\[([^\]]+)\]$/;e&&s(t(e,","),function(e){var r=n.exec(e),i,o;r&&(o=r[1],i=o?b[r[2]]:b[r[2]]={"#comment":{}},i=b[r[2]],s(t(r[3],"|"),function(e){"-"===o?(b[r[2]]=i=l({},b[r[2]]),delete i[e]):i[e]={}}))})}function g(e){var t=y[e],n;if(t)return t;for(n=C.length;n--;)if(t=C[n],t.pattern.test(e))return t}var v=this,y={},b={},C=[],x,w,_,E,N,k,S,T,R,A,B,D,L={},H={};e=e||{},_=n(e.schema),e.verify_html===!1&&(e.valid_elements="*[*]"),x=r(e.valid_styles),w=r(e.invalid_styles,"map"),T=r(e.valid_classes,"map"),E=o("whitespace_elements","pre script noscript style textarea video audio iframe object"),N=o("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),k=o("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),S=o("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls"),A=o("non_empty_elements","td th iframe video audio object script",k),B=o("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside nav figure"),R=o("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup",B),D=o("text_inline_elements","span strong b em i font strike u var cite dfn code mark q sup sub samp"),s((e.special||"script noscript style textarea").split(" "),function(e){H[e]=new RegExp("]*>","gi")}),e.valid_elements?p(e.valid_elements):(s(_,function(e,t){y[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},b[t]=e.children}),"html5"!=e.schema&&s(t("strong/b em/i"),function(e){e=t(e,"/"),y[e[1]].outputName=e[0]}),y.img.attributesDefault=[{name:"alt",value:""}],s(t("ol ul sub sup blockquote span font a table tbody tr strong em b i"),function(e){y[e]&&(y[e].removeEmpty=!0)}),s(t("p h1 h2 h3 h4 h5 h6 th td pre div address caption"),function(e){y[e].paddEmpty=!0}),s(t("span"),function(e){y[e].removeEmptyAttrs=!0})),h(e.custom_elements),m(e.valid_children),f(e.extended_valid_elements),m("+ol[ul|ol],+ul[ul|ol]"),e.invalid_elements&&s(c(e.invalid_elements),function(e){y[e]&&delete y[e]}),g("span")||f("span[!data-mce-type|*]"),v.children=b,v.getValidStyles=function(){return x},v.getInvalidStyles=function(){return w},v.getValidClasses=function(){return T},v.getBoolAttrs=function(){return S},v.getBlockElements=function(){return R},v.getTextBlockElements=function(){return B},v.getTextInlineElements=function(){return D},v.getShortEndedElements=function(){return k},v.getSelfClosingElements=function(){return N},v.getNonEmptyElements=function(){return A},v.getWhiteSpaceElements=function(){return E},v.getSpecialElements=function(){return H},v.isValidChild=function(e,t){var n=b[e];return!(!n||!n[t])},v.isValid=function(e,t){var n,r,i=g(e);if(i){if(!t)return!0;if(i.attributes[t])return!0;if(n=i.attributePatterns)for(r=n.length;r--;)if(n[r].pattern.test(e))return!0}return!1},v.getElementRule=g,v.getCustomElements=function(){return L},v.addValidElements=f,v.setValidElements=p,v.addCustomElements=h,v.addValidChildren=m,v.elements=y}}),r(N,[E,g,d],function(e,t,n){function r(e,t,n){var r=1,i,o,a,s;for(s=e.getShortEndedElements(),a=/<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g,a.lastIndex=i=n;o=a.exec(t);){if(i=a.lastIndex,"/"===o[1])r--;else if(!o[1]){if(o[2]in s)continue;r++}if(0===r)break}return i}function i(i,a){function s(){}var l=this;i=i||{},l.schema=a=a||new e,i.fix_self_closing!==!1&&(i.fix_self_closing=!0),o("comment cdata text start end pi doctype".split(" "),function(e){e&&(l[e]=i[e]||s)}),l.parse=function(e){function o(e){var t,n;for(t=p.length;t--&&p[t].name!==e;);if(t>=0){for(n=p.length-1;n>=t;n--)e=p[n],e.valid&&l.end(e.name);p.length=t}}function s(e,t,n,r,o){var a,s,l=/[\s\u0000-\u001F]+/g;if(t=t.toLowerCase(),n=t in x?t:z(n||r||o||""),_&&!y&&0!==t.indexOf("data-")){if(a=T[t],!a&&R){for(s=R.length;s--&&(a=R[s],!a.pattern.test(t)););-1===s&&(a=null)}if(!a)return;if(a.validValues&&!(n in a.validValues))return}if(V[t]&&!i.allow_script_urls){var c=n.replace(l,"");try{c=decodeURIComponent(c)}catch(u){c=unescape(c)}if(U.test(c))return;if(!i.allow_html_data_urls&&$.test(c)&&!/^data:image\//i.test(c))return}h.map[t]=n,h.push({name:t,value:n})}var l=this,c,u=0,d,f,p=[],h,m,g,v,y,b,C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F=0,z=t.decode,W,V=n.makeMap("src,href,data,background,formaction,poster"),U=/((java|vb)script|mhtml):/i,$=/^data:/i;for(M=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([^>]+)>)|(?:([A-Za-z0-9\\-_\\:\\.]+)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g"),P=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g,C=a.getShortEndedElements(),H=i.self_closing_elements||a.getSelfClosingElements(),x=a.getBoolAttrs(),_=i.validate,b=i.remove_internals,W=i.fix_self_closing,O=a.getSpecialElements();c=M.exec(e);){if(u0&&p[p.length-1].name===d&&o(d),!_||(E=a.getElementRule(d))){if(N=!0,_&&(T=E.attributes,R=E.attributePatterns),(S=c[8])?(y=-1!==S.indexOf("data-mce-type"),y&&b&&(N=!1),h=[],h.map={},S.replace(P,s)):(h=[],h.map={}),_&&!y){if(A=E.attributesRequired,B=E.attributesDefault,D=E.attributesForced,L=E.removeEmptyAttrs,L&&!h.length&&(N=!1),D)for(m=D.length;m--;)k=D[m],v=k.name,I=k.value,"{$uid}"===I&&(I="mce_"+F++),h.map[v]=I,h.push({name:v,value:I});if(B)for(m=B.length;m--;)k=B[m],v=k.name,v in h.map||(I=k.value,"{$uid}"===I&&(I="mce_"+F++),h.map[v]=I,h.push({name:v,value:I}));if(A){for(m=A.length;m--&&!(A[m]in h.map););-1===m&&(N=!1)}if(k=h.map["data-mce-bogus"]){if("all"===k){u=r(a,e,M.lastIndex),M.lastIndex=u;continue}N=!1}}N&&l.start(d,h,w)}else N=!1;if(f=O[d]){f.lastIndex=u=c.index+c[0].length,(c=f.exec(e))?(N&&(g=e.substr(u,c.index-u)),u=c.index+c[0].length):(g=e.substr(u),u=e.length),N&&(g.length>0&&l.text(g,!0),l.end(d)),M.lastIndex=u;continue}w||(S&&S.indexOf("/")==S.length-1?N&&l.end(d):p.push({name:d,valid:N}))}else(d=c[1])?(">"===d.charAt(0)&&(d=" "+d),i.allow_conditional_comments||"[if"!==d.substr(0,3)||(d=" "+d),l.comment(d)):(d=c[2])?l.cdata(d):(d=c[3])?l.doctype(d):(d=c[4])&&l.pi(d,c[5]);u=c.index+c[0].length}for(u=0;m--)d=p[m],d.valid&&l.end(d.name)}}var o=n.each;return i.findEndTag=r,i}),r(k,[_,E,N,d],function(e,t,n,r){var i=r.makeMap,o=r.each,a=r.explode,s=r.extend;return function(r,l){function c(t){var n,r,o,a,s,c,d,f,p,h,m,g,v,y;for(m=i("tr,td,th,tbody,thead,tfoot,table"),h=l.getNonEmptyElements(),g=l.getTextBlockElements(),n=0;n1){for(a.reverse(),s=c=u.filterNode(a[0].clone()),p=0;p0?(t.value=n,t=t.prev):(r=t.prev,t.remove(),t=r)}function g(e){var t,n={};for(t in e)"li"!==t&&"p"!=t&&(n[t]=e[t]);return n}var v,y,b,C,x,w,_,E,N,k,S,T,R,A=[],B,D,L,H,M,P,O,I;if(o=o||{},p={},h={},T=s(i("script,style,head,html,body,title,meta,param"),l.getBlockElements()),O=l.getNonEmptyElements(),P=l.children,S=r.validate,I="forced_root_block"in o?o.forced_root_block:r.forced_root_block,M=l.getWhiteSpaceElements(),R=/^[ \t\r\n]+/,D=/[ \t\r\n]+$/,L=/[ \t\r\n]+/g,H=/^[ \t\r\n]+$/,v=new n({validate:S,allow_script_urls:r.allow_script_urls,allow_conditional_comments:r.allow_conditional_comments,self_closing_elements:g(l.getSelfClosingElements()),cdata:function(e){b.append(u("#cdata",4)).value=e},text:function(e,t){var n;B||(e=e.replace(L," "),b.lastChild&&T[b.lastChild.name]&&(e=e.replace(R,""))),0!==e.length&&(n=u("#text",3),n.raw=!!t,b.append(n).value=e)},comment:function(e){b.append(u("#comment",8)).value=e},pi:function(e,t){b.append(u(e,7)).value=t,m(b)},doctype:function(e){var t;t=b.append(u("#doctype",10)),t.value=e,m(b)},start:function(e,t,n){var r,i,o,a,s;if(o=S?l.getElementRule(e):{}){for(r=u(o.outputName||e,1),r.attributes=t,r.shortEnded=n,b.append(r),s=P[b.name],s&&P[r.name]&&!s[r.name]&&A.push(r),i=f.length;i--;)a=f[i].name,a in t.map&&(N=h[a],N?N.push(r):h[a]=[r]);T[e]&&m(r),n||(b=r),!B&&M[e]&&(B=!0)}},end:function(t){var n,r,i,o,a;if(r=S?l.getElementRule(t):{}){if(T[t]&&!B){if(n=b.firstChild,n&&3===n.type)if(i=n.value.replace(R,""),i.length>0)n.value=i,n=n.next;else for(o=n.next,n.remove(),n=o;n&&3===n.type;)i=n.value,o=n.next,(0===i.length||H.test(i))&&(n.remove(),n=o),n=o;if(n=b.lastChild,n&&3===n.type)if(i=n.value.replace(D,""),i.length>0)n.value=i,n=n.prev;else for(o=n.prev,n.remove(),n=o;n&&3===n.type;)i=n.value,o=n.prev,(0===i.length||H.test(i))&&(n.remove(),n=o),n=o}if(B&&M[t]&&(B=!1),(r.removeEmpty||r.paddEmpty)&&b.isEmpty(O))if(r.paddEmpty)b.empty().append(new e("#text","3")).value="\xa0";else if(!b.attributes.map.name&&!b.attributes.map.id)return a=b.parent,T[b.name]?b.empty().remove():b.unwrap(),void(b=a); +b=b.parent}}},l),y=b=new e(o.context||r.root_name,11),v.parse(t),S&&A.length&&(o.context?o.invalid=!0:c(A)),I&&("body"==y.name||o.isRootContent)&&a(),!o.invalid){for(k in p){for(N=d[k],C=p[k],_=C.length;_--;)C[_].parent||C.splice(_,1);for(x=0,w=N.length;w>x;x++)N[x](C,k,o)}for(x=0,w=f.length;w>x;x++)if(N=f[x],N.name in h){for(C=h[N.name],_=C.length;_--;)C[_].parent||C.splice(_,1);for(_=0,E=N.callbacks.length;E>_;_++)N.callbacks[_](C,N.name,o)}}return y},r.remove_trailing_brs&&u.addNodeFilter("br",function(t){var n,r=t.length,i,o=s({},l.getBlockElements()),a=l.getNonEmptyElements(),c,u,d,f,p,h;for(o.body=1,n=0;r>n;n++)if(i=t[n],c=i.parent,o[i.parent.name]&&i===c.lastChild){for(d=i.prev;d;){if(f=d.name,"span"!==f||"bookmark"!==d.attr("data-mce-type")){if("br"!==f)break;if("br"===f){i=null;break}}d=d.prev}i&&(i.remove(),c.isEmpty(a)&&(p=l.getElementRule(c.name),p&&(p.removeEmpty?c.remove():p.paddEmpty&&(c.empty().append(new e("#text",3)).value="\xa0"))))}else{for(u=i;c&&c.firstChild===u&&c.lastChild===u&&(u=c,!o[c.name]);)c=c.parent;u===c&&(h=new e("#text",3),h.value="\xa0",i.replace(h))}}),r.allow_html_in_named_anchor||u.addAttributeFilter("id,name",function(e){for(var t=e.length,n,r,i,o;t--;)if(o=e[t],"a"===o.name&&o.firstChild&&!o.attr("href")){i=o.parent,n=o.lastChild;do r=n.prev,i.insert(n,o),n=r;while(n)}}),r.validate&&l.getValidClasses()&&u.addAttributeFilter("class",function(e){for(var t=e.length,n,r,i,o,a,s=l.getValidClasses(),c,u;t--;){for(n=e[t],r=n.attr("class").split(" "),a="",i=0;i0&&(f=r[r.length-1],f.length>0&&"\n"!==f&&r.push("\n")),r.push("<",e),t)for(c=0,u=t.length;u>c;c++)d=t[c],r.push(" ",d.name,'="',s(d.value,!0),'"');r[r.length]=!n||l?">":" />",n&&i&&a[e]&&r.length>0&&(f=r[r.length-1],f.length>0&&"\n"!==f&&r.push("\n"))},end:function(e){var t;r.push(""),i&&a[e]&&r.length>0&&(t=r[r.length-1],t.length>0&&"\n"!==t&&r.push("\n"))},text:function(e,t){e.length>0&&(r[r.length]=t?e:s(e))},cdata:function(e){r.push("")},comment:function(e){r.push("")},pi:function(e,t){t?r.push(""):r.push(""),i&&r.push("\n")},doctype:function(e){r.push("",i?"\n":"")},reset:function(){r.length=0},getContent:function(){return r.join("").replace(/\n$/,"")}}}}),r(T,[S,E],function(e,t){return function(n,r){var i=this,o=new e(n);n=n||{},n.validate="validate"in n?n.validate:!0,i.schema=r=r||new t,i.writer=o,i.serialize=function(e){function t(e){var n=i[e.type],s,l,c,u,d,f,p,h,m;if(n)n(e);else{if(s=e.name,l=e.shortEnded,c=e.attributes,a&&c&&c.length>1){for(f=[],f.map={},m=r.getElementRule(e.name),p=0,h=m.attributesOrder.length;h>p;p++)u=m.attributesOrder[p],u in c.map&&(d=c.map[u],f.map[u]=d,f.push({name:u,value:d}));for(p=0,h=c.length;h>p;p++)u=c[p].name,u in f.map||(d=c.map[u],f.map[u]=d,f.push({name:u,value:d}));c=f}if(o.start(e.name,c,l),!l){if(e=e.firstChild)do t(e);while(e=e.next);o.end(s)}}}var i,a;return a=n.validate,i={3:function(e){o.text(e.value,e.raw)},8:function(e){o.comment(e.value)},7:function(e){o.pi(e.name,e.value)},10:function(e){o.doctype(e.value)},4:function(e){o.cdata(e.value)},11:function(e){if(e=e.firstChild)do t(e);while(e=e.next)}},o.reset(),1!=e.type||n.inner?i[11](e):t(e),o.getContent()}}}),r(R,[y,k,g,T,_,E,u,d],function(e,t,n,r,i,o,a,s){var l=s.each,c=s.trim,u=e.DOM;return function(e,i){var s,d,f;return i&&(s=i.dom,d=i.schema),s=s||u,d=d||new o(e),e.entity_encoding=e.entity_encoding||"named",e.remove_trailing_brs="remove_trailing_brs"in e?e.remove_trailing_brs:!0,f=new t(e,d),f.addAttributeFilter("data-mce-tabindex",function(e,t){for(var n=e.length,r;n--;)r=e[n],r.attr("tabindex",r.attributes.map["data-mce-tabindex"]),r.attr(t,null)}),f.addAttributeFilter("src,href,style",function(t,n){for(var r=t.length,i,o,a="data-mce-"+n,l=e.url_converter,c=e.url_converter_scope,u;r--;)i=t[r],o=i.attributes.map[a],o!==u?(i.attr(n,o.length>0?o:null),i.attr(a,null)):(o=i.attributes.map[n],"style"===n?o=s.serializeStyle(s.parseStyle(o),i.name):l&&(o=l.call(c,o,n,i.name)),i.attr(n,o.length>0?o:null))}),f.addAttributeFilter("class",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.attr("class"),r&&(r=n.attr("class").replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),n.attr("class",r.length>0?r:null))}),f.addAttributeFilter("data-mce-type",function(e,t,n){for(var r=e.length,i;r--;)i=e[r],"bookmark"!==i.attributes.map["data-mce-type"]||n.cleanup||i.remove()}),f.addNodeFilter("noscript",function(e){for(var t=e.length,r;t--;)r=e[t].firstChild,r&&(r.value=n.decode(r.value))}),f.addNodeFilter("script,style",function(e,t){function n(e){return e.replace(/()/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")}for(var r=e.length,i,o,a;r--;)i=e[r],o=i.firstChild?i.firstChild.value:"","script"===t?(a=i.attr("type"),a&&i.attr("type","mce-no/type"==a?null:a.replace(/^mce\-/,"")),o.length>0&&(i.firstChild.value="// ")):o.length>0&&(i.firstChild.value="")}),f.addNodeFilter("#comment",function(e){for(var t=e.length,n;t--;)n=e[t],0===n.value.indexOf("[CDATA[")?(n.name="#cdata",n.type=4,n.value=n.value.replace(/^\[CDATA\[|\]\]$/g,"")):0===n.value.indexOf("mce:protected ")&&(n.name="#text",n.type=3,n.raw=!0,n.value=unescape(n.value).substr(14))}),f.addNodeFilter("xml:namespace,input",function(e,t){for(var n=e.length,r;n--;)r=e[n],7===r.type?r.remove():1===r.type&&("input"!==t||"type"in r.attributes.map||r.attr("type","text"))}),e.fix_list_elements&&f.addNodeFilter("ul,ol",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.parent,("ul"===r.name||"ol"===r.name)&&n.prev&&"li"===n.prev.name&&n.prev.append(n)}),f.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-type,data-mce-resize",function(e,t){for(var n=e.length;n--;)e[n].attr(t,null)}),{schema:d,addNodeFilter:f.addNodeFilter,addAttributeFilter:f.addAttributeFilter,serialize:function(t,n){var i=this,o,u,p,h,m;return a.ie&&s.select("script,style,select,map").length>0?(m=t.innerHTML,t=t.cloneNode(!1),s.setHTML(t,m)):t=t.cloneNode(!0),o=t.ownerDocument.implementation,o.createHTMLDocument&&(u=o.createHTMLDocument(""),l("BODY"==t.nodeName?t.childNodes:[t],function(e){u.body.appendChild(u.importNode(e,!0))}),t="BODY"!=t.nodeName?u.body.firstChild:u.body,p=s.doc,s.doc=u),n=n||{},n.format=n.format||"html",n.selection&&(n.forced_root_block=""),n.no_events||(n.node=t,i.onPreProcess(n)),h=new r(e,d),n.content=h.serialize(f.parse(c(n.getInner?t.innerHTML:s.getOuterHTML(t)),n)),n.cleanup||(n.content=n.content.replace(/\uFEFF/g,"")),n.no_events||i.onPostProcess(n),p&&(s.doc=p),n.node=null,n.content},addRules:function(e){d.addValidElements(e)},setRules:function(e){d.setValidElements(e)},onPreProcess:function(e){i&&i.fire("PreProcess",e)},onPostProcess:function(e){i&&i.fire("PostProcess",e)}}}}),r(A,[],function(){function e(e){function t(t,n){var r,i=0,o,a,s,l,c,u,d=-1,f;if(r=t.duplicate(),r.collapse(n),f=r.parentElement(),f.ownerDocument===e.dom.doc){for(;"false"===f.contentEditable;)f=f.parentNode;if(!f.hasChildNodes())return{node:f,inside:1};for(s=f.children,o=s.length-1;o>=i;)if(u=Math.floor((i+o)/2),l=s[u],r.moveToElementText(l),d=r.compareEndPoints(n?"StartToStart":"EndToEnd",t),d>0)o=u-1;else{if(!(0>d))return{node:l};i=u+1}if(0>d)for(l?r.collapse(!1):(r.moveToElementText(f),r.collapse(!0),l=f,a=!0),c=0;0!==r.compareEndPoints(n?"StartToStart":"StartToEnd",t)&&0!==r.move("character",1)&&f==r.parentElement();)c++;else for(r.collapse(!0),c=0;0!==r.compareEndPoints(n?"StartToStart":"StartToEnd",t)&&0!==r.move("character",-1)&&f==r.parentElement();)c++;return{node:l,position:d,offset:c,inside:a}}}function n(){function n(e){var n=t(o,e),r,i,s=0,l,c,u;if(r=n.node,i=n.offset,n.inside&&!r.hasChildNodes())return void a[e?"setStart":"setEnd"](r,0);if(i===c)return void a[e?"setStartBefore":"setEndAfter"](r);if(n.position<0){if(l=n.inside?r.firstChild:r.nextSibling,!l)return void a[e?"setStartAfter":"setEndAfter"](r);if(!i)return void(3==l.nodeType?a[e?"setStart":"setEnd"](l,0):a[e?"setStartBefore":"setEndBefore"](l));for(;l;){if(3==l.nodeType&&(u=l.nodeValue,s+=u.length,s>=i)){r=l,s-=i,s=u.length-s;break}l=l.nextSibling}}else{if(l=r.previousSibling,!l)return a[e?"setStartBefore":"setEndBefore"](r);if(!i)return void(3==r.nodeType?a[e?"setStart":"setEnd"](l,r.nodeValue.length):a[e?"setStartAfter":"setEndAfter"](l));for(;l;){if(3==l.nodeType&&(s+=l.nodeValue.length,s>=i)){r=l,s-=i;break}l=l.previousSibling}}a[e?"setStart":"setEnd"](r,s)}var o=e.getRng(),a=i.createRng(),s,l,c,u,d;if(s=o.item?o.item(0):o.parentElement(),s.ownerDocument!=i.doc)return a;if(l=e.isCollapsed(),o.item)return a.setStart(s.parentNode,i.nodeIndex(s)),a.setEnd(a.startContainer,a.startOffset+1),a;try{n(!0),l||n()}catch(f){if(-2147024809!=f.number)throw f;d=r.getBookmark(2),c=o.duplicate(),c.collapse(!0),s=c.parentElement(),l||(c=o.duplicate(),c.collapse(!1),u=c.parentElement(),u.innerHTML=u.innerHTML),s.innerHTML=s.innerHTML,r.moveToBookmark(d),o=e.getRng(),n(!0),l||n()}return a}var r=this,i=e.dom,o=!1;this.getBookmark=function(n){function r(e){var t,n,r,o,a=[];for(t=e.parentNode,n=i.getRoot().parentNode;t!=n&&9!==t.nodeType;){for(r=t.children,o=r.length;o--;)if(e===r[o]){a.push(o);break}e=t,t=t.parentNode}return a}function o(e){var n;return n=t(a,e),n?{position:n.position,offset:n.offset,indexes:r(n.node),inside:n.inside}:void 0}var a=e.getRng(),s={};return 2===n&&(a.item?s.start={ctrl:!0,indexes:r(a.item(0))}:(s.start=o(!0),e.isCollapsed()||(s.end=o()))),s},this.moveToBookmark=function(e){function t(e){var t,n,r,o;for(t=i.getRoot(),n=e.length-1;n>=0;n--)o=t.children,r=e[n],r<=o.length-1&&(t=o[r]);return t}function n(n){var i=e[n?"start":"end"],a,s,l,c;i&&(a=i.position>0,s=o.createTextRange(),s.moveToElementText(t(i.indexes)),c=i.offset,c!==l?(s.collapse(i.inside||a),s.moveStart("character",a?-c:c)):s.collapse(n),r.setEndPoint(n?"StartToStart":"EndToStart",s),n&&r.collapse(!0))}var r,o=i.doc.body;e.start&&(e.start.ctrl?(r=o.createControlRange(),r.addElement(t(e.start.indexes)),r.select()):(r=o.createTextRange(),n(!0),n(),r.select()))},this.addRange=function(t){function n(e){var t,n,a,d,h;a=i.create("a"),t=e?s:c,n=e?l:u,d=r.duplicate(),(t==f||t==f.documentElement)&&(t=p,n=0),3==t.nodeType?(t.parentNode.insertBefore(a,t),d.moveToElementText(a),d.moveStart("character",n),i.remove(a),r.setEndPoint(e?"StartToStart":"EndToEnd",d)):(h=t.childNodes,h.length?(n>=h.length?i.insertAfter(a,h[h.length-1]):t.insertBefore(a,h[n]),d.moveToElementText(a)):t.canHaveHTML&&(t.innerHTML="",a=t.firstChild,d.moveToElementText(a),d.collapse(o)),r.setEndPoint(e?"StartToStart":"EndToEnd",d),i.remove(a))}var r,a,s,l,c,u,d,f=e.dom.doc,p=f.body,h,m;if(s=t.startContainer,l=t.startOffset,c=t.endContainer,u=t.endOffset,r=p.createTextRange(),s==c&&1==s.nodeType){if(l==u&&!s.hasChildNodes()){if(s.canHaveHTML)return d=s.previousSibling,d&&!d.hasChildNodes()&&i.isBlock(d)?d.innerHTML="":d=null,s.innerHTML="",r.moveToElementText(s.lastChild),r.select(),i.doc.selection.clear(),s.innerHTML="",void(d&&(d.innerHTML=""));l=i.nodeIndex(s),s=s.parentNode}if(l==u-1)try{if(m=s.childNodes[l],a=p.createControlRange(),a.addElement(m),a.select(),h=e.getRng(),h.item&&m===h.item(0))return}catch(g){}}n(!0),n(),r.select()},this.getRangeAt=n}return e}),r(B,[u],function(e){return{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(e){return e.shiftKey||e.ctrlKey||e.altKey||this.metaKeyPressed(e)},metaKeyPressed:function(t){return e.mac?t.metaKey:t.ctrlKey&&!t.altKey}}}),r(D,[B,d,u],function(e,t,n){return function(r,i){function o(e){var t=i.settings.object_resizing;return t===!1||n.iOS?!1:("string"!=typeof t&&(t="table,img,div"),"false"===e.getAttribute("data-mce-resize")?!1:i.dom.is(e,t))}function a(t){var n,r,o,a,s;n=t.screenX-T,r=t.screenY-R,P=n*k[2]+D,O=r*k[3]+L,P=5>P?5:P,O=5>O?5:O,o="IMG"==w.nodeName&&i.settings.resize_img_proportional!==!1?!e.modifierPressed(t):e.modifierPressed(t)||"IMG"==w.nodeName&&k[2]*k[3]!==0,o&&(W(n)>W(r)?(O=V(P*H),P=V(O/H)):(P=V(O/H),O=V(P*H))),C.setStyles(_,{width:P,height:O}),a=k.startPos.x+n,s=k.startPos.y+r,a=a>0?a:0,s=s>0?s:0,C.setStyles(E,{left:a,top:s,display:"block"}),E.innerHTML=P+" × "+O,k[2]<0&&_.clientWidth<=P&&C.setStyle(_,"left",A+(D-P)),k[3]<0&&_.clientHeight<=O&&C.setStyle(_,"top",B+(L-O)),n=U.scrollWidth-$,r=U.scrollHeight-q,n+r!==0&&C.setStyles(E,{left:a-n,top:s-r}),M||(i.fire("ObjectResizeStart",{target:w,width:D,height:L}),M=!0)}function s(){function e(e,t){t&&(w.style[e]||!i.schema.isValid(w.nodeName.toLowerCase(),e)?C.setStyle(w,e,t):C.setAttrib(w,e,t))}M=!1,e("width",P),e("height",O),C.unbind(I,"mousemove",a),C.unbind(I,"mouseup",s),F!=I&&(C.unbind(F,"mousemove",a),C.unbind(F,"mouseup",s)),C.remove(_),C.remove(E),z&&"TABLE"!=w.nodeName||l(w),i.fire("ObjectResized",{target:w,width:P,height:O}),C.setAttrib(w,"style",C.getAttrib(w,"style")),i.nodeChanged()}function l(e,t,r){var l,u,d,f,p;g(),l=C.getPos(e,U),A=l.x,B=l.y,p=e.getBoundingClientRect(),u=p.width||p.right-p.left,d=p.height||p.bottom-p.top,w!=e&&(m(),w=e,P=O=0),f=i.fire("ObjectSelected",{target:e}),o(e)&&!f.isDefaultPrevented()?x(N,function(e,i){function o(t){T=t.screenX,R=t.screenY,D=w.clientWidth,L=w.clientHeight,H=L/D,k=e,e.startPos={x:u*e[0]+A,y:d*e[1]+B},$=U.scrollWidth,q=U.scrollHeight,_=w.cloneNode(!0),C.addClass(_,"mce-clonedresizable"),C.setAttrib(_,"data-mce-bogus","all"),_.contentEditable=!1,_.unSelectabe=!0,C.setStyles(_,{left:A,top:B,margin:0}),_.removeAttribute("data-mce-selected"),U.appendChild(_),C.bind(I,"mousemove",a),C.bind(I,"mouseup",s),F!=I&&(C.bind(F,"mousemove",a),C.bind(F,"mouseup",s)),E=C.add(U,"div",{"class":"mce-resize-helper","data-mce-bogus":"all"},D+" × "+L)}var l,c;return t?void(i==t&&o(r)):(l=C.get("mceResizeHandle"+i),l?C.show(l):(c=U,l=C.add(c,"div",{id:"mceResizeHandle"+i,"data-mce-bogus":"all","class":"mce-resizehandle",unselectable:!0,style:"cursor:"+i+"-resize; margin:0; padding:0"}),n.ie&&(l.contentEditable=!1)),e.elm||(C.bind(l,"mousedown",function(e){e.stopImmediatePropagation(),e.preventDefault(),o(e)}),e.elm=l),void C.setStyles(l,{left:u*e[0]+A-l.offsetWidth/2,top:d*e[1]+B-l.offsetHeight/2}))}):c(),w.setAttribute("data-mce-selected","1")}function c(){var e,t;g(),w&&w.removeAttribute("data-mce-selected");for(e in N)t=C.get("mceResizeHandle"+e),t&&(C.unbind(t),C.remove(t))}function u(e){function t(e,t){if(e)do if(e===t)return!0;while(e=e.parentNode)}var n,i;if(!M)return x(C.select("img[data-mce-selected],hr[data-mce-selected]"),function(e){e.removeAttribute("data-mce-selected")}),i="mousedown"==e.type?e.target:r.getNode(),i=C.$(i).closest(z?"table":"table,img,hr")[0],t(i,U)&&(v(),n=r.getStart(!0),t(n,i)&&t(r.getEnd(!0),i)&&(!z||i!=n&&"IMG"!==n.nodeName))?void l(i):void c()}function d(e,t,n){e&&e.attachEvent&&e.attachEvent("on"+t,n)}function f(e,t,n){e&&e.detachEvent&&e.detachEvent("on"+t,n)}function p(e){var t=e.srcElement,n,r,o,a,s,c,u;n=t.getBoundingClientRect(),c=S.clientX-n.left,u=S.clientY-n.top;for(r in N)if(o=N[r],a=t.offsetWidth*o[0],s=t.offsetHeight*o[1],W(a-c)<8&&W(s-u)<8){k=o;break}M=!0,i.fire("ObjectResizeStart",{target:w,width:w.clientWidth,height:w.clientHeight}),i.getDoc().selection.empty(),l(t,r,S)}function h(e){var t=e.srcElement;if(t!=w){if(i.fire("ObjectSelected",{target:t}),m(),0===t.id.indexOf("mceResizeHandle"))return void(e.returnValue=!1);("IMG"==t.nodeName||"TABLE"==t.nodeName)&&(c(),w=t,d(t,"resizestart",p))}}function m(){f(w,"resizestart",p)}function g(){for(var e in N){var t=N[e];t.elm&&(C.unbind(t.elm),delete t.elm)}}function v(){try{i.getDoc().execCommand("enableObjectResizing",!1,!1)}catch(e){}}function y(e){var t;if(z){t=I.body.createControlRange();try{return t.addElement(e),t.select(),!0}catch(n){}}}function b(){w=_=null,z&&(m(),f(U,"controlselect",h))}var C=i.dom,x=t.each,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I=i.getDoc(),F=document,z=n.ie&&n.ie<11,W=Math.abs,V=Math.round,U=i.getBody(),$,q;N={n:[.5,0,0,-1],e:[1,.5,1,0],s:[.5,1,0,1],w:[0,.5,-1,0],nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]};var j=".mce-content-body";return i.contentStyles.push(j+" div.mce-resizehandle {position: absolute;border: 1px solid black;background: #FFF;width: 5px;height: 5px;z-index: 10000}"+j+" .mce-resizehandle:hover {background: #000}"+j+" img[data-mce-selected], hr[data-mce-selected] {outline: 1px solid black;resize: none}"+j+" .mce-clonedresizable {position: absolute;"+(n.gecko?"":"outline: 1px dashed black;")+"opacity: .5;filter: alpha(opacity=50);z-index: 10000}"+j+" .mce-resize-helper {background: #555;background: rgba(0,0,0,0.75);border-radius: 3px;border: 1px;color: white;display: none;font-family: sans-serif;font-size: 12px;white-space: nowrap;line-height: 14px;margin: 5px 10px;padding: 5px;position: absolute;z-index: 10001}"),i.on("init",function(){z?(i.on("ObjectResized",function(e){"TABLE"!=e.target.nodeName&&(c(),y(e.target))}),d(U,"controlselect",h),i.on("mousedown",function(e){S=e})):(v(),n.ie>=11&&(i.on("mouseup",function(e){var t=e.target.nodeName;!M&&/^(TABLE|IMG|HR)$/.test(t)&&(i.selection.select(e.target,"TABLE"==t),i.nodeChanged())}),i.dom.bind(U,"mscontrolselect",function(e){/^(TABLE|IMG|HR)$/.test(e.target.nodeName)&&(e.preventDefault(),"IMG"==e.target.tagName&&window.setTimeout(function(){i.selection.select(e.target)},0))}))),i.on("nodechange ResizeEditor",u),i.on("keydown keyup",function(e){w&&"TABLE"==w.nodeName&&u(e)}),i.on("hide",c)}),i.on("remove",g),{isResizable:o,showResizeRect:l,hideResizeRect:c,updateResizeRect:u,controlSelect:y,destroy:b}}}),r(L,[u,d],function(e,t){function n(n){var r=n.dom;this.getBookmark=function(e,i){function o(e,n){var i=0;return t.each(r.select(e),function(e,t){e==n&&(i=t)}),i}function a(e){function t(t){var n,r,i,o=t?"start":"end";n=e[o+"Container"],r=e[o+"Offset"],1==n.nodeType&&"TR"==n.nodeName&&(i=n.childNodes,n=i[Math.min(t?r:r-1,i.length-1)],n&&(r=t?0:n.childNodes.length,e["set"+(t?"Start":"End")](n,r)))}return t(!0),t(),e}function s(){function e(e,t){var n=e[t?"startContainer":"endContainer"],a=e[t?"startOffset":"endOffset"],s=[],l,c,u=0;if(3==n.nodeType){if(i)for(l=n.previousSibling;l&&3==l.nodeType;l=l.previousSibling)a+=l.nodeValue.length;s.push(a)}else c=n.childNodes,a>=c.length&&c.length&&(u=1,a=Math.max(0,c.length-1)),s.push(r.nodeIndex(c[a],i)+u);for(;n&&n!=o;n=n.parentNode)s.push(r.nodeIndex(n,i));return s}var t=n.getRng(!0),o=r.getRoot(),a={};return a.start=e(t,!0),n.isCollapsed()||(a.end=e(t)),a}var l,c,u,d,f,p,h="",m;if(2==e)return p=n.getNode(),f=p?p.nodeName:null,"IMG"==f?{name:f,index:o(f,p)}:n.tridentSel?n.tridentSel.getBookmark(e):s();if(e)return{rng:n.getRng()};if(l=n.getRng(),u=r.uniqueId(),d=n.isCollapsed(),m="overflow:hidden;line-height:0px",l.duplicate||l.item){if(l.item)return p=l.item(0),f=p.nodeName,{name:f,index:o(f,p)};c=l.duplicate();try{l.collapse(),l.pasteHTML(''+h+""),d||(c.collapse(!1),l.moveToElementText(c.parentElement()),0===l.compareEndPoints("StartToEnd",c)&&c.move("character",-1),c.pasteHTML(''+h+""))}catch(g){return null}}else{if(p=n.getNode(),f=p.nodeName,"IMG"==f)return{name:f,index:o(f,p)};c=a(l.cloneRange()),d||(c.collapse(!1),c.insertNode(r.create("span",{"data-mce-type":"bookmark",id:u+"_end",style:m},h))),l=a(l),l.collapse(!0),l.insertNode(r.create("span",{"data-mce-type":"bookmark",id:u+"_start",style:m},h))}return n.moveToBookmark({id:u,keep:1}),{id:u}},this.moveToBookmark=function(i){function o(e){var t=i[e?"start":"end"],n,r,o,a;if(t){for(o=t[0],r=c,n=t.length-1;n>=1;n--){if(a=r.childNodes,t[n]>a.length-1)return;r=a[t[n]]}3===r.nodeType&&(o=Math.min(t[0],r.nodeValue.length)),1===r.nodeType&&(o=Math.min(t[0],r.childNodes.length)),e?l.setStart(r,o):l.setEnd(r,o)}return!0}function a(n){var o=r.get(i.id+"_"+n),a,s,l,c,h=i.keep;if(o&&(a=o.parentNode,"start"==n?(h?(a=o.firstChild,s=1):s=r.nodeIndex(o),u=d=a,f=p=s):(h?(a=o.firstChild,s=1):s=r.nodeIndex(o),d=a,p=s),!h)){for(c=o.previousSibling,l=o.nextSibling,t.each(t.grep(o.childNodes),function(e){3==e.nodeType&&(e.nodeValue=e.nodeValue.replace(/\uFEFF/g,""))});o=r.get(i.id+"_"+n);)r.remove(o,1);c&&l&&c.nodeType==l.nodeType&&3==c.nodeType&&!e.opera&&(s=c.nodeValue.length,c.appendData(l.nodeValue),r.remove(l),"start"==n?(u=d=c,f=p=s):(d=c,p=s))}}function s(t){return!r.isBlock(t)||t.innerHTML||e.ie||(t.innerHTML='
          '),t}var l,c,u,d,f,p;if(i)if(i.start){if(l=r.createRng(),c=r.getRoot(),n.tridentSel)return n.tridentSel.moveToBookmark(i);o(!0)&&o()&&n.setRng(l)}else i.id?(a("start"),a("end"),u&&(l=r.createRng(),l.setStart(s(u),f),l.setEnd(s(d),p),n.setRng(l))):i.name?n.select(r.select(i.name)[i.index]):i.rng&&n.setRng(i.rng)}}return n.isBookmarkNode=function(e){return e&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type")},n}),r(H,[h,A,D,x,L,u,d],function(e,n,r,i,o,a,s){function l(e,t,i,a){var s=this;s.dom=e,s.win=t,s.serializer=i,s.editor=a,s.bookmarkManager=new o(s),s.controlSelection=new r(s,a),s.win.getSelection||(s.tridentSel=new n(s))}var c=s.each,u=s.trim,d=a.ie;return l.prototype={setCursorLocation:function(e,t){var n=this,r=n.dom.createRng();e?(r.setStart(e,t),r.setEnd(e,t),n.setRng(r),n.collapse(!1)):(n._moveEndPoint(r,n.editor.getBody(),!0),n.setRng(r))},getContent:function(e){var n=this,r=n.getRng(),i=n.dom.create("body"),o=n.getSel(),a,s,l;return e=e||{},a=s="",e.get=!0,e.format=e.format||"html",e.selection=!0,n.editor.fire("BeforeGetContent",e),"text"==e.format?n.isCollapsed()?"":r.text||(o.toString?o.toString():""):(r.cloneContents?(l=r.cloneContents(),l&&i.appendChild(l)):r.item!==t||r.htmlText!==t?(i.innerHTML="
          "+(r.item?r.item(0).outerHTML:r.htmlText),i.removeChild(i.firstChild)):i.innerHTML=r.toString(),/^\s/.test(i.innerHTML)&&(a=" "),/\s+$/.test(i.innerHTML)&&(s=" "),e.getInner=!0,e.content=n.isCollapsed()?"":a+n.serializer.serialize(i,e)+s,n.editor.fire("GetContent",e),e.content)},setContent:function(e,t){var n=this,r=n.getRng(),i,o=n.win.document,a,s;if(t=t||{format:"html"},t.set=!0,t.selection=!0,e=t.content=e,t.no_events||n.editor.fire("BeforeSetContent",t),e=t.content,r.insertNode){e+='_',r.startContainer==o&&r.endContainer==o?o.body.innerHTML=e:(r.deleteContents(),0===o.body.childNodes.length?o.body.innerHTML=e:r.createContextualFragment?r.insertNode(r.createContextualFragment(e)):(a=o.createDocumentFragment(),s=o.createElement("div"),a.appendChild(s),s.outerHTML=e,r.insertNode(a))),i=n.dom.get("__caret"),r=o.createRange(),r.setStartBefore(i),r.setEndBefore(i),n.setRng(r),n.dom.remove("__caret");try{n.setRng(r)}catch(l){}}else r.item&&(o.execCommand("Delete",!1,null),r=n.getRng()),/^\s+/.test(e)?(r.pasteHTML('_'+e),n.dom.remove("__mce_tmp")):r.pasteHTML(e);t.no_events||n.editor.fire("SetContent",t)},getStart:function(e){var t=this,n=t.getRng(),r,i,o,a;if(n.duplicate||n.item){if(n.item)return n.item(0);for(o=n.duplicate(),o.collapse(1),r=o.parentElement(),r.ownerDocument!==t.dom.doc&&(r=t.dom.getRoot()),i=a=n.parentElement();a=a.parentNode;)if(a==r){r=i;break}return r}return r=n.startContainer,1==r.nodeType&&r.hasChildNodes()&&(e&&n.collapsed||(r=r.childNodes[Math.min(r.childNodes.length-1,n.startOffset)])),r&&3==r.nodeType?r.parentNode:r},getEnd:function(e){var t=this,n=t.getRng(),r,i;return n.duplicate||n.item?n.item?n.item(0):(n=n.duplicate(),n.collapse(0),r=n.parentElement(),r.ownerDocument!==t.dom.doc&&(r=t.dom.getRoot()),r&&"BODY"==r.nodeName?r.lastChild||r:r):(r=n.endContainer,i=n.endOffset,1==r.nodeType&&r.hasChildNodes()&&(e&&n.collapsed||(r=r.childNodes[i>0?i-1:i])),r&&3==r.nodeType?r.parentNode:r)},getBookmark:function(e,t){return this.bookmarkManager.getBookmark(e,t)},moveToBookmark:function(e){return this.bookmarkManager.moveToBookmark(e)},select:function(e,t){var n=this,r=n.dom,i=r.createRng(),o;if(n.lastFocusBookmark=null,e){if(!t&&n.controlSelection.controlSelect(e))return;o=r.nodeIndex(e),i.setStart(e.parentNode,o),i.setEnd(e.parentNode,o+1),t&&(n._moveEndPoint(i,e,!0),n._moveEndPoint(i,e)),n.setRng(i)}return e},isCollapsed:function(){var e=this,t=e.getRng(),n=e.getSel();return!t||t.item?!1:t.compareEndPoints?0===t.compareEndPoints("StartToEnd",t):!n||t.collapsed},collapse:function(e){var t=this,n=t.getRng(),r;n.item&&(r=n.item(0),n=t.win.document.body.createTextRange(),n.moveToElementText(r)),n.collapse(!!e),t.setRng(n)},getSel:function(){var e=this.win;return e.getSelection?e.getSelection():e.document.selection},getRng:function(e){function t(e,t,n){try{return t.compareBoundaryPoints(e,n)}catch(r){return-1}}var n=this,r,i,o,a=n.win.document,s;if(!e&&n.lastFocusBookmark){var l=n.lastFocusBookmark;return l.startContainer?(i=a.createRange(),i.setStart(l.startContainer,l.startOffset),i.setEnd(l.endContainer,l.endOffset)):i=l,i}if(e&&n.tridentSel)return n.tridentSel.getRangeAt(0);try{(r=n.getSel())&&(i=r.rangeCount>0?r.getRangeAt(0):r.createRange?r.createRange():a.createRange())}catch(c){}if(d&&i&&i.setStart&&a.selection){try{s=a.selection.createRange()}catch(c){}s&&s.item&&(o=s.item(0),i=a.createRange(),i.setStartBefore(o),i.setEndAfter(o))}return i||(i=a.createRange?a.createRange():a.body.createTextRange()),i.setStart&&9===i.startContainer.nodeType&&i.collapsed&&(o=n.dom.getRoot(),i.setStart(o,0),i.setEnd(o,0)),n.selectedRange&&n.explicitRange&&(0===t(i.START_TO_START,i,n.selectedRange)&&0===t(i.END_TO_END,i,n.selectedRange)?i=n.explicitRange:(n.selectedRange=null,n.explicitRange=null)),i},setRng:function(e,t){var n=this,r;if(e)if(e.select)try{e.select()}catch(i){}else if(n.tridentSel){if(e.cloneRange)try{return void n.tridentSel.addRange(e)}catch(i){}}else if(r=n.getSel()){n.explicitRange=e;try{r.removeAllRanges(),r.addRange(e)}catch(i){}t===!1&&r.extend&&(r.collapse(e.endContainer,e.endOffset),r.extend(e.startContainer,e.startOffset)),n.selectedRange=r.rangeCount>0?r.getRangeAt(0):null}},setNode:function(e){var t=this;return t.setContent(t.dom.getOuterHTML(e)),e},getNode:function(){function e(e,t){for(var n=e;e&&3===e.nodeType&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||n}var t=this,n=t.getRng(),r,i=n.startContainer,o=n.endContainer,a=n.startOffset,s=n.endOffset,l=t.dom.getRoot();return n?n.setStart?(r=n.commonAncestorContainer,!n.collapsed&&(i==o&&2>s-a&&i.hasChildNodes()&&(r=i.childNodes[a]),3===i.nodeType&&3===o.nodeType&&(i=i.length===a?e(i.nextSibling,!0):i.parentNode,o=0===s?e(o.previousSibling,!1):o.parentNode,i&&i===o))?i:r&&3==r.nodeType?r.parentNode:r):(r=n.item?n.item(0):n.parentElement(),r.ownerDocument!==t.win.document&&(r=l),r):l},getSelectedBlocks:function(t,n){var r=this,i=r.dom,o,a,s=[];if(a=i.getRoot(),t=i.getParent(t||r.getStart(),i.isBlock),n=i.getParent(n||r.getEnd(),i.isBlock),t&&t!=a&&s.push(t),t&&n&&t!=n){o=t;for(var l=new e(t,a);(o=l.next())&&o!=n;)i.isBlock(o)&&s.push(o)}return n&&t!=n&&n!=a&&s.push(n),s},isForward:function(){var e=this.dom,t=this.getSel(),n,r;return t&&t.anchorNode&&t.focusNode?(n=e.createRng(),n.setStart(t.anchorNode,t.anchorOffset),n.collapse(!0),r=e.createRng(),r.setStart(t.focusNode,t.focusOffset),r.collapse(!0),n.compareBoundaryPoints(n.START_TO_START,r)<=0):!0},normalize:function(){var e=this,t=e.getRng();return!d&&new i(e.dom).normalize(t)&&e.setRng(t,e.isForward()),t},selectorChanged:function(e,t){var n=this,r;return n.selectorChangedData||(n.selectorChangedData={},r={},n.editor.on("NodeChange",function(e){var t=e.element,i=n.dom,o=i.getParents(t,null,i.getRoot()),a={};c(n.selectorChangedData,function(e,t){c(o,function(n){return i.is(n,t)?(r[t]||(c(e,function(e){e(!0,{node:n,selector:t,parents:o})}),r[t]=e),a[t]=e,!1):void 0})}),c(r,function(e,n){a[n]||(delete r[n],c(e,function(e){e(!1,{node:t,selector:n,parents:o})}))})})),n.selectorChangedData[e]||(n.selectorChangedData[e]=[]),n.selectorChangedData[e].push(t),n},getScrollContainer:function(){for(var e,t=this.dom.getRoot();t&&"BODY"!=t.nodeName;){if(t.scrollHeight>t.clientHeight){e=t;break}t=t.parentNode}return e},scrollIntoView:function(e){function t(e){for(var t=0,n=0,r=e;r&&r.nodeType;)t+=r.offsetLeft||0,n+=r.offsetTop||0,r=r.offsetParent;return{x:t,y:n}}var n,r,i=this,o=i.dom,a=o.getRoot(),s,l;if("BODY"!=a.nodeName){var c=i.getScrollContainer();if(c)return n=t(e).y-t(c).y,l=c.clientHeight,s=c.scrollTop,void((s>n||n+25>s+l)&&(c.scrollTop=s>n?n:n-l+25))}r=o.getViewPort(i.editor.getWin()),n=o.getPos(e).y,s=r.y,l=r.h,(ns+l)&&i.editor.getWin().scrollTo(0,s>n?n:n-l+25)},placeCaretAt:function(e,t){var n=this.editor.getDoc(),r,i;if(n.caretPositionFromPoint)i=n.caretPositionFromPoint(e,t),r=n.createRange(),r.setStart(i.offsetNode,i.offset),r.collapse(!0);else if(n.caretRangeFromPoint)r=n.caretRangeFromPoint(e,t);else if(n.body.createTextRange){r=n.body.createTextRange();try{r.moveToPoint(e,t),r.collapse(!0)}catch(o){r.collapse(t=e;e++)a.addShortcut("ctrl+"+e,"",["FormatBlock",!1,"h"+e]);a.addShortcut("ctrl+7","",["FormatBlock",!1,"p"]),a.addShortcut("ctrl+8","",["FormatBlock",!1,"div"]),a.addShortcut("ctrl+9","",["FormatBlock",!1,"address"])}function f(e){return e?V[e]:V}function p(e,t){e&&("string"!=typeof e?at(e,function(e,t){p(t,e)}):(t=t.length?t:[t],at(t,function(e){e.deep===tt&&(e.deep=!e.selector),e.split===tt&&(e.split=!e.selector||e.inline),e.remove===tt&&e.selector&&!e.inline&&(e.remove="none"),e.selector&&e.inline&&(e.mixed=!0,e.block_expand=!0),"string"==typeof e.classes&&(e.classes=e.classes.split(/\s+/))}),V[e]=t))}function h(e){return e&&V[e]&&delete V[e],V}function m(e){var t;return a.dom.getParent(e,function(e){return t=a.dom.getStyle(e,"text-decoration"),t&&"none"!==t}),t}function g(e){var t;1===e.nodeType&&e.parentNode&&1===e.parentNode.nodeType&&(t=m(e.parentNode),a.dom.getStyle(e,"color")&&t?a.dom.setStyle(e,"text-decoration",t):a.dom.getStyle(e,"textdecoration")===t&&a.dom.setStyle(e,"text-decoration",null))}function v(t,n,r){function i(e,t){if(t=t||d,e){if(t.onformat&&t.onformat(e,t,n,r),at(t.styles,function(t,r){U.setStyle(e,r,A(t,n))}),t.styles){var i=U.getAttrib(e,"style");i&&e.setAttribute("data-mce-style",i)}at(t.attributes,function(t,r){U.setAttrib(e,r,A(t,n))}),at(t.classes,function(t){t=A(t,n),U.hasClass(e,t)||U.addClass(e,t)})}}function o(){function t(t,n){var i=new e(n);for(r=i.current();r;r=i.prev())if(r.childNodes.length>1||r==t||"BR"==r.tagName)return r}var n=a.selection.getRng(),i=n.startContainer,o=n.endContainer;if(i!=o&&0===n.endOffset){var s=t(i,o),l=3==s.nodeType?s.length:s.childNodes.length;n.setEnd(s,l)}return n}function l(e,r,o){var a=[],l,f,p=!0;l=d.inline||d.block,f=U.create(l),i(f),q.walk(e,function(e){function r(e){var g,v,y,b,x;return x=p,g=e.nodeName.toLowerCase(),v=e.parentNode.nodeName.toLowerCase(),1===e.nodeType&&nt(e)&&(x=p,p="true"===nt(e),b=!0),S(g,"br")?(h=0,void(d.block&&U.remove(e))):d.wrapper&&C(e,t,n)?void(h=0):p&&!b&&d.block&&!d.wrapper&&s(g)&&j(v,l)?(e=U.rename(e,l),i(e),a.push(e),void(h=0)):d.selector&&(at(u,function(t){"collapsed"in t&&t.collapsed!==m||U.is(e,t.selector)&&!c(e)&&(i(e,t),y=!0)}),!d.inline||y)?void(h=0):void(!p||b||!j(l,g)||!j(v,l)||!o&&3===e.nodeType&&1===e.nodeValue.length&&65279===e.nodeValue.charCodeAt(0)||c(e)||d.inline&&Y(e)?(h=0,at(st(e.childNodes),r),b&&(p=x),h=0):(h||(h=U.clone(f,Q),e.parentNode.insertBefore(h,e),a.push(h)),h.appendChild(e)))}var h;at(e,r)}),d.links===!0&&at(a,function(e){function t(e){"A"===e.nodeName&&i(e,d),at(st(e.childNodes),t)}t(e)}),at(a,function(e){function r(e){var t=0;return at(e.childNodes,function(e){B(e)||ot(e)||t++}),t}function o(e){var t,n;return at(e.childNodes,function(e){return 1!=e.nodeType||ot(e)||c(e)?void 0:(t=e,Q)}),t&&!ot(t)&&k(t,d)&&(n=U.clone(t,Q),i(n),U.replace(n,e,Z),U.remove(t,1)),n||e}var s;if(s=r(e),(a.length>1||!Y(e))&&0===s)return void U.remove(e,1);if(d.inline||d.wrapper){if(d.exact||1!==s||(e=o(e)),at(u,function(t){at(U.select(t.inline,e),function(e){ot(e)||M(t,n,e,t.exact?e:null)})}),C(e.parentNode,t,n))return U.remove(e,1),e=0,Z;d.merge_with_parents&&U.getParent(e.parentNode,function(r){return C(r,t,n)?(U.remove(e,1),e=0,Z):void 0}),e&&d.merge_siblings!==!1&&(e=I(O(e),e),e=I(e,O(e,Z)))}})}var u=f(t),d=u[0],p,h,m=!r&&$.isCollapsed();if(d)if(r)r.nodeType?(h=U.createRng(),h.setStartBefore(r),h.setEndAfter(r),l(L(h,u),null,!0)):l(r,null,!0);else if(m&&d.inline&&!U.select("td.mce-item-selected,th.mce-item-selected").length)z("apply",t,n);else{var y=a.selection.getNode();K||!u[0].defaultBlock||U.getParent(y,U.isBlock)||v(u[0].defaultBlock),a.selection.setRng(o()),p=$.getBookmark(),l(L($.getRng(Z),u),p),d.styles&&(d.styles.color||d.styles.textDecoration)&&(lt(y,g,"childNodes"),g(y)),$.moveToBookmark(p),W($.getRng(Z)),a.nodeChanged()}}function y(e,t,n,r){function i(e){var n,r,o,a,s;if(1===e.nodeType&&nt(e)&&(a=y,y="true"===nt(e),s=!0),n=st(e.childNodes),y&&!s)for(r=0,o=p.length;o>r&&!M(p[r],t,e,e);r++);if(h.deep&&n.length){for(r=0,o=n.length;o>r;r++)i(n[r]);s&&(y=a)}}function o(n){var i;return at(l(n.parentNode).reverse(),function(n){var o;i||"_start"==n.id||"_end"==n.id||(o=C(n,e,t,r),o&&o.split!==!1&&(i=n))}),i}function s(e,n,r,i){var o,a,s,l,c,u;if(e){for(u=e.parentNode,o=n.parentNode;o&&o!=u;o=o.parentNode){for(a=U.clone(o,Q),c=0;c=0;o--){if(a=t[o].selector,!a||t[o].defaultBlock)return Z;for(i=r.length-1;i>=0;i--)if(U.is(r[i],a))return Z}return Q}function E(e,t,n){var r;return et||(et={},r={},a.on("NodeChange",function(e){var t=l(e.element),n={};t=i.grep(t,function(e){return 1==e.nodeType&&!e.getAttribute("data-mce-bogus")}),at(et,function(e,i){at(t,function(o){return C(o,i,{},e.similar)?(r[i]||(at(e,function(e){e(!0,{node:o,format:i,parents:t})}),r[i]=e),n[i]=e,!1):void 0})}),at(r,function(i,o){n[o]||(delete r[o],at(i,function(n){n(!1,{node:e.element,format:o,parents:t})}))})})),at(e.split(","),function(e){et[e]||(et[e]=[],et[e].similar=n),et[e].push(t)}),this}function N(e){return o.getCssText(a,e)}function k(e,t){return S(e,t.inline)?Z:S(e,t.block)?Z:t.selector?1==e.nodeType&&U.is(e,t.selector):void 0}function S(e,t){return e=e||"",t=t||"",e=""+(e.nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()==t.toLowerCase()}function T(e,t){return R(U.getStyle(e,t),t)}function R(e,t){return("color"==t||"backgroundColor"==t)&&(e=U.toHex(e)),"fontWeight"==t&&700==e&&(e="bold"),"fontFamily"==t&&(e=e.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),""+e}function A(e,t){return"string"!=typeof e?e=e(t):t&&(e=e.replace(/%(\w+)/g,function(e,n){return t[n]||e})),e}function B(e){return e&&3===e.nodeType&&/^([\t \r\n]+|)$/.test(e.nodeValue)}function D(e,t,n){var r=U.create(t,n);return e.parentNode.insertBefore(r,e),r.appendChild(e),r}function L(t,n,r){function i(e){function t(e){return"BR"==e.nodeName&&e.getAttribute("data-mce-bogus")&&!e.nextSibling}var r,i,o,a,s;if(r=i=e?g:y,a=e?"previousSibling":"nextSibling",s=U.getRoot(),3==r.nodeType&&!B(r)&&(e?v>0:bo?n:o,-1===n||r||n++):(n=a.indexOf(" ",t),o=a.indexOf("\xa0",t),n=-1!==n&&(-1===o||o>n)?n:o),n}var s,l,c,u;if(3===t.nodeType){if(c=o(t,n),-1!==c)return{container:t,offset:c};u=t}for(s=new e(t,U.getParent(t,Y)||a.getBody());l=s[i?"prev":"next"]();)if(3===l.nodeType){if(u=l,c=o(l),-1!==c)return{container:l,offset:c}}else if(Y(l))break;return u?(n=i?0:u.length,{container:u,offset:n}):void 0}function d(e,r){var i,o,a,s;for(3==e.nodeType&&0===e.nodeValue.length&&e[r]&&(e=e[r]),i=l(e),o=0;op?p:v],3==g.nodeType&&(v=0)),1==y.nodeType&&y.hasChildNodes()&&(p=y.childNodes.length-1,y=y.childNodes[b>p?p:b-1],3==y.nodeType&&(b=y.nodeValue.length)),g=c(g),y=c(y),(ot(g.parentNode)||ot(g))&&(g=ot(g)?g:g.parentNode,g=g.nextSibling||g,3==g.nodeType&&(v=0)),(ot(y.parentNode)||ot(y))&&(y=ot(y)?y:y.parentNode,y=y.previousSibling||y,3==y.nodeType&&(b=y.length)),n[0].inline&&(t.collapsed&&(m=u(g,v,!0),m&&(g=m.container,v=m.offset),m=u(y,b),m&&(y=m.container,b=m.offset)),h=o(y,b),h.node)){for(;h.node&&0===h.offset&&h.node.previousSibling;)h=o(h.node.previousSibling);h.node&&h.offset>0&&3===h.node.nodeType&&" "===h.node.nodeValue.charAt(h.offset-1)&&h.offset>1&&(y=h.node,y.splitText(h.offset-1))}return(n[0].inline||n[0].block_expand)&&(n[0].inline&&3==g.nodeType&&0!==v||(g=i(!0)),n[0].inline&&3==y.nodeType&&b!==y.nodeValue.length||(y=i())),n[0].selector&&n[0].expand!==Q&&!n[0].inline&&(g=d(g,"previousSibling"),y=d(y,"nextSibling")),(n[0].block||n[0].selector)&&(g=f(g,"previousSibling"),y=f(y,"nextSibling"),n[0].block&&(Y(g)||(g=i(!0)),Y(y)||(y=i()))),1==g.nodeType&&(v=G(g),g=g.parentNode),1==y.nodeType&&(b=G(y)+1,y=y.parentNode),{startContainer:g,startOffset:v,endContainer:y,endOffset:b}}function H(e,t){return t.links&&"A"==e.tagName}function M(e,t,n,r){var i,o,a;if(!k(n,e)&&!H(n,e))return Q;if("all"!=e.remove)for(at(e.styles,function(i,o){i=R(A(i,t),o),"number"==typeof o&&(o=i,r=0),(e.remove_similar||!r||S(T(r,o),i))&&U.setStyle(n,o,""),a=1}),a&&""===U.getAttrib(n,"style")&&(n.removeAttribute("style"),n.removeAttribute("data-mce-style")),at(e.attributes,function(e,i){var o;if(e=A(e,t),"number"==typeof i&&(i=e,r=0),!r||S(U.getAttrib(r,i),e)){if("class"==i&&(e=U.getAttrib(n,i),e&&(o="",at(e.split(/\s+/),function(e){/mce\w+/.test(e)&&(o+=(o?" ":"")+e)}),o)))return void U.setAttrib(n,i,o);"class"==i&&n.removeAttribute("className"),J.test(i)&&n.removeAttribute("data-mce-"+i),n.removeAttribute(i)}}),at(e.classes,function(e){e=A(e,t),(!r||U.hasClass(r,e))&&U.removeClass(n,e)}),o=U.getAttribs(n),i=0;io?o:i]),3===r.nodeType&&n&&i>=r.nodeValue.length&&(r=new e(r,a.getBody()).next()||r),3!==r.nodeType||n||0!==i||(r=new e(r,a.getBody()).prev()||r),r}function z(t,n,r,i){function o(e){var t=U.create("span",{id:g,"data-mce-bogus":!0,style:b?"color:red":""});return e&&t.appendChild(a.getDoc().createTextNode(X)),t}function l(e,t){for(;e;){if(3===e.nodeType&&e.nodeValue!==X||e.childNodes.length>1)return!1;t&&1===e.nodeType&&t.push(e),e=e.firstChild}return!0}function c(e){for(;e;){if(e.id===g)return e;e=e.parentNode}}function u(t){var n;if(t)for(n=new e(t,t),t=n.current();t;t=n.next())if(3===t.nodeType)return t}function d(e,t){var n,r;if(e)r=$.getRng(!0),l(e)?(t!==!1&&(r.setStartBefore(e),r.setEndBefore(e)),U.remove(e)):(n=u(e),n.nodeValue.charAt(0)===X&&(n.deleteData(0,1),r.startContainer==n&&r.startOffset>0&&r.setStart(n,r.startOffset-1),r.endContainer==n&&r.endOffset>0&&r.setEnd(n,r.endOffset-1)),U.remove(e,1)),$.setRng(r);else if(e=c($.getStart()),!e)for(;e=U.get(g);)d(e,!1)}function p(){var e,t,i,a,s,l,d;e=$.getRng(!0),a=e.startOffset,l=e.startContainer,d=l.nodeValue,t=c($.getStart()),t&&(i=u(t)),d&&a>0&&a=0;h--)u.appendChild(U.clone(p[h],!1)),u=u.firstChild;u.appendChild(U.doc.createTextNode(X)),u=u.firstChild;var g=U.getParent(d,s);g&&U.isEmpty(g)?d.parentNode.replaceChild(m,d):U.insertAfter(m,d),$.setCursorLocation(u,1),U.isEmpty(d)&&U.remove(d)}}function m(){var e;e=c($.getStart()),e&&!U.isEmpty(e)&<(e,function(e){1!=e.nodeType||e.id===g||U.isEmpty(e)||U.setAttrib(e,"data-mce-bogus",null)},"childNodes")}var g="_mce_caret",b=a.settings.caret_debug;a._hasCaretEvents||(it=function(){var e=[],t;if(l(c($.getStart()),e))for(t=e.length;t--;)U.setAttrib(e[t],"data-mce-bogus","1")},rt=function(e){var t=e.keyCode;d(),(8==t||37==t||39==t)&&d(c($.getStart())),m()},a.on("SetContent",function(e){e.selection&&m()}),a._hasCaretEvents=!0),"apply"==t?p():h()}function W(t){var n=t.startContainer,r=t.startOffset,i,o,a,s,l;if(3==n.nodeType&&r>=n.nodeValue.length&&(r=G(n),n=n.parentNode,i=!0),1==n.nodeType)for(s=n.childNodes,n=s[Math.min(r,s.length-1)],o=new e(n,U.getParent(n,U.isBlock)),(r>s.length-1||i)&&o.next(),a=o.current();a;a=o.next())if(3==a.nodeType&&!B(a))return l=U.create("a",{"data-mce-bogus":"all"},X),a.parentNode.insertBefore(l,a),t.setStart(a,0),$.setRng(t),void U.remove(l)}var V={},U=a.dom,$=a.selection,q=new t(U),j=a.schema.isValidChild,Y=U.isBlock,K=a.settings.forced_root_block,G=U.nodeIndex,X="\ufeff",J=/^(src|href|style)$/,Q=!1,Z=!0,et,tt,nt=U.getContentEditable,rt,it,ot=n.isBookmarkNode,at=i.each,st=i.grep,lt=i.walk,ct=i.extend;ct(this,{get:f,register:p,unregister:h,apply:v,remove:y,toggle:b,match:x,matchAll:w,matchNode:C,canApply:_,formatChanged:E,getCssText:N}),u(),d(),a.on("BeforeGetContent",function(e){it&&"raw"!=e.format&&it()}),a.on("mouseup keydown",function(e){rt&&rt(e)})}}),r(I,[B,u,d,N],function(e,t,n,r){var i=n.trim,o;return o=new RegExp(["]+data-mce-bogus[^>]+>[\u200b\ufeff]+<\\/span>",'\\s?data-mce-selected="[^"]+"'].join("|"),"gi"),function(n){function a(){var e=n.getContent({format:"raw",no_events:1}),t=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,a,s,l,c,u,d=n.schema;for(e=e.replace(o,""),u=d.getShortEndedElements();c=t.exec(e);)s=t.lastIndex,l=c[0].length,a=u[c[1]]?s:r.findEndTag(d,e,s),e=e.substring(0,s-l)+e.substring(a),t.lastIndex=s-l;return i(e)}function s(e){l.typing=!1,l.add({},e)}var l=this,c=0,u=[],d,f,p=0;return n.on("init",function(){l.add()}),n.on("BeforeExecCommand",function(e){var t=e.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&l.beforeChange()}),n.on("ExecCommand",function(e){var t=e.command;"Undo"!=t&&"Redo"!=t&&"mceRepaint"!=t&&s(e)}),n.on("ObjectResizeStart",function(){l.beforeChange()}),n.on("SaveContent ObjectResized blur",s),n.on("DragEnd",s),n.on("KeyUp",function(e){var r=e.keyCode;(r>=33&&36>=r||r>=37&&40>=r||45==r||13==r||e.ctrlKey)&&(s(),n.nodeChanged()),(46==r||8==r||t.mac&&(91==r||93==r))&&n.nodeChanged(),f&&l.typing&&(n.isDirty()||(n.isNotDirty=!u[0]||a()==u[0].content,n.isNotDirty||n.fire("change",{level:u[0],lastLevel:null})),n.fire("TypingUndo"),f=!1,n.nodeChanged())}),n.on("KeyDown",function(t){var n=t.keyCode;if(n>=33&&36>=n||n>=37&&40>=n||45==n)return void(l.typing&&s(t));var r=e.modifierPressed(t);!(16>n||n>20)||224==n||91==n||l.typing||r||(l.beforeChange(),l.typing=!0,l.add({},t),f=!0)}),n.on("MouseDown",function(e){l.typing&&s(e)}),n.addShortcut("ctrl+z","","Undo"),n.addShortcut("ctrl+y,ctrl+shift+z","","Redo"),n.on("AddUndo Undo Redo ClearUndos",function(e){e.isDefaultPrevented()||n.nodeChanged()}),l={data:u,typing:!1,beforeChange:function(){p||(d=n.selection.getBookmark(2,!0))},add:function(e,t){var r,i=n.settings,o;if(e=e||{},e.content=a(),p||n.removed)return null;if(o=u[c],n.fire("BeforeAddUndo",{level:e,lastLevel:o,originalEvent:t}).isDefaultPrevented())return null;if(o&&o.content==e.content)return null;if(u[c]&&(u[c].beforeBookmark=d),i.custom_undo_redo_levels&&u.length>i.custom_undo_redo_levels){for(r=0;r0&&(n.isNotDirty=!1,n.fire("change",s)),e},undo:function(){var e;return l.typing&&(l.add(),l.typing=!1),c>0&&(e=u[--c],0===c&&(n.isNotDirty=!0),n.setContent(e.content,{format:"raw"}),n.selection.moveToBookmark(e.beforeBookmark),n.fire("undo",{level:e})),e},redo:function(){var e;return c0||l.typing&&u[0]&&a()!=u[0].content},hasRedo:function(){return cB)&&(u=a.create("br"),t.parentNode.insertBefore(u,t)),l.setStartBefore(t),l.setEndBefore(t)):(l.setStartAfter(t),l.setEndAfter(t)):(l.setStart(t,0),l.setEnd(t,0));s.setRng(l),a.remove(u),s.scrollIntoView(t)}}function g(e){var t=l.forced_root_block;t&&t.toLowerCase()===e.tagName.toLowerCase()&&a.setAttribs(e,l.forced_root_block_attrs)}function v(e){var t=T,n,i,o,s=u.getTextInlineElements();if(e||"TABLE"==P?(n=a.create(e||I),g(n)):n=A.cloneNode(!1),o=n,l.keep_styles!==!1)do if(s[t.nodeName]){if("_mce_caret"==t.id)continue;i=t.cloneNode(!1),a.setAttrib(i,"id",""),n.hasChildNodes()?(i.appendChild(n.firstChild),n.appendChild(i)):(o=i,n.appendChild(i))}while(t=t.parentNode);return r||(o.innerHTML='
          '),n}function y(t){var n,r,i;if(3==T.nodeType&&(t?R>0:RT.childNodes.length-1,T=T.childNodes[Math.min(R,T.childNodes.length-1)]||T,R=F&&3==T.nodeType?T.nodeValue.length:0),S=_(T)){if(c.beforeChange(),!a.isBlock(S)&&S!=a.getRoot())return void((!I||D)&&x());if((I&&!D||!I&&D)&&(T=b(T,R)),A=a.getParent(T,a.isBlock),M=A?a.getParent(A.parentNode,a.isBlock):null,P=A?A.nodeName.toUpperCase():"",O=M?M.nodeName.toUpperCase():"","LI"!=O||o.ctrlKey||(A=M,P=O),/^(LI|DT|DD)$/.test(P)){if(!I&&D)return void x();if(a.isEmpty(A))return void C()}if("PRE"==P&&l.br_in_pre!==!1){if(!D)return void x()}else if(!I&&!D&&"LI"!=P||I&&D)return void x();I&&A===i.getBody()||(I=I||"P",y()?(L=/^(H[1-6]|PRE|FIGURE)$/.test(P)&&"HGROUP"!=O?v(I):v(),l.end_container_on_empty_block&&f(M)&&a.isEmpty(A)?L=a.split(M,A):a.insertAfter(L,A),m(L)):y(!0)?(L=A.parentNode.insertBefore(v(),A),p(L),m(A)):(k=N.cloneRange(),k.setEndAfter(A),H=k.extractContents(),w(H),L=H.firstChild,a.insertAfter(H,A),h(L),E(A),m(L)),a.setAttrib(L,"id",""),i.fire("NewBlock",{newBlock:L}),c.add())}}}var a=i.dom,s=i.selection,l=i.settings,c=i.undoManager,u=i.schema,d=u.getNonEmptyElements();i.on("keydown",function(e){13==e.keyCode&&o(e)!==!1&&e.preventDefault()})}}),r(z,[],function(){return function(e){function t(){var t=i.getStart(),s=e.getBody(),l,c,u,d,f,p,h,m=-16777215,g,v,y,b,C;if(C=n.forced_root_block,t&&1===t.nodeType&&C){for(;t&&t!=s;){if(a[t.nodeName])return;t=t.parentNode}if(l=i.getRng(),l.setStart){c=l.startContainer,u=l.startOffset,d=l.endContainer,f=l.endOffset;try{v=e.getDoc().activeElement===s}catch(x){}}else l.item&&(t=l.item(0),l=e.getDoc().body.createTextRange(),l.moveToElementText(t)),v=l.parentElement().ownerDocument===e.getDoc(),y=l.duplicate(),y.collapse(!0),u=-1*y.move("character",m),y.collapsed||(y=l.duplicate(),y.collapse(!1),f=-1*y.move("character",m)-u);for(t=s.firstChild,b=s.nodeName.toLowerCase();t;)if((3===t.nodeType||1==t.nodeType&&!a[t.nodeName])&&o.isValidChild(b,C.toLowerCase())){if(3===t.nodeType&&0===t.nodeValue.length){h=t,t=t.nextSibling,r.remove(h);continue}p||(p=r.create(C,e.settings.forced_root_block_attrs),t.parentNode.insertBefore(p,t),g=!0),h=t,t=t.nextSibling,p.appendChild(h)}else p=null,t=t.nextSibling;if(g&&v){if(l.setStart)l.setStart(c,u),l.setEnd(d,f),i.setRng(l);else try{l=e.getDoc().body.createTextRange(),l.moveToElementText(s),l.collapse(!0),l.moveStart("character",u),f>0&&l.moveEnd("character",f),l.select()}catch(x){}e.nodeChanged()}}}var n=e.settings,r=e.dom,i=e.selection,o=e.schema,a=o.getBlockElements();n.forced_root_block&&e.on("NodeChange",t)}}),r(W,[T,u,d,M,x,h],function(e,n,r,i,o,a){var s=r.each,l=r.extend,c=r.map,u=r.inArray,d=r.explode,f=n.gecko,p=n.ie,h=n.ie&&n.ie<11,m=!0,g=!1;return function(r){function v(e,t,n){var r;return e=e.toLowerCase(),(r=T.exec[e])?(r(e,t,n),m):g}function y(e){var t;return e=e.toLowerCase(),(t=T.state[e])?t(e):-1}function b(e){var t;return e=e.toLowerCase(),(t=T.value[e])?t(e):g}function C(e,t){t=t||"exec",s(e,function(e,n){s(n.toLowerCase().split(","),function(n){T[t][n]=e})})}function x(e,n,i){return n===t&&(n=g),i===t&&(i=null),r.getDoc().execCommand(e,n,i)}function w(e){return A.match(e)}function _(e,n){A.toggle(e,n?{value:n}:t),r.nodeChanged()}function E(e){B=S.getBookmark(e)}function N(){S.moveToBookmark(B)}var k=r.dom,S=r.selection,T={state:{},exec:{},value:{}},R=r.settings,A=r.formatter,B;l(this,{execCommand:v,queryCommandState:y,queryCommandValue:b,addCommands:C}),C({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){r.undoManager.add()},"Cut,Copy,Paste":function(e){var t=r.getDoc(),i;try{x(e)}catch(o){i=m}if(i||!t.queryCommandSupported(e)){var a=r.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");n.mac&&(a=a.replace(/Ctrl\+/g,"\u2318+")),r.windowManager.alert(a)}},unlink:function(){if(S.isCollapsed()){var e=S.getNode();return void("A"==e.tagName&&r.dom.remove(e,!0))}A.remove("link")},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(e){var t=e.substring(7);"full"==t&&(t="justify"),s("left,center,right,justify".split(","),function(e){t!=e&&A.remove("align"+e)}),_("align"+t),v("mceRepaint") +},"InsertUnorderedList,InsertOrderedList":function(e){var t,n;x(e),t=k.getParent(S.getNode(),"ol,ul"),t&&(n=t.parentNode,/^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName)&&(E(),k.split(n,t),N()))},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){_(e)},"ForeColor,HiliteColor,FontName":function(e,t,n){_(e,n)},FontSize:function(e,t,n){var r,i;n>=1&&7>=n&&(i=d(R.font_size_style_values),r=d(R.font_size_classes),n=r?r[n-1]||n:i[n-1]||n),_(e,n)},RemoveFormat:function(e){A.remove(e)},mceBlockQuote:function(){_("blockquote")},FormatBlock:function(e,t,n){return _(n||"p")},mceCleanup:function(){var e=S.getBookmark();r.setContent(r.getContent({cleanup:m}),{cleanup:m}),S.moveToBookmark(e)},mceRemoveNode:function(e,t,n){var i=n||S.getNode();i!=r.getBody()&&(E(),r.dom.remove(i,m),N())},mceSelectNodeDepth:function(e,t,n){var i=0;k.getParent(S.getNode(),function(e){return 1==e.nodeType&&i++==n?(S.select(e),g):void 0},r.getBody())},mceSelectNode:function(e,t,n){S.select(n)},mceInsertContent:function(t,n,o){function a(e){function t(e){return r[e]&&3==r[e].nodeType}var n,r,i;return n=S.getRng(!0),r=n.startContainer,i=n.startOffset,3==r.nodeType&&(i>0?e=e.replace(/^ /," "):t("previousSibling")||(e=e.replace(/^ /," ")),i|)$/," "):t("nextSibling")||(e=e.replace(/( | )(
          |)$/," "))),e}function l(e){if(w)for(b=e.firstChild;b;b=b.walk(!0))_[b.name]&&b.attr("data-mce-new","true")}function c(){if(w){var e=r.getBody(),t=new i(k);s(k.select("*[data-mce-new]"),function(n){n.removeAttribute("data-mce-new");for(var r=n.parentNode;r&&r!=e;r=r.parentNode)t.compare(r,n)&&k.remove(n,!0)})}}var u,d,f,h,m,g,v,y,b,C,x,w,_=r.schema.getTextInlineElements();"string"!=typeof o&&(w=o.merge,o=o.content),/^ | $/.test(o)&&(o=a(o)),u=r.parser,d=new e({},r.schema),x='​',g={content:o,format:"html",selection:!0},r.fire("BeforeSetContent",g),o=g.content,-1==o.indexOf("{$caret}")&&(o+="{$caret}"),o=o.replace(/\{\$caret\}/,x),y=S.getRng();var E=y.startContainer||(y.parentElement?y.parentElement():null),N=r.getBody();E===N&&S.isCollapsed()&&k.isBlock(N.firstChild)&&k.isEmpty(N.firstChild)&&(y=k.createRng(),y.setStart(N.firstChild,0),y.setEnd(N.firstChild,0),S.setRng(y)),S.isCollapsed()||r.getDoc().execCommand("Delete",!1,null),f=S.getNode();var T={context:f.nodeName.toLowerCase()};if(m=u.parse(o,T),l(m),b=m.lastChild,"mce_marker"==b.attr("id"))for(v=b,b=b.prev;b;b=b.walk(!0))if(3==b.type||!k.isBlock(b.name)){r.schema.isValidChild(b.parent.name,"span")&&b.parent.insert(v,b,"br"===b.name);break}if(T.invalid){for(S.setContent(x),f=S.getNode(),h=r.getBody(),9==f.nodeType?f=b=h:b=f;b!==h;)f=b,b=b.parentNode;o=f==h?h.innerHTML:k.getOuterHTML(f),o=d.serialize(u.parse(o.replace(//i,function(){return d.serialize(m)}))),f==h?k.setHTML(h,o):k.setOuterHTML(f,o)}else o=d.serialize(m),b=f.firstChild,C=f.lastChild,!b||b===C&&"BR"===b.nodeName?k.setHTML(f,o):S.setContent(o);c(),v=k.get("mce_marker"),S.scrollIntoView(v),y=k.createRng(),b=v.previousSibling,b&&3==b.nodeType?(y.setStart(b,b.nodeValue.length),p||(C=v.nextSibling,C&&3==C.nodeType&&(b.appendData(C.data),C.parentNode.removeChild(C)))):(y.setStartBefore(v),y.setEndBefore(v)),k.remove(v),S.setRng(y),r.fire("SetContent",g),r.addVisual()},mceInsertRawHTML:function(e,t,n){S.setContent("tiny_mce_marker"),r.setContent(r.getContent().replace(/tiny_mce_marker/g,function(){return n}))},mceToggleFormat:function(e,t,n){_(n)},mceSetContent:function(e,t,n){r.setContent(n)},"Indent,Outdent":function(e){var t,n,i;t=R.indentation,n=/[a-z%]+$/i.exec(t),t=parseInt(t,10),y("InsertUnorderedList")||y("InsertOrderedList")?x(e):(R.forced_root_block||k.getParent(S.getNode(),k.isBlock)||A.apply("div"),s(S.getSelectedBlocks(),function(o){if("LI"!=o.nodeName){var a=r.getParam("indent_use_margin",!1)?"margin":"padding";a+="rtl"==k.getStyle(o,"direction",!0)?"Right":"Left","outdent"==e?(i=Math.max(0,parseInt(o.style[a]||0,10)-t),k.setStyle(o,a,i?i+n:"")):(i=parseInt(o.style[a]||0,10)+t+n,k.setStyle(o,a,i))}}))},mceRepaint:function(){if(f)try{E(m),S.getSel()&&S.getSel().selectAllChildren(r.getBody()),S.collapse(m),N()}catch(e){}},InsertHorizontalRule:function(){r.execCommand("mceInsertContent",!1,"
          ")},mceToggleVisualAid:function(){r.hasVisual=!r.hasVisual,r.addVisual()},mceReplaceContent:function(e,t,n){r.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,S.getContent({format:"text"})))},mceInsertLink:function(e,t,n){var r;"string"==typeof n&&(n={href:n}),r=k.getParent(S.getNode(),"a"),n.href=n.href.replace(" ","%20"),r&&n.href||A.remove("link"),n.href&&A.apply("link",n,r)},selectAll:function(){var e=k.getRoot(),t;S.getRng().setStart?(t=k.createRng(),t.setStart(e,0),t.setEnd(e,e.childNodes.length),S.setRng(t)):(t=S.getRng(),t.item||(t.moveToElementText(e),t.select()))},"delete":function(){x("Delete");var e=r.getBody();k.isEmpty(e)&&(r.setContent(""),e.firstChild&&k.isBlock(e.firstChild)?r.selection.setCursorLocation(e.firstChild,0):r.selection.setCursorLocation(e,0))},mceNewDocument:function(){r.setContent("")},InsertLineBreak:function(e,t,n){function i(){for(var e=new a(p,v),t,n=r.schema.getNonEmptyElements();t=e.next();)if(n[t.nodeName.toLowerCase()]||t.length>0)return!0}var s=n,l,c,u,d=S.getRng(!0);new o(k).normalize(d);var f=d.startOffset,p=d.startContainer;if(1==p.nodeType&&p.hasChildNodes()){var g=f>p.childNodes.length-1;p=p.childNodes[Math.min(f,p.childNodes.length-1)]||p,f=g&&3==p.nodeType?p.nodeValue.length:0}var v=k.getParent(p,k.isBlock),y=v?v.nodeName.toUpperCase():"",b=v?k.getParent(v.parentNode,k.isBlock):null,C=b?b.nodeName.toUpperCase():"",x=s&&s.ctrlKey;"LI"!=C||x||(v=b,y=C),p&&3==p.nodeType&&f>=p.nodeValue.length&&(h||i()||(l=k.create("br"),d.insertNode(l),d.setStartAfter(l),d.setEndAfter(l),c=!0)),l=k.create("br"),d.insertNode(l);var w=k.doc.documentMode;return h&&"PRE"==y&&(!w||8>w)&&l.parentNode.insertBefore(k.doc.createTextNode("\r"),l),u=k.create("span",{}," "),l.parentNode.insertBefore(u,l),S.scrollIntoView(u),k.remove(u),c?(d.setStartBefore(l),d.setEndBefore(l)):(d.setStartAfter(l),d.setEndAfter(l)),S.setRng(d),r.undoManager.add(),m}}),C({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(e){var t="align"+e.substring(7),n=S.isCollapsed()?[k.getParent(S.getNode(),k.isBlock)]:S.getSelectedBlocks(),r=c(n,function(e){return!!A.matchNode(e,t)});return-1!==u(r,m)},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){return w(e)},mceBlockQuote:function(){return w("blockquote")},Outdent:function(){var e;if(R.inline_styles){if((e=k.getParent(S.getStart(),k.isBlock))&&parseInt(e.style.paddingLeft,10)>0)return m;if((e=k.getParent(S.getEnd(),k.isBlock))&&parseInt(e.style.paddingLeft,10)>0)return m}return y("InsertUnorderedList")||y("InsertOrderedList")||!R.inline_styles&&!!k.getParent(S.getNode(),"BLOCKQUOTE")},"InsertUnorderedList,InsertOrderedList":function(e){var t=k.getParent(S.getNode(),"ul,ol");return t&&("insertunorderedlist"===e&&"UL"===t.tagName||"insertorderedlist"===e&&"OL"===t.tagName)}},"state"),C({"FontSize,FontName":function(e){var t=0,n;return(n=k.getParent(S.getNode(),"span"))&&(t="fontsize"==e?n.style.fontSize:n.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()),t}},"value"),C({Undo:function(){r.undoManager.undo()},Redo:function(){r.undoManager.redo()}})}}),r(V,[d],function(e){function t(e,o){var a=this,s,l;if(e=r(e),o=a.settings=o||{},s=o.base_uri,/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(a.source=e);var c=0===e.indexOf("//");0!==e.indexOf("/")||c||(e=(s?s.protocol||"http":"http")+"://mce_host"+e),/^[\w\-]*:?\/\//.test(e)||(l=o.base_uri?o.base_uri.path:new t(location.href).directory,""===o.base_uri.protocol?e="//mce_host"+a.toAbsPath(l,e):(e=/([^#?]*)([#?]?.*)/.exec(e),e=(s&&s.protocol||"http")+"://mce_host"+a.toAbsPath(l,e[1])+e[2])),e=e.replace(/@@/g,"(mce_at)"),e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e),n(i,function(t,n){var r=e[n];r&&(r=r.replace(/\(mce_at\)/g,"@@")),a[t]=r}),s&&(a.protocol||(a.protocol=s.protocol),a.userInfo||(a.userInfo=s.userInfo),a.port||"mce_host"!==a.host||(a.port=s.port),a.host&&"mce_host"!==a.host||(a.host=s.host),a.source=""),c&&(a.protocol="")}var n=e.each,r=e.trim,i="source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),o={ftp:21,http:80,https:443,mailto:25};return t.prototype={setPath:function(e){var t=this;e=/^(.*?)\/?(\w+)?$/.exec(e),t.path=e[0],t.directory=e[1],t.file=e[2],t.source="",t.getURI()},toRelative:function(e){var n=this,r;if("./"===e)return e;if(e=new t(e,{base_uri:n}),"mce_host"!=e.host&&n.host!=e.host&&e.host||n.port!=e.port||n.protocol!=e.protocol&&""!==e.protocol)return e.getURI();var i=n.getURI(),o=e.getURI();return i==o||"/"==i.charAt(i.length-1)&&i.substr(0,i.length-1)==o?i:(r=n.toRelPath(n.path,e.path),e.query&&(r+="?"+e.query),e.anchor&&(r+="#"+e.anchor),r)},toAbsolute:function(e,n){return e=new t(e,{base_uri:this}),e.getURI(n&&this.isSameOrigin(e))},isSameOrigin:function(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;var t=o[this.protocol];if(t&&(this.port||t)==(e.port||t))return!0}return!1},toRelPath:function(e,t){var n,r=0,i="",o,a;if(e=e.substring(0,e.lastIndexOf("/")),e=e.split("/"),n=t.split("/"),e.length>=n.length)for(o=0,a=e.length;a>o;o++)if(o>=n.length||e[o]!=n[o]){r=o+1;break}if(e.lengtho;o++)if(o>=e.length||e[o]!=n[o]){r=o+1;break}if(1===r)return t;for(o=0,a=e.length-(r-1);a>o;o++)i+="../";for(o=r-1,a=n.length;a>o;o++)i+=o!=r-1?"/"+n[o]:n[o];return i},toAbsPath:function(e,t){var r,i=0,o=[],a,s;for(a=/\/$/.test(t)?"/":"",e=e.split("/"),t=t.split("/"),n(e,function(e){e&&o.push(e)}),e=o,r=t.length-1,o=[];r>=0;r--)0!==t[r].length&&"."!==t[r]&&(".."!==t[r]?i>0?i--:o.push(t[r]):i++);return r=e.length-i,s=0>=r?o.reverse().join("/"):e.slice(0,r).join("/")+"/"+o.reverse().join("/"),0!==s.indexOf("/")&&(s="/"+s),a&&s.lastIndexOf("/")!==s.length-1&&(s+=a),s},getURI:function(e){var t,n=this;return(!n.source||e)&&(t="",e||(t+=n.protocol?n.protocol+"://":"//",n.userInfo&&(t+=n.userInfo+"@"),n.host&&(t+=n.host),n.port&&(t+=":"+n.port)),n.path&&(t+=n.path),n.query&&(t+="?"+n.query),n.anchor&&(t+="#"+n.anchor),n.source=t),n.source}},t}),r(U,[d],function(e){function t(){}var n=e.each,r=e.extend,i,o;return t.extend=i=function(e){function t(){var e,t,n,r=this;if(!o&&(r.init&&r.init.apply(r,arguments),t=r.Mixins))for(e=t.length;e--;)n=t[e],n.init&&n.init.apply(r,arguments)}function a(){return this}function s(e,t){return function(){var n=this,r=n._super,i;return n._super=c[e],i=t.apply(n,arguments),n._super=r,i}}var l=this,c=l.prototype,u,d,f;o=!0,u=new l,o=!1,e.Mixins&&(n(e.Mixins,function(t){t=t;for(var n in t)"init"!==n&&(e[n]=t[n])}),c.Mixins&&(e.Mixins=c.Mixins.concat(e.Mixins))),e.Methods&&n(e.Methods.split(","),function(t){e[t]=a}),e.Properties&&n(e.Properties.split(","),function(t){var n="_"+t;e[t]=function(e){var t=this,r;return e!==r?(t[n]=e,t):t[n]}}),e.Statics&&n(e.Statics,function(e,n){t[n]=e}),e.Defaults&&c.Defaults&&(e.Defaults=r({},c.Defaults,e.Defaults));for(d in e)f=e[d],u[d]="function"==typeof f&&c[d]?s(d,f):f;return t.prototype=u,t.constructor=t,t.extend=i,t},t}),r($,[d],function(e){function t(t){function n(){return!1}function r(){return!0}function i(e,i){var o,s,l,c;if(e=e.toLowerCase(),i=i||{},i.type=e,i.target||(i.target=u),i.preventDefault||(i.preventDefault=function(){i.isDefaultPrevented=r},i.stopPropagation=function(){i.isPropagationStopped=r},i.stopImmediatePropagation=function(){i.isImmediatePropagationStopped=r},i.isDefaultPrevented=n,i.isPropagationStopped=n,i.isImmediatePropagationStopped=n),t.beforeFire&&t.beforeFire(i),o=d[e])for(s=0,l=o.length;l>s;s++){if(c=o[s],c.once&&a(e,c.func),i.isImmediatePropagationStopped())return i.stopPropagation(),i;if(c.func.call(u,i)===!1)return i.preventDefault(),i}return i}function o(t,r,i,o){var a,s,l;if(r===!1&&(r=n),r)for(r={func:r},o&&e.extend(r,o),s=t.toLowerCase().split(" "),l=s.length;l--;)t=s[l],a=d[t],a||(a=d[t]=[],f(t,!0)),i?a.unshift(r):a.push(r);return c}function a(e,t){var n,r,i,o,a;if(e)for(o=e.toLowerCase().split(" "),n=o.length;n--;){if(e=o[n],r=d[e],!e){for(i in d)f(i,!1),delete d[i];return c}if(r){if(t)for(a=r.length;a--;)r[a].func===t&&(r=r.slice(0,a).concat(r.slice(a+1)),d[e]=r);else r.length=0;r.length||(f(e,!1),delete d[e])}}else{for(e in d)f(e,!1);d={}}return c}function s(e,t,n){return o(e,t,n,{once:!0})}function l(e){return e=e.toLowerCase(),!(!d[e]||0===d[e].length)}var c=this,u,d={},f;t=t||{},u=t.scope||c,f=t.toggleEvent||n,c.fire=i,c.on=o,c.off=a,c.once=s,c.has=l}var n=e.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchend"," ");return t.isNative=function(e){return!!n[e.toLowerCase()]},t}),r(q,[U],function(e){function t(e){for(var t=[],n=e.length,r;n--;)r=e[n],r.__checked||(t.push(r),r.__checked=1);for(n=t.length;n--;)delete t[n].__checked;return t}var n=/^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i,r=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,i=/^\s*|\s*$/g,o,a=e.extend({init:function(e){function t(e){return e?(e=e.toLowerCase(),function(t){return"*"===e||t.type===e}):void 0}function o(e){return e?function(t){return t._name===e}:void 0}function a(e){return e?(e=e.split("."),function(t){for(var n=e.length;n--;)if(!t.hasClass(e[n]))return!1;return!0}):void 0}function s(e,t,n){return e?function(r){var i=r[e]?r[e]():"";return t?"="===t?i===n:"*="===t?i.indexOf(n)>=0:"~="===t?(" "+i+" ").indexOf(" "+n+" ")>=0:"!="===t?i!=n:"^="===t?0===i.indexOf(n):"$="===t?i.substr(i.length-n.length)===n:!1:!!n}:void 0}function l(e){var t;return e?(e=/(?:not\((.+)\))|(.+)/i.exec(e),e[1]?(t=u(e[1],[]),function(e){return!d(e,t)}):(e=e[2],function(t,n,r){return"first"===e?0===n:"last"===e?n===r-1:"even"===e?n%2===0:"odd"===e?n%2===1:t[e]?t[e]():!1})):void 0}function c(e,r,c){function u(e){e&&r.push(e)}var d;return d=n.exec(e.replace(i,"")),u(t(d[1])),u(o(d[2])),u(a(d[3])),u(s(d[4],d[5],d[6])),u(l(d[7])),r.psuedo=!!d[7],r.direct=c,r}function u(e,t){var n=[],i,o,a;do if(r.exec(""),o=r.exec(e),o&&(e=o[3],n.push(o[1]),o[2])){i=o[3];break}while(o);for(i&&u(i,t),e=[],a=0;a"!=n[a]&&e.push(c(n[a],[],">"===n[a-1]));return t.push(e),t}var d=this.match;this._selectors=u(e,[])},match:function(e,t){var n,r,i,o,a,s,l,c,u,d,f,p,h;for(t=t||this._selectors,n=0,r=t.length;r>n;n++){for(a=t[n],o=a.length,h=e,p=0,i=o-1;i>=0;i--)for(c=a[i];h;){if(c.psuedo)for(f=h.parent().items(),u=d=f.length;u--&&f[u]!==h;);for(s=0,l=c.length;l>s;s++)if(!c[s](h,u,d)){s=l+1;break}if(s===l){p++;break}if(i===o-1)break;h=h.parent()}if(p===o)return!0}return!1},find:function(e){function n(e,t,i){var o,a,s,l,c,u=t[i];for(o=0,a=e.length;a>o;o++){for(c=e[o],s=0,l=u.length;l>s;s++)if(!u[s](c,o,a)){s=l+1;break}if(s===l)i==t.length-1?r.push(c):c.items&&n(c.items(),t,i+1);else if(u.direct)return;c.items&&n(c.items(),t,i)}}var r=[],i,s,l=this._selectors;if(e.items){for(i=0,s=l.length;s>i;i++)n(e.items(),l[i],0);s>1&&(r=t(r))}return o||(o=a.Collection),new o(r)}});return a}),r(j,[d,q,U],function(e,t,n){var r,i,o=Array.prototype.push,a=Array.prototype.slice;return i={length:0,init:function(e){e&&this.add(e)},add:function(t){var n=this;return e.isArray(t)?o.apply(n,t):t instanceof r?n.add(t.toArray()):o.call(n,t),n},set:function(e){var t=this,n=t.length,r;for(t.length=0,t.add(e),r=t.length;n>r;r++)delete t[r];return t},filter:function(e){var n=this,i,o,a=[],s,l;for("string"==typeof e?(e=new t(e),l=function(t){return e.match(t)}):l=e,i=0,o=n.length;o>i;i++)s=n[i],l(s)&&a.push(s);return new r(a)},slice:function(){return new r(a.apply(this,arguments))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},each:function(t){return e.each(this,t),this},toArray:function(){return e.toArray(this)},indexOf:function(e){for(var t=this,n=t.length;n--&&t[n]!==e;);return n},reverse:function(){return new r(e.toArray(this).reverse())},hasClass:function(e){return this[0]?this[0].hasClass(e):!1},prop:function(e,t){var n=this,r,i;return t!==r?(n.each(function(n){n[e]&&n[e](t)}),n):(i=n[0],i&&i[e]?i[e]():void 0)},exec:function(t){var n=this,r=e.toArray(arguments).slice(1);return n.each(function(e){e[t]&&e[t].apply(e,r)}),n},remove:function(){for(var e=this.length;e--;)this[e].remove();return this}},e.each("fire on off show hide addClass removeClass append prepend before after reflow".split(" "),function(t){i[t]=function(){var n=e.toArray(arguments);return this.each(function(e){t in e&&e[t].apply(e,n)}),this}}),e.each("text name disabled active selected checked visible parent value data".split(" "),function(e){i[e]=function(t){return this.prop(e,t)}}),r=n.extend(i),t.Collection=r,r}),r(Y,[d,y],function(e,t){var n=0;return{id:function(){return"mceu_"+n++},createFragment:function(e){return t.DOM.createFragment(e)},getWindowSize:function(){return t.DOM.getViewPort()},getSize:function(e){var t,n;if(e.getBoundingClientRect){var r=e.getBoundingClientRect();t=Math.max(r.width||r.right-r.left,e.offsetWidth),n=Math.max(r.height||r.bottom-r.bottom,e.offsetHeight)}else t=e.offsetWidth,n=e.offsetHeight;return{width:t,height:n}},getPos:function(e,n){return t.DOM.getPos(e,n)},getViewPort:function(e){return t.DOM.getViewPort(e)},get:function(e){return document.getElementById(e)},addClass:function(e,n){return t.DOM.addClass(e,n)},removeClass:function(e,n){return t.DOM.removeClass(e,n)},hasClass:function(e,n){return t.DOM.hasClass(e,n)},toggleClass:function(e,n,r){return t.DOM.toggleClass(e,n,r)},css:function(e,n,r){return t.DOM.setStyle(e,n,r)},getRuntimeStyle:function(e,n){return t.DOM.getStyle(e,n,!0)},on:function(e,n,r,i){return t.DOM.bind(e,n,r,i)},off:function(e,n,r){return t.DOM.unbind(e,n,r)},fire:function(e,n,r){return t.DOM.fire(e,n,r)},innerHtml:function(e,n){t.DOM.setHTML(e,n)}}}),r(K,[U,d,$,j,Y],function(e,t,n,r,i){function o(e){return e._eventDispatcher||(e._eventDispatcher=new n({scope:e,toggleEvent:function(t,r){r&&n.isNative(t)&&(e._nativeEvents||(e._nativeEvents={}),e._nativeEvents[t]=!0,e._rendered&&e.bindPendingEvents())}})),e._eventDispatcher}var a="onmousewheel"in document,s=!1,l="mce-",c=e.extend({Statics:{classPrefix:l},isRtl:function(){return c.rtl},classPrefix:l,init:function(e){var n=this,r,o;if(n.settings=e=t.extend({},n.Defaults,e),n._id=e.id||i.id(),n._text=n._name="",n._width=n._height=0,n._aria={role:e.role},this._elmCache={},r=e.classes)for(r=r.split(" "),r.map={},o=r.length;o--;)r.map[r[o]]=!0;n._classes=r||[],n.visible(!0),t.each("title text width height name classes visible disabled active value".split(" "),function(t){var r=e[t],i;r!==i?n[t](r):n["_"+t]===i&&(n["_"+t]=!1)}),n.on("click",function(){return n.disabled()?!1:void 0}),e.classes&&t.each(e.classes.split(" "),function(e){n.addClass(e)}),n.settings=e,n._borderBox=n.parseBox(e.border),n._paddingBox=n.parseBox(e.padding),n._marginBox=n.parseBox(e.margin),e.hidden&&n.hide()},Properties:"parent,title,text,width,height,disabled,active,name,value",Methods:"renderHtml",getContainerElm:function(){return document.body},getParentCtrl:function(e){for(var t,n=this.getRoot().controlIdLookup;e&&n&&!(t=n[e.id]);)e=e.parentNode;return t},parseBox:function(e){var t,n=10;if(e)return"number"==typeof e?(e=e||0,{top:e,left:e,bottom:e,right:e}):(e=e.split(" "),t=e.length,1===t?e[1]=e[2]=e[3]=e[0]:2===t?(e[2]=e[0],e[3]=e[1]):3===t&&(e[3]=e[1]),{top:parseInt(e[0],n)||0,right:parseInt(e[1],n)||0,bottom:parseInt(e[2],n)||0,left:parseInt(e[3],n)||0})},borderBox:function(){return this._borderBox},paddingBox:function(){return this._paddingBox},marginBox:function(){return this._marginBox},measureBox:function(e,t){function n(t){var n=document.defaultView;return n?(t=t.replace(/[A-Z]/g,function(e){return"-"+e}),n.getComputedStyle(e,null).getPropertyValue(t)):e.currentStyle[t]}function r(e){var t=parseFloat(n(e),10);return isNaN(t)?0:t}return{top:r(t+"TopWidth"),right:r(t+"RightWidth"),bottom:r(t+"BottomWidth"),left:r(t+"LeftWidth")}},initLayoutRect:function(){var e=this,t=e.settings,n,r,o=e.getEl(),a,s,l,c,u,d,f,p;n=e._borderBox=e._borderBox||e.measureBox(o,"border"),e._paddingBox=e._paddingBox||e.measureBox(o,"padding"),e._marginBox=e._marginBox||e.measureBox(o,"margin"),p=i.getSize(o),d=t.minWidth,f=t.minHeight,l=d||p.width,c=f||p.height,a=t.width,s=t.height,u=t.autoResize,u="undefined"!=typeof u?u:!a&&!s,a=a||l,s=s||c;var h=n.left+n.right,m=n.top+n.bottom,g=t.maxWidth||65535,v=t.maxHeight||65535;return e._layoutRect=r={x:t.x||0,y:t.y||0,w:a,h:s,deltaW:h,deltaH:m,contentW:a-h,contentH:s-m,innerW:a-h,innerH:s-m,startMinWidth:d||0,startMinHeight:f||0,minW:Math.min(l,g),minH:Math.min(c,v),maxW:g,maxH:v,autoResize:u,scrollW:0},e._lastLayoutRect={},r},layoutRect:function(e){var t=this,n=t._layoutRect,r,i,o,a,s,l;return n||(n=t.initLayoutRect()),e?(o=n.deltaW,a=n.deltaH,e.x!==s&&(n.x=e.x),e.y!==s&&(n.y=e.y),e.minW!==s&&(n.minW=e.minW),e.minH!==s&&(n.minH=e.minH),i=e.w,i!==s&&(i=in.maxW?n.maxW:i,n.w=i,n.innerW=i-o),i=e.h,i!==s&&(i=in.maxH?n.maxH:i,n.h=i,n.innerH=i-a),i=e.innerW,i!==s&&(i=in.maxW-o?n.maxW-o:i,n.innerW=i,n.w=i+o),i=e.innerH,i!==s&&(i=in.maxH-a?n.maxH-a:i,n.innerH=i,n.h=i+a),e.contentW!==s&&(n.contentW=e.contentW),e.contentH!==s&&(n.contentH=e.contentH),r=t._lastLayoutRect,(r.x!==n.x||r.y!==n.y||r.w!==n.w||r.h!==n.h)&&(l=c.repaintControls,l&&l.map&&!l.map[t._id]&&(l.push(t),l.map[t._id]=!0),r.x=n.x,r.y=n.y,r.w=n.w,r.h=n.h),t):n},repaint:function(){var e=this,t,n,r,i,o=0,a=0,s,l;l=document.createRange?function(e){return e}:Math.round,t=e.getEl().style,r=e._layoutRect,s=e._lastRepaintRect||{},i=e._borderBox,o=i.left+i.right,a=i.top+i.bottom,r.x!==s.x&&(t.left=l(r.x)+"px",s.x=r.x),r.y!==s.y&&(t.top=l(r.y)+"px",s.y=r.y),r.w!==s.w&&(t.width=l(r.w-o)+"px",s.w=r.w),r.h!==s.h&&(t.height=l(r.h-a)+"px",s.h=r.h),e._hasBody&&r.innerW!==s.innerW&&(n=e.getEl("body").style,n.width=l(r.innerW)+"px",s.innerW=r.innerW),e._hasBody&&r.innerH!==s.innerH&&(n=n||e.getEl("body").style,n.height=l(r.innerH)+"px",s.innerH=r.innerH),e._lastRepaintRect=s,e.fire("repaint",{},!1)},on:function(e,t){function n(e){var t,n;return"string"!=typeof e?e:function(i){return t||r.parentsAndSelf().each(function(r){var i=r.settings.callbacks;return i&&(t=i[e])?(n=r,!1):void 0}),t.call(n,i)}}var r=this;return o(r).on(e,n(t)),r},off:function(e,t){return o(this).off(e,t),this},fire:function(e,t,n){var r=this;if(t=t||{},t.control||(t.control=r),t=o(r).fire(e,t),n!==!1&&r.parent)for(var i=r.parent();i&&!t.isPropagationStopped();)i.fire(e,t,!1),i=i.parent();return t},hasEventListeners:function(e){return o(this).has(e)},parents:function(e){var t=this,n,i=new r;for(n=t.parent();n;n=n.parent())i.add(n);return e&&(i=i.filter(e)),i},parentsAndSelf:function(e){return new r(this).add(this.parents(e))},next:function(){var e=this.parent().items();return e[e.indexOf(this)+1]},prev:function(){var e=this.parent().items();return e[e.indexOf(this)-1]},findCommonAncestor:function(e,t){for(var n;e;){for(n=t;n&&e!=n;)n=n.parent();if(e==n)break;e=e.parent()}return e},hasClass:function(e,t){var n=this._classes[t||"control"];return e=this.classPrefix+e,n&&!!n.map[e]},addClass:function(e,t){var n=this,r,i;return e=this.classPrefix+e,r=n._classes[t||"control"],r||(r=[],r.map={},n._classes[t||"control"]=r),r.map[e]||(r.map[e]=e,r.push(e),n._rendered&&(i=n.getEl(t),i&&(i.className=r.join(" ")))),n},removeClass:function(e,t){var n=this,r,i,o;if(e=this.classPrefix+e,r=n._classes[t||"control"],r&&r.map[e])for(delete r.map[e],i=r.length;i--;)r[i]===e&&r.splice(i,1);return n._rendered&&(o=n.getEl(t),o&&(o.className=r.join(" "))),n},toggleClass:function(e,t,n){var r=this;return t?r.addClass(e,n):r.removeClass(e,n),r},classes:function(e){var t=this._classes[e||"control"];return t?t.join(" "):""},innerHtml:function(e){return i.innerHtml(this.getEl(),e),this},getEl:function(e){var t=e?this._id+"-"+e:this._id;return this._elmCache[t]||(this._elmCache[t]=i.get(t)),this._elmCache[t]},visible:function(e){var t=this,n;return"undefined"!=typeof e?(t._visible!==e&&(t._rendered&&(t.getEl().style.display=e?"":"none"),t._visible=e,n=t.parent(),n&&(n._lastRect=null),t.fire(e?"show":"hide")),t):t._visible},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(e){}return this},blur:function(){return this.getEl().blur(),this},aria:function(e,t){var n=this,r=n.getEl(n.ariaTarget);return"undefined"==typeof t?n._aria[e]:(n._aria[e]=t,n._rendered&&r.setAttribute("role"==e?e:"aria-"+e,t),n)},encode:function(e,t){return t!==!1&&(e=this.translate(e)),(e||"").replace(/[&<>"]/g,function(e){return"&#"+e.charCodeAt(0)+";"})},translate:function(e){return c.translate?c.translate(e):e},before:function(e){var t=this,n=t.parent();return n&&n.insert(e,n.items().indexOf(t),!0),t},after:function(e){var t=this,n=t.parent();return n&&n.insert(e,n.items().indexOf(t)),t},remove:function(){var e=this,t=e.getEl(),n=e.parent(),r,o;if(e.items){var a=e.items().toArray();for(o=a.length;o--;)a[o].remove()}n&&n.items&&(r=[],n.items().each(function(t){t!==e&&r.push(t)}),n.items().set(r),n._lastRect=null),e._eventsRoot&&e._eventsRoot==e&&i.off(t);var s=e.getRoot().controlIdLookup;return s&&delete s[e._id],t&&t.parentNode&&t.parentNode.removeChild(t),e._rendered=!1,e},renderBefore:function(e){var t=this;return e.parentNode.insertBefore(i.createFragment(t.renderHtml()),e),t.postRender(),t},renderTo:function(e){var t=this;return e=e||t.getContainerElm(),e.appendChild(i.createFragment(t.renderHtml())),t.postRender(),t},postRender:function(){var e=this,t=e.settings,n,r,o,a,s;for(a in t)0===a.indexOf("on")&&e.on(a.substr(2),t[a]);if(e._eventsRoot){for(o=e.parent();!s&&o;o=o.parent())s=o._eventsRoot;if(s)for(a in s._nativeEvents)e._nativeEvents[a]=!0}e.bindPendingEvents(),t.style&&(n=e.getEl(),n&&(n.setAttribute("style",t.style),n.style.cssText=t.style)),e._visible||i.css(e.getEl(),"display","none"),e.settings.border&&(r=e.borderBox(),i.css(e.getEl(),{"border-top-width":r.top,"border-right-width":r.right,"border-bottom-width":r.bottom,"border-left-width":r.left}));var l=e.getRoot();l.controlIdLookup||(l.controlIdLookup={}),l.controlIdLookup[e._id]=e;for(var c in e._aria)e.aria(c,e._aria[c]);e.fire("postrender",{},!1)},scrollIntoView:function(e){function t(e,t){var n,r,i=e;for(n=r=0;i&&i!=t&&i.nodeType;)n+=i.offsetLeft||0,r+=i.offsetTop||0,i=i.offsetParent;return{x:n,y:r}}var n=this.getEl(),r=n.parentNode,i,o,a,s,l,c,u=t(n,r);return i=u.x,o=u.y,a=n.offsetWidth,s=n.offsetHeight,l=r.clientWidth,c=r.clientHeight,"end"==e?(i-=l-a,o-=c-s):"center"==e&&(i-=l/2-a/2,o-=c/2-s/2),r.scrollLeft=i,r.scrollTop=o,this},bindPendingEvents:function(){function e(e){var t=o.getParentCtrl(e.target);t&&t.fire(e.type,e)}function t(){var e=d._lastHoverCtrl;e&&(e.fire("mouseleave",{target:e.getEl()}),e.parents().each(function(e){e.fire("mouseleave",{target:e.getEl()})}),d._lastHoverCtrl=null)}function n(e){var t=o.getParentCtrl(e.target),n=d._lastHoverCtrl,r=0,i,a,s;if(t!==n){if(d._lastHoverCtrl=t,a=t.parents().toArray().reverse(),a.push(t),n){for(s=n.parents().toArray().reverse(),s.push(n),r=0;r=r;i--)n=s[i],n.fire("mouseleave",{target:n.getEl()})}for(i=r;il;l++)d=u[l]._eventsRoot;for(d||(d=u[u.length-1]||o),o._eventsRoot=d,c=l,l=0;c>l;l++)u[l]._eventsRoot=d;var h=d._delegates;h||(h=d._delegates={});for(p in f){if(!f)return!1;"wheel"!==p||s?("mouseenter"===p||"mouseleave"===p?d._hasMouseEnter||(i.on(d.getEl(),"mouseleave",t),i.on(d.getEl(),"mouseover",n),d._hasMouseEnter=1):h[p]||(i.on(d.getEl(),p,e),h[p]=!0),f[p]=!1):a?i.on(o.getEl(),"mousewheel",r):i.on(o.getEl(),"DOMMouseScroll",r)}}},getRoot:function(){for(var e=this,t,n=[];e;){if(e.rootControl){t=e.rootControl;break}n.push(e),t=e,e=e.parent()}t||(t=this);for(var r=n.length;r--;)n[r].rootControl=t;return t},reflow:function(){return this.repaint(),this}});return c}),r(G,[],function(){var e={},t;return{add:function(t,n){e[t.toLowerCase()]=n},has:function(t){return!!e[t.toLowerCase()]},create:function(n,r){var i,o,a;if(!t){a=tinymce.ui;for(o in a)e[o.toLowerCase()]=a[o];t=!0}if("string"==typeof n?(r=r||{},r.type=n):(r=n,n=r.type),n=n.toLowerCase(),i=e[n],!i)throw new Error("Could not find control by type: "+n);return i=new i(r),i.type=n,i}}}),r(X,[],function(){return function(e){function t(e){return e=e||b,e&&e.getAttribute("role")}function n(e){for(var n,r=e||b;r=r.parentNode;)if(n=t(r))return n}function r(e){var t=b;return t?t.getAttribute("aria-"+e):void 0}function i(e){var t=e.tagName.toUpperCase();return"INPUT"==t||"TEXTAREA"==t}function o(e){return i(e)&&!e.hidden?!0:/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell)$/.test(t(e))?!0:!1}function a(e){function t(e){if(1==e.nodeType&&"none"!=e.style.display){o(e)&&n.push(e);for(var r=0;re?e=t.length-1:e>=t.length&&(e=0),t[e]&&t[e].focus(),e}function u(e,t){var n=-1,r=s();t=t||a(r.getEl());for(var i=0;i=0&&(n=t.getEl(),n&&n.parentNode.removeChild(n),n=e.getEl(),n&&n.parentNode.removeChild(n)),t.parent(this)},create:function(t){var n=this,i,a=[];return o.isArray(t)||(t=[t]),o.each(t,function(t){t&&(t instanceof e||("string"==typeof t&&(t={type:t}),i=o.extend({},n.settings.defaults,t),t.type=i.type=i.type||t.type||n.settings.defaultType||(i.defaults?i.defaults.type:null),t=r.create(i)),a.push(t))}),a},renderNew:function(){var e=this;return e.items().each(function(t,n){var r,i;t.parent(e),t._rendered||(r=e.getEl("body"),i=a.createFragment(t.renderHtml()),r.hasChildNodes()&&n<=r.childNodes.length-1?r.insertBefore(i,r.childNodes[n]):r.appendChild(i),t.postRender())}),e._layout.applyClasses(e),e._lastRect=null,e},append:function(e){return this.add(e).renderNew()},prepend:function(e){var t=this;return t.items().set(t.create(e).concat(t.items().toArray())),t.renderNew()},insert:function(e,t,n){var r=this,i,o,a;return e=r.create(e),i=r.items(),!n&&t=0&&t
          '+(e.settings.html||"")+t.renderHtml(e)+"
          "},postRender:function(){var e=this,t;return e.items().exec("postRender"),e._super(),e._layout.postRender(e),e._rendered=!0,e.settings.style&&a.css(e.getEl(),e.settings.style),e.settings.border&&(t=e.borderBox(),a.css(e.getEl(),{"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left})),e.parent()||(e.keyboardNav=new i({root:e})),e},initLayoutRect:function(){var e=this,t=e._super();return e._layout.recalc(e),t},recalc:function(){var e=this,t=e._layoutRect,n=e._lastRect;return n&&n.w==t.w&&n.h==t.h?void 0:(e._layout.recalc(e),t=e.layoutRect(),e._lastRect={x:t.x,y:t.y,w:t.w,h:t.h},!0)},reflow:function(){var t;if(this.visible()){for(e.repaintControls=[],e.repaintControls.map={},this.recalc(),t=e.repaintControls.length;t--;)e.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),e.repaintControls=[]}return this}})}),r(Q,[Y],function(e){function t(){var e=document,t,n,r,i,o,a,s,l,c=Math.max;return t=e.documentElement,n=e.body,r=c(t.scrollWidth,n.scrollWidth),i=c(t.clientWidth,n.clientWidth),o=c(t.offsetWidth,n.offsetWidth),a=c(t.scrollHeight,n.scrollHeight),s=c(t.clientHeight,n.clientHeight),l=c(t.offsetHeight,n.offsetHeight),{width:o>r?i:r,height:l>a?s:a}}return function(n,r){function i(){return a.getElementById(r.handle||n)}var o,a=document,s,l,c,u,d,f;r=r||{},l=function(n){var l=t(),p,h;n.preventDefault(),s=n.button,p=i(),d=n.screenX,f=n.screenY,h=window.getComputedStyle?window.getComputedStyle(p,null).getPropertyValue("cursor"):p.runtimeStyle.cursor,o=a.createElement("div"),e.css(o,{position:"absolute",top:0,left:0,width:l.width,height:l.height,zIndex:2147483647,opacity:1e-4,cursor:h}),a.body.appendChild(o),e.on(a,"mousemove",u),e.on(a,"mouseup",c),r.start(n)},u=function(e){return e.button!==s?c(e):(e.deltaX=e.screenX-d,e.deltaY=e.screenY-f,e.preventDefault(),void r.drag(e))},c=function(t){e.off(a,"mousemove",u),e.off(a,"mouseup",c),o.parentNode.removeChild(o),r.stop&&r.stop(t)},this.destroy=function(){e.off(i())},e.on(i(),"mousedown",l)}}),r(Z,[Y,Q],function(e,t){return{init:function(){var e=this;e.on("repaint",e.renderScroll)},renderScroll:function(){function n(){function t(t,a,s,l,c,u){var d,f,p,h,m,g,v,y,b;if(f=i.getEl("scroll"+t)){if(y=a.toLowerCase(),b=s.toLowerCase(),i.getEl("absend")&&e.css(i.getEl("absend"),y,i.layoutRect()[l]-1),!c)return void e.css(f,"display","none");e.css(f,"display","block"),d=i.getEl("body"),p=i.getEl("scroll"+t+"t"),h=d["client"+s]-2*o,h-=n&&r?f["client"+u]:0,m=d["scroll"+s],g=h/m,v={},v[y]=d["offset"+a]+o,v[b]=h,e.css(f,v),v={},v[y]=d["scroll"+a]*g,v[b]=h*g,e.css(p,v)}}var n,r,a;a=i.getEl("body"),n=a.scrollWidth>a.clientWidth,r=a.scrollHeight>a.clientHeight,t("h","Left","Width","contentW",n,"Height"),t("v","Top","Height","contentH",r,"Width")}function r(){function n(n,r,a,s,l){var c,u=i._id+"-scroll"+n,d=i.classPrefix;i.getEl().appendChild(e.createFragment('
          ')),i.draghelper=new t(u+"t",{start:function(){c=i.getEl("body")["scroll"+r],e.addClass(e.get(u),d+"active")},drag:function(e){var t,u,d,f,p=i.layoutRect();u=p.contentW>p.innerW,d=p.contentH>p.innerH,f=i.getEl("body")["client"+a]-2*o,f-=u&&d?i.getEl("scroll"+n)["client"+l]:0,t=f/i.getEl("body")["scroll"+a],i.getEl("body")["scroll"+r]=c+e["delta"+s]/t},stop:function(){e.removeClass(e.get(u),d+"active")}})}i.addClass("scroll"),n("v","Top","Height","Y","Width"),n("h","Left","Width","X","Height")}var i=this,o=2;i.settings.autoScroll&&(i._hasScroll||(i._hasScroll=!0,r(),i.on("wheel",function(e){var t=i.getEl("body");t.scrollLeft+=10*(e.deltaX||0),t.scrollTop+=10*e.deltaY,n()}),e.on(i.getEl("body"),"scroll",n)),n())}}}),r(et,[J,Z],function(e,t){return e.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[t],renderHtml:function(){var e=this,t=e._layout,n=e.settings.html;return e.preRender(),t.preRender(e),"undefined"==typeof n?n='
          '+t.renderHtml(e)+"
          ":("function"==typeof n&&(n=n.call(e)),e._hasBody=!1),'
          '+(e._preBodyHtml||"")+n+"
          "}})}),r(tt,[Y],function(e){function t(t,n,r){var i,o,a,s,l,c,u,d,f,p;return f=e.getViewPort(),o=e.getPos(n),a=o.x,s=o.y,t._fixed&&"static"==e.getRuntimeStyle(document.body,"position")&&(a-=f.x,s-=f.y),i=t.getEl(),p=e.getSize(i),l=p.width,c=p.height,p=e.getSize(n),u=p.width,d=p.height,r=(r||"").split(""),"b"===r[0]&&(s+=d),"r"===r[1]&&(a+=u),"c"===r[0]&&(s+=Math.round(d/2)),"c"===r[1]&&(a+=Math.round(u/2)),"b"===r[3]&&(s-=c),"r"===r[4]&&(a-=l),"c"===r[3]&&(s-=Math.round(c/2)),"c"===r[4]&&(a-=Math.round(l/2)),{x:a,y:s,w:l,h:c}}return{testMoveRel:function(n,r){for(var i=e.getViewPort(),o=0;o0&&a.x+a.w0&&a.y+a.hi.x&&a.x+a.wi.y&&a.y+a.he?0:e+n>t?(e=t-n,0>e?0:e):e}var i=this;if(i.settings.constrainToViewport){var o=e.getViewPort(window),a=i.layoutRect();t=r(t,o.w+o.x,a.w),n=r(n,o.h+o.y,a.h)}return i._rendered?i.layoutRect({x:t,y:n}).repaint():(i.settings.x=t,i.settings.y=n),i.fire("move",{x:t,y:n}),i}}}),r(nt,[Y],function(e){return{resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(t,n){if(1>=t||1>=n){var r=e.getWindowSize();t=1>=t?t*r.w:t,n=1>=n?n*r.h:n}return this._layoutRect.autoResize=!1,this.layoutRect({minW:t,minH:n,w:t,h:n}).reflow()},resizeBy:function(e,t){var n=this,r=n.layoutRect();return n.resizeTo(r.w+e,r.h+t)}}}),r(rt,[et,tt,nt,Y],function(e,t,n,r){function i(){function e(e,t){for(;e;){if(e==t)return!0;e=e.parent()}}u||(u=function(t){if(2!=t.button)for(var n=p.length;n--;){var r=p[n],i=r.getParentCtrl(t.target);if(r.settings.autohide){if(i&&(e(i,r)||r.parent()===i))continue;t=r.fire("autohide",{target:t.target}),t.isDefaultPrevented()||r.hide()}}},r.on(document,"click",u))}function o(){d||(d=function(){var e;for(e=p.length;e--;)s(p[e])},r.on(window,"scroll",d))}function a(){if(!f){var e=document.documentElement,t=e.clientWidth,n=e.clientHeight;f=function(){document.all&&t==e.clientWidth&&n==e.clientHeight||(t=e.clientWidth,n=e.clientHeight,g.hideAll())},r.on(window,"resize",f)}}function s(e){function t(t,n){for(var r,i=0;in&&(e.fixed(!1).layoutRect({y:e._autoFixY}).repaint(),t(!1,e._autoFixY-n)):(e._autoFixY=e.layoutRect().y,e._autoFixY
          '),n=n.firstChild,t.getContainerElm().appendChild(n),setTimeout(function(){r.addClass(n,i+"in"),r.addClass(t.getEl(),i+"in")},0),m=!0),l(!0,t)}}),t.on("show",function(){t.parents().each(function(e){return e._fixed?(t.fixed(!0),!1):void 0})}),e.popover&&(t._preBodyHtml='
          ',t.addClass("popover").addClass("bottom").addClass(t.isRtl()?"end":"start"))},fixed:function(e){var t=this;if(t._fixed!=e){if(t._rendered){var n=r.getViewPort();e?t.layoutRect().y-=n.y:t.layoutRect().y+=n.y}t.toggleClass("fixed",e),t._fixed=e}return t},show:function(){var e=this,t,n=e._super();for(t=p.length;t--&&p[t]!==e;);return-1===t&&p.push(e),n},hide:function(){return c(this),l(!1,this),this._super()},hideAll:function(){g.hideAll()},close:function(){var e=this;return e.fire("close").isDefaultPrevented()||(e.remove(),l(!1,e)),e},remove:function(){c(this),this._super()},postRender:function(){var e=this;return e.settings.bodyRole&&this.getEl("body").setAttribute("role",e.settings.bodyRole),e._super()}});return g.hideAll=function(){for(var e=p.length;e--;){var t=p[e];t&&t.settings.autohide&&(t.hide(),p.splice(e,1))}},g}),r(it,[rt,et,Y,Q],function(e,t,n,r){var i=e.extend({modal:!0,Defaults:{border:1,layout:"flex",containerCls:"panel",role:"dialog",callbacks:{submit:function(){this.fire("submit",{data:this.toJSON()})},close:function(){this.close()}}},init:function(e){var n=this;n._super(e),n.isRtl()&&n.addClass("rtl"),n.addClass("window"),n._fixed=!0,e.buttons&&(n.statusbar=new t({layout:"flex",border:"1 0 0 0",spacing:3,padding:10,align:"center",pack:n.isRtl()?"start":"end",defaults:{type:"button"},items:e.buttons}),n.statusbar.addClass("foot"),n.statusbar.parent(n)),n.on("click",function(e){-1!=e.target.className.indexOf(n.classPrefix+"close")&&n.close()}),n.on("cancel",function(){n.close()}),n.aria("describedby",n.describedBy||n._id+"-none"),n.aria("label",e.title),n._fullscreen=!1},recalc:function(){var e=this,t=e.statusbar,r,i,o,a;e._fullscreen&&(e.layoutRect(n.getWindowSize()),e.layoutRect().contentH=e.layoutRect().innerH),e._super(),r=e.layoutRect(),e.settings.title&&!e._fullscreen&&(i=r.headerW,i>r.w&&(o=r.x-Math.max(0,i/2),e.layoutRect({w:i,x:o}),a=!0)),t&&(t.layoutRect({w:e.layoutRect().innerW}).recalc(),i=t.layoutRect().minW+r.deltaW,i>r.w&&(o=r.x-Math.max(0,i-r.w),e.layoutRect({w:i,x:o}),a=!0)),a&&e.recalc()},initLayoutRect:function(){var e=this,t=e._super(),r=0,i;if(e.settings.title&&!e._fullscreen){i=e.getEl("head");var o=n.getSize(i);t.headerW=o.width,t.headerH=o.height,r+=t.headerH}e.statusbar&&(r+=e.statusbar.layoutRect().h),t.deltaH+=r,t.minH+=r,t.h+=r;var a=n.getWindowSize();return t.x=Math.max(0,a.w/2-t.w/2),t.y=Math.max(0,a.h/2-t.h/2),t},renderHtml:function(){var e=this,t=e._layout,n=e._id,r=e.classPrefix,i=e.settings,o="",a="",s=i.html;return e.preRender(),t.preRender(e),i.title&&(o='
          '+e.encode(i.title)+'
          '),i.url&&(s=''),"undefined"==typeof s&&(s=t.renderHtml(e)),e.statusbar&&(a=e.statusbar.renderHtml()),'
          '+o+'
          '+s+"
          "+a+"
          "},fullscreen:function(e){var t=this,r=document.documentElement,i,o=t.classPrefix,a;if(e!=t._fullscreen)if(n.on(window,"resize",function(){var e;if(t._fullscreen)if(i)t._timer||(t._timer=setTimeout(function(){var e=n.getWindowSize();t.moveTo(0,0).resizeTo(e.w,e.h),t._timer=0},50));else{e=(new Date).getTime();var r=n.getWindowSize();t.moveTo(0,0).resizeTo(r.w,r.h),(new Date).getTime()-e>50&&(i=!0)}}),a=t.layoutRect(),t._fullscreen=e,e){t._initial={x:a.x,y:a.y,w:a.w,h:a.h},t._borderBox=t.parseBox("0"),t.getEl("head").style.display="none",a.deltaH-=a.headerH+2,n.addClass(r,o+"fullscreen"),n.addClass(document.body,o+"fullscreen"),t.addClass("fullscreen");var s=n.getWindowSize();t.moveTo(0,0).resizeTo(s.w,s.h)}else t._borderBox=t.parseBox(t.settings.border),t.getEl("head").style.display="",a.deltaH+=a.headerH,n.removeClass(r,o+"fullscreen"),n.removeClass(document.body,o+"fullscreen"),t.removeClass("fullscreen"),t.moveTo(t._initial.x,t._initial.y).resizeTo(t._initial.w,t._initial.h);return t.reflow()},postRender:function(){var e=this,t;setTimeout(function(){e.addClass("in")},0),e._super(),e.statusbar&&e.statusbar.postRender(),e.focus(),this.dragHelper=new r(e._id+"-dragh",{start:function(){t={x:e.layoutRect().x,y:e.layoutRect().y}},drag:function(n){e.moveTo(t.x+n.deltaX,t.y+n.deltaY)}}),e.on("submit",function(t){t.isDefaultPrevented()||e.close()})},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var e=this,t=e.classPrefix;e.dragHelper.destroy(),e._super(),e.statusbar&&this.statusbar.remove(),e._fullscreen&&(n.removeClass(document.documentElement,t+"fullscreen"),n.removeClass(document.body,t+"fullscreen"))},getContentWindow:function(){var e=this.getEl().getElementsByTagName("iframe")[0];return e?e.contentWindow:null}});return i}),r(ot,[it],function(e){var t=e.extend({init:function(e){e={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}},this._super(e)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(n){function r(e,t,n){return{type:"button",text:e,subtype:n?"primary":"",onClick:function(e){e.control.parents()[1].close(),o(t)}}}var i,o=n.callback||function(){};switch(n.buttons){case t.OK_CANCEL:i=[r("Ok",!0,!0),r("Cancel",!1)];break;case t.YES_NO:case t.YES_NO_CANCEL:i=[r("Yes",1,!0),r("No",0)],n.buttons==t.YES_NO_CANCEL&&i.push(r("Cancel",-1));break;default:i=[r("Ok",!0,!0)]}return new e({padding:20,x:n.x,y:n.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:i,title:n.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:n.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:n.onClose,onCancel:function(){o(!1)}}).renderTo(document.body).reflow()},alert:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,t.msgBox(e)},confirm:function(e,n){return"string"==typeof e&&(e={text:e}),e.callback=n,e.buttons=t.OK_CANCEL,t.msgBox(e)}}});return t}),r(at,[it,ot],function(e,t){return function(n){function r(){return o.length?o[o.length-1]:void 0}var i=this,o=[];i.windows=o,n.on("remove",function(){for(var e=o.length;e--;)o[e].close()}),i.open=function(t,r){var i;return n.editorManager.setActive(n),t.title=t.title||" ",t.url=t.url||t.file,t.url&&(t.width=parseInt(t.width||320,10),t.height=parseInt(t.height||240,10)),t.body&&(t.items={defaults:t.defaults,type:t.bodyType||"form",items:t.body}),t.url||t.buttons||(t.buttons=[{text:"Ok",subtype:"primary",onclick:function(){i.find("form")[0].submit()}},{text:"Cancel",onclick:function(){i.close()}}]),i=new e(t),o.push(i),i.on("close",function(){for(var e=o.length;e--;)o[e]===i&&o.splice(e,1);o.length||n.focus()}),t.data&&i.on("postRender",function(){this.find("*").each(function(e){var n=e.name();n in t.data&&e.value(t.data[n])})}),i.features=t||{},i.params=r||{},1===o.length&&n.nodeChanged(),i.renderTo().reflow()},i.alert=function(e,r,i){t.alert(e,function(){r?r.call(i||this):n.focus()})},i.confirm=function(e,n,r){t.confirm(e,function(e){n.call(r||this,e)})},i.close=function(){r()&&r().close()},i.getParams=function(){return r()?r().params:null},i.setParams=function(e){r()&&(r().params=e)},i.getWindows=function(){return o}}}),r(st,[B,x,_,g,u,d],function(e,t,n,r,i,o){return function(a){function s(e,t){try{a.getDoc().execCommand(e,!1,t)}catch(n){}}function l(){var e=a.getDoc().documentMode;return e?e:6}function c(e){return e.isDefaultPrevented()}function u(){function t(e){var t=new i(function(){});o.each(a.getBody().getElementsByTagName("*"),function(e){"SPAN"==e.tagName&&e.setAttribute("mce-data-marked",1),!e.hasAttribute("data-mce-style")&&e.hasAttribute("style")&&a.dom.setAttrib(e,"style",a.dom.getAttrib(e,"style"))}),t.observe(a.getDoc(),{childList:!0,attributes:!0,subtree:!0,attributeFilter:["style"]}),a.getDoc().execCommand(e?"ForwardDelete":"Delete",!1,null);var n=a.selection.getRng(),r=n.startContainer.parentNode;o.each(t.takeRecords(),function(e){if(q.isChildOf(e.target,a.getBody())){if("style"==e.attributeName){var t=e.target.getAttribute("data-mce-style");t?e.target.setAttribute("style",t):e.target.removeAttribute("style")}o.each(e.addedNodes,function(e){if("SPAN"==e.nodeName&&!e.getAttribute("mce-data-marked")){var t,i;e==r&&(t=n.startOffset,i=e.firstChild),q.remove(e,!0),i&&(n.setStart(i,t),n.setEnd(i,t),a.selection.setRng(n))}})}}),t.disconnect(),o.each(a.dom.select("span[mce-data-marked]"),function(e){e.removeAttribute("mce-data-marked")})}var n=a.getDoc(),r="data:text/mce-internal,",i=window.MutationObserver,s,l;i||(s=!0,i=function(){function e(e){var t=e.relatedNode||e.target;n.push({target:t,addedNodes:[t]})}function t(e){var t=e.relatedNode||e.target;n.push({target:t,attributeName:e.attrName})}var n=[],r;this.observe=function(n){r=n,r.addEventListener("DOMSubtreeModified",e,!1),r.addEventListener("DOMNodeInsertedIntoDocument",e,!1),r.addEventListener("DOMNodeInserted",e,!1),r.addEventListener("DOMAttrModified",t,!1)},this.disconnect=function(){r.removeEventListener("DOMSubtreeModified",e,!1),r.removeEventListener("DOMNodeInsertedIntoDocument",e,!1),r.removeEventListener("DOMNodeInserted",e,!1),r.removeEventListener("DOMAttrModified",t,!1)},this.takeRecords=function(){return n}}),a.on("keydown",function(n){var r=n.keyCode==$,i=e.metaKeyPressed(n);if(!c(n)&&(r||n.keyCode==U)){var o=a.selection.getRng(),s=o.startContainer,l=o.startOffset;if(!i&&o.collapsed&&3==s.nodeType&&(r?l0))return;n.preventDefault(),i&&a.selection.getSel().modify("extend",r?"forward":"backward","word"),t(r)}}),a.on("keypress",function(n){c(n)||j.isCollapsed()||!n.charCode||e.metaKeyPressed(n)||(n.preventDefault(),t(!0),a.selection.setContent(String.fromCharCode(n.charCode)))}),a.addCommand("Delete",function(){t()}),a.addCommand("ForwardDelete",function(){t(!0)}),s||(a.on("dragstart",function(e){var t;a.selection.isCollapsed()&&"IMG"==e.target.tagName&&j.select(e.target),l=j.getRng(),t=a.selection.getContent(),t.length>0&&e.dataTransfer.setData("URL","data:text/mce-internal,"+escape(t))}),a.on("drop",function(e){if(!c(e)){var i=e.dataTransfer.getData("URL");if(!i||-1==i.indexOf(r)||!n.caretRangeFromPoint)return;i=unescape(i.substr(r.length)),n.caretRangeFromPoint&&(e.preventDefault(),window.setTimeout(function(){var r=n.caretRangeFromPoint(e.x,e.y);l&&(j.setRng(l),l=null),t(),j.setRng(r),a.insertContent(i)},0))}}),a.on("cut",function(e){!c(e)&&e.clipboardData&&(e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/html",a.selection.getContent()),e.clipboardData.setData("text/plain",a.selection.getContent({format:"text"})),t(!0))}))}function d(){function e(e){var t=q.create("body"),n=e.cloneContents();return t.appendChild(n),j.serializer.serialize(t,{format:"html"})}function n(n){if(!n.setStart){if(n.item)return!1;var r=n.duplicate();return r.moveToElementText(a.getBody()),t.compareRanges(n,r)}var i=e(n),o=q.createRng();o.selectNode(a.getBody());var s=e(o);return i===s}a.on("keydown",function(e){var t=e.keyCode,r,i;if(!c(e)&&(t==$||t==U)){if(r=a.selection.isCollapsed(),i=a.getBody(),r&&!q.isEmpty(i))return;if(!r&&!n(a.selection.getRng()))return;e.preventDefault(),a.setContent(""),i.firstChild&&q.isBlock(i.firstChild)?a.selection.setCursorLocation(i.firstChild,0):a.selection.setCursorLocation(i,0),a.nodeChanged()}})}function f(){a.shortcuts.add("ctrl+a",null,"SelectAll")}function p(){a.settings.content_editable||(q.bind(a.getDoc(),"focusin",function(){j.setRng(j.getRng())}),q.bind(a.getDoc(),"mousedown mouseup",function(e){e.target==a.getDoc().documentElement&&(a.getBody().focus(),"mousedown"==e.type?j.placeCaretAt(e.clientX,e.clientY):j.setRng(j.getRng()))}))}function h(){a.on("keydown",function(e){if(!c(e)&&e.keyCode===U){if(!a.getBody().getElementsByTagName("hr").length)return;if(j.isCollapsed()&&0===j.getRng(!0).startOffset){var t=j.getNode(),n=t.previousSibling;if("HR"==t.nodeName)return q.remove(t),void e.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(q.remove(n),e.preventDefault())}}})}function m(){window.Range.prototype.getClientRects||a.on("mousedown",function(e){if(!c(e)&&"HTML"===e.target.nodeName){var t=a.getBody();t.blur(),setTimeout(function(){t.focus()},0)}})}function g(){a.on("click",function(e){var t=e.target;/^(IMG|HR)$/.test(t.nodeName)&&(e.preventDefault(),j.getSel().setBaseAndExtent(t,0,t,1),a.nodeChanged()),"A"==t.nodeName&&q.hasClass(t,"mce-item-anchor")&&(e.preventDefault(),j.select(t))})}function v(){function e(){var e=q.getAttribs(j.getStart().cloneNode(!1));return function(){var t=j.getStart();t!==a.getBody()&&(q.setAttrib(t,"style",null),V(e,function(e){t.setAttributeNode(e.cloneNode(!0))}))}}function t(){return!j.isCollapsed()&&q.getParent(j.getStart(),q.isBlock)!=q.getParent(j.getEnd(),q.isBlock)}a.on("keypress",function(n){var r;return c(n)||8!=n.keyCode&&46!=n.keyCode||!t()?void 0:(r=e(),a.getDoc().execCommand("delete",!1,null),r(),n.preventDefault(),!1)}),q.bind(a.getDoc(),"cut",function(n){var r;!c(n)&&t()&&(r=e(),setTimeout(function(){r()},0))})}function y(){document.body.setAttribute("role","application")}function b(){a.on("keydown",function(e){if(!c(e)&&e.keyCode===U&&j.isCollapsed()&&0===j.getRng(!0).startOffset){var t=j.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}})}function C(){l()>7||(s("RespectVisibilityInDesign",!0),a.contentStyles.push(".mceHideBrInPre pre br {display: none}"),q.addClass(a.getBody(),"mceHideBrInPre"),K.addNodeFilter("pre",function(e){for(var t=e.length,r,i,o,a;t--;)for(r=e[t].getAll("br"),i=r.length;i--;)o=r[i],a=o.prev,a&&3===a.type&&"\n"!=a.value.charAt(a.value-1)?a.value+="\n":o.parent.insert(new n("#text",3),o,!0).value="\n"}),G.addNodeFilter("pre",function(e){for(var t=e.length,n,r,i,o;t--;)for(n=e[t].getAll("br"),r=n.length;r--;)i=n[r],o=i.prev,o&&3==o.type&&(o.value=o.value.replace(/\r?\n$/,""))}))}function x(){q.bind(a.getBody(),"mouseup",function(){var e,t=j.getNode();"IMG"==t.nodeName&&((e=q.getStyle(t,"width"))&&(q.setAttrib(t,"width",e.replace(/[^0-9%]+/g,"")),q.setStyle(t,"width","")),(e=q.getStyle(t,"height"))&&(q.setAttrib(t,"height",e.replace(/[^0-9%]+/g,"")),q.setStyle(t,"height","")))})}function w(){a.on("keydown",function(t){var n,r,i,o,s;if(!c(t)&&t.keyCode==e.BACKSPACE&&(n=j.getRng(),r=n.startContainer,i=n.startOffset,o=q.getRoot(),s=r,n.collapsed&&0===i)){for(;s&&s.parentNode&&s.parentNode.firstChild==s&&s.parentNode!=o;)s=s.parentNode;"BLOCKQUOTE"===s.tagName&&(a.formatter.toggle("blockquote",null,s),n=q.createRng(),n.setStart(r,0),n.setEnd(r,0),j.setRng(n))}})}function _(){function e(){a._refreshContentEditable(),s("StyleWithCSS",!1),s("enableInlineTableEditing",!1),Y.object_resizing||s("enableObjectResizing",!1)}Y.readonly||a.on("BeforeExecCommand MouseDown",e)}function E(){function e(){V(q.select("a"),function(e){var t=e.parentNode,n=q.getRoot();if(t.lastChild===e){for(;t&&!q.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}q.add(t,"br",{"data-mce-bogus":1})}})}a.on("SetContent ExecCommand",function(t){("setcontent"==t.type||"mceInsertLink"===t.command)&&e()})}function N(){Y.forced_root_block&&a.on("init",function(){s("DefaultParagraphSeparator",Y.forced_root_block)})}function k(){a.on("Undo Redo SetContent",function(e){e.initial||a.execCommand("mceRepaint")})}function S(){a.on("keydown",function(e){var t;c(e)||e.keyCode!=U||(t=a.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),a.undoManager.beforeChange(),q.remove(t.item(0)),a.undoManager.add()))})}function T(){var e;l()>=10&&(e="",V("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),a.contentStyles.push(e+"{padding-right: 1px !important}"))}function R(){l()<9&&(K.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),G.addNodeFilter("noscript",function(e){for(var t=e.length,i,o,a;t--;)i=e[t],o=e[t].firstChild,o?o.value=r.decode(o.value):(a=i.attributes.map["data-mce-innertext"],a&&(i.attr("data-mce-innertext",null),o=new n("#text",3),o.value=a,o.raw=!0,i.append(o)))}))}function A(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),q.unbind(r,"mouseup",n),q.unbind(r,"mousemove",t),a=o=0}var r=q.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,q.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(q.bind(r,"mouseup",n),q.bind(r,"mousemove",t),q.getRoot().focus(),a.select())}})}function B(){a.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||j.normalize()},!0)}function D(){a.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function L(){a.inline||a.on("keydown",function(){document.activeElement==document.body&&a.getWin().focus()})}function H(){a.inline||(a.contentStyles.push("body {min-height: 150px}"),a.on("click",function(e){"HTML"==e.target.nodeName&&(a.getBody().focus(),a.selection.normalize(),a.nodeChanged())}))}function M(){i.mac&&a.on("keydown",function(t){!e.metaKeyPressed(t)||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),a.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","word"))})}function P(){s("AutoUrlDetect",!1)}function O(){a.inline||a.on("focus blur beforegetcontent",function(){var e=a.dom.create("br");a.getBody().appendChild(e),e.parentNode.removeChild(e)},!0)}function I(){a.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),a.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function F(){a.on("touchstart",function(e){var t,n,r,i;t=e.target,n=(new Date).getTime(),i=e.changedTouches,!i||i.length>1||(r=i[0],a.once("touchend",function(e){var i=e.changedTouches[0],o;(new Date).getTime()-n>500||Math.abs(r.clientX-i.clientX)>5||Math.abs(r.clientY-i.clientY)>5||(o={target:t},V("pageX pageY clientX clientY screenX screenY".split(" "),function(e){o[e]=i[e]}),o=a.fire("click",o),o.isDefaultPrevented()||(a.selection.placeCaretAt(i.clientX,i.clientY),a.nodeChanged()))}))})}function z(){a.on("init",function(){a.dom.bind(a.getBody(),"submit",function(e){e.preventDefault()})})}function W(){K.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}var V=o.each,U=e.BACKSPACE,$=e.DELETE,q=a.dom,j=a.selection,Y=a.settings,K=a.parser,G=a.serializer,X=i.gecko,J=i.ie,Q=i.webkit;w(),d(),B(),Q&&(u(),p(),g(),N(),z(),b(),W(),F(),i.iOS?(L(),H(),I()):f()),J&&i.ie<11&&(h(),y(),C(),x(),S(),T(),R(),A()),i.ie>=11&&(H(),O(),b()),i.ie&&(f(),P()),X&&(h(),m(),v(),_(),E(),k(),D(),M(),b())}}),r(lt,[$],function(e){function t(t){return t._eventDispatcher||(t._eventDispatcher=new e({scope:t,toggleEvent:function(n,r){e.isNative(n)&&t.toggleNativeEvent&&t.toggleNativeEvent(n,r)}})),t._eventDispatcher}return{fire:function(e,n,r){var i=this;if(i.removed&&"remove"!==e)return n;if(n=t(i).fire(e,n,r),r!==!1&&i.parent)for(var o=i.parent();o&&!n.isPropagationStopped();)o.fire(e,n,!1),o=o.parent();return n},on:function(e,n,r){return t(this).on(e,n,r)},off:function(e,n){return t(this).off(e,n)},once:function(e,n){return t(this).once(e,n)},hasEventListeners:function(e){return t(this).has(e)}}}),r(ct,[lt,y,d],function(e,t,n){function r(e,t){return"selectionchange"==t?e.getDoc():!e.inline&&/^mouse|click|contextmenu|drop|dragover|dragend/.test(t)?e.getDoc().documentElement:e.settings.event_root?(e.eventRoot||(e.eventRoot=o.select(e.settings.event_root)[0]),e.eventRoot):e.getBody()}function i(e,t){var n=r(e,t),i;if(e.delegates||(e.delegates={}),!e.delegates[t])if(e.settings.event_root){if(a||(a={},e.editorManager.on("removeEditor",function(){var t;if(!e.editorManager.activeEditor&&a){for(t in a)e.dom.unbind(r(e,t));a=null}})),a[t])return;i=function(n){for(var r=n.target,i=e.editorManager.editors,a=i.length;a--;){var s=i[a].getBody();(s===r||o.isChildOf(r,s))&&(i[a].hidden||i[a].fire(t,n))}},a[t]=i,o.bind(n,t,i)}else i=function(n){e.hidden||e.fire(t,n)},o.bind(n,t,i),e.delegates[t]=i}var o=t.DOM,a,s={bindPendingEventDelegates:function(){var e=this;n.each(e._pendingNativeEvents,function(t){i(e,t)})},toggleNativeEvent:function(e,t){var n=this;n.settings.readonly||"focus"!=e&&"blur"!=e&&(t?n.initialized?i(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&(n.dom.unbind(r(n,e),e,n.delegates[e]),delete n.delegates[e]))},unbindAllNativeEvents:function(){var e=this,t;if(e.delegates){for(t in e.delegates)e.dom.unbind(r(e,t),t,e.delegates[t]);delete e.delegates}e.inline||(e.getBody().onload=null,e.dom.unbind(e.getWin()),e.dom.unbind(e.getDoc())),e.dom.unbind(e.getBody()),e.dom.unbind(e.getContainer())}};return s=n.extend({},e,s)}),r(ut,[d,u],function(e,t){var n=e.each,r=e.explode,i={f9:120,f10:121,f11:122};return function(o){var a=this,s={};o.on("keyup keypress keydown",function(e){(e.altKey||e.ctrlKey||e.metaKey)&&!e.isDefaultPrevented()&&n(s,function(n){var r=t.mac?e.metaKey:e.ctrlKey;if(n.ctrl==r&&n.alt==e.altKey&&n.shift==e.shiftKey)return e.keyCode==n.keyCode||e.charCode&&e.charCode==n.charCode?(e.preventDefault(),"keydown"==e.type&&n.func.call(n.scope),!0):void 0 +})}),a.add=function(t,a,l,c){var u;return u=l,"string"==typeof l?l=function(){o.execCommand(u,!1,null)}:e.isArray(u)&&(l=function(){o.execCommand(u[0],u[1],u[2])}),n(r(t.toLowerCase()),function(e){var t={func:l,scope:c||o,desc:o.translate(a),alt:!1,ctrl:!1,shift:!1};n(r(e,"+"),function(e){switch(e){case"alt":case"ctrl":case"shift":t[e]=!0;break;default:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=i[e]||e.toUpperCase().charCodeAt(0))}}),s[(t.ctrl?"ctrl":"")+","+(t.alt?"alt":"")+","+(t.shift?"shift":"")+","+t.keyCode]=t}),!0}}}),r(dt,[y,f,C,w,_,R,T,H,O,I,F,z,W,V,b,l,at,E,k,st,u,d,ct,ut],function(e,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E){function N(e,t,i){var o=this,a,s;a=o.documentBaseUrl=i.documentBaseURL,s=i.baseURI,o.settings=t=R({id:e,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:a,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",validate:!0,entity_encoding:"named",url_converter:o.convertURL,url_converter_scope:o,ie7_compat:!0},t),r.language=t.language||"en",r.languageLoad=t.language_load,r.baseURL=i.baseURL,o.id=t.id=e,o.isNotDirty=!0,o.plugins={},o.documentBaseURI=new h(t.document_base_url||a,{base_uri:s}),o.baseURI=s,o.contentCSS=[],o.contentStyles=[],o.shortcuts=new E(o),o.execCommands={},o.queryStateCommands={},o.queryValueCommands={},o.loadedCSS={},t.target&&(o.targetElm=t.target),o.suffix=i.suffix,o.editorManager=i,o.inline=t.inline,t.cache_suffix&&(x.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),i.fire("SetupEditor",o),o.execCallback("setup",o),o.$=n.overrideDefaults(function(){return{context:o.inline?o.getBody():o.getDoc(),element:o.getBody()}})}var k=e.DOM,S=r.ThemeManager,T=r.PluginManager,R=w.extend,A=w.each,B=w.explode,D=w.inArray,L=w.trim,H=w.resolve,M=g.Event,P=x.gecko,O=x.ie;return N.prototype={render:function(){function e(){k.unbind(window,"ready",e),n.render()}function t(){var e=m.ScriptLoader;if(r.language&&"en"!=r.language&&!r.language_url&&(r.language_url=n.editorManager.baseURL+"/langs/"+r.language+".js"),r.language_url&&e.add(r.language_url),r.theme&&"function"!=typeof r.theme&&"-"!=r.theme.charAt(0)&&!S.urls[r.theme]){var t=r.theme_url;t=t?n.documentBaseURI.toAbsolute(t):"themes/"+r.theme+"/theme"+o+".js",S.load(r.theme,t)}w.isArray(r.plugins)&&(r.plugins=r.plugins.join(" ")),A(r.external_plugins,function(e,t){T.load(t,e),r.plugins+=" "+t}),A(r.plugins.split(/[ ,]/),function(e){if(e=L(e),e&&!T.urls[e])if("-"==e.charAt(0)){e=e.substr(1,e.length);var t=T.dependencies(e);A(t,function(e){var t={prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"};e=T.createUrl(t,e),T.load(e.resource,e)})}else T.load(e,{prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"})}),e.loadQueue(function(){n.removed||n.init()})}var n=this,r=n.settings,i=n.id,o=n.suffix;if(!M.domLoaded)return void k.bind(window,"ready",e);if(n.getElement()&&x.contentEditable){r.inline?n.inline=!0:(n.orgVisibility=n.getElement().style.visibility,n.getElement().style.visibility="hidden");var a=n.getElement().form||k.getParent(i,"form");a&&(n.formElement=a,r.hidden_input&&!/TEXTAREA|INPUT/i.test(n.getElement().nodeName)&&(k.insertAfter(k.create("input",{type:"hidden",name:i}),i),n.hasHiddenInput=!0),n.formEventDelegate=function(e){n.fire(e.type,e)},k.bind(a,"submit reset",n.formEventDelegate),n.on("reset",function(){n.setContent(n.startContent,{format:"raw"})}),!r.submit_patch||a.submit.nodeType||a.submit.length||a._mceOldSubmit||(a._mceOldSubmit=a.submit,a.submit=function(){return n.editorManager.triggerSave(),n.isNotDirty=!0,a._mceOldSubmit(a)})),n.windowManager=new v(n),"xml"==r.encoding&&n.on("GetContent",function(e){e.save&&(e.content=k.encode(e.content))}),r.add_form_submit_trigger&&n.on("submit",function(){n.initialized&&n.save()}),r.add_unload_trigger&&(n._beforeUnload=function(){!n.initialized||n.destroyed||n.isHidden()||n.save({format:"raw",no_events:!0,set_dirty:!1})},n.editorManager.on("BeforeUnload",n._beforeUnload)),t()}},init:function(){function e(n){var r=T.get(n),i,o;i=T.urls[n]||t.documentBaseUrl.replace(/\/$/,""),n=L(n),r&&-1===D(m,n)&&(A(T.dependencies(n),function(t){e(t)}),o=new r(t,i,t.$),t.plugins[n]=o,o.init&&(o.init(t,i),m.push(n)))}var t=this,n=t.settings,r=t.getElement(),i,o,a,s,l,c,u,d,f,p,h,m=[];if(t.rtl=this.editorManager.i18n.rtl,t.editorManager.add(t),n.aria_label=n.aria_label||k.getAttrib(r,"aria-label",t.getLang("aria.rich_text_area")),n.theme&&("function"!=typeof n.theme?(n.theme=n.theme.replace(/-/,""),c=S.get(n.theme),t.theme=new c(t,S.urls[n.theme]),t.theme.init&&t.theme.init(t,S.urls[n.theme]||t.documentBaseUrl.replace(/\/$/,""),t.$)):t.theme=n.theme),A(n.plugins.replace(/\-/g,"").split(/[ ,]/),e),n.render_ui&&t.theme&&(t.orgDisplay=r.style.display,"function"!=typeof n.theme?(i=n.width||r.style.width||r.offsetWidth,o=n.height||r.style.height||r.offsetHeight,a=n.min_height||100,p=/^[0-9\.]+(|px)$/i,p.test(""+i)&&(i=Math.max(parseInt(i,10),100)),p.test(""+o)&&(o=Math.max(parseInt(o,10),a)),l=t.theme.renderUI({targetNode:r,width:i,height:o,deltaWidth:n.delta_width,deltaHeight:n.delta_height}),n.content_editable||(o=(l.iframeHeight||o)+("number"==typeof o?l.deltaHeight||0:""),a>o&&(o=a))):(l=n.theme(t,r),l.editorContainer.nodeType&&(l.editorContainer=l.editorContainer.id=l.editorContainer.id||t.id+"_parent"),l.iframeContainer.nodeType&&(l.iframeContainer=l.iframeContainer.id=l.iframeContainer.id||t.id+"_iframecontainer"),o=l.iframeHeight||r.offsetHeight),t.editorContainer=l.editorContainer),n.content_css&&A(B(n.content_css),function(e){t.contentCSS.push(t.documentBaseURI.toAbsolute(e))}),n.content_style&&t.contentStyles.push(n.content_style),n.content_editable)return r=s=l=null,t.initContentBody();for(t.iframeHTML=n.doctype+"",n.document_base_url!=t.documentBaseUrl&&(t.iframeHTML+=''),!x.caretAfter&&n.ie7_compat&&(t.iframeHTML+=''),t.iframeHTML+='',h=0;h',t.loadedCSS[g]=!0}d=n.body_id||"tinymce",-1!=d.indexOf("=")&&(d=t.getParam("body_id","","hash"),d=d[t.id]||d),f=n.body_class||"",-1!=f.indexOf("=")&&(f=t.getParam("body_class","","hash"),f=f[t.id]||""),n.content_security_policy&&(t.iframeHTML+=''),t.iframeHTML+='
          ';var v='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody(true);})()';document.domain!=location.hostname&&(u=v);var y=k.create("iframe",{id:t.id+"_ifr",frameBorder:"0",allowTransparency:"true",title:t.editorManager.translate("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),style:{width:"100%",height:o,display:"block"}});if(y.onload=function(){y.onload=null,t.fire("load")},k.setAttrib(y,"src",u||'javascript:""'),t.contentAreaContainer=l.iframeContainer,t.iframeElement=y,s=k.add(l.iframeContainer,y),O)try{t.getDoc()}catch(b){s.src=u=v}l.editorContainer&&(k.get(l.editorContainer).style.display=t.orgDisplay,t.hidden=k.isHidden(l.editorContainer)),t.getElement().style.display="none",k.setAttrib(t.id,"aria-hidden",!0),u||t.initContentBody(),r=s=l=null},initContentBody:function(t){var n=this,r=n.settings,s=n.getElement(),h=n.getDoc(),m,g;r.inline||(n.getElement().style.visibility=n.orgVisibility),t||r.content_editable||(h.open(),h.write(n.iframeHTML),h.close()),r.content_editable&&(n.on("remove",function(){var e=this.getBody();k.removeClass(e,"mce-content-body"),k.removeClass(e,"mce-edit-focus"),k.setAttrib(e,"contentEditable",null)}),k.addClass(s,"mce-content-body"),n.contentDocument=h=r.content_document||document,n.contentWindow=r.content_window||window,n.bodyElement=s,r.content_document=r.content_window=null,r.root_name=s.nodeName.toLowerCase()),m=n.getBody(),m.disabled=!0,r.readonly||(n.inline&&"static"==k.getStyle(m,"position",!0)&&(m.style.position="relative"),m.contentEditable=n.getParam("content_editable_state",!0)),m.disabled=!1,n.schema=new y(r),n.dom=new e(h,{keep_values:!0,url_converter:n.convertURL,url_converter_scope:n,hex_colors:r.force_hex_style_colors,class_filter:r.class_filter,update_styles:!0,root_element:n.inline?n.getBody():null,collect:r.content_editable,schema:n.schema,onSetAttrib:function(e){n.fire("SetAttrib",e)}}),n.parser=new b(r,n.schema),n.parser.addAttributeFilter("src,href,style,tabindex",function(e,t){for(var r=e.length,i,o=n.dom,a,s;r--;)i=e[r],a=i.attr(t),s="data-mce-"+t,i.attributes.map[s]||("style"===t?(a=o.serializeStyle(o.parseStyle(a),i.name),a.length||(a=null),i.attr(s,a),i.attr(t,a)):"tabindex"===t?(i.attr(s,a),i.attr(t,null)):i.attr(s,n.convertURL(a,t,i.name)))}),n.parser.addNodeFilter("script",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("type","mce-"+(n.attr("type")||"no/type"))}),n.parser.addNodeFilter("#cdata",function(e){for(var t=e.length,n;t--;)n=e[t],n.type=8,n.name="#comment",n.value="[CDATA["+n.value+"]]"}),n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(e){for(var t=e.length,r,i=n.schema.getNonEmptyElements();t--;)r=e[t],r.isEmpty(i)&&(r.append(new o("br",1)).shortEnded=!0)}),n.serializer=new a(r,n),n.selection=new l(n.dom,n.getWin(),n.serializer,n),n.formatter=new c(n),n.undoManager=new u(n),n.forceBlocks=new f(n),n.enterKey=new d(n),n.editorCommands=new p(n),n._nodeChangeDispatcher=new i(n),n.fire("PreInit"),r.browser_spellcheck||r.gecko_spellcheck||(h.body.spellcheck=!1,k.setAttrib(m,"spellcheck","false")),n.fire("PostRender"),n.quirks=new C(n),r.directionality&&(m.dir=r.directionality),r.nowrap&&(m.style.whiteSpace="nowrap"),r.protect&&n.on("BeforeSetContent",function(e){A(r.protect,function(t){e.content=e.content.replace(t,function(e){return""})})}),n.on("SetContent",function(){n.addVisual(n.getBody())}),r.padd_empty_editor&&n.on("PostProcess",function(e){e.content=e.content.replace(/^(]*>( | |\s|\u00a0|)<\/p>[\r\n]*|
          [\r\n]*)$/,"")}),n.load({initial:!0,format:"html"}),n.startContent=n.getContent({format:"raw"}),n.initialized=!0,n.bindPendingEventDelegates(),n.fire("init"),n.focus(!0),n.nodeChanged({initial:!0}),n.execCallback("init_instance_callback",n),n.contentStyles.length>0&&(g="",A(n.contentStyles,function(e){g+=e+"\r\n"}),n.dom.addStyle(g)),A(n.contentCSS,function(e){n.loadedCSS[e]||(n.dom.loadCSS(e),n.loadedCSS[e]=!0)}),r.auto_focus&&setTimeout(function(){var e;e=r.auto_focus===!0?n:n.editorManager.get(r.auto_focus),e.focus()},100),s=h=m=null},focus:function(e){var t=this,n=t.selection,r=t.settings.content_editable,i,o,a=t.getDoc(),s;if(!e){if(i=n.getRng(),i.item&&(o=i.item(0)),t._refreshContentEditable(),r||(x.opera||t.getBody().focus(),t.getWin().focus()),P||r){if(s=t.getBody(),s.setActive)try{s.setActive()}catch(l){s.focus()}else s.focus();r&&n.normalize()}o&&o.ownerDocument==a&&(i=a.body.createControlRange(),i.addElement(o),i.select())}t.editorManager.setActive(t)},execCallback:function(e){var t=this,n=t.settings[e],r;if(n)return t.callbackLookup&&(r=t.callbackLookup[e])&&(n=r.func,r=r.scope),"string"==typeof n&&(r=n.replace(/\.\w+$/,""),r=r?H(r):0,n=H(n),t.callbackLookup=t.callbackLookup||{},t.callbackLookup[e]={func:n,scope:r}),n.apply(r||t,Array.prototype.slice.call(arguments,1))},translate:function(e){var t=this.settings.language||"en",n=this.editorManager.i18n;return e?n.data[t+"."+e]||e.replace(/\{\#([^\}]+)\}/g,function(e,r){return n.data[t+"."+r]||"{#"+r+"}"}):""},getLang:function(e,n){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+e]||(n!==t?n:"{#"+e+"}")},getParam:function(e,t,n){var r=e in this.settings?this.settings[e]:t,i;return"hash"===n?(i={},"string"==typeof r?A(r.split(r.indexOf("=")>0?/[;,](?![^=;,]*(?:[;,]|$))/:","),function(e){e=e.split("="),i[L(e[0])]=L(e.length>1?e[1]:e)}):i=r,i):r},nodeChanged:function(e){this._nodeChangeDispatcher.nodeChanged(e)},addButton:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),t.text||t.icon||(t.icon=e),n.buttons=n.buttons||{},t.tooltip=t.tooltip||t.title,n.buttons[e]=t},addMenuItem:function(e,t){var n=this;t.cmd&&(t.onclick=function(){n.execCommand(t.cmd)}),n.menuItems=n.menuItems||{},n.menuItems[e]=t},addCommand:function(e,t,n){this.execCommands[e]={func:t,scope:n||this}},addQueryStateHandler:function(e,t,n){this.queryStateCommands[e]={func:t,scope:n||this}},addQueryValueHandler:function(e,t,n){this.queryValueCommands[e]={func:t,scope:n||this}},addShortcut:function(e,t,n,r){this.shortcuts.add(e,t,n,r)},execCommand:function(e,t,n,r){var i=this,o=0,a;if(/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(e)||r&&r.skip_focus||i.focus(),r=R({},r),r=i.fire("BeforeExecCommand",{command:e,ui:t,value:n}),r.isDefaultPrevented())return!1;if((a=i.execCommands[e])&&a.func.call(a.scope,t,n)!==!0)return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;if(A(i.plugins,function(r){return r.execCommand&&r.execCommand(e,t,n)?(i.fire("ExecCommand",{command:e,ui:t,value:n}),o=!0,!1):void 0}),o)return o;if(i.theme&&i.theme.execCommand&&i.theme.execCommand(e,t,n))return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;if(i.editorCommands.execCommand(e,t,n))return i.fire("ExecCommand",{command:e,ui:t,value:n}),!0;try{o=i.getDoc().execCommand(e,t,n)}catch(s){}return o?(i.fire("ExecCommand",{command:e,ui:t,value:n}),!0):!1},queryCommandState:function(e){var t=this,n,r;if(!t._isHidden()){if((n=t.queryStateCommands[e])&&(r=n.func.call(n.scope),r===!0||r===!1))return r;if(r=t.editorCommands.queryCommandState(e),-1!==r)return r;try{return t.getDoc().queryCommandState(e)}catch(i){}}},queryCommandValue:function(e){var n=this,r,i;if(!n._isHidden()){if((r=n.queryValueCommands[e])&&(i=r.func.call(r.scope),i!==!0))return i;if(i=n.editorCommands.queryCommandValue(e),i!==t)return i;try{return n.getDoc().queryCommandValue(e)}catch(o){}}},show:function(){var e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable=!0:(k.show(e.getContainer()),k.hide(e.id)),e.load(),e.fire("show"))},hide:function(){var e=this,t=e.getDoc();e.hidden||(O&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable=!1,e==e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(k.hide(e.getContainer()),k.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(e,t){this.fire("ProgressState",{state:e,time:t})},load:function(e){var n=this,r=n.getElement(),i;return r?(e=e||{},e.load=!0,i=n.setContent(r.value!==t?r.value:r.innerHTML,e),e.element=r,e.no_events||n.fire("LoadContent",e),e.element=r=null,i):void 0},save:function(e){var t=this,n=t.getElement(),r,i;if(n&&t.initialized)return e=e||{},e.save=!0,e.element=n,r=e.content=t.getContent(e),e.no_events||t.fire("SaveContent",e),r=e.content,/TEXTAREA|INPUT/i.test(n.nodeName)?n.value=r:(t.inline||(n.innerHTML=r),(i=k.getParent(t.id,"form"))&&A(i.elements,function(e){return e.name==t.id?(e.value=r,!1):void 0})),e.element=n=null,e.set_dirty!==!1&&(t.isNotDirty=!0),r},setContent:function(e,t){var n=this,r=n.getBody(),i;return t=t||{},t.format=t.format||"html",t.set=!0,t.content=e,t.no_events||n.fire("BeforeSetContent",t),e=t.content,0===e.length||/^\s+$/.test(e)?(i=n.settings.forced_root_block,i&&n.schema.isValidChild(r.nodeName.toLowerCase(),i.toLowerCase())?(e=O&&11>O?"":'
          ',e=n.dom.createHTML(i,n.settings.forced_root_block_attrs,e)):O||(e='
          '),n.dom.setHTML(r,e),n.fire("SetContent",t)):("raw"!==t.format&&(e=new s({},n.schema).serialize(n.parser.parse(e,{isRootContent:!0}))),t.content=L(e),n.dom.setHTML(r,t.content),t.no_events||n.fire("SetContent",t)),t.content},getContent:function(e){var t=this,n,r=t.getBody();return e=e||{},e.format=e.format||"html",e.get=!0,e.getInner=!0,e.no_events||t.fire("BeforeGetContent",e),n="raw"==e.format?r.innerHTML:"text"==e.format?r.innerText||r.textContent:t.serializer.serialize(r,e),e.content="text"!=e.format?L(n):n,e.no_events||t.fire("GetContent",e),e.content},insertContent:function(e,t){t&&(e=R({content:e},t)),this.execCommand("mceInsertContent",!1,e)},isDirty:function(){return!this.isNotDirty},getContainer:function(){var e=this;return e.container||(e.container=k.get(e.editorContainer||e.id+"_parent")),e.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=k.get(this.id)),this.targetElm},getWin:function(){var e=this,t;return e.contentWindow||(t=e.iframeElement,t&&(e.contentWindow=t.contentWindow)),e.contentWindow},getDoc:function(){var e=this,t;return e.contentDocument||(t=e.getWin(),t&&(e.contentDocument=t.document)),e.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(e,t,n){var r=this,i=r.settings;return i.urlconverter_callback?r.execCallback("urlconverter_callback",e,n,!0,t):!i.convert_urls||n&&"LINK"==n.nodeName||0===e.indexOf("file:")||0===e.length?e:i.relative_urls?r.documentBaseURI.toRelative(e):e=r.documentBaseURI.toAbsolute(e,i.remove_script_host)},addVisual:function(e){var n=this,r=n.settings,i=n.dom,o;e=e||n.getBody(),n.hasVisual===t&&(n.hasVisual=r.visual),A(i.select("table,a",e),function(e){var t;switch(e.nodeName){case"TABLE":return o=r.visual_table_class||"mce-item-table",t=i.getAttrib(e,"border"),void(t&&"0"!=t||!n.hasVisual?i.removeClass(e,o):i.addClass(e,o));case"A":return void(i.getAttrib(e,"href",!1)||(t=i.getAttrib(e,"name")||e.id,o=r.visual_anchor_class||"mce-item-anchor",t&&n.hasVisual?i.addClass(e,o):i.removeClass(e,o)))}}),n.fire("VisualAid",{element:e,hasVisual:n.hasVisual})},remove:function(){var e=this;e.removed||(e.save(),e.removed=1,e.unbindAllNativeEvents(),e.hasHiddenInput&&k.remove(e.getElement().nextSibling),e.inline||(O&&10>O&&e.getDoc().execCommand("SelectAll",!1,null),k.setStyle(e.id,"display",e.orgDisplay),e.getBody().onload=null),e.fire("remove"),e.editorManager.remove(e),k.remove(e.getContainer()),e.destroy())},destroy:function(e){var t=this,n;if(!t.destroyed){if(!e&&!t.removed)return void t.remove();e||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),t.selection.destroy(),t.dom.destroy()),n=t.formElement,n&&(n._mceOldSubmit&&(n.submit=n._mceOldSubmit,n._mceOldSubmit=null),k.unbind(n,"submit reset",t.formEventDelegate)),t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null,t.selection&&(t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null),t.destroyed=1}},_refreshContentEditable:function(){var e=this,t,n;e._isHidden()&&(t=e.getBody(),n=t.parentNode,n.removeChild(t),n.appendChild(t),t.focus())},_isHidden:function(){var e;return P?(e=this.selection.getSel(),!e||!e.rangeCount||0===e.rangeCount):0}},R(N.prototype,_),N}),r(ft,[],function(){var e={};return{rtl:!1,add:function(t,n){for(var r in n)e[r]=n[r];this.rtl=this.rtl||"rtl"===e._dir},translate:function(t){if("undefined"==typeof t)return t;if("string"!=typeof t&&t.raw)return t.raw;if(t.push){var n=t.slice(1);t=(e[t[0]]||t[0]).replace(/\{([^\}]+)\}/g,function(e,t){return n[t]})}return e[t]||t},data:e}}),r(pt,[y,u],function(e,t){function n(e){function s(){try{return document.activeElement}catch(e){return document.body}}function l(e,t){if(t&&t.startContainer){if(!e.isChildOf(t.startContainer,e.getRoot())||!e.isChildOf(t.endContainer,e.getRoot()))return;return{startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}}return t}function c(e,t){var n;return t.startContainer?(n=e.getDoc().createRange(),n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset)):n=t,n}function u(e){return!!a.getParent(e,n.isEditorUIElement)}function d(n){var d=n.editor;d.on("init",function(){(d.inline||t.ie)&&("onbeforedeactivate"in document&&t.ie<9?d.dom.bind(d.getBody(),"beforedeactivate",function(e){if(e.target==d.getBody())try{d.lastRng=d.selection.getRng()}catch(t){}}):d.on("nodechange mouseup keyup",function(e){var t=s();"nodechange"==e.type&&e.selectionChange||(t&&t.id==d.id+"_ifr"&&(t=d.getBody()),d.dom.isChildOf(t,d.getBody())&&(d.lastRng=d.selection.getRng()))}),t.webkit&&!r&&(r=function(){var t=e.activeEditor;if(t&&t.selection){var n=t.selection.getRng();n&&!n.collapsed&&(d.lastRng=n)}},a.bind(document,"selectionchange",r)))}),d.on("setcontent",function(){d.lastRng=null}),d.on("mousedown",function(){d.selection.lastFocusBookmark=null}),d.on("focusin",function(){var t=e.focusedEditor;d.selection.lastFocusBookmark&&(d.selection.setRng(c(d,d.selection.lastFocusBookmark)),d.selection.lastFocusBookmark=null),t!=d&&(t&&t.fire("blur",{focusedEditor:d}),e.setActive(d),e.focusedEditor=d,d.fire("focus",{blurredEditor:t}),d.focus(!0)),d.lastRng=null}),d.on("focusout",function(){window.setTimeout(function(){var t=e.focusedEditor;u(s())||t!=d||(d.fire("blur",{focusedEditor:null}),e.focusedEditor=null,d.selection&&(d.selection.lastFocusBookmark=null))},0)}),i||(i=function(t){var n=e.activeEditor;n&&t.target.ownerDocument==document&&(n.selection&&t.target!=n.getBody()&&(n.selection.lastFocusBookmark=l(n.dom,n.lastRng)),t.target==document.body||u(t.target)||e.focusedEditor!=n||(n.fire("blur",{focusedEditor:null}),e.focusedEditor=null))},a.bind(document,"focusin",i)),d.inline&&!o&&(o=function(t){var n=e.activeEditor;if(n.inline&&!n.dom.isChildOf(t.target,n.getBody())){var r=n.selection.getRng();r.collapsed||(n.lastRng=r)}},a.bind(document,"mouseup",o))}function f(t){e.focusedEditor==t.editor&&(e.focusedEditor=null),e.activeEditor||(a.unbind(document,"selectionchange",r),a.unbind(document,"focusin",i),a.unbind(document,"mouseup",o),r=i=o=null)}e.on("AddEditor",d),e.on("RemoveEditor",f)}var r,i,o,a=e.DOM;return n.isEditorUIElement=function(e){return-1!==e.className.toString().indexOf("mce-")},n}),r(ht,[dt,f,y,V,u,d,lt,ft,pt],function(e,t,n,r,i,o,a,s,l){function c(e){var t=v.editors,n;delete t[e.id];for(var r=0;r0&&p(f(e),function(e){var n;(n=d.get(e))?r(e,t,n):p(document.forms,function(n){p(n.elements,function(n){n.name===e&&(e="mce_editor_"+m++,d.setAttrib(n,"id",e),r(e,t,n))})})});break;case"textareas":case"specific_textareas":p(d.select("textarea"),function(e){t.editor_deselector&&o(e,t.editor_deselector)||(!t.editor_selector||o(e,t.editor_selector))&&r(n(e),t,e)})}t.oninit&&(e=s=0,p(l,function(t){s++,t.initialized?e++:t.on("init",function(){e++,e==s&&i("oninit")}),e==s&&i("oninit")}))}var s=this,l=[];s.settings=t,d.bind(window,"ready",a)},get:function(e){return arguments.length?e in this.editors?this.editors[e]:null:this.editors},add:function(e){var t=this,n=t.editors;return n[e.id]=e,n.push(e),t.activeEditor=e,t.fire("AddEditor",{editor:e}),g||(g=function(){t.fire("BeforeUnload")},d.bind(window,"beforeunload",g)),e},createEditor:function(t,n){return this.add(new e(t,n,this))},remove:function(e){var t=this,n,r=t.editors,i;{if(e)return"string"==typeof e?(e=e.selector||e,void p(d.select(e),function(e){i=r[e.id],i&&t.remove(i)})):(i=e,r[i.id]?(c(i)&&t.fire("RemoveEditor",{editor:i}),r.length||d.unbind(window,"beforeunload",g),i.remove(),i):null);for(n=r.length-1;n>=0;n--)t.remove(r[n])}},execCommand:function(t,n,r){var i=this,o=i.get(r);switch(t){case"mceAddEditor":return i.get(r)||new e(r,i.settings,i).render(),!0;case"mceRemoveEditor":return o&&o.remove(),!0;case"mceToggleEditor":return o?(o.isHidden()?o.show():o.hide(),!0):(i.execCommand("mceAddEditor",0,r),!0)}return i.activeEditor?i.activeEditor.execCommand(t,n,r):!1},triggerSave:function(){p(this.editors,function(e){e.save()})},addI18n:function(e,t){s.add(e,t)},translate:function(e){return s.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!=e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e}},h(v,a),v.setup(),window.tinymce=window.tinyMCE=v,v}),r(mt,[ht,d],function(e,t){var n=t.each,r=t.explode;e.on("AddEditor",function(e){var t=e.editor;t.on("preInit",function(){function e(e,t){n(t,function(t,n){t&&s.setStyle(e,n,t)}),s.rename(e,"span")}function i(e){s=t.dom,l.convert_fonts_to_spans&&n(s.select("font,u,strike",e.node),function(e){o[e.nodeName.toLowerCase()](s,e)})}var o,a,s,l=t.settings;l.inline_styles&&(a=r(l.font_size_legacy_values),o={font:function(t,n){e(n,{backgroundColor:n.style.backgroundColor,color:n.color,fontFamily:n.face,fontSize:a[parseInt(n.size,10)-1]})},u:function(t,n){e(n,{textDecoration:"underline"})},strike:function(t,n){e(n,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",i))})})}),r(gt,[lt,d],function(e,t){var n={send:function(e){function t(){!e.async||4==r.readyState||i++>1e4?(e.success&&1e4>i&&200==r.status?e.success.call(e.success_scope,""+r.responseText,r,e):e.error&&e.error.call(e.error_scope,i>1e4?"TIMED_OUT":"GENERAL",r,e),r=null):setTimeout(t,10)}var r,i=0;if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=e.async===!1?!1:!0,e.data=e.data||"",r=new XMLHttpRequest){if(r.overrideMimeType&&r.overrideMimeType(e.content_type),r.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(r.withCredentials=!0),e.content_type&&r.setRequestHeader("Content-Type",e.content_type),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r=n.fire("beforeSend",{xhr:r,settings:e}).xhr,r.send(e.data),!e.async)return t();setTimeout(t,10)}}};return t.extend(n,e),n}),r(vt,[],function(){function e(t,n){var r,i,o,a;if(n=n||'"',null===t)return"null";if(o=typeof t,"string"==o)return i="\bb t\nn\ff\rr\"\"''\\\\",n+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=i.indexOf(t),r+1?"\\"+i.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e))})+n;if("object"==o){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(r=0,i="[";r0?",":"")+e(t[r],n);return i+"]"}i="{";for(a in t)t.hasOwnProperty(a)&&(i+="function"!=typeof t[a]?(i.length>1?","+n:n)+a+n+":"+e(t[a],n):"");return i+"}"}return""+t}return{serialize:e,parse:function(e){try{return window[String.fromCharCode(101)+"val"]("("+e+")")}catch(t){}}}}),r(yt,[vt,gt,d],function(e,t,n){function r(e){this.settings=i({},e),this.count=0}var i=n.extend;return r.sendRPC=function(e){return(new r).send(e)},r.prototype={send:function(n){var r=n.error,o=n.success;n=i(this.settings,n),n.success=function(t,i){t=e.parse(t),"undefined"==typeof t&&(t={error:"JSON Parse error."}),t.error?r.call(n.error_scope||n.scope,t.error,i):o.call(n.success_scope||n.scope,t.result)},n.error=function(e,t){r&&r.call(n.error_scope||n.scope,e,t)},n.data=e.serialize({id:n.id||"c"+this.count++,method:n.method,params:n.params}),n.content_type="application/json",t.send(n)}},r}),r(bt,[y],function(e){return{callbacks:{},count:0,send:function(n){var r=this,i=e.DOM,o=n.count!==t?n.count:r.count,a="tinymce_jsonp_"+o;r.callbacks[o]=function(e){i.remove(a),delete r.callbacks[o],n.callback(e)},i.add(i.doc.body,"script",{id:a,src:n.url,type:"text/javascript"}),r.count++}}}),r(Ct,[],function(){function e(){s=[];for(var e in a)s.push(e);i.length=s.length}function n(){function n(e){var n,r;return r=e!==t?u+e:i.indexOf(",",u),-1===r||r>i.length?null:(n=i.substring(u,r),u=r+1,n)}var r,i,s,u=0;if(a={},c){o.load(l),i=o.getAttribute(l)||"";do{var d=n();if(null===d)break;if(r=n(parseInt(d,32)||0),null!==r){if(d=n(),null===d)break;s=n(parseInt(d,32)||0),r&&(a[r]=s)}}while(null!==r);e()}}function r(){var t,n="";if(c){for(var r in a)t=a[r],n+=(n?",":"")+r.length.toString(32)+","+r+","+t.length.toString(32)+","+t;o.setAttribute(l,n);try{o.save(l)}catch(i){}e()}}var i,o,a,s,l,c;try{if(window.localStorage)return localStorage}catch(u){}return l="tinymce",o=document.documentElement,c=!!o.addBehavior,c&&o.addBehavior("#default#userData"),i={key:function(e){return s[e]},getItem:function(e){return e in a?a[e]:null},setItem:function(e,t){a[e]=""+t,r()},removeItem:function(e){delete a[e],r()},clear:function(){a={},r()}},n(),i}),r(xt,[y,l,b,C,d,u],function(e,t,n,r,i,o){var a=window.tinymce;return a.DOM=e.DOM,a.ScriptLoader=n.ScriptLoader,a.PluginManager=r.PluginManager,a.ThemeManager=r.ThemeManager,a.dom=a.dom||{},a.dom.Event=t.Event,i.each(i,function(e,t){a[t]=e}),i.each("isOpera isWebKit isIE isGecko isMac".split(" "),function(e){a[e]=o[e.substr(2).toLowerCase()]}),{}}),r(wt,[U,d],function(e,t){return e.extend({Defaults:{firstControlClass:"first",lastControlClass:"last"},init:function(e){this.settings=t.extend({},this.Defaults,e)},preRender:function(e){e.addClass(this.settings.containerClass,"body")},applyClasses:function(e){var t=this,n=t.settings,r,i,o;r=e.items().filter(":visible"),i=n.firstControlClass,o=n.lastControlClass,r.each(function(e){e.removeClass(i).removeClass(o),n.controlClass&&e.addClass(n.controlClass)}),r.eq(0).addClass(i),r.eq(-1).addClass(o)},renderHtml:function(e){var t=this,n=t.settings,r,i=""; +return r=e.items(),r.eq(0).addClass(n.firstControlClass),r.eq(-1).addClass(n.lastControlClass),r.each(function(e){n.controlClass&&e.addClass(n.controlClass),i+=e.renderHtml()}),i},recalc:function(){},postRender:function(){}})}),r(_t,[wt],function(e){return e.extend({Defaults:{containerClass:"abs-layout",controlClass:"abs-layout-item"},recalc:function(e){e.items().filter(":visible").each(function(e){var t=e.settings;e.layoutRect({x:t.x,y:t.y,w:t.w,h:t.h}),e.recalc&&e.recalc()})},renderHtml:function(e){return'
          '+this._super(e)}})}),r(Et,[K,tt],function(e,t){return e.extend({Mixins:[t],Defaults:{classes:"widget tooltip tooltip-n"},text:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t._rendered&&(t.getEl().lastChild.innerHTML=t.encode(e)),t):t._value},renderHtml:function(){var e=this,t=e.classPrefix;return'"},repaint:function(){var e=this,t,n;t=e.getEl().style,n=e._layoutRect,t.left=n.x+"px",t.top=n.y+"px",t.zIndex=131070}})}),r(Nt,[K,Et],function(e,t){var n,r=e.extend({init:function(e){var t=this;t._super(e),e=t.settings,t.canFocus=!0,e.tooltip&&r.tooltips!==!1&&(t.on("mouseenter",function(n){var r=t.tooltip().moveTo(-65535);if(n.control==t){var i=r.text(e.tooltip).show().testMoveRel(t.getEl(),["bc-tc","bc-tl","bc-tr"]);r.toggleClass("tooltip-n","bc-tc"==i),r.toggleClass("tooltip-nw","bc-tl"==i),r.toggleClass("tooltip-ne","bc-tr"==i),r.moveRel(t.getEl(),i)}else r.hide()}),t.on("mouseleave mousedown click",function(){t.tooltip().hide()})),t.aria("label",e.ariaLabel||e.tooltip)},tooltip:function(){return n||(n=new t({type:"tooltip"}),n.renderTo()),n},active:function(e){var t=this,n;return e!==n&&(t.aria("pressed",e),t.toggleClass("active",e)),t._super(e)},disabled:function(e){var t=this,n;return e!==n&&(t.aria("disabled",e),t.toggleClass("disabled",e)),t._super(e)},postRender:function(){var e=this,t=e.settings;e._rendered=!0,e._super(),e.parent()||!t.width&&!t.height||(e.initLayoutRect(),e.repaint()),t.autofocus&&e.focus()},remove:function(){this._super(),n&&(n.remove(),n=null)}});return r}),r(kt,[Nt],function(e){return e.extend({Defaults:{classes:"widget btn",role:"button"},init:function(e){var t=this,n;t.on("click mousedown",function(e){e.preventDefault()}),t._super(e),n=e.size,e.subtype&&t.addClass(e.subtype),n&&t.addClass("btn-"+n)},icon:function(e){var t=this,n=t.classPrefix;if("undefined"==typeof e)return t.settings.icon;if(t.settings.icon=e,e=e?n+"ico "+n+"i-"+t.settings.icon:"",t._rendered){var r=t.getEl().firstChild,i=r.getElementsByTagName("i")[0];e?(i&&i==r.firstChild||(i=document.createElement("i"),r.insertBefore(i,r.firstChild)),i.className=e):i&&r.removeChild(i),t.text(t._text)}return t},repaint:function(){var e=this.getEl().firstChild.style;e.width=e.height="100%",this._super()},text:function(e){var t=this;if(t._rendered){var n=t.getEl().lastChild.lastChild;n&&(n.data=t.translate(e))}return t._super(e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.settings.icon,i;return i=e.settings.image,i?(r="none","string"!=typeof i&&(i=window.getSelection?i[0]:i[1]),i=" style=\"background-image: url('"+i+"')\""):i="",r=e.settings.icon?n+"ico "+n+"i-"+r:"",'
          "}})}),r(St,[J],function(e){return e.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var e=this,t=e._layout;return e.addClass("btn-group"),e.preRender(),t.preRender(e),'
          '+(e.settings.html||"")+t.renderHtml(e)+"
          "}})}),r(Tt,[Nt],function(e){return e.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(e){var t=this;t._super(e),t.on("click mousedown",function(e){e.preventDefault()}),t.on("click",function(e){e.preventDefault(),t.disabled()||t.checked(!t.checked())}),t.checked(t.settings.checked)},checked:function(e){var t=this;return"undefined"!=typeof e?(e?t.addClass("checked"):t.removeClass("checked"),t._checked=e,t.aria("checked",e),t):t._checked},value:function(e){return this.checked(e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix;return'
          '+e.encode(e._text)+"
          "}})}),r(Rt,[Nt,G,Y],function(e,t,n){return e.extend({init:function(e){var t=this;t._super(e),t.addClass("combobox"),t.subinput=!0,t.ariaTarget="inp",e=t.settings,e.menu=e.menu||e.values,e.menu&&(e.icon="caret"),t.on("click",function(n){for(var r=n.target,i=t.getEl();r&&r!=i;)r.id&&-1!=r.id.indexOf("-open")&&(t.fire("action"),e.menu&&(t.showMenu(),n.aria&&t.menu.items()[0].focus())),r=r.parentNode}),t.on("keydown",function(e){"INPUT"==e.target.nodeName&&13==e.keyCode&&t.parents().reverse().each(function(n){return e.preventDefault(),t.fire("change"),n.hasEventListeners("submit")&&n.toJSON?(n.fire("submit",{data:n.toJSON()}),!1):void 0})}),e.placeholder&&(t.addClass("placeholder"),t.on("focusin",function(){t._hasOnChange||(n.on(t.getEl("inp"),"change",function(){t.fire("change")}),t._hasOnChange=!0),t.hasClass("placeholder")&&(t.getEl("inp").value="",t.removeClass("placeholder"))}),t.on("focusout",function(){0===t.value().length&&(t.getEl("inp").value=e.placeholder,t.addClass("placeholder"))}))},showMenu:function(){var e=this,n=e.settings,r;e.menu||(r=n.menu||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",e.menu=t.create(r).parent(e).renderTo(e.getContainerElm()),e.fire("createmenu"),e.menu.reflow(),e.menu.on("cancel",function(t){t.control===e.menu&&e.focus()}),e.menu.on("show hide",function(t){t.control.items().each(function(t){t.active(t.value()==e.value())})}).fire("show"),e.menu.on("select",function(t){e.value(t.control.value())}),e.on("focusin",function(t){"INPUT"==t.target.tagName.toUpperCase()&&e.menu.hide()}),e.aria("expanded",!0)),e.menu.show(),e.menu.layoutRect({w:e.layoutRect().w}),e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},value:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t.removeClass("placeholder"),t._rendered&&(t.getEl("inp").value=e),t):t._rendered?(e=t.getEl("inp").value,e!=t.settings.placeholder?e:""):t._value},disabled:function(e){var t=this;return t._rendered&&"undefined"!=typeof e&&(t.getEl("inp").disabled=e),t._super(e)},focus:function(){this.getEl("inp").focus()},repaint:function(){var e=this,t=e.getEl(),r=e.getEl("open"),i=e.layoutRect(),o,a;o=r?i.w-n.getSize(r).width-10:i.w-10;var s=document;return s.all&&(!s.documentMode||s.documentMode<=8)&&(a=e.layoutRect().h-2+"px"),n.css(t.firstChild,{width:o,lineHeight:a}),e._super(),e},postRender:function(){var e=this;return n.on(this.getEl("inp"),"change",function(){e.fire("change")}),e._super()},remove:function(){n.off(this.getEl("inp")),this._super()},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.classPrefix,i=n.value||n.placeholder||"",o,a,s="",l="";return"spellcheck"in n&&(l+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(l+=' maxlength="'+n.maxLength+'"'),n.size&&(l+=' size="'+n.size+'"'),n.subtype&&(l+=' type="'+n.subtype+'"'),e.disabled()&&(l+=' disabled="disabled"'),o=n.icon,o&&"caret"!=o&&(o=r+"ico "+r+"i-"+n.icon),a=e._text,(o||a)&&(s='
          ",e.addClass("has-open")),'
          "+s+"
          "}})}),r(At,[Rt],function(e){return e.extend({init:function(e){var t=this;e.spellcheck=!1,e.onaction&&(e.icon="none"),t._super(e),t.addClass("colorbox"),t.on("change keyup postrender",function(){t.repaintColor(t.value())})},repaintColor:function(e){var t=this.getEl().getElementsByTagName("i")[0];if(t)try{t.style.background=e}catch(n){}},value:function(e){var t=this;return"undefined"!=typeof e&&t._rendered&&t.repaintColor(e),t._super(e)}})}),r(Bt,[kt,rt],function(e,t){return e.extend({showPanel:function(){var e=this,n=e.settings;if(e.active(!0),e.panel)e.panel.show();else{var r=n.panel;r.type&&(r={layout:"grid",items:r}),r.role=r.role||"dialog",r.popover=!0,r.autohide=!0,r.ariaRoot=!0,e.panel=new t(r).on("hide",function(){e.active(!1)}).on("cancel",function(t){t.stopPropagation(),e.focus(),e.hidePanel()}).parent(e).renderTo(e.getContainerElm()),e.panel.fire("show"),e.panel.reflow()}e.panel.moveRel(e.getEl(),n.popoverAlign||(e.isRtl()?["bc-tr","bc-tc"]:["bc-tl","bc-tc"]))},hidePanel:function(){var e=this;e.panel&&e.panel.hide()},postRender:function(){var e=this;return e.aria("haspopup",!0),e.on("click",function(t){t.control===e&&(e.panel&&e.panel.visible()?e.hidePanel():(e.showPanel(),e.panel.focus(!!t.aria)))}),e._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})}),r(Dt,[Bt,y],function(e,t){var n=t.DOM;return e.extend({init:function(e){this._super(e),this.addClass("colorbutton")},color:function(e){return e?(this._color=e,this.getEl("preview").style.backgroundColor=e,this):this._color},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r=e.settings.icon?n+"ico "+n+"i-"+e.settings.icon:"",i=e.settings.image?" style=\"background-image: url('"+e.settings.image+"')\"":"";return'
          '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(r){r.aria&&"down"==r.aria.key||r.control!=e||n.getParent(r.target,"."+e.classPrefix+"open")||(r.stopImmediatePropagation(),t.call(e,r))}),delete e.settings.onclick,e._super()}})}),r(Lt,[],function(){function e(e){function i(e,i,o){var a,s,l,c,u,d;return a=0,s=0,l=0,e/=255,i/=255,o/=255,u=t(e,t(i,o)),d=n(e,n(i,o)),u==d?(l=u,{h:0,s:0,v:100*l}):(c=e==u?i-o:o==u?e-i:o-e,a=e==u?3:o==u?1:5,a=60*(a-c/(d-u)),s=(d-u)/d,l=d,{h:r(a),s:r(100*s),v:r(100*l)})}function o(e,i,o){var a,s,l,c;if(e=(parseInt(e,10)||0)%360,i=parseInt(i,10)/100,o=parseInt(o,10)/100,i=n(0,t(i,1)),o=n(0,t(o,1)),0===i)return void(d=f=p=r(255*o));switch(a=e/60,s=o*i,l=s*(1-Math.abs(a%2-1)),c=o-s,Math.floor(a)){case 0:d=s,f=l,p=0;break;case 1:d=l,f=s,p=0;break;case 2:d=0,f=s,p=l;break;case 3:d=0,f=l,p=s;break;case 4:d=l,f=0,p=s;break;case 5:d=s,f=0,p=l;break;default:d=f=p=0}d=r(255*(d+c)),f=r(255*(f+c)),p=r(255*(p+c))}function a(){function e(e){return e=parseInt(e,10).toString(16),e.length>1?e:"0"+e}return"#"+e(d)+e(f)+e(p)}function s(){return{r:d,g:f,b:p}}function l(){return i(d,f,p)}function c(e){var t;return"object"==typeof e?"r"in e?(d=e.r,f=e.g,p=e.b):"v"in e&&o(e.h,e.s,e.v):(t=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(e))?(d=parseInt(t[1],10),f=parseInt(t[2],10),p=parseInt(t[3],10)):(t=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(e))?(d=parseInt(t[1],16),f=parseInt(t[2],16),p=parseInt(t[3],16)):(t=/#([0-F])([0-F])([0-F])/gi.exec(e))&&(d=parseInt(t[1]+t[1],16),f=parseInt(t[2]+t[2],16),p=parseInt(t[3]+t[3],16)),d=0>d?0:d>255?255:d,f=0>f?0:f>255?255:f,p=0>p?0:p>255?255:p,u}var u=this,d=0,f=0,p=0;e&&c(e),u.toRgb=s,u.toHsv=l,u.toHex=a,u.parse=c}var t=Math.min,n=Math.max,r=Math.round;return e}),r(Ht,[Nt,Q,Y,Lt],function(e,t,n,r){return e.extend({Defaults:{classes:"widget colorpicker"},init:function(e){this._super(e)},postRender:function(){function e(e,t){var r=n.getPos(e),i,o;return i=t.pageX-r.x,o=t.pageY-r.y,i=Math.max(0,Math.min(i/e.clientWidth,1)),o=Math.max(0,Math.min(o/e.clientHeight,1)),{x:i,y:o}}function i(e,t){var i=(360-e.h)/360;n.css(d,{top:100*i+"%"}),t||n.css(p,{left:e.s+"%",top:100-e.v+"%"}),f.style.background=new r({s:100,v:100,h:e.h}).toHex(),s.color().parse({s:e.s,v:e.v,h:e.h})}function o(t){var n;n=e(f,t),c.s=100*n.x,c.v=100*(1-n.y),i(c),s.fire("change")}function a(t){var n;n=e(u,t),c=l.toHsv(),c.h=360*(1-n.y),i(c,!0),s.fire("change")}var s=this,l=s.color(),c,u,d,f,p;u=s.getEl("h"),d=s.getEl("hp"),f=s.getEl("sv"),p=s.getEl("svp"),s._repaint=function(){c=l.toHsv(),i(c)},s._super(),s._svdraghelper=new t(s._id+"-sv",{start:o,drag:o}),s._hdraghelper=new t(s._id+"-h",{start:a,drag:a}),s._repaint()},rgb:function(){return this.color().toRgb()},value:function(e){var t=this;return arguments.length?(t.color().parse(e),void(t._rendered&&t._repaint())):t.color().toHex()},color:function(){return this._color||(this._color=new r),this._color},renderHtml:function(){function e(){var e,t,n="",i,a;for(i="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",a=o.split(","),e=0,t=a.length-1;t>e;e++)n+='
          ';return n}var t=this,n=t._id,r=t.classPrefix,i,o="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",a="background: -ms-linear-gradient(top,"+o+");background: linear-gradient(to bottom,"+o+");";return i='
          '+e()+'
          ','
          '+i+"
          "}})}),r(Mt,[Nt],function(e){return e.extend({init:function(e){var t=this;e.delimiter||(e.delimiter="\xbb"),t._super(e),t.addClass("path"),t.canFocus=!0,t.on("click",function(e){var n,r=e.target;(n=r.getAttribute("data-index"))&&t.fire("select",{value:t.data()[n],index:n})})},focus:function(){var e=this;return e.getEl().firstChild.focus(),e},data:function(e){var t=this;return"undefined"!=typeof e?(t._data=e,t.update(),t):t._data},update:function(){this.innerHtml(this._getPathHtml())},postRender:function(){var e=this;e._super(),e.data(e.settings.data)},renderHtml:function(){var e=this;return'
          '+e._getPathHtml()+"
          "},_getPathHtml:function(){var e=this,t=e._data||[],n,r,i="",o=e.classPrefix;for(n=0,r=t.length;r>n;n++)i+=(n>0?'":"")+'
          '+t[n].name+"
          ";return i||(i='
          \xa0
          '),i}})}),r(Pt,[Mt,ht],function(e,t){return e.extend({postRender:function(){function e(e){if(1===e.nodeType){if("BR"==e.nodeName||e.getAttribute("data-mce-bogus"))return!0;if("bookmark"===e.getAttribute("data-mce-type"))return!0}return!1}var n=this,r=t.activeEditor;return n.on("select",function(e){r.focus(),r.selection.select(this.data()[e.index].element),r.nodeChanged()}),r.on("nodeChange",function(t){for(var i=[],o=t.parents,a=o.length;a--;)if(1==o[a].nodeType&&!e(o[a])){var s=r.fire("ResolveName",{name:o[a].nodeName.toLowerCase(),target:o[a]});if(s.isDefaultPrevented()||i.push({name:s.name,element:o[a]}),s.isPropagationStopped())break}n.data(i)}),n._super()}})}),r(Ot,[J],function(e){return e.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.addClass("formitem"),t.preRender(e),'
          '+(e.settings.title?'
          '+e.settings.title+"
          ":"")+'
          '+(e.settings.html||"")+t.renderHtml(e)+"
          "}})}),r(It,[J,Ot,d],function(e,t,n){return e.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:20,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var e=this,r=e.items();e.settings.formItemDefaults||(e.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),r.each(function(r){var i,o=r.settings.label;o&&(i=new t(n.extend({items:{type:"label",id:r._id+"-l",text:o,flex:0,forId:r._id,disabled:r.disabled()}},e.settings.formItemDefaults)),i.type="formitem",r.aria("labelledby",r._id+"-l"),"undefined"==typeof r.settings.flex&&(r.settings.flex=1),e.replace(r,i),i.add(r))})},recalcLabels:function(){var e=this,t=0,n=[],r,i,o;if(e.settings.labelGapCalc!==!1)for(o="children"==e.settings.labelGapCalc?e.find("formitem"):e.items(),o.filter("formitem").each(function(e){var r=e.items()[0],i=r.getEl().clientWidth;t=i>t?i:t,n.push(r)}),i=e.settings.labelGap||0,r=n.length;r--;)n[r].settings.minWidth=t+i},visible:function(e){var t=this._super(e);return e===!0&&this._rendered&&this.recalcLabels(),t},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var e=this;e._super(),e.recalcLabels(),e.fromJSON(e.settings.data)}})}),r(Ft,[It],function(e){return e.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.preRender(),t.preRender(e),'
          '+(e.settings.title?''+e.settings.title+"":"")+'
          '+(e.settings.html||"")+t.renderHtml(e)+"
          "}})}),r(zt,[Rt,d],function(e,t){return e.extend({init:function(e){var n=this,r=tinymce.activeEditor,i=r.settings,o,a,s;e.spellcheck=!1,s=i.file_picker_types||i.file_browser_callback_types,s&&(s=t.makeMap(s,/[, ]/)),(!s||s[e.filetype])&&(a=i.file_picker_callback,!a||s&&!s[e.filetype]?(a=i.file_browser_callback,!a||s&&!s[e.filetype]||(o=function(){a(n.getEl("inp").id,n.value(),e.filetype,window)})):o=function(){var i=n.fire("beforecall").meta;i=t.extend({filetype:e.filetype},i),a.call(r,function(e,t){n.value(e).fire("change",{meta:t})},n.value(),i)}),o&&(e.icon="browse",e.onaction=o),n._super(e)}})}),r(Wt,[_t],function(e){return e.extend({recalc:function(e){var t=e.layoutRect(),n=e.paddingBox();e.items().filter(":visible").each(function(e){e.layoutRect({x:n.left,y:n.top,w:t.innerW-n.right-n.left,h:t.innerH-n.top-n.bottom}),e.recalc&&e.recalc()})}})}),r(Vt,[_t],function(e){return e.extend({recalc:function(e){var t,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v=[],y,b,C,x,w,_,E,N,k,S,T,R,A,B,D,L,H,M,P,O,I,F,z=Math.max,W=Math.min;for(r=e.items().filter(":visible"),i=e.layoutRect(),o=e._paddingBox,a=e.settings,f=e.isRtl()?a.direction||"row-reversed":a.direction,s=a.align,l=e.isRtl()?a.pack||"end":a.pack,c=a.spacing||0,("row-reversed"==f||"column-reverse"==f)&&(r=r.set(r.toArray().reverse()),f=f.split("-")[0]),"column"==f?(k="y",E="h",N="minH",S="maxH",R="innerH",T="top",A="deltaH",B="contentH",P="left",H="w",D="x",L="innerW",M="minW",O="right",I="deltaW",F="contentW"):(k="x",E="w",N="minW",S="maxW",R="innerW",T="left",A="deltaW",B="contentW",P="top",H="h",D="y",L="innerH",M="minH",O="bottom",I="deltaH",F="contentH"),d=i[R]-o[T]-o[T],_=u=0,t=0,n=r.length;n>t;t++)p=r[t],h=p.layoutRect(),m=p.settings,g=m.flex,d-=n-1>t?c:0,g>0&&(u+=g,h[S]&&v.push(p),h.flex=g),d-=h[N],y=o[P]+h[M]+o[O],y>_&&(_=y);if(x={},x[N]=0>d?i[N]-d+i[A]:i[R]-d+i[A],x[M]=_+i[I],x[B]=i[R]-d,x[F]=_,x.minW=W(x.minW,i.maxW),x.minH=W(x.minH,i.maxH),x.minW=z(x.minW,i.startMinWidth),x.minH=z(x.minH,i.startMinHeight),!i.autoResize||x.minW==i.minW&&x.minH==i.minH){for(C=d/u,t=0,n=v.length;n>t;t++)p=v[t],h=p.layoutRect(),b=h[S],y=h[N]+h.flex*C,y>b?(d-=h[S]-h[N],u-=h.flex,h.flex=0,h.maxFlexSize=b):h.maxFlexSize=0;for(C=d/u,w=o[T],x={},0===u&&("end"==l?w=d+o[T]:"center"==l?(w=Math.round(i[R]/2-(i[R]-d)/2)+o[T],0>w&&(w=o[T])):"justify"==l&&(w=o[T],c=Math.floor(d/(r.length-1)))),x[D]=o[P],t=0,n=r.length;n>t;t++)p=r[t],h=p.layoutRect(),y=h.maxFlexSize||h[N],"center"===s?x[D]=Math.round(i[L]/2-h[H]/2):"stretch"===s?(x[H]=z(h[M]||0,i[L]-o[P]-o[O]),x[D]=o[P]):"end"===s&&(x[D]=i[L]-h[H]-o.top),h.flex>0&&(y+=h.flex*C),x[E]=y,x[k]=w,p.layoutRect(x),p.recalc&&p.recalc(),w+=y+c}else if(x.w=x.minW,x.h=x.minH,e.layoutRect(x),this.recalc(e),null===e._lastRect){var V=e.parent();V&&(V._lastRect=null,V.recalc())}}})}),r(Ut,[wt],function(e){return e.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(e){e.items().filter(":visible").each(function(e){e.recalc&&e.recalc()})}})}),r($t,[K,Nt,rt,d,ht,u],function(e,t,n,r,i,o){function a(e){function t(t,n){return function(){var r=this;e.on("nodeChange",function(i){var o=e.formatter,a=null;s(i.parents,function(e){return s(t,function(t){return n?o.matchNode(e,n,{value:t.value})&&(a=t.value):o.matchNode(e,t.value)&&(a=t.value),a?!1:void 0}),a?!1:void 0}),r.value(a)})}}function r(e){e=e.replace(/;$/,"").split(";");for(var t=e.length;t--;)e[t]=e[t].split("=");return e}function i(){function t(e){var n=[];if(e)return s(e,function(e){var o={text:e.title,icon:e.icon};if(e.items)o.menu=t(e.items);else{var a=e.format||"custom"+r++;e.format||(e.name=a,i.push(e)),o.format=a,o.cmd=e.cmd}n.push(o)}),n}function n(){var n;return n=t(e.settings.style_formats_merge?e.settings.style_formats?o.concat(e.settings.style_formats):o:e.settings.style_formats||o)}var r=0,i=[],o=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}];return e.on("init",function(){s(i,function(t){e.formatter.register(t.name,t)})}),{type:"menu",items:n(),onPostRender:function(t){e.fire("renderFormatsMenu",{control:t.control})},itemDefaults:{preview:!0,textStyle:function(){return this.settings.format?e.formatter.getCssText(this.settings.format):void 0},onPostRender:function(){var t=this;t.parent().on("show",function(){var n,r;n=t.settings.format,n&&(t.disabled(!e.formatter.canApply(n)),t.active(e.formatter.match(n))),r=t.settings.cmd,r&&t.active(e.queryCommandState(r))})},onclick:function(){this.settings.format&&l(this.settings.format),this.settings.cmd&&e.execCommand(this.settings.cmd)}}}}function o(t){return function(){function n(){return e.undoManager?e.undoManager[t]():!1}var r=this;t="redo"==t?"hasRedo":"hasUndo",r.disabled(!n()),e.on("Undo Redo AddUndo TypingUndo ClearUndos",function(){r.disabled(!n())})}}function a(){var t=this;e.on("VisualAid",function(e){t.active(e.hasVisual)}),t.active(e.hasVisual)}function l(t){t.control&&(t=t.control.value()),t&&e.execCommand("mceToggleFormat",!1,t)}var c;c=i(),s({bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript"},function(t,n){e.addButton(n,{tooltip:t,onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",shortcut:"Ctrl+N",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Ctrl+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Ctrl+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Ctrl+X"],copy:["Copy","Copy","Ctrl+C"],paste:["Paste","Paste","Ctrl+V"],selectall:["Select all","SelectAll","Ctrl+A"],bold:["Bold","Bold","Ctrl+B"],italic:["Italic","Italic","Ctrl+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Address=address;Pre=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(qt,[_t],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;f++)_+=N[f]+(f>0?b:0),R-=(f>0?b:0)+N[f];if(w+=g.left+g.right,_+=g.top+g.bottom,l={},l.minW=w+(o.w-o.innerW),l.minH=_+(o.h-o.innerH),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH,l.minW=Math.min(l.minW,o.maxW),l.minH=Math.min(l.minH,o.maxH),l.minW=Math.max(l.minW,o.startMinWidth),l.minH=Math.max(l.minH,o.startMinHeight),!o.autoResize||l.minW==o.minW&&l.minH==o.minH){o.autoResize&&(l=e.layoutRect(l),l.contentW=l.minW-o.deltaW,l.contentH=l.minH-o.deltaH);var D;D="start"==t.packV?0:R>0?Math.floor(R/n):0;var L=0,H=t.flexWidths;if(H)for(d=0;dd;d++)E[d]+=H?H[d]*M:M;for(h=g.top,f=0;n>f;f++){for(p=g.left,s=N[f]+D,d=0;r>d&&(B=A?f*r+r-1-d:f*r+d,u=i[B],u);d++)m=u.settings,c=u.layoutRect(),a=Math.max(E[d],c.startMinWidth),c.x=p,c.y=h,v=m.alignH||(C?C[d]||C[0]:null),"center"==v?c.x=p+a/2-c.w/2:"right"==v?c.x=p+a-c.w:"stretch"==v&&(c.w=a),v=m.alignV||(x?x[d]||x[0]:null),"center"==v?c.y=h+s/2-c.h/2:"bottom"==v?c.y=h+s-c.h:"stretch"==v&&(c.h=s),u.layoutRect(c),p+=a+y,u.recalc&&u.recalc();h+=s+b}}else if(l.w=l.minW,l.h=l.minH,e.layoutRect(l),this.recalc(e),null===e._lastRect){var P=e.parent();P&&(P._lastRect=null,P.recalc())}}})}),r(jt,[Nt],function(e){return e.extend({renderHtml:function(){var e=this;return e.addClass("iframe"),e.canFocus=!1,''},src:function(e){this.getEl().src=e},html:function(e,t){var n=this,r=this.getEl().contentWindow.document.body;return r?(r.innerHTML=e,t&&t()):setTimeout(function(){n.html(e)},0),this}})}),r(Yt,[Nt,Y],function(e,t){return e.extend({init:function(e){var t=this;t._super(e),t.addClass("widget"),t.addClass("label"),t.canFocus=!1,e.multiline&&t.addClass("autoscroll"),e.strong&&t.addClass("strong")},initLayoutRect:function(){var e=this,n=e._super();if(e.settings.multiline){var r=t.getSize(e.getEl());r.width>n.maxW&&(n.minW=n.maxW,e.addClass("multiline")),e.getEl().style.width=n.minW+"px",n.startMinH=n.h=n.minH=Math.min(n.maxH,t.getSize(e.getEl()).height)}return n},repaint:function(){var e=this;return e.settings.multiline||(e.getEl().style.lineHeight=e.layoutRect().h+"px"),e._super()},text:function(e){var t=this;return t._rendered&&e&&this.innerHtml(t.encode(e)),t._super(e)},renderHtml:function(){var e=this,t=e.settings.forId;return'" +}})}),r(Kt,[J],function(e){return e.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(e){var t=this;t._super(e),t.addClass("toolbar")},postRender:function(){var e=this;return e.items().addClass("toolbar-item"),e._super()}})}),r(Gt,[Kt],function(e){return e.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})}),r(Xt,[kt,G,Gt],function(e,t,n){function r(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1}var i=e.extend({init:function(e){var t=this;t._renderOpen=!0,t._super(e),t.addClass("menubtn"),e.fixedWidth&&t.addClass("fixed-width"),t.aria("haspopup",!0),t.hasPopup=!0},showMenu:function(){var e=this,n=e.settings,r;return e.menu&&e.menu.visible()?e.hideMenu():(e.menu||(r=n.menu||[],r.length?r={type:"menu",items:r}:r.type=r.type||"menu",e.menu=t.create(r).parent(e).renderTo(),e.fire("createmenu"),e.menu.reflow(),e.menu.on("cancel",function(t){t.control.parent()===e.menu&&(t.stopPropagation(),e.focus(),e.hideMenu())}),e.menu.on("select",function(){e.focus()}),e.menu.on("show hide",function(t){t.control==e.menu&&e.activeMenu("show"==t.type),e.aria("expanded","show"==t.type)}).fire("show")),e.menu.show(),e.menu.layoutRect({w:e.layoutRect().w}),void e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]))},hideMenu:function(){var e=this;e.menu&&(e.menu.items().each(function(e){e.hideMenu&&e.hideMenu()}),e.menu.hide())},activeMenu:function(e){this.toggleClass("active",e)},renderHtml:function(){var e=this,t=e._id,r=e.classPrefix,i=e.settings.icon,o;return o=e.settings.image,o?(i="none","string"!=typeof o&&(o=window.getSelection?o[0]:o[1]),o=" style=\"background-image: url('"+o+"')\""):o="",i=e.settings.icon?r+"ico "+r+"i-"+i:"",e.aria("role",e.parent()instanceof n?"menuitem":"button"),'
          '},postRender:function(){var e=this;return e.on("click",function(t){t.control===e&&r(t.target,e.getEl())&&(e.showMenu(),t.aria&&e.menu.items()[0].focus())}),e.on("mouseenter",function(t){var n=t.control,r=e.parent(),o;n&&r&&n instanceof i&&n.parent()==r&&(r.items().filter("MenuButton").each(function(e){e.hideMenu&&e!=n&&(e.menu&&e.menu.visible()&&(o=!0),e.hideMenu())}),o&&(n.focus(),n.showMenu()))}),e._super()},text:function(e){var t=this,n,r;if(t._rendered)for(r=t.getEl("open").getElementsByTagName("span"),n=0;n0&&(o=r[0].text,n._value=r[0].value),e.menu=r),e.text=e.text||o||r[0].text,n._super(e),n.addClass("listbox"),n.on("select",function(t){var r=t.control;a&&(t.lastControl=a),e.multiple?r.active(!r.active()):n.value(t.control.settings.value),a=r})},value:function(e){function t(e,n){e.items().each(function(e){i=e.value()===n,i&&(o=o||e.text()),e.active(i),e.menu&&t(e.menu,n)})}function n(t){for(var r=0;r'+("-"!==o?'\xa0":"")+("-"!==o?''+o+"":"")+(l?'
          '+l+"
          ":"")+(r.menu?'
          ':"")+"
          "},postRender:function(){var e=this,t=e.settings,n=t.textStyle;if("function"==typeof n&&(n=n.call(this)),n){var r=e.getEl("text");r&&r.setAttribute("style",n)}return e.on("mouseenter click",function(n){n.control===e&&(t.menu||"click"!==n.type?(e.showMenu(),n.aria&&e.menu.focus(!0)):(e.fire("select"),e.parent().hideAll()))}),e._super(),e},active:function(e){return"undefined"!=typeof e&&this.aria("checked",e),this._super(e)},remove:function(){this._super(),this.menu&&this.menu.remove()}})}),r(Zt,[rt,Qt,d],function(e,t,n){var r=e.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(e){var t=this;if(e.autohide=!0,e.constrainToViewport=!0,e.itemDefaults)for(var r=e.items,i=r.length;i--;)r[i]=n.extend({},e.itemDefaults,r[i]);t._super(e),t.addClass("menu")},repaint:function(){return this.toggleClass("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var e=this;e.hideAll(),e.fire("select")},hideAll:function(){var e=this;return this.find("menuitem").exec("hideMenu"),e._super()},preRender:function(){var e=this;return e.items().each(function(t){var n=t.settings;return n.icon||n.selectable?(e._hasIcons=!0,!1):void 0}),e._super()}});return r}),r(en,[Tt],function(e){return e.extend({Defaults:{classes:"radio",role:"radio"}})}),r(tn,[Nt,Q],function(e,t){return e.extend({renderHtml:function(){var e=this,t=e.classPrefix;return e.addClass("resizehandle"),"both"==e.settings.direction&&e.addClass("resizehandle-both"),e.canFocus=!1,'
          '},postRender:function(){var e=this;e._super(),e.resizeDragHelper=new t(this._id,{start:function(){e.fire("ResizeStart")},drag:function(t){"both"!=e.settings.direction&&(t.deltaX=0),e.fire("Resize",t)},stop:function(){e.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})}),r(nn,[Nt],function(e){return e.extend({renderHtml:function(){var e=this;return e.addClass("spacer"),e.canFocus=!1,'
          '}})}),r(rn,[Xt,Y],function(e,t){return e.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var e=this,n=e.getEl(),r=e.layoutRect(),i,o;return e._super(),i=n.firstChild,o=n.lastChild,t.css(i,{width:r.w-t.getSize(o).width,height:r.h-2}),t.css(o,{height:r.h-2}),e},activeMenu:function(e){var n=this;t.toggleClass(n.getEl().lastChild,n.classPrefix+"active",e)},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix,r,i=e.settings.icon;return r=e.settings.image,r?(i="none","string"!=typeof r&&(r=window.getSelection?r[0]:r[1]),r=" style=\"background-image: url('"+r+"')\""):r="",i=e.settings.icon?n+"ico "+n+"i-"+i:"",'
          '},postRender:function(){var e=this,t=e.settings.onclick;return e.on("click",function(e){var n=e.target;if(e.control==this)for(;n;){if(e.aria&&"down"!=e.aria.key||"BUTTON"==n.nodeName&&-1==n.className.indexOf("open"))return e.stopImmediatePropagation(),void t.call(this,e);n=n.parentNode}}),delete e.settings.onclick,e._super()}})}),r(on,[Ut],function(e){return e.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"}})}),r(an,[et,Y],function(e,t){return e.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(e){var n;this.activeTabId&&(n=this.getEl(this.activeTabId),t.removeClass(n,this.classPrefix+"active"),n.setAttribute("aria-selected","false")),this.activeTabId="t"+e,n=this.getEl("t"+e),n.setAttribute("aria-selected","true"),t.addClass(n,this.classPrefix+"active"),this.items()[e].show().fire("showtab"),this.reflow(),this.items().each(function(t,n){e!=n&&t.hide()})},renderHtml:function(){var e=this,t=e._layout,n="",r=e.classPrefix;return e.preRender(),t.preRender(e),e.items().each(function(t,i){var o=e._id+"-t"+i;t.aria("role","tabpanel"),t.aria("labelledby",o),n+='"}),'
          '+n+'
          '+t.renderHtml(e)+"
          "},postRender:function(){var e=this;e._super(),e.settings.activeTab=e.settings.activeTab||0,e.activateTab(e.settings.activeTab),this.on("click",function(t){var n=t.target.parentNode;if(t.target.parentNode.id==e._id+"-head")for(var r=n.childNodes.length;r--;)n.childNodes[r]==t.target&&e.activateTab(r)})},initLayoutRect:function(){var e=this,n,r,i;r=t.getSize(e.getEl("head")).width,r=0>r?0:r,i=0,e.items().each(function(e){r=Math.max(r,e.layoutRect().minW),i=Math.max(i,e.layoutRect().minH)}),e.items().each(function(e){e.settings.x=0,e.settings.y=0,e.settings.w=r,e.settings.h=i,e.layoutRect({x:0,y:0,w:r,h:i})});var o=t.getSize(e.getEl("head")).height;return e.settings.minWidth=r,e.settings.minHeight=i+o,n=e._super(),n.deltaH+=o,n.innerH=n.h-n.deltaH,n}})}),r(sn,[Nt,Y],function(e,t){return e.extend({init:function(e){var t=this;t._super(e),t._value=e.value||"",t.addClass("textbox"),e.multiline?t.addClass("multiline"):t.on("keydown",function(e){13==e.keyCode&&t.parents().reverse().each(function(t){return e.preventDefault(),t.hasEventListeners("submit")&&t.toJSON?(t.fire("submit",{data:t.toJSON()}),!1):void 0})})},disabled:function(e){var t=this;return t._rendered&&"undefined"!=typeof e&&(t.getEl().disabled=e),t._super(e)},value:function(e){var t=this;return"undefined"!=typeof e?(t._value=e,t._rendered&&(t.getEl().value=e),t):t._rendered?t.getEl().value:t._value},repaint:function(){var e=this,t,n,r,i=0,o=0,a;t=e.getEl().style,n=e._layoutRect,a=e._lastRepaintRect||{};var s=document;return!e.settings.multiline&&s.all&&(!s.documentMode||s.documentMode<=8)&&(t.lineHeight=n.h-o+"px"),r=e._borderBox,i=r.left+r.right+8,o=r.top+r.bottom+(e.settings.multiline?8:0),n.x!==a.x&&(t.left=n.x+"px",a.x=n.x),n.y!==a.y&&(t.top=n.y+"px",a.y=n.y),n.w!==a.w&&(t.width=n.w-i+"px",a.w=n.w),n.h!==a.h&&(t.height=n.h-o+"px",a.h=n.h),e._lastRepaintRect=a,e.fire("repaint",{},!1),e},renderHtml:function(){var e=this,t=e._id,n=e.settings,r=e.encode(e._value,!1),i="";return"spellcheck"in n&&(i+=' spellcheck="'+n.spellcheck+'"'),n.maxLength&&(i+=' maxlength="'+n.maxLength+'"'),n.size&&(i+=' size="'+n.size+'"'),n.subtype&&(i+=' type="'+n.subtype+'"'),e.disabled()&&(i+=' disabled="disabled"'),n.multiline?'":'"},postRender:function(){var e=this;return t.on(e.getEl(),"change",function(t){e.fire("change",t)}),e._super()},remove:function(){t.off(this.getEl()),this._super()}})}),r(ln,[Y,K],function(e,t){return function(n,r){var i=this,o,a=t.classPrefix;i.show=function(t){return i.hide(),o=!0,window.setTimeout(function(){o&&n.appendChild(e.createFragment('
          '))},t||0),i},i.hide=function(){var e=n.lastChild;return e&&-1!=e.className.indexOf("throbber")&&e.parentNode.removeChild(e),o=!1,i}}}),a([l,c,u,d,f,p,h,m,g,y,b,C,_,E,N,k,S,T,R,A,B,D,L,H,M,O,I,F,z,W,V,U,$,q,j,Y,K,G,X,J,Q,Z,et,tt,nt,rt,it,ot,at,st,lt,ct,ut,dt,ft,pt,ht,mt,gt,vt,yt,bt,Ct,xt,wt,_t,Et,Nt,kt,St,Tt,Rt,At,Bt,Dt,Lt,Ht,Mt,Pt,Ot,It,Ft,zt,Wt,Vt,Ut,$t,qt,jt,Yt,Kt,Gt,Xt,Jt,Qt,Zt,en,tn,nn,rn,on,an,sn,ln])}(this); +/*! + + handlebars v1.3.0 + +Copyright (C) 2011 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +@license +*/ +/* exported Handlebars */ +var Handlebars = (function() { +// handlebars/safe-string.js +var __module4__ = (function() { + "use strict"; + var __exports__; + // Build out our basic SafeString type + function SafeString(string) { + this.string = string; + } + + SafeString.prototype.toString = function() { + return "" + this.string; + }; + + __exports__ = SafeString; + return __exports__; +})(); + +// handlebars/utils.js +var __module3__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + /*jshint -W004 */ + var SafeString = __dependency1__; + + var escape = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" + }; + + var badChars = /[&<>"'`]/g; + var possible = /[&<>"'`]/; + + function escapeChar(chr) { + return escape[chr] || "&"; + } + + function extend(obj, value) { + for(var key in value) { + if(Object.prototype.hasOwnProperty.call(value, key)) { + obj[key] = value[key]; + } + } + } + + __exports__.extend = extend;var toString = Object.prototype.toString; + __exports__.toString = toString; + // Sourced from lodash + // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt + var isFunction = function(value) { + return typeof value === 'function'; + }; + // fallback for older versions of Chrome and Safari + if (isFunction(/x/)) { + isFunction = function(value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; + } + var isFunction; + __exports__.isFunction = isFunction; + var isArray = Array.isArray || function(value) { + return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; + }; + __exports__.isArray = isArray; + + function escapeExpression(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof SafeString) { + return string.toString(); + } else if (!string && string !== 0) { + return ""; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = "" + string; + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + } + + __exports__.escapeExpression = escapeExpression;function isEmpty(value) { + if (!value && value !== 0) { + return true; + } else if (isArray(value) && value.length === 0) { + return true; + } else { + return false; + } + } + + __exports__.isEmpty = isEmpty; + return __exports__; +})(__module4__); + +// handlebars/exception.js +var __module5__ = (function() { + "use strict"; + var __exports__; + + var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + + function Exception(message, node) { + var line; + if (node && node.firstLine) { + line = node.firstLine; + + message += ' - ' + line + ':' + node.firstColumn; + } + + var tmp = Error.prototype.constructor.call(this, message); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } + + if (line) { + this.lineNumber = line; + this.column = node.firstColumn; + } + } + + Exception.prototype = new Error(); + + __exports__ = Exception; + return __exports__; +})(); + +// handlebars/base.js +var __module2__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var Utils = __dependency1__; + var Exception = __dependency2__; + + var VERSION = "1.3.0"; + __exports__.VERSION = VERSION;var COMPILER_REVISION = 4; + __exports__.COMPILER_REVISION = COMPILER_REVISION; + var REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '>= 1.0.0' + }; + __exports__.REVISION_CHANGES = REVISION_CHANGES; + var isArray = Utils.isArray, + isFunction = Utils.isFunction, + toString = Utils.toString, + objectType = '[object Object]'; + + function HandlebarsEnvironment(helpers, partials) { + this.helpers = helpers || {}; + this.partials = partials || {}; + + registerDefaultHelpers(this); + } + + __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = { + constructor: HandlebarsEnvironment, + + logger: logger, + log: log, + + registerHelper: function(name, fn, inverse) { + if (toString.call(name) === objectType) { + if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); } + Utils.extend(this.helpers, name); + } else { + if (inverse) { fn.not = inverse; } + this.helpers[name] = fn; + } + }, + + registerPartial: function(name, str) { + if (toString.call(name) === objectType) { + Utils.extend(this.partials, name); + } else { + this.partials[name] = str; + } + } + }; + + function registerDefaultHelpers(instance) { + instance.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Exception("Missing helper: '" + arg + "'"); + } + }); + + instance.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + if (isFunction(context)) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if (isArray(context)) { + if(context.length > 0) { + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } + }); + + instance.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (isFunction(context)) { context = context.call(this); } + + if (options.data) { + data = createFrame(options.data); + } + + if(context && typeof context === 'object') { + if (isArray(context)) { + for(var j = context.length; i 0) { + throw new Exception("Invalid path: " + original, this); + } else if (part === "..") { + depth++; + } else { + this.isScoped = true; + } + } else { + dig.push(part); + } + } + + this.original = original; + this.parts = dig; + this.string = dig.join('.'); + this.depth = depth; + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; + + this.stringModeValue = this.string; + }, + + PartialNameNode: function(name, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "PARTIAL_NAME"; + this.name = name.original; + }, + + DataNode: function(id, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "DATA"; + this.id = id; + }, + + StringNode: function(string, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "STRING"; + this.original = + this.string = + this.stringModeValue = string; + }, + + IntegerNode: function(integer, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "INTEGER"; + this.original = + this.integer = integer; + this.stringModeValue = Number(integer); + }, + + BooleanNode: function(bool, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "BOOLEAN"; + this.bool = bool; + this.stringModeValue = bool === "true"; + }, + + CommentNode: function(comment, locInfo) { + LocationInfo.call(this, locInfo); + this.type = "comment"; + this.comment = comment; + } + }; + + // Must be exported as an object rather than the root of the module as the jison lexer + // most modify the object to operate properly. + __exports__ = AST; + return __exports__; +})(__module5__); + +// handlebars/compiler/parser.js +var __module9__ = (function() { + "use strict"; + var __exports__; + /* jshint ignore:start */ + /* Jison generated parser */ + var handlebars = (function(){ + var parser = {trace: function trace() { }, + yy: {}, + symbols_: {"error":2,"root":3,"statements":4,"EOF":5,"program":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"sexpr":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"CLOSE_UNESCAPED":24,"OPEN_PARTIAL":25,"partialName":26,"partial_option0":27,"sexpr_repetition0":28,"sexpr_option0":29,"dataName":30,"param":31,"STRING":32,"INTEGER":33,"BOOLEAN":34,"OPEN_SEXPR":35,"CLOSE_SEXPR":36,"hash":37,"hash_repetition_plus0":38,"hashSegment":39,"ID":40,"EQUALS":41,"DATA":42,"pathSegments":43,"SEP":44,"$accept":0,"$end":1}, + terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"CLOSE_UNESCAPED",25:"OPEN_PARTIAL",32:"STRING",33:"INTEGER",34:"BOOLEAN",35:"OPEN_SEXPR",36:"CLOSE_SEXPR",40:"ID",41:"EQUALS",42:"DATA",44:"SEP"}, + productions_: [0,[3,2],[3,1],[6,2],[6,3],[6,2],[6,1],[6,1],[6,0],[4,1],[4,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,4],[7,2],[17,3],[17,1],[31,1],[31,1],[31,1],[31,1],[31,1],[31,3],[37,1],[39,3],[26,1],[26,1],[26,1],[30,2],[21,1],[43,3],[43,1],[27,0],[27,1],[28,0],[28,2],[29,0],[29,1],[38,1],[38,2]], + performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { + + var $0 = $$.length - 1; + switch (yystate) { + case 1: return new yy.ProgramNode($$[$0-1], this._$); + break; + case 2: return new yy.ProgramNode([], this._$); + break; + case 3:this.$ = new yy.ProgramNode([], $$[$0-1], $$[$0], this._$); + break; + case 4:this.$ = new yy.ProgramNode($$[$0-2], $$[$0-1], $$[$0], this._$); + break; + case 5:this.$ = new yy.ProgramNode($$[$0-1], $$[$0], [], this._$); + break; + case 6:this.$ = new yy.ProgramNode($$[$0], this._$); + break; + case 7:this.$ = new yy.ProgramNode([], this._$); + break; + case 8:this.$ = new yy.ProgramNode([], this._$); + break; + case 9:this.$ = [$$[$0]]; + break; + case 10: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; + break; + case 11:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1].inverse, $$[$0-1], $$[$0], this._$); + break; + case 12:this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0-1].inverse, $$[$0], this._$); + break; + case 13:this.$ = $$[$0]; + break; + case 14:this.$ = $$[$0]; + break; + case 15:this.$ = new yy.ContentNode($$[$0], this._$); + break; + case 16:this.$ = new yy.CommentNode($$[$0], this._$); + break; + case 17:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 18:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 19:this.$ = {path: $$[$0-1], strip: stripFlags($$[$0-2], $$[$0])}; + break; + case 20:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 21:this.$ = new yy.MustacheNode($$[$0-1], null, $$[$0-2], stripFlags($$[$0-2], $$[$0]), this._$); + break; + case 22:this.$ = new yy.PartialNode($$[$0-2], $$[$0-1], stripFlags($$[$0-3], $$[$0]), this._$); + break; + case 23:this.$ = stripFlags($$[$0-1], $$[$0]); + break; + case 24:this.$ = new yy.SexprNode([$$[$0-2]].concat($$[$0-1]), $$[$0], this._$); + break; + case 25:this.$ = new yy.SexprNode([$$[$0]], null, this._$); + break; + case 26:this.$ = $$[$0]; + break; + case 27:this.$ = new yy.StringNode($$[$0], this._$); + break; + case 28:this.$ = new yy.IntegerNode($$[$0], this._$); + break; + case 29:this.$ = new yy.BooleanNode($$[$0], this._$); + break; + case 30:this.$ = $$[$0]; + break; + case 31:$$[$0-1].isHelper = true; this.$ = $$[$0-1]; + break; + case 32:this.$ = new yy.HashNode($$[$0], this._$); + break; + case 33:this.$ = [$$[$0-2], $$[$0]]; + break; + case 34:this.$ = new yy.PartialNameNode($$[$0], this._$); + break; + case 35:this.$ = new yy.PartialNameNode(new yy.StringNode($$[$0], this._$), this._$); + break; + case 36:this.$ = new yy.PartialNameNode(new yy.IntegerNode($$[$0], this._$)); + break; + case 37:this.$ = new yy.DataNode($$[$0], this._$); + break; + case 38:this.$ = new yy.IdNode($$[$0], this._$); + break; + case 39: $$[$0-2].push({part: $$[$0], separator: $$[$0-1]}); this.$ = $$[$0-2]; + break; + case 40:this.$ = [{part: $$[$0]}]; + break; + case 43:this.$ = []; + break; + case 44:$$[$0-1].push($$[$0]); + break; + case 47:this.$ = [$$[$0]]; + break; + case 48:$$[$0-1].push($$[$0]); + break; + } + }, + table: [{3:1,4:2,5:[1,3],8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[3]},{5:[1,16],8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],25:[1,15]},{1:[2,2]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],25:[2,9]},{4:20,6:18,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{4:20,6:22,7:19,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,8],22:[1,13],23:[1,14],25:[1,15]},{5:[2,13],14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],25:[2,13]},{5:[2,14],14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],25:[2,14]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],25:[2,15]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],25:[2,16]},{17:23,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:29,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:30,21:24,30:25,40:[1,28],42:[1,27],43:26},{17:31,21:24,30:25,40:[1,28],42:[1,27],43:26},{21:33,26:32,32:[1,34],33:[1,35],40:[1,28],43:26},{1:[2,1]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],25:[2,10]},{10:36,20:[1,37]},{4:38,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,7],22:[1,13],23:[1,14],25:[1,15]},{7:39,8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,21],20:[2,6],22:[1,13],23:[1,14],25:[1,15]},{17:23,18:[1,40],21:24,30:25,40:[1,28],42:[1,27],43:26},{10:41,20:[1,37]},{18:[1,42]},{18:[2,43],24:[2,43],28:43,32:[2,43],33:[2,43],34:[2,43],35:[2,43],36:[2,43],40:[2,43],42:[2,43]},{18:[2,25],24:[2,25],36:[2,25]},{18:[2,38],24:[2,38],32:[2,38],33:[2,38],34:[2,38],35:[2,38],36:[2,38],40:[2,38],42:[2,38],44:[1,44]},{21:45,40:[1,28],43:26},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,40],36:[2,40],40:[2,40],42:[2,40],44:[2,40]},{18:[1,46]},{18:[1,47]},{24:[1,48]},{18:[2,41],21:50,27:49,40:[1,28],43:26},{18:[2,34],40:[2,34]},{18:[2,35],40:[2,35]},{18:[2,36],40:[2,36]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],25:[2,11]},{21:51,40:[1,28],43:26},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,3],22:[1,13],23:[1,14],25:[1,15]},{4:52,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,5],22:[1,13],23:[1,14],25:[1,15]},{14:[2,23],15:[2,23],16:[2,23],19:[2,23],20:[2,23],22:[2,23],23:[2,23],25:[2,23]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],25:[2,12]},{14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],25:[2,18]},{18:[2,45],21:56,24:[2,45],29:53,30:60,31:54,32:[1,57],33:[1,58],34:[1,59],35:[1,61],36:[2,45],37:55,38:62,39:63,40:[1,64],42:[1,27],43:26},{40:[1,65]},{18:[2,37],24:[2,37],32:[2,37],33:[2,37],34:[2,37],35:[2,37],36:[2,37],40:[2,37],42:[2,37]},{14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],25:[2,17]},{5:[2,20],14:[2,20],15:[2,20],16:[2,20],19:[2,20],20:[2,20],22:[2,20],23:[2,20],25:[2,20]},{5:[2,21],14:[2,21],15:[2,21],16:[2,21],19:[2,21],20:[2,21],22:[2,21],23:[2,21],25:[2,21]},{18:[1,66]},{18:[2,42]},{18:[1,67]},{8:17,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],25:[1,15]},{18:[2,24],24:[2,24],36:[2,24]},{18:[2,44],24:[2,44],32:[2,44],33:[2,44],34:[2,44],35:[2,44],36:[2,44],40:[2,44],42:[2,44]},{18:[2,46],24:[2,46],36:[2,46]},{18:[2,26],24:[2,26],32:[2,26],33:[2,26],34:[2,26],35:[2,26],36:[2,26],40:[2,26],42:[2,26]},{18:[2,27],24:[2,27],32:[2,27],33:[2,27],34:[2,27],35:[2,27],36:[2,27],40:[2,27],42:[2,27]},{18:[2,28],24:[2,28],32:[2,28],33:[2,28],34:[2,28],35:[2,28],36:[2,28],40:[2,28],42:[2,28]},{18:[2,29],24:[2,29],32:[2,29],33:[2,29],34:[2,29],35:[2,29],36:[2,29],40:[2,29],42:[2,29]},{18:[2,30],24:[2,30],32:[2,30],33:[2,30],34:[2,30],35:[2,30],36:[2,30],40:[2,30],42:[2,30]},{17:68,21:24,30:25,40:[1,28],42:[1,27],43:26},{18:[2,32],24:[2,32],36:[2,32],39:69,40:[1,70]},{18:[2,47],24:[2,47],36:[2,47],40:[2,47]},{18:[2,40],24:[2,40],32:[2,40],33:[2,40],34:[2,40],35:[2,40],36:[2,40],40:[2,40],41:[1,71],42:[2,40],44:[2,40]},{18:[2,39],24:[2,39],32:[2,39],33:[2,39],34:[2,39],35:[2,39],36:[2,39],40:[2,39],42:[2,39],44:[2,39]},{5:[2,22],14:[2,22],15:[2,22],16:[2,22],19:[2,22],20:[2,22],22:[2,22],23:[2,22],25:[2,22]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],25:[2,19]},{36:[1,72]},{18:[2,48],24:[2,48],36:[2,48],40:[2,48]},{41:[1,71]},{21:56,30:60,31:73,32:[1,57],33:[1,58],34:[1,59],35:[1,61],40:[1,28],42:[1,27],43:26},{18:[2,31],24:[2,31],32:[2,31],33:[2,31],34:[2,31],35:[2,31],36:[2,31],40:[2,31],42:[2,31]},{18:[2,33],24:[2,33],36:[2,33],40:[2,33]}], + defaultActions: {3:[2,2],16:[2,1],50:[2,42]}, + parseError: function parseError(str, hash) { + throw new Error(str); + }, + parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == "undefined") + this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === "function") + this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== "number") { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + if (!recovering) { + expected = []; + for (p in table[state]) + if (this.terminals_[p] && p > 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + + + function stripFlags(open, close) { + return { + left: open.charAt(2) === '~', + right: close.charAt(0) === '~' || close.charAt(1) === '~' + }; + } + + /* Jison generated lexer */ + var lexer = (function(){ + var lexer = ({EOF:1, + parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + setInput:function (input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; + if (this.options.ranges) this.yylloc.range = [0,0]; + this.offset = 0; + return this; + }, + input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, + unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length-len-1); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length-1); + this.matched = this.matched.substr(0, this.matched.length-1); + + if (lines.length-1) this.yylineno -= lines.length-1; + var r = this.yylloc.range; + + this.yylloc = {first_line: this.yylloc.first_line, + last_line: this.yylineno+1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, + more:function () { + this._more = true; + return this; + }, + less:function (n) { + this.unput(this.match.slice(n)); + }, + pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, + upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); + }, + showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c+"^"; + }, + next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, + match, + tempMatch, + index, + col, + lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i=0;i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = {first_line: this.yylloc.last_line, + last_line: this.yylineno+1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); + if (this.done && this._input) this.done = false; + if (token) return token; + else return; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + {text: "", token: null, line: this.yylineno}); + } + }, + lex:function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, + begin:function begin(condition) { + this.conditionStack.push(condition); + }, + popState:function popState() { + return this.conditionStack.pop(); + }, + _currentRules:function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; + }, + topState:function () { + return this.conditionStack[this.conditionStack.length-2]; + }, + pushState:function begin(condition) { + this.begin(condition); + }}); + lexer.options = {}; + lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + + + function strip(start, end) { + return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end); + } + + + var YYSTATE=YY_START + switch($avoiding_name_collisions) { + case 0: + if(yy_.yytext.slice(-2) === "\\\\") { + strip(0,1); + this.begin("mu"); + } else if(yy_.yytext.slice(-1) === "\\") { + strip(0,1); + this.begin("emu"); + } else { + this.begin("mu"); + } + if(yy_.yytext) return 14; + + break; + case 1:return 14; + break; + case 2: + this.popState(); + return 14; + + break; + case 3:strip(0,4); this.popState(); return 15; + break; + case 4:return 35; + break; + case 5:return 36; + break; + case 6:return 25; + break; + case 7:return 16; + break; + case 8:return 20; + break; + case 9:return 19; + break; + case 10:return 19; + break; + case 11:return 23; + break; + case 12:return 22; + break; + case 13:this.popState(); this.begin('com'); + break; + case 14:strip(3,5); this.popState(); return 15; + break; + case 15:return 22; + break; + case 16:return 41; + break; + case 17:return 40; + break; + case 18:return 40; + break; + case 19:return 44; + break; + case 20:// ignore whitespace + break; + case 21:this.popState(); return 24; + break; + case 22:this.popState(); return 18; + break; + case 23:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 32; + break; + case 24:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 32; + break; + case 25:return 42; + break; + case 26:return 34; + break; + case 27:return 34; + break; + case 28:return 33; + break; + case 29:return 40; + break; + case 30:yy_.yytext = strip(1,2); return 40; + break; + case 31:return 'INVALID'; + break; + case 32:return 5; + break; + } + }; + lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?=([~}\s)])))/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; + lexer.conditions = {"mu":{"rules":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[3],"inclusive":false},"INITIAL":{"rules":[0,1,32],"inclusive":true}}; + return lexer;})() + parser.lexer = lexer; + function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; + return new Parser; + })();__exports__ = handlebars; + /* jshint ignore:end */ + return __exports__; +})(); + +// handlebars/compiler/base.js +var __module8__ = (function(__dependency1__, __dependency2__) { + "use strict"; + var __exports__ = {}; + var parser = __dependency1__; + var AST = __dependency2__; + + __exports__.parser = parser; + + function parse(input) { + // Just return if an already-compile AST was passed in. + if(input.constructor === AST.ProgramNode) { return input; } + + parser.yy = AST; + return parser.parse(input); + } + + __exports__.parse = parse; + return __exports__; +})(__module9__, __module7__); + +// handlebars/compiler/compiler.js +var __module10__ = (function(__dependency1__) { + "use strict"; + var __exports__ = {}; + var Exception = __dependency1__; + + function Compiler() {} + + __exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a + // function in a context. This is necessary for mustache compatibility, which + // requires that context functions in blocks are evaluated by blockHelperMissing, + // and then proceed as if the resulting value was provided to blockHelperMissing. + + Compiler.prototype = { + compiler: Compiler, + + disassemble: function() { + var opcodes = this.opcodes, opcode, out = [], params, param; + + for (var i=0, l=opcodes.length; i 0) { + this.source[1] = this.source[1] + ", " + locals.join(", "); + } + + // Generate minimizer alias mappings + if (!this.isChild) { + for (var alias in this.context.aliases) { + if (this.context.aliases.hasOwnProperty(alias)) { + this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; + } + } + } + + if (this.source[1]) { + this.source[1] = "var " + this.source[1].substring(2) + ";"; + } + + // Merge children + if (!this.isChild) { + this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; + } + + if (!this.environment.isSimple) { + this.pushSource("return buffer;"); + } + + var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; + + for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } + return this.topStackName(); + }, + topStackName: function() { + return "stack" + this.stackSlot; + }, + flushInline: function() { + var inlineStack = this.inlineStack; + if (inlineStack.length) { + this.inlineStack = []; + for (var i = 0, len = inlineStack.length; i < len; i++) { + var entry = inlineStack[i]; + if (entry instanceof Literal) { + this.compileStack.push(entry); + } else { + this.pushStack(entry); + } + } + } + }, + isInline: function() { + return this.inlineStack.length; + }, + + popStack: function(wrapped) { + var inline = this.isInline(), + item = (inline ? this.inlineStack : this.compileStack).pop(); + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + if (!inline) { + if (!this.stackSlot) { + throw new Exception('Invalid stack pop'); + } + this.stackSlot--; + } + return item; + } + }, + + topStack: function(wrapped) { + var stack = (this.isInline() ? this.inlineStack : this.compileStack), + item = stack[stack.length - 1]; + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + return item; + } + }, + + quotedString: function(str) { + return '"' + str + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2029/g, '\\u2029') + '"'; + }, + + setupHelper: function(paramSize, name, missingParams) { + var params = [], + paramsInit = this.setupParams(paramSize, params, missingParams); + var foundHelper = this.nameLookup('helpers', name, 'helper'); + + return { + params: params, + paramsInit: paramsInit, + name: foundHelper, + callParams: ["depth0"].concat(params).join(", "), + helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ") + }; + }, + + setupOptions: function(paramSize, params) { + var options = [], contexts = [], types = [], param, inverse, program; + + options.push("hash:" + this.popStack()); + + if (this.options.stringParams) { + options.push("hashTypes:" + this.popStack()); + options.push("hashContexts:" + this.popStack()); + } + + inverse = this.popStack(); + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + if (!program) { + this.context.aliases.self = "this"; + program = "self.noop"; + } + + if (!inverse) { + this.context.aliases.self = "this"; + inverse = "self.noop"; + } + + options.push("inverse:" + inverse); + options.push("fn:" + program); + } + + for(var i=0; ij;j++)if(a=arguments[j],null!==a||void 0!==a)for(b in a)c=g[b],d=a[b],g!==d&&(i&&d&&(OpenSeadragon.isPlainObject(d)||(e=OpenSeadragon.isArray(d)))?(e?(e=!1,f=c&&OpenSeadragon.isArray(c)?c:[]):f=c&&OpenSeadragon.isPlainObject(c)?c:{},g[b]=OpenSeadragon.extend(i,f,d)):void 0!==d&&(g[b]=d));return g},a.extend(a,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,pinchToZoom:!1,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,pinchToZoom:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,pixelsPerWheelLine:40,autoResize:!0,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorRotate:!0,degrees:0,opacity:1,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,useCanvas:!0,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:"#437AB2"},SIGNAL:"----seadragon----",delegate:function(a,b){return function(){var c=arguments;return void 0===c&&(c=[]),b.apply(a,c)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5},getElement:function(a){return"string"==typeof a&&(a=document.getElementById(a)),a},getElementPosition:function(c){var d,e,f=new a.Point;for(c=a.getElement(c),d="fixed"==a.getElementStyle(c).position,e=b(c,d);e;)f.x+=c.offsetLeft,f.y+=c.offsetTop,d&&(f=f.plus(a.getPageScroll())),c=e,d="fixed"==a.getElementStyle(c).position,e=b(c,d);return f},getElementOffset:function(b){b=a.getElement(b);var c,d,e=b&&b.ownerDocument,f={top:0,left:0};return e?(c=e.documentElement,"undefined"!=typeof b.getBoundingClientRect&&(f=b.getBoundingClientRect()),d=e==e.window?e:9===e.nodeType?e.defaultView||e.parentWindow:!1,new a.Point(f.left+(d.pageXOffset||c.scrollLeft)-(c.clientLeft||0),f.top+(d.pageYOffset||c.scrollTop)-(c.clientTop||0))):new a.Point},getElementSize:function(b){return b=a.getElement(b),new a.Point(b.clientWidth,b.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(b){return b=a.getElement(b),b.currentStyle}:function(b){return b=a.getElement(b),window.getComputedStyle(b,"")},pointInElement:function(b,c){b=a.getElement(b);var d=a.getElementOffset(b),e=a.getElementSize(b);return c.x>=d.x&&c.x=d.y},getEvent:function(b){return a.getEvent=b?function(a){return a}:function(){return window.event},a.getEvent(b)},getMousePosition:function(b){if("number"==typeof b.pageX)a.getMousePosition=function(b){var c=new a.Point;return b=a.getEvent(b),c.x=b.pageX,c.y=b.pageY,c};else{if("number"!=typeof b.clientX)throw new Error("Unknown event mouse position, no known technique.");a.getMousePosition=function(b){var c=new a.Point;return b=a.getEvent(b),c.x=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,c.y=b.clientY+document.body.scrollTop+document.documentElement.scrollTop,c}}return a.getMousePosition(b)},getPageScroll:function(){var b=document.documentElement||{},c=document.body||{};if("number"==typeof window.pageXOffset)a.getPageScroll=function(){return new a.Point(window.pageXOffset,window.pageYOffset)};else if(c.scrollLeft||c.scrollTop)a.getPageScroll=function(){return new a.Point(document.body.scrollLeft,document.body.scrollTop)};else{if(!b.scrollLeft&&!b.scrollTop)return new a.Point(0,0);a.getPageScroll=function(){return new a.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)}}return a.getPageScroll()},setPageScroll:function(b){if("undefined"!=typeof window.scrollTo)a.setPageScroll=function(a){window.scrollTo(a.x,a.y)};else{var c=a.getPageScroll();if(c.x===b.x&&c.y===b.y)return;document.body.scrollLeft=b.x,document.body.scrollTop=b.y;var d=a.getPageScroll();if(d.x!==c.x&&d.y!==c.y)return void(a.setPageScroll=function(a){document.body.scrollLeft=a.x,document.body.scrollTop=a.y});if(document.documentElement.scrollLeft=b.x,document.documentElement.scrollTop=b.y,d=a.getPageScroll(),d.x!==c.x&&d.y!==c.y)return void(a.setPageScroll=function(a){document.documentElement.scrollLeft=a.x,document.documentElement.scrollTop=a.y});a.setPageScroll=function(){}}return a.setPageScroll(b)},getWindowSize:function(){var b=document.documentElement||{},c=document.body||{};if("number"==typeof window.innerWidth)a.getWindowSize=function(){return new a.Point(window.innerWidth,window.innerHeight)};else if(b.clientWidth||b.clientHeight)a.getWindowSize=function(){return new a.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else{if(!c.clientWidth&&!c.clientHeight)throw new Error("Unknown window size, no known technique.");a.getWindowSize=function(){return new a.Point(document.body.clientWidth,document.body.clientHeight)}}return a.getWindowSize()},makeCenteredNode:function(b){b=a.getElement(b);var c=[a.makeNeutralElement("div"),a.makeNeutralElement("div"),a.makeNeutralElement("div")];return a.extend(c[0].style,{display:"table",height:"100%",width:"100%"}),a.extend(c[1].style,{display:"table-row"}),a.extend(c[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),c[0].appendChild(c[1]),c[1].appendChild(c[2]),c[2].appendChild(b),c[0]},makeNeutralElement:function(a){var b=document.createElement(a),c=b.style;return c.background="transparent none",c.border="none",c.margin="0px",c.padding="0px",c.position="static",b},now:function(){return a.now=Date.now?Date.now:function(){return(new Date).getTime()},a.now()},makeTransparentImage:function(b){return a.makeTransparentImage=function(b){var c=a.makeNeutralElement("img");return c.src=b,c},a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<7&&(a.makeTransparentImage=function(b){var c=a.makeNeutralElement("img"),d=null;return d=a.makeNeutralElement("span"),d.style.display="inline-block",c.onload=function(){d.style.width=d.style.width||c.width+"px",d.style.height=d.style.height||c.height+"px",c.onload=null,c=null},c.src=b,d.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"', sizingMethod='scale')",d}),a.makeTransparentImage(b)},setElementOpacity:function(b,c,d){var e,f;b=a.getElement(b),d&&!a.Browser.alpha&&(c=Math.round(c)),a.Browser.opacity?b.style.opacity=1>c?c:"":1>c?(e=Math.round(100*c),f="alpha(opacity="+e+")",b.style.filter=f):b.style.filter=""},setElementTouchActionNone:function(b){b=a.getElement(b),"undefined"!=typeof b.style.touchAction?b.style.touchAction="none":"undefined"!=typeof b.style.msTouchAction&&(b.style.msTouchAction="none")},addClass:function(b,c){b=a.getElement(b),b.className?-1===(" "+b.className+" ").indexOf(" "+c+" ")&&(b.className+=" "+c):b.className=c},indexOf:function(a,b,c){return this.indexOf=Array.prototype.indexOf?function(a,b,c){return a.indexOf(b,c)}:function(a,b,c){var d,e,f=c?c:0;if(!a)throw new TypeError;if(e=a.length,0===e||f>=e)return-1;for(0>f&&(f=e-Math.abs(f)),d=f;e>d;d++)if(a[d]===b)return d;return-1},this.indexOf(a,b,c)},removeClass:function(b,c){var d,e,f=[];for(b=a.getElement(b),d=b.className.split(/\s+/),e=0;e=0?(a.Browser.vendor=a.BROWSERS.FIREFOX,a.Browser.version=parseFloat(e.substring(e.indexOf("Firefox")+8))):e.indexOf("Safari")>=0?(a.Browser.vendor=e.indexOf("Chrome")>=0?a.BROWSERS.CHROME:a.BROWSERS.SAFARI,a.Browser.version=parseFloat(e.substring(e.substring(0,e.indexOf("Safari")).lastIndexOf("/")+1,e.indexOf("Safari")))):(b=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),null!==b.exec(e)&&(a.Browser.vendor=a.BROWSERS.IE,a.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":a.Browser.vendor=a.BROWSERS.OPERA,a.Browser.version=parseFloat(c)}var f,g,h,i=window.location.search.substring(1),j=i.split("&");for(h=0;h0&&(d[f.substring(0,g)]=decodeURIComponent(f.substring(g+1)));a.Browser.alpha=!(a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<9||a.Browser.vendor==a.BROWSERS.CHROME&&a.Browser.version<2),a.Browser.opacity=!(a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version<9)}();var e=function(){};a.console=window.console||{log:e,debug:e,info:e,warn:e,error:e,assert:e},function(b){var c=b.requestAnimationFrame||b.mozRequestAnimationFrame||b.webkitRequestAnimationFrame||b.msRequestAnimationFrame,d=b.cancelAnimationFrame||b.mozCancelAnimationFrame||b.webkitCancelAnimationFrame||b.msCancelAnimationFrame;if(c&&d)a.requestAnimationFrame=function(){return c.apply(b,arguments)},a.cancelAnimationFrame=function(){return d.apply(b,arguments)};else{var e,f=[],g=[],h=0;a.requestAnimationFrame=function(b){return f.push([++h,b]),e||(e=setInterval(function(){if(f.length){var b=a.now(),c=g;for(g=f,f=c;g.length;)g.shift()[1](b)}else clearInterval(e),e=void 0},20)),h},a.cancelAnimationFrame=function(a){var b,c;for(b=0,c=f.length;c>b;b+=1)if(f[b][0]===a)return void f.splice(b,1);for(b=0,c=g.length;c>b;b+=1)if(g[b][0]===a)return void g.splice(b,1)}}}(window),a._processDZIError=function(a){var b=a.getElementsByTagName("Message")[0],c=b.firstChild.nodeValue;throw new Error(c)}}(OpenSeadragon),function(a){var b={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.fullscreenElement},b.requestFullScreen=function(a){return a.requestFullscreen()},b.exitFullScreen=function(){document.exitFullscreen()},b.fullScreenEventName="fullscreenchange",b.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.msFullscreenElement},b.requestFullScreen=function(a){return a.msRequestFullscreen()},b.exitFullScreen=function(){document.msExitFullscreen()},b.fullScreenEventName="MSFullscreenChange",b.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.webkitFullscreenElement},b.requestFullScreen=function(a){return a.webkitRequestFullscreen()},b.exitFullScreen=function(){document.webkitExitFullscreen()},b.fullScreenEventName="webkitfullscreenchange",b.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},b.requestFullScreen=function(a){return a.webkitRequestFullScreen()},b.exitFullScreen=function(){document.webkitCancelFullScreen()},b.fullScreenEventName="webkitfullscreenchange",b.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(b.supportsFullScreen=!0,b.getFullScreenElement=function(){return document.mozFullScreenElement},b.requestFullScreen=function(a){return a.mozRequestFullScreen()},b.exitFullScreen=function(){document.mozCancelFullScreen()},b.fullScreenEventName="mozfullscreenchange",b.fullScreenErrorEventName="mozfullscreenerror"),b.isFullScreen=function(){return null!==b.getFullScreenElement()},b.cancelFullScreen=function(){a.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),b.exitFullScreen()},a.extend(a,b)}(OpenSeadragon),function(a){a.EventSource=function(){this.events={}},a.EventSource.prototype={addHandler:function(b,c,d){var e=this.events[b];e||(this.events[b]=e=[]),c&&a.isFunction(c)&&(e[e.length]={handler:c,userData:d||null})},removeHandler:function(b,c){var d,e=this.events[b],f=[];if(e&&a.isArray(e)){for(d=0;dd;d++)b[d]&&(c.eventSource=a,c.userData=b[d].userData,b[d].handler(c))}):null},raiseEvent:function(a,b){var c=this.getHandler(a);c&&(b||(b={}),c(this,b))}}}(OpenSeadragon),function(a){function b(b){var c,d,e=bb[b.hash];if(!e.tracking){for(d=0;dd;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});W(b,c,f)}function D(b,c){var d,e=c.changedTouches.length,f=[];for(d=0;e>d;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});X(b,c,f)}function E(b,c){var d,e,f=c.changedTouches.length,h=[];for(d=a.now(),e=0;f>e;e++)h.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:g(c.changedTouches[e]),currentTime:d});a.MouseTracker.haveTouchEnter||W(b,c,h),Y(b,c,h,0),a.cancelEvent(c)}function F(b,c){var d,e,f=c.changedTouches.length,h=[];for(d=a.now(),e=0;f>e;e++)h.push({id:c.changedTouches[e].identifier,type:"touch",currentPos:g(c.changedTouches[e]),currentTime:d});Z(b,c,h,0),!a.MouseTracker.haveTouchEnter&&f>0&&X(b,c,h),a.cancelEvent(c)}function G(b,c){var d,e=c.changedTouches.length,f=[];for(d=0;e>d;d++)f.push({id:c.changedTouches[d].identifier,type:"touch",currentPos:g(c.changedTouches[d]),currentTime:a.now()});$(b,c,f),a.cancelEvent(c)}function H(a,b){var c,d=b.changedTouches.length,e=[];for(c=0;d>c;c++)e.push({id:b.changedTouches[c].identifier,type:"touch"});_(a,b,e)}function I(a,b){return b.stopPropagation(),b.preventDefault(),!1}function J(a,b){return b.stopPropagation(),b.preventDefault(),!1}function K(b,c){var d;this===c.relatedTarget||s(c.currentTarget,c.relatedTarget)||(d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},W(b,c,[d]))}function L(b,c){var d;this===c.relatedTarget||s(c.currentTarget,c.relatedTarget)||(d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},X(b,c,[d]))}function M(b,c){var e;e={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},Y(b,c,[e],c.button)&&(d(b,!1),a.stopEvent(c)),(b.clickHandler||b.dblClickHandler||b.pressHandler||b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.cancelEvent(c)}function N(a,b){P(a,b)}function O(b,c){var d=b.getActivePointersListByType(f(c));d.getById(c.pointerId)&&P(b,c),a.stopEvent(c)}function P(b,c){var d;d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},Z(b,c,[d],c.button)&&e(b,!1)}function Q(a,b){S(a,b)}function R(b,c){var d=b.getActivePointersListByType(f(c));d.getById(c.pointerId)&&S(b,c),a.stopEvent(c)}function S(b,c){var d;d={id:c.pointerId,type:f(c),isPrimary:c.isPrimary,currentPos:g(c),currentTime:a.now()},$(b,c,[d])}function T(a,b){var c;c={id:b.pointerId,type:f(b)},_(a,b,[c])}function U(a,b){return b.hasOwnProperty("isPrimary")||(b.isPrimary=0===a.getLength()?!0:!1),b.speed=0,b.direction=0,b.contactPos=b.currentPos,b.contactTime=b.currentTime,b.lastPos=b.currentPos,b.lastTime=b.currentTime,a.add(b)}function V(a,b){var c,d;return a.getById(b.id)?(c=a.removeById(b.id),b.hasOwnProperty("isPrimary")||(d=a.getPrimary(),d||(d=a.getByIndex(0),d&&(d.isPrimary=!0)))):c=a.getLength(),c}function W(b,c,d){var e,f,g,h,j=b.getActivePointersListByType(d[0].type),k=d.length;for(e=0;k>e;e++)f=d[e],g=j.getById(f.id),g?(g.insideElement=!0,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime,f=g):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,U(j,f)),b.enterHandler&&(h=b.enterHandler({eventSource:b,pointerType:f.type,position:i(f.currentPos,b.element),buttons:j.buttons,insideElementPressed:f.insideElementPressed,buttonDownAny:0!==j.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),h===!1&&a.cancelEvent(c))}function X(b,c,d){var e,f,g,h,j=(bb[b.hash],b.getActivePointersListByType(d[0].type)),k=d.length;for(e=0;k>e;e++)f=d[e],g=j.getById(f.id),g&&(g.captured?(g.insideElement=!1,g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):V(j,g),f=g),b.exitHandler&&(h=b.exitHandler({eventSource:b,pointerType:f.type,position:i(f.currentPos,b.element),buttons:j.buttons,insideElementPressed:g?g.insideElementPressed:!1,buttonDownAny:0!==j.buttons,isTouchEvent:"touch"===f.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),h===!1&&a.cancelEvent(c))}function Y(b,c,d,e){var f,g,h,k,l=bb[b.hash],m=b.getActivePointersListByType(d[0].type),n=d.length;if("undefined"!=typeof c.buttons?m.buttons=c.buttons:0===e?m.buttons|=1:1===e?m.buttons|=4:2===e?m.buttons|=2:3===e?m.buttons|=8:4===e?m.buttons|=16:5===e&&(m.buttons|=32),0!==e&&1!==e)return!1;for(g=0;n>g;g++)h=d[g],k=m.getById(h.id),k?(k.captured=!0,k.insideElementPressed=!0,k.insideElement=!0,k.contactPos=h.currentPos,k.contactTime=h.currentTime,k.lastPos=k.currentPos,k.lastTime=k.currentTime,k.currentPos=h.currentPos,k.currentTime=h.currentTime,h=k):(h.captured=!0,h.insideElementPressed=!0,h.insideElement=!0,U(m,h)),m.contacts++,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.addPoint(b,h),1===m.contacts?b.pressHandler&&(f=b.pressHandler({eventSource:b,pointerType:h.type,position:i(h.contactPos,b.element),buttons:m.buttons,isTouchEvent:"touch"===h.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)):2===m.contacts&&b.pinchHandler&&"touch"===h.type&&(l.pinchGPoints=m.asArray(),l.lastPinchDist=l.currentPinchDist=l.pinchGPoints[0].currentPos.distanceTo(l.pinchGPoints[1].currentPos),l.lastPinchCenter=l.currentPinchCenter=j(l.pinchGPoints[0].currentPos,l.pinchGPoints[1].currentPos));return!0}function Z(b,c,d,e){var f,g,h,k,l,m,n,o=bb[b.hash],p=b.getActivePointersListByType(d[0].type),q=d.length,r=!1,s=!1;if("undefined"!=typeof c.buttons?p.buttons=c.buttons:0===e?p.buttons^=-2:1===e?p.buttons^=-5:2===e?p.buttons^=-3:3===e?p.buttons^=-9:4===e?p.buttons^=-17:5===e&&(p.buttons^=-33),0!==e&&1!==e)return!1;for(k=0;q>k;k++)l=d[k],m=p.getById(l.id),m&&(m.captured&&(m.captured=!1,r=!0,s=!0),m.lastPos=m.currentPos,m.lastTime=m.currentTime,m.currentPos=l.currentPos,m.currentTime=l.currentTime,m.insideElement||V(p,m),g=m.currentPos,h=m.currentTime,s?(p.contacts--,(b.dragHandler||b.dragEndHandler||b.pinchHandler)&&a.MouseTracker.gesturePointVelocityTracker.removePoint(b,m),0===p.contacts?(b.releaseHandler&&(f=b.releaseHandler({eventSource:b,pointerType:m.type,position:i(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),b.dragEndHandler&&!m.currentPos.equals(m.contactPos)&&(f=b.dragEndHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),speed:m.speed,direction:m.direction,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),(b.clickHandler||b.dblClickHandler)&&m.insideElement&&(n=h-m.contactTime<=b.clickTimeThreshold&&m.contactPos.distanceTo(g)<=b.clickDistThreshold,b.clickHandler&&(f=b.clickHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),quick:n,shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),b.dblClickHandler&&n&&(p.clicks++,1===p.clicks?(o.lastClickPos=g,o.dblClickTimeOut=setTimeout(function(){p.clicks=0},b.dblClickTimeThreshold)):2===p.clicks&&(clearTimeout(o.dblClickTimeOut),p.clicks=0,o.lastClickPos.distanceTo(g)<=b.dblClickDistThreshold&&(f=b.dblClickHandler({eventSource:b,pointerType:m.type,position:i(m.currentPos,b.element),shift:c.shiftKey,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c)),o.lastClickPos=null)))):2===p.contacts&&b.pinchHandler&&"touch"===m.type&&(o.pinchGPoints=p.asArray(),o.lastPinchDist=o.currentPinchDist=o.pinchGPoints[0].currentPos.distanceTo(o.pinchGPoints[1].currentPos),o.lastPinchCenter=o.currentPinchCenter=j(o.pinchGPoints[0].currentPos,o.pinchGPoints[1].currentPos))):b.releaseHandler&&(f=b.releaseHandler({eventSource:b,pointerType:m.type,position:i(g,b.element),buttons:p.buttons,insideElementPressed:m.insideElementPressed,insideElementReleased:m.insideElement,isTouchEvent:"touch"===m.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),f===!1&&a.cancelEvent(c))); +return r}function $(b,c,d){var e,f,g,h,k,l,m=bb[b.hash],n=b.getActivePointersListByType(d[0].type),o=d.length;for("undefined"!=typeof c.buttons&&(n.buttons=c.buttons),e=0;o>e;e++)f=d[e],g=n.getById(f.id),g?(f.hasOwnProperty("isPrimary")&&(g.isPrimary=f.isPrimary),g.lastPos=g.currentPos,g.lastTime=g.currentTime,g.currentPos=f.currentPos,g.currentTime=f.currentTime):(f.captured=!1,f.insideElementPressed=!1,f.insideElement=!0,U(n,f));b.stopHandler&&"mouse"===d[0].type&&(clearTimeout(b.stopTimeOut),b.stopTimeOut=setTimeout(function(){ab(b,c,d[0].type)},b.stopDelay)),0===n.contacts?b.moveHandler&&(l=b.moveHandler({eventSource:b,pointerType:d[0].type,position:i(d[0].currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===d[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)):1===n.contacts?(b.moveHandler&&(g=n.asArray()[0],l=b.moveHandler({eventSource:b,pointerType:g.type,position:i(g.currentPos,b.element),buttons:n.buttons,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)),b.dragHandler&&(g=n.asArray()[0],k=g.currentPos.minus(g.lastPos),l=b.dragHandler({eventSource:b,pointerType:g.type,position:i(g.currentPos,b.element),buttons:n.buttons,delta:k,speed:g.speed,direction:g.direction,shift:c.shiftKey,isTouchEvent:"touch"===g.type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c))):2===n.contacts&&(b.moveHandler&&(h=n.asArray(),l=b.moveHandler({eventSource:b,pointerType:h[0].type,position:i(j(h[0].currentPos,h[1].currentPos),b.element),buttons:n.buttons,isTouchEvent:"touch"===h[0].type,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c)),b.pinchHandler&&"touch"===d[0].type&&(k=m.pinchGPoints[0].currentPos.distanceTo(m.pinchGPoints[1].currentPos),k!=m.currentPinchDist&&(m.lastPinchDist=m.currentPinchDist,m.currentPinchDist=k,m.lastPinchCenter=m.currentPinchCenter,m.currentPinchCenter=j(m.pinchGPoints[0].currentPos,m.pinchGPoints[1].currentPos),l=b.pinchHandler({eventSource:b,pointerType:"touch",gesturePoints:m.pinchGPoints,lastCenter:i(m.lastPinchCenter,b.element),center:i(m.currentPinchCenter,b.element),lastDistance:m.lastPinchDist,distance:m.currentPinchDist,shift:c.shiftKey,originalEvent:c,preventDefaultAction:!1,userData:b.userData}),l===!1&&a.cancelEvent(c))))}function _(a,b,c){Z(a,b,c,0),X(a,b,c)}function ab(a,b,c){a.stopHandler&&a.stopHandler({eventSource:a,pointerType:c,position:h(b,a.element),buttons:a.getActivePointersListByType(c).buttons,isTouchEvent:"touch"===c,originalEvent:b,preventDefaultAction:!1,userData:a.userData})}var bb={};a.MouseTracker=function(b){var c=arguments;a.isPlainObject(b)||(b={element:c[0],clickTimeThreshold:c[1],clickDistThreshold:c[2]}),this.hash=Math.random(),this.element=a.getElement(b.element),this.clickTimeThreshold=b.clickTimeThreshold||a.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=b.clickDistThreshold||a.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=b.dblClickTimeThreshold||a.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=b.dblClickDistThreshold||a.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=b.userData||null,this.stopDelay=b.stopDelay||50,this.enterHandler=b.enterHandler||null,this.exitHandler=b.exitHandler||null,this.pressHandler=b.pressHandler||null,this.releaseHandler=b.releaseHandler||null,this.moveHandler=b.moveHandler||null,this.scrollHandler=b.scrollHandler||null,this.clickHandler=b.clickHandler||null,this.dblClickHandler=b.dblClickHandler||null,this.dragHandler=b.dragHandler||null,this.dragEndHandler=b.dragEndHandler||null,this.pinchHandler=b.pinchHandler||null,this.stopHandler=b.stopHandler||null,this.keyHandler=b.keyHandler||null,this.focusHandler=b.focusHandler||null,this.blurHandler=b.blurHandler||null;var d=this;bb[this.hash]={click:function(a){k(d,a)},dblclick:function(a){l(d,a)},keypress:function(a){m(d,a)},focus:function(a){n(d,a)},blur:function(a){o(d,a)},wheel:function(a){p(d,a)},mousewheel:function(a){q(d,a)},DOMMouseScroll:function(a){q(d,a)},MozMousePixelScroll:function(a){q(d,a)},mouseover:function(a){t(d,a)},mouseout:function(a){u(d,a)},mousedown:function(a){v(d,a)},mouseup:function(a){w(d,a)},mouseupcaptured:function(a){x(d,a)},mousemove:function(a){z(d,a)},mousemovecaptured:function(a){A(d,a)},touchenter:function(a){C(d,a)},touchleave:function(a){D(d,a)},touchstart:function(a){E(d,a)},touchend:function(a){F(d,a)},touchmove:function(a){G(d,a)},touchcancel:function(a){H(d,a)},gesturestart:function(a){I(d,a)},gesturechange:function(a){J(d,a)},pointerover:function(a){K(d,a)},MSPointerOver:function(a){K(d,a)},pointerout:function(a){L(d,a)},MSPointerOut:function(a){L(d,a)},pointerdown:function(a){M(d,a)},MSPointerDown:function(a){M(d,a)},pointerup:function(a){N(d,a)},MSPointerUp:function(a){N(d,a)},pointermove:function(a){Q(d,a)},MSPointerMove:function(a){Q(d,a)},pointercancel:function(a){T(d,a)},MSPointerCancel:function(a){T(d,a)},pointerupcaptured:function(a){O(d,a)},pointermovecaptured:function(a){R(d,a)},tracking:!1,activePointersLists:[],capturing:!1,pointerCaptureCount:0,lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null}},a.MouseTracker.prototype={destroy:function(){c(this),this.element=null,bb[this.hash]=null,delete bb[this.hash]},isTracking:function(){return bb[this.hash].tracking},setTracking:function(a){return a?b(this):c(this),this},getActivePointersListByType:function(b){var c,d,e=bb[this.hash],f=e.activePointersLists.length;for(c=0;f>c;c++)if(e.activePointersLists[c].type===b)return e.activePointersLists[c];return d=new a.MouseTracker.GesturePointList(b),e.activePointersLists.push(d),d},enterHandler:function(){},exitHandler:function(){},pressHandler:function(){},releaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}},a.MouseTracker.gesturePointVelocityTracker=function(){var b=[],c=0,d=0,e=function(a,b){return a.hash.toString()+b.type+b.id.toString()},f=function(){var c,e,f,g,h,i,j=b.length,k=a.now();for(g=k-d,d=k,c=0;j>c;c++)e=b[c],f=e.gPoint,f.direction=Math.atan2(f.currentPos.y-e.lastPos.y,f.currentPos.x-e.lastPos.x),h=e.lastPos.distanceTo(f.currentPos),e.lastPos=f.currentPos,i=1e3*h/(g+1),f.speed=.75*i+.25*f.speed},g=function(g,h){var i=e(g,h);b.push({guid:i,gPoint:h,lastPos:h.currentPos}),1===b.length&&(d=a.now(),c=window.setInterval(f,50))},h=function(a,d){var f,g=e(a,d),h=b.length;for(f=0;h>f;f++)if(b[f].guid===g){b.splice(f,1),h--,0===h&&window.clearInterval(c);break}};return{addPoint:g,removePoint:h}}(),a.MouseTracker.wheelEventName=a.Browser.vendor==a.BROWSERS.IE&&a.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",a.MouseTracker.supportsMouseCapture=function(){var b=document.createElement("div");return a.isFunction(b.setCapture)&&a.isFunction(b.releaseCapture)}(),a.MouseTracker.subscribeEvents=["click","dblclick","keypress","focus","blur",a.MouseTracker.wheelEventName],"DOMMouseScroll"==a.MouseTracker.wheelEventName&&a.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(a.MouseTracker.subscribeEvents.push("pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),a.MouseTracker.unprefixedPointerEvents=!0,a.MouseTracker.maxTouchPoints=navigator.maxTouchPoints?navigator.maxTouchPoints:0,a.MouseTracker.haveTouchEnter=!1,a.MouseTracker.haveMouseEnter=!1):window.MSPointerEvent?(a.MouseTracker.subscribeEvents.push("MSPointerOver","MSPointerOut","MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"),a.MouseTracker.unprefixedPointerEvents=!1,a.MouseTracker.maxTouchPoints=navigator.msMaxTouchPoints?navigator.msMaxTouchPoints:0,a.MouseTracker.haveTouchEnter=!1,a.MouseTracker.haveMouseEnter=!1):(a.MouseTracker.subscribeEvents.push("mouseover","mouseout","mousedown","mouseup","mousemove"),a.MouseTracker.haveMouseEnter=!1,"ontouchstart"in window?(a.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ontouchenter"in window?(a.MouseTracker.subscribeEvents.push("touchenter","touchleave"),a.MouseTracker.haveTouchEnter=!0):a.MouseTracker.haveTouchEnter=!1):a.MouseTracker.haveTouchEnter=!1,"ongesturestart"in window&&a.MouseTracker.subscribeEvents.push("gesturestart","gesturechange"),a.MouseTracker.mousePointerId="legacy-mouse",a.MouseTracker.maxTouchPoints=10),a.MouseTracker.GesturePointList=function(a){this._gPoints=[],this.type=a,this.buttons=0,this.contacts=0,this.clicks=0},a.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(a){return this._gPoints.push(a)},removeById:function(a){var b,c=this._gPoints.length;for(b=0;c>b;b++)if(this._gPoints[b].id===a){this._gPoints.splice(b,1);break}return this._gPoints.length},getByIndex:function(a){return ab;b++)if(this._gPoints[b].id===a)return this._gPoints[b];return null},getPrimary:function(){var a,b=this._gPoints.length;for(a=0;b>a;a++)if(this._gPoints[a].isPrimary)return this._gPoints[a];return null}}}(OpenSeadragon),function(a){a.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},a.Control=function(b,c,d){var e=b.parentNode;"number"==typeof c&&(a.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013"),c={anchor:c}),c.attachToViewer="undefined"==typeof c.attachToViewer?!0:c.attachToViewer,this.autoFade="undefined"==typeof c.autoFade?!0:c.autoFade,this.element=b,this.anchor=c.anchor,this.container=d,this.anchor==a.ControlAnchor.ABSOLUTE?(this.wrapper=a.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top="number"==typeof c.top?c.top+"px":c.top,this.wrapper.style.left="number"==typeof c.left?c.left+"px":c.left,this.wrapper.style.height="number"==typeof c.height?c.height+"px":c.height,this.wrapper.style.width="number"==typeof c.width?c.width+"px":c.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=a.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor==a.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),c.attachToViewer?this.anchor==a.ControlAnchor.TOP_RIGHT||this.anchor==a.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):e.appendChild(this.wrapper)},a.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.container.removeChild(this.wrapper)},isVisible:function(){return"none"!=this.wrapper.style.display},setVisible:function(b){this.wrapper.style.display=b?this.anchor==a.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(b){this.element[a.SIGNAL]&&a.Browser.vendor==a.BROWSERS.IE?a.setElementOpacity(this.element,b,!0):a.setElementOpacity(this.wrapper,b,!0)}}}(OpenSeadragon),function(a){function b(a,b){var c,d=a.controls;for(c=d.length-1;c>=0;c--)if(d[c].element==b)return c;return-1}a.ControlDock=function(b){var c,d,e=["topleft","topright","bottomright","bottomleft"];for(a.extend(!0,this,{id:"controldock-"+a.now()+"-"+Math.floor(1e6*Math.random()),container:a.makeNeutralElement("div"),controls:[]},b),this.container.onsubmit=function(){return!1},this.element&&(this.element=a.getElement(this.element),this.element.appendChild(this.container),this.element.style.position="relative",this.container.style.width="100%",this.container.style.height="100%"),d=0;d=0)){switch(d.anchor){case a.ControlAnchor.TOP_RIGHT:e=this.controls.topright,c.style.position="relative",c.style.paddingRight="0px",c.style.paddingTop="0px";break;case a.ControlAnchor.BOTTOM_RIGHT:e=this.controls.bottomright,c.style.position="relative",c.style.paddingRight="0px",c.style.paddingBottom="0px";break;case a.ControlAnchor.BOTTOM_LEFT:e=this.controls.bottomleft,c.style.position="relative",c.style.paddingLeft="0px",c.style.paddingBottom="0px";break;case a.ControlAnchor.TOP_LEFT:e=this.controls.topleft,c.style.position="relative",c.style.paddingLeft="0px",c.style.paddingTop="0px";break;case a.ControlAnchor.ABSOLUTE:e=this.container,c.style.margin="0px",c.style.padding="0px";break;default:case a.ControlAnchor.NONE:e=this.container,c.style.margin="0px",c.style.padding="0px"}this.controls.push(new a.Control(c,d,e)),c.style.display="inline-block"}},removeControl:function(c){c=a.getElement(c);var d=b(this,c);return d>=0&&(this.controls[d].destroy(),this.controls.splice(d,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var a;for(a=this.controls.length-1;a>=0;a--)if(this.controls[a].isVisible())return!0;return!1},setControlsEnabled:function(a){var b;for(b=this.controls.length-1;b>=0;b--)this.controls[b].setVisible(a);return this}}}(OpenSeadragon),function($){function _getSafeElemSize(a){return a=$.getElement(a),new $.Point(0===a.clientWidth?1:a.clientWidth,0===a.clientHeight?1:a.clientHeight)}function getTileSourceImplementation(viewer,tileSource,successCallback,failCallback){var _this=viewer;"string"==$.type(tileSource)&&(tileSource.match(/\s*<.*/)?tileSource=$.parseXml(tileSource):tileSource.match(/\s*[\{\[].*/)&&(tileSource=eval("("+tileSource+")"))),setTimeout(function(){if("string"==$.type(tileSource))tileSource=new $.TileSource(tileSource,function(a){successCallback(a.tileSource)}),tileSource.addHandler("open-failed",function(a){failCallback(a)});else if($.isPlainObject(tileSource)||tileSource.nodeType)if($.isFunction(tileSource.getTileUrl)){var a=new $.TileSource(tileSource);a.getTileUrl=tileSource.getTileUrl,successCallback(a)}else{var b=$.TileSource.determineType(_this,tileSource);if(!b)return void failCallback({message:"Unable to load TileSource",source:tileSource});var c=b.prototype.configure.apply(_this,[tileSource]),d=new b(c);successCallback(d)}else successCallback(tileSource)},1)}function openTileSource(a,b,c){var d,e=a;c=c||{},e.source&&e.close(),THIS[e.hash].prevContainerSize=_getSafeElemSize(e.container),e.collectionMode?(e.source=new $.TileSourceCollection({rows:e.collectionRows,layout:e.collectionLayout,tileSize:e.collectionTileSize,tileSources:e.tileSources,tileMargin:e.collectionTileMargin}),e.viewport=e.viewport?e.viewport:new $.Viewport({collectionMode:!0,collectionTileSource:e.source,containerSize:THIS[e.hash].prevContainerSize,springStiffness:e.springStiffness,animationTime:e.animationTime,showNavigator:!1,minZoomImageRatio:1,maxZoomPixelRatio:1,viewer:e,degrees:e.degrees})):(b&&(e.source=b),e.viewport=e.viewport?e.viewport:new $.Viewport({containerSize:THIS[e.hash].prevContainerSize,springStiffness:e.springStiffness,animationTime:e.animationTime,minZoomImageRatio:e.minZoomImageRatio,maxZoomPixelRatio:e.maxZoomPixelRatio,visibilityRatio:e.visibilityRatio,wrapHorizontal:e.wrapHorizontal,wrapVertical:e.wrapVertical,defaultZoomLevel:e.defaultZoomLevel,minZoomLevel:e.minZoomLevel,maxZoomLevel:e.maxZoomLevel,viewer:e,degrees:e.degrees,navigatorRotate:e.navigatorRotate,homeFillsViewer:e.homeFillsViewer})),e.source.overlays=e.source.overlays||[],e.imageLoader=new $.ImageLoader,e.tileCache=new $.TileCache({maxImageCacheCount:e.maxImageCacheCount}),e.world=new $.World({viewer:e}),e.world.addHandler("add-item",function(){e.viewport.setHomeBounds(e.world.getHomeBounds(),e.world.getContentFactor()),THIS[e.hash].forceRedraw=!0}),e.world.addHandler("remove-item",function(){e.viewport.setHomeBounds(e.world.getHomeBounds(),e.world.getContentFactor()),THIS[e.hash].forceRedraw=!0}),e.drawer=new $.Drawer({viewer:e,viewport:e.viewport,element:e.canvas,opacity:e.opacity,debugGridColor:e.debugGridColor});var f=new $.TiledImage({viewer:e,source:e.source,viewport:e.viewport,drawer:e.drawer,tileCache:e.tileCache,imageLoader:e.imageLoader,x:c.x,y:c.y,width:c.width,height:c.height,imageLoaderLimit:e.imageLoaderLimit,minZoomImageRatio:e.minZoomImageRatio,wrapHorizontal:e.wrapHorizontal,wrapVertical:e.wrapVertical,immediateRender:e.immediateRender,blendTime:e.blendTime,alwaysBlend:e.alwaysBlend,minPixelRatio:e.collectionMode?0:e.minPixelRatio,debugMode:e.debugMode,debugGridColor:e.debugGridColor,crossOriginPolicy:e.crossOriginPolicy});return e.world.addItem(f),e.viewport.goHome(!0),e.drawer.canRotate()||(e.rotateLeft&&(d=e.buttons.buttons.indexOf(e.rotateLeft),e.buttons.buttons.splice(d,1),e.buttons.element.removeChild(e.rotateLeft.element)),e.rotateRight&&(d=e.buttons.buttons.indexOf(e.rotateRight),e.buttons.buttons.splice(d,1),e.buttons.element.removeChild(e.rotateRight.element))),e.showNavigator&&!e.collectionMode&&(e.navigator?e.navigator.open(b):e.navigator=new $.Navigator({id:e.navigatorId,position:e.navigatorPosition,sizeRatio:e.navigatorSizeRatio,maintainSizeRatio:e.navigatorMaintainSizeRatio,top:e.navigatorTop,left:e.navigatorLeft,width:e.navigatorWidth,height:e.navigatorHeight,autoResize:e.navigatorAutoResize,tileSources:b,tileHost:e.tileHost,prefixUrl:e.prefixUrl,viewer:e,navigatorRotate:e.navigatorRotate})),e.showReferenceStrip&&!e.referenceStrip&&(e.referenceStrip=new $.ReferenceStrip({id:e.referenceStripElement,position:e.referenceStripPosition,sizeRatio:e.referenceStripSizeRatio,scroll:e.referenceStripScroll,height:e.referenceStripHeight,width:e.referenceStripWidth,tileSources:e.tileSources,tileHost:e.tileHost,prefixUrl:e.prefixUrl,viewer:e})),THIS[e.hash].animating=!1,THIS[e.hash].forceRedraw=!0,e._updateRequestId=scheduleUpdate(e,updateMulti),VIEWERS[e.hash]=e,loadOverlays(e),e.raiseEvent("open",{source:b}),e}function loadOverlays(a){a.currentOverlays=[];for(var b=0;b=0;c--)if(a[c].element===b)return c;return-1}function drawOverlays(a,b,c){var d,e=b.length;for(d=0;e>d;d++)b[d].drawHTML(c,a)}function scheduleUpdate(a,b){return $.requestAnimationFrame(function(){b(a)})}function scheduleControlsFade(a){$.requestAnimationFrame(function(){updateControlsFade(a)})}function beginControlsAutoHide(a){a.autoHideControls&&(a.controlsShouldFade=!0,a.controlsFadeBeginTime=$.now()+a.controlsFadeDelay,window.setTimeout(function(){scheduleControlsFade(a)},a.controlsFadeDelay))}function updateControlsFade(a){var b,c,d,e;if(a.controlsShouldFade){for(b=$.now(),c=b-a.controlsFadeBeginTime,d=1-c/a.controlsFadeLength,d=Math.min(1,d),d=Math.max(0,d),e=a.controls.length-1;e>=0;e--)a.controls[e].autoFade&&a.controls[e].setOpacity(d);d>0&&scheduleControlsFade(a)}}function abortControlsAutoHide(a){var b;for(a.controlsShouldFade=!1,b=a.controls.length-1;b>=0;b--)a.controls[b].setOpacity(1)}function onFocus(){abortControlsAutoHide(this)}function onBlur(){beginControlsAutoHide(this)}function onCanvasClick(a){var b;!a.preventDefaultAction&&this.viewport&&a.quick&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.clickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-click",{tracker:a.eventSource,position:a.position,quick:a.quick,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDblClick(a){var b;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.dblClickToZoom&&(this.viewport.zoomBy(a.shift?1/this.zoomPerClick:this.zoomPerClick,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-double-click",{tracker:a.eventSource,position:a.position,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDrag(a){var b;!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta.negate()),b.flickEnabled),this.constrainDuringPan&&this.viewport.applyConstraints()),this.raiseEvent("canvas-drag",{tracker:a.eventSource,position:a.position,delta:a.delta,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasDragEnd(a){var b;if(!a.preventDefaultAction&&this.viewport){if(b=this.gestureSettingsByDeviceType(a.pointerType),b.flickEnabled&&a.speed>=b.flickMinSpeed){var c=b.flickMomentum*a.speed*Math.cos(a.direction-Math.PI/180*this.viewport.degrees),d=b.flickMomentum*a.speed*Math.sin(a.direction-Math.PI/180*this.viewport.degrees),e=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),f=this.viewport.pointFromPixel(new $.Point(e.x-c,e.y-d));this.panHorizontal||(f.x=e.x),this.panVertical||(f.y=e.y),this.viewport.panTo(f,!1)}this.viewport.applyConstraints()}this.raiseEvent("canvas-drag-end",{tracker:a.eventSource,position:a.position,speed:a.speed,direction:a.direction,shift:a.shift,originalEvent:a.originalEvent})}function onCanvasRelease(a){this.raiseEvent("canvas-release",{tracker:a.eventSource,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function onCanvasPinch(a){var b,c,d,e;if(!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.pinchToZoom&&(c=this.viewport.pointFromPixel(a.center,!0),d=this.viewport.pointFromPixel(a.lastCenter,!0),e=d.minus(c),this.panHorizontal||(e.x=0),this.panVertical||(e.y=0),this.viewport.zoomBy(a.distance/a.lastDistance,c,!0),this.viewport.panBy(e,!0),this.viewport.applyConstraints()),b.pinchRotate)){var f=Math.atan2(a.gesturePoints[0].currentPos.y-a.gesturePoints[1].currentPos.y,a.gesturePoints[0].currentPos.x-a.gesturePoints[1].currentPos.x),g=Math.atan2(a.gesturePoints[0].lastPos.y-a.gesturePoints[1].lastPos.y,a.gesturePoints[0].lastPos.x-a.gesturePoints[1].lastPos.x);this.viewport.setRotation(this.viewport.getRotation()+(f-g)*(180/Math.PI))}return this.raiseEvent("canvas-pinch",{tracker:a.eventSource,gesturePoints:a.gesturePoints,lastCenter:a.lastCenter,center:a.center,lastDistance:a.lastDistance,distance:a.distance,shift:a.shift,originalEvent:a.originalEvent}),!1}function onCanvasScroll(a){var b,c;return!a.preventDefaultAction&&this.viewport&&(b=this.gestureSettingsByDeviceType(a.pointerType),b.scrollToZoom&&(c=Math.pow(this.zoomPerScroll,a.scroll),this.viewport.zoomBy(c,this.viewport.pointFromPixel(a.position,!0)),this.viewport.applyConstraints())),this.raiseEvent("canvas-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent}),!1}function onContainerExit(a){a.insideElementPressed||(THIS[this.hash].mouseInside=!1,THIS[this.hash].animating||beginControlsAutoHide(this)),this.raiseEvent("container-exit",{tracker:a.eventSource,position:a.position,buttons:a.buttons,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function onContainerPress(a){"touch"!==a.pointerType||$.MouseTracker.haveTouchEnter||(THIS[this.hash].mouseInside=!0,abortControlsAutoHide(this))}function onContainerRelease(a){(!a.insideElementReleased||"touch"===a.pointerType&&!$.MouseTracker.haveTouchEnter)&&(THIS[this.hash].mouseInside=!1,THIS[this.hash].animating||beginControlsAutoHide(this)),this.raiseEvent("container-release",{tracker:a.eventSource,position:a.position,insideElementPressed:a.insideElementPressed,insideElementReleased:a.insideElementReleased,originalEvent:a.originalEvent})}function onContainerEnter(a){THIS[this.hash].mouseInside=!0,abortControlsAutoHide(this),this.raiseEvent("container-enter",{tracker:a.eventSource,position:a.position,buttons:a.buttons,insideElementPressed:a.insideElementPressed,buttonDownAny:a.buttonDownAny,originalEvent:a.originalEvent})}function updateMulti(a){return a.source?(updateOnce(a),void(a.source&&(a._updateRequestId=scheduleUpdate(a,updateMulti)))):void(a._updateRequestId=null)}function updateOnce(a){var b,c;if(a.source){if(a.autoResize&&(b=_getSafeElemSize(a.container),!b.equals(THIS[a.hash].prevContainerSize))){var d=a.viewport.getBounds(),e=a.viewport.getCenter();resizeViewportAndRecenter(a,b,d,e),THIS[a.hash].prevContainerSize=b,THIS[a.hash].forceRedraw=!0}c=a.viewport.update(),a.referenceStrip&&(c=a.referenceStrip.update(a.viewport)||c),!THIS[a.hash].animating&&c&&(a.raiseEvent("animation-start"),abortControlsAutoHide(a)),c?(updateWorld(a),drawOverlays(a.viewport,a.currentOverlays,a.overlaysContainer),a.navigator&&a.navigator.update(a.viewport),a.raiseEvent("animation")):(THIS[a.hash].forceRedraw||a.world.needsUpdate())&&(updateWorld(a),drawOverlays(a.viewport,a.currentOverlays,a.overlaysContainer),a.navigator&&a.navigator.update(a.viewport),THIS[a.hash].forceRedraw=!1),THIS[a.hash].animating&&!c&&(a.raiseEvent("animation-finish"),THIS[a.hash].mouseInside||beginControlsAutoHide(a)),THIS[a.hash].animating=c}}function resizeViewportAndRecenter(a,b,c,d){var e=a.viewport;e.resize(b,!0);var f=1/a.source.aspectRatio,g=c.width<=1?c.width:1,h=c.height<=f?c.height:f,i=new $.Rect(d.x-g/2,d.y-h/2,g,h);e.fitBounds(i,!0)}function updateWorld(a){a.drawer.clear(),a.world.update(),a.raiseEvent("update-viewport",{})}function resolveUrl(a,b){return a?a+b:b}function beginZoomingIn(){THIS[this.hash].lastZoomTime=$.now(),THIS[this.hash].zoomFactor=this.zoomPerSecond,THIS[this.hash].zooming=!0,scheduleZoom(this)}function beginZoomingOut(){THIS[this.hash].lastZoomTime=$.now(),THIS[this.hash].zoomFactor=1/this.zoomPerSecond,THIS[this.hash].zooming=!0,scheduleZoom(this)}function endZooming(){THIS[this.hash].zooming=!1}function scheduleZoom(a){$.requestAnimationFrame($.delegate(a,doZoom))}function doZoom(){var a,b,c;THIS[this.hash].zooming&&this.viewport&&(a=$.now(),b=a-THIS[this.hash].lastZoomTime,c=Math.pow(THIS[this.hash].zoomFactor,b/1e3),this.viewport.zoomBy(c),this.viewport.applyConstraints(),THIS[this.hash].lastZoomTime=a,scheduleZoom(this))}function doSingleZoomIn(){this.viewport&&(THIS[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function doSingleZoomOut(){this.viewport&&(THIS[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function lightUp(){this.buttons.emulateEnter(),this.buttons.emulateExit()}function onHome(){this.viewport&&this.viewport.goHome()}function onFullScreen(){this.isFullPage()&&!$.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttons&&this.buttons.emulateExit(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function onRotateLeft(){if(this.viewport){var a=this.viewport.getRotation();0===a?a=270:a-=90,this.viewport.setRotation(a)}}function onRotateRight(){if(this.viewport){var a=this.viewport.getRotation();270===a?a=0:a+=90,this.viewport.setRotation(a)}}function onPrevious(){var a=THIS[this.hash].sequence-1;this.navPrevNextWrap&&0>a&&(a+=this.tileSources.length),this.goToPage(a)}function onNext(){var a=THIS[this.hash].sequence+1;this.navPrevNextWrap&&a>=this.tileSources.length&&(a=0),this.goToPage(a)}var THIS={},VIEWERS={};$.Viewer=function(a){var b,c=arguments,d=this;if($.isPlainObject(a)||(a={id:c[0],xmlPath:c.length>1?c[1]:void 0,prefixUrl:c.length>2?c[2]:void 0,controls:c.length>3?c[3]:void 0,overlays:c.length>4?c[4]:void 0}),a.config&&($.extend(!0,a,a.config),delete a.config),$.extend(!0,this,{id:a.id,hash:a.hash||a.id,element:null,container:null,keyboardCommandArea:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttons:null,profiler:null},$.DEFAULT_SETTINGS,a),"undefined"==typeof this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");"undefined"!=typeof THIS[this.hash]&&$.console.warn("Hash "+this.hash+" has already been used."),THIS[this.hash]={fsBoundsDelta:new $.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,sequenced:!1,sequence:0,fullPage:!1,onfullscreenchange:null},this._updateRequestId=null,this.currentOverlays=[],$.EventSource.call(this),this.addHandler("open-failed",function(a){var b=$.getString("Errors.OpenFailed",a.eventSource,a.message);d._showMessage(b)}),$.ControlDock.call(this,a);var e;for(this.xmlPath&&(this.tileSources=[this.xmlPath]),this.tileSources&&($.isArray(this.tileSources)?(this.tileSources.length>1&&(THIS[this.hash].sequenced=!0),this.initialPage>this.tileSources.length-1&&(this.initialPage=this.tileSources.length-1),e=this.tileSources[this.initialPage],THIS[this.hash].sequence=this.initialPage):e=this.tileSources),this.element=this.element||document.getElementById(this.id),this.canvas=$.makeNeutralElement("div"),this.keyboardCommandArea=$.makeNeutralElement("textarea"),this.overlaysContainer=$.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",function(a){a.width="100%",a.height="100%",a.overflow="hidden",a.position="absolute",a.top="0px",a.left="0px"}(this.canvas.style),$.setElementTouchActionNone(this.canvas),this.container.className="openseadragon-container",function(a){a.width="100%",a.height="100%",a.position="relative",a.overflow="hidden",a.left="0px",a.top="0px",a.textAlign="left"}(this.container.style),this.keyboardCommandArea.className="keyboard-command-area",function(a){a.width="100%",a.height="100%",a.overflow="hidden",a.position="absolute",a.top="0px",a.left="0px",a.resize="none"}(this.keyboardCommandArea.style),this.container.insertBefore(this.canvas,this.container.firstChild),this.container.insertBefore(this.keyboardCommandArea,this.container.firstChild),this.element.appendChild(this.container),this.canvas.appendChild(this.overlaysContainer),this.bodyWidth=document.body.style.width,this.bodyHeight=document.body.style.height,this.bodyOverflow=document.body.style.overflow,this.docOverflow=document.documentElement.style.overflow,this.keyboardCommandArea.innerTracker=new $.MouseTracker({_this:this,element:this.keyboardCommandArea,focusHandler:function(a){if(!a.preventDefaultAction){var b=$.getElementPosition(this.element); +window.scrollTo(0,b.y)}},keyHandler:function(a){if(!a.preventDefaultAction)switch(a.keyCode){case 61:return d.viewport.zoomBy(1.1),d.viewport.applyConstraints(),!1;case 45:return d.viewport.zoomBy(.9),d.viewport.applyConstraints(),!1;case 48:return d.viewport.goHome(),d.viewport.applyConstraints(),!1;case 119:case 87:case 38:return a.shift?d.viewport.zoomBy(1.1):d.viewport.panBy(new $.Point(0,-.05)),d.viewport.applyConstraints(),!1;case 115:case 83:case 40:return a.shift?d.viewport.zoomBy(.9):d.viewport.panBy(new $.Point(0,.05)),d.viewport.applyConstraints(),!1;case 97:case 37:return d.viewport.panBy(new $.Point(-.05,0)),d.viewport.applyConstraints(),!1;case 100:case 39:return d.viewport.panBy(new $.Point(.05,0)),d.viewport.applyConstraints(),!1;default:return!0}}}).setTracking(!0),this.innerTracker=new $.MouseTracker({element:this.canvas,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,clickHandler:$.delegate(this,onCanvasClick),dblClickHandler:$.delegate(this,onCanvasDblClick),dragHandler:$.delegate(this,onCanvasDrag),dragEndHandler:$.delegate(this,onCanvasDragEnd),releaseHandler:$.delegate(this,onCanvasRelease),scrollHandler:$.delegate(this,onCanvasScroll),pinchHandler:$.delegate(this,onCanvasPinch)}).setTracking(this.mouseNavEnabled?!0:!1),this.outerTracker=new $.MouseTracker({element:this.container,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:$.delegate(this,onContainerEnter),exitHandler:$.delegate(this,onContainerExit),pressHandler:$.delegate(this,onContainerPress),releaseHandler:$.delegate(this,onContainerRelease)}).setTracking(this.mouseNavEnabled?!0:!1),this.toolbar&&(this.toolbar=new $.ControlDock({element:this.toolbar})),this.bindStandardControls(),this.bindSequenceControls(),e&&(this.open(e),this.tileSources.length>1&&this._updateSequenceButtons(this.initialPage)),b=0;bc;c++)this.previousBody.push(d.childNodes[0]),d.removeChild(d.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,d.appendChild(this.toolbar.element),$.addClass(this.toolbar.element,"fullpage")),$.addClass(this.element,"fullpage"),d.appendChild(this.element),this.element.style.height=$.getWindowSize().y+"px",this.element.style.width=$.getWindowSize().x+"px",this.toolbar&&this.toolbar.element&&(this.element.style.height=$.getElementSize(this.element).y-$.getElementSize(this.toolbar.element).y+"px"),THIS[this.hash].fullPage=!0,$.delegate(this,onContainerEnter)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,e.margin=this.bodyMargin,f.margin=this.docMargin,e.padding=this.bodyPadding,f.padding=this.docPadding,e.width=this.bodyWidth,e.height=this.bodyHeight,d.removeChild(this.element),b=this.previousBody.length,c=0;b>c;c++)d.appendChild(this.previousBody.shift());$.removeClass(this.element,"fullpage"),THIS[this.hash].prevElementParent.insertBefore(this.element,THIS[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(d.removeChild(this.toolbar.element),$.removeClass(this.toolbar.element,"fullpage"),this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling),delete this.toolbar.parentNode,delete this.toolbar.nextSibling),this.element.style.width=THIS[this.hash].prevElementWidth,this.element.style.height=THIS[this.hash].prevElementHeight;var i=0,j=function(){$.setPageScroll(g.pageScroll);var a=$.getPageScroll();i++,(10>i&&a.x!==g.pageScroll.x||a.y!==g.pageScroll.y)&&$.requestAnimationFrame(j)};$.requestAnimationFrame(j),THIS[this.hash].fullPage=!1,$.delegate(this,onContainerExit)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:a}),this},setFullScreen:function(a){var b=this;if(!$.supportsFullScreen)return this.setFullPage(a);if($.isFullScreen()===a)return this;var c={fullScreen:a,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",c),c.preventDefaultAction)return this;if(a){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var d=function(){var a=$.isFullScreen();a||($.removeEvent(document,$.fullScreenEventName,d),$.removeEvent(document,$.fullScreenErrorEventName,d),b.setFullPage(!1),b.isFullPage()&&(b.element.style.width=b.fullPageStyleWidth,b.element.style.height=b.fullPageStyleHeight)),b.navigator&&b.viewport&&b.navigator.update(b.viewport),b.raiseEvent("full-screen",{fullScreen:a})};$.addEvent(document,$.fullScreenEventName,d),$.addEvent(document,$.fullScreenErrorEventName,d),$.requestFullScreen(document.body)}else $.exitFullScreen();return this},isVisible:function(){return"hidden"!=this.container.style.visibility},setVisible:function(a){return this.container.style.visibility=a?"":"hidden",this.raiseEvent("visible",{visible:a}),this},addTiledImage:function(a){function b(a){c.raiseEvent("add-item-failed",a)}$.console.assert(a,"[Viewer.addTiledImage] options is required"),$.console.assert(a.tileSource,"[Viewer.addTiledImage] options.tileSource is required");var c=this,d=a.tileSource;if(!this.isOpen())throw new Error("An image must be loaded before adding additional images.");getTileSourceImplementation(this,d,function(d){if(d instanceof Array)return void b({message:"[Viewer.addTiledImage] Sequences can not be added.",source:d,options:a});var e=new $.TiledImage({viewer:c,source:d,viewport:c.viewport,drawer:c.drawer,tileCache:c.tileCache,imageLoader:c.imageLoader,x:a.x,y:a.y,width:a.width,height:a.height,imageLoaderLimit:c.imageLoaderLimit,minZoomImageRatio:c.minZoomImageRatio,wrapHorizontal:c.wrapHorizontal,wrapVertical:c.wrapVertical,immediateRender:c.immediateRender,blendTime:c.blendTime,alwaysBlend:c.alwaysBlend,minPixelRatio:c.minPixelRatio,debugMode:c.debugMode,debugGridColor:c.debugGridColor});c.world.addItem(e,{index:a.index})},function(c){c.options=a,b(c)})},addLayer:function(a){var b=this;$.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var c=function(d){b.world.removeHandler("add-item",c),b.raiseEvent("add-layer",{options:a,drawer:d.item})},d=function(a){b.removeHandler("add-item-failed",d),b.raiseEvent("add-layer-failed",a)};return this.world.addHandler("add-item",c),this.addHandler("add-item-failed",d),this.addTiledImage(a),this},getLayerAtLevel:function(a){return $.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(a)},getLevelOfLayer:function(a){return $.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(a)},getLayersCount:function(){return $.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(a,b){return $.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(a,b)},removeLayer:function(a){return $.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(a)},forceRedraw:function(){return THIS[this.hash].forceRedraw=!0,this},bindSequenceControls:function(){var a=$.delegate(this,onFocus),b=$.delegate(this,onBlur),c=$.delegate(this,onNext),d=$.delegate(this,onPrevious),e=this.navImages,f=!0;return this.showSequenceControl&&THIS[this.hash].sequenced&&((this.previousButton||this.nextButton)&&(f=!1),this.previousButton=new $.Button({element:this.previousButton?$.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.PreviousPage"),srcRest:resolveUrl(this.prefixUrl,e.previous.REST),srcGroup:resolveUrl(this.prefixUrl,e.previous.GROUP),srcHover:resolveUrl(this.prefixUrl,e.previous.HOVER),srcDown:resolveUrl(this.prefixUrl,e.previous.DOWN),onRelease:d,onFocus:a,onBlur:b}),this.nextButton=new $.Button({element:this.nextButton?$.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.NextPage"),srcRest:resolveUrl(this.prefixUrl,e.next.REST),srcGroup:resolveUrl(this.prefixUrl,e.next.GROUP),srcHover:resolveUrl(this.prefixUrl,e.next.HOVER),srcDown:resolveUrl(this.prefixUrl,e.next.DOWN),onRelease:c,onFocus:a,onBlur:b}),this.navPrevNextWrap||this.previousButton.disable(),f&&(this.paging=new $.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.pagingControl=this.paging.element,this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:$.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||$.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var a=$.delegate(this,beginZoomingIn),b=$.delegate(this,endZooming),c=$.delegate(this,doSingleZoomIn),d=$.delegate(this,beginZoomingOut),e=$.delegate(this,doSingleZoomOut),f=$.delegate(this,onHome),g=$.delegate(this,onFullScreen),h=$.delegate(this,onRotateLeft),i=$.delegate(this,onRotateRight),j=$.delegate(this,onFocus),k=$.delegate(this,onBlur),l=this.navImages,m=[],n=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton)&&(n=!1),this.showZoomControl&&(m.push(this.zoomInButton=new $.Button({element:this.zoomInButton?$.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.ZoomIn"),srcRest:resolveUrl(this.prefixUrl,l.zoomIn.REST),srcGroup:resolveUrl(this.prefixUrl,l.zoomIn.GROUP),srcHover:resolveUrl(this.prefixUrl,l.zoomIn.HOVER),srcDown:resolveUrl(this.prefixUrl,l.zoomIn.DOWN),onPress:a,onRelease:b,onClick:c,onEnter:a,onExit:b,onFocus:j,onBlur:k})),m.push(this.zoomOutButton=new $.Button({element:this.zoomOutButton?$.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.ZoomOut"),srcRest:resolveUrl(this.prefixUrl,l.zoomOut.REST),srcGroup:resolveUrl(this.prefixUrl,l.zoomOut.GROUP),srcHover:resolveUrl(this.prefixUrl,l.zoomOut.HOVER),srcDown:resolveUrl(this.prefixUrl,l.zoomOut.DOWN),onPress:d,onRelease:b,onClick:e,onEnter:d,onExit:b,onFocus:j,onBlur:k}))),this.showHomeControl&&m.push(this.homeButton=new $.Button({element:this.homeButton?$.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.Home"),srcRest:resolveUrl(this.prefixUrl,l.home.REST),srcGroup:resolveUrl(this.prefixUrl,l.home.GROUP),srcHover:resolveUrl(this.prefixUrl,l.home.HOVER),srcDown:resolveUrl(this.prefixUrl,l.home.DOWN),onRelease:f,onFocus:j,onBlur:k})),this.showFullPageControl&&m.push(this.fullPageButton=new $.Button({element:this.fullPageButton?$.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.FullPage"),srcRest:resolveUrl(this.prefixUrl,l.fullpage.REST),srcGroup:resolveUrl(this.prefixUrl,l.fullpage.GROUP),srcHover:resolveUrl(this.prefixUrl,l.fullpage.HOVER),srcDown:resolveUrl(this.prefixUrl,l.fullpage.DOWN),onRelease:g,onFocus:j,onBlur:k})),this.showRotationControl&&(m.push(this.rotateLeftButton=new $.Button({element:this.rotateLeftButton?$.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.RotateLeft"),srcRest:resolveUrl(this.prefixUrl,l.rotateleft.REST),srcGroup:resolveUrl(this.prefixUrl,l.rotateleft.GROUP),srcHover:resolveUrl(this.prefixUrl,l.rotateleft.HOVER),srcDown:resolveUrl(this.prefixUrl,l.rotateleft.DOWN),onRelease:h,onFocus:j,onBlur:k})),m.push(this.rotateRightButton=new $.Button({element:this.rotateRightButton?$.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:$.getString("Tooltips.RotateRight"),srcRest:resolveUrl(this.prefixUrl,l.rotateright.REST),srcGroup:resolveUrl(this.prefixUrl,l.rotateright.GROUP),srcHover:resolveUrl(this.prefixUrl,l.rotateright.HOVER),srcDown:resolveUrl(this.prefixUrl,l.rotateright.DOWN),onRelease:i,onFocus:j,onBlur:k}))),n&&(this.buttons=new $.ButtonGroup({buttons:m,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttons.element,this.addHandler("open",$.delegate(this,lightUp)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:$.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||$.ControlAnchor.TOP_LEFT}))),this},currentPage:function(){return THIS[this.hash].sequence},goToPage:function(a){return a>=0&&a=0?this:(this.currentOverlays.push(getOverlayObject(this,e)),THIS[this.hash].forceRedraw=!0,this.raiseEvent("add-overlay",{element:a,location:e.location,placement:e.placement}),this)},updateOverlay:function(a,b,c){var d;return a=$.getElement(a),d=getOverlayIndex(this.currentOverlays,a),d>=0&&(this.currentOverlays[d].update(b,c),THIS[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:a,location:b,placement:c})),this},removeOverlay:function(a){var b;return a=$.getElement(a),b=getOverlayIndex(this.currentOverlays,a),b>=0&&(this.currentOverlays[b].destroy(),this.currentOverlays.splice(b,1),THIS[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:a})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return THIS[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},_updateSequenceButtons:function(a){this.nextButton&&(this.tileSources.length-1===a?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(a>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(a){this._hideMessage();var b=$.makeNeutralElement("div");b.appendChild(document.createTextNode(a)),this.messageDiv=$.makeCenteredNode(b),$.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var a=this.messageDiv;a&&(a.parentNode.removeChild(a),delete this.messageDiv)},gestureSettingsByDeviceType:function(a){switch(a){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}}})}(OpenSeadragon),function(a){function b(a){a.quick&&this.viewer.viewport&&(this.viewer.viewport.panTo(this.viewport.pointFromPixel(a.position).rotate(-this.viewer.viewport.degrees,this.viewer.viewport.getHomeBounds().getCenter())),this.viewer.viewport.applyConstraints())}function c(a){this.viewer.viewport&&(this.panHorizontal||(a.delta.x=0),this.panVertical||(a.delta.y=0),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(a.delta)))}function d(a){a.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function e(a){return this.viewer.raiseEvent("navigator-scroll",{tracker:a.eventSource,position:a.position,scroll:a.scroll,shift:a.shift,originalEvent:a.originalEvent}),!1}function f(a,b){a.style.webkitTransform="rotate("+b+"deg)",a.style.mozTransform="rotate("+b+"deg)",a.style.msTransform="rotate("+b+"deg)",a.style.oTransform="rotate("+b+"deg)",a.style.transform="rotate("+b+"deg)"}a.Navigator=function(g){var h,i,j,k=g.viewer,l=this;g.id?(this.element=document.getElementById(g.id),g.controlOptions={anchor:a.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(g.id="navigator-"+a.now(),this.element=a.makeNeutralElement("div"),g.controlOptions={anchor:a.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:!0},g.position&&("BOTTOM_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_RIGHT:"BOTTOM_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.BOTTOM_LEFT:"TOP_RIGHT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_RIGHT:"TOP_LEFT"==g.position?g.controlOptions.anchor=a.ControlAnchor.TOP_LEFT:"ABSOLUTE"==g.position&&(g.controlOptions.anchor=a.ControlAnchor.ABSOLUTE,g.controlOptions.top=g.top,g.controlOptions.left=g.left,g.controlOptions.height=g.height,g.controlOptions.width=g.width))),this.element.id=g.id,this.element.className+=" navigator",g=a.extend(!0,{sizeRatio:a.DEFAULT_SETTINGS.navigatorSizeRatio},g,{element:this.element,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,autoResize:g.autoResize}),g.minPixelRatio=this.minPixelRatio=k.minPixelRatio,a.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new a.Point(1,1),this.totalBorderWidths=new a.Point(2*this.borderWidth,2*this.borderWidth).minus(this.fudge),g.controlOptions.anchor!=a.ControlAnchor.NONE&&!function(a,b){a.margin="0px",a.border=b+"px solid #555",a.padding="0px",a.background="#000",a.opacity=.8,a.overflow="hidden"}(this.element.style,this.borderWidth),this.displayRegion=a.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(a,b){a.position="relative",a.top="0px",a.left="0px",a.fontSize="0px",a.overflow="hidden",a.border=b+"px solid #900",a.margin="0px",a.padding="0px",a.background="transparent",a["float"]="left",a.cssFloat="left",a.styleFloat="left",a.zIndex=999999999,a.cursor="default"}(this.displayRegion.style,this.borderWidth),this.displayRegionContainer=a.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",this.element.innerTracker=new a.MouseTracker({element:this.element,dragHandler:a.delegate(this,c),clickHandler:a.delegate(this,b),releaseHandler:a.delegate(this,d),scrollHandler:a.delegate(this,e)}).setTracking(!0),k.addControl(this.element,g.controlOptions),g.controlOptions.anchor!=a.ControlAnchor.ABSOLUTE&&g.controlOptions.anchor!=a.ControlAnchor.NONE&&(g.width&&g.height?(this.element.style.height="number"==typeof g.height?g.height+"px":g.height,this.element.style.width="number"==typeof g.width?g.width+"px":g.width):(h=a.getElementSize(k.element),this.element.style.height=Math.round(h.y*g.sizeRatio)+"px",this.element.style.width=Math.round(h.x*g.sizeRatio)+"px",this.oldViewerSize=h),i=a.getElementSize(this.element),this.elementArea=i.x*i.y),this.oldContainerSize=new a.Point(0,0),a.Viewer.apply(this,[g]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer),j=this.element.getElementsByTagName("textarea")[0],j&&j.parentNode.removeChild(j),g.navigatorRotate&&g.viewer.addHandler("rotate",function(a){f(l.displayRegionContainer,a.degrees),f(l.displayRegion,-a.degrees),l.viewport.setRotation(a.degrees)})},a.extend(a.Navigator.prototype,a.EventSource.prototype,a.Viewer.prototype,{updateSize:function(){if(this.viewport){var b=new a.Point(0===this.container.clientWidth?1:this.container.clientWidth,0===this.container.clientHeight?1:this.container.clientHeight);if(!b.equals(this.oldContainerSize)){var c=this.viewport.getBounds(),d=this.viewport.getCenter();this.viewport.resize(b,!0);var e=1/this.source.aspectRatio,f=c.width<=1?c.width:1,g=c.height<=e?c.height:e,h=new a.Rect(d.x-f/2,d.y-g/2,f,g);this.viewport.fitBounds(h,!0),this.oldContainerSize=b,this.drawer.update()}}},update:function(b){var c,d,e,f,g,h;c=a.getElementSize(this.viewer.element),c.equals(this.oldViewerSize)||(this.oldViewerSize=c,this.maintainSizeRatio?(d=c.x*this.sizeRatio,e=c.y*this.sizeRatio):(d=Math.sqrt(this.elementArea*(c.x/c.y)),e=this.elementArea/d),this.element.style.width=Math.round(d)+"px",this.element.style.height=Math.round(e)+"px",this.updateSize()),b&&this.viewport&&(f=b.getBounds(!0),g=this.viewport.pixelFromPoint(f.getTopLeft(),!1),h=this.viewport.pixelFromPoint(f.getBottomRight(),!1).minus(this.totalBorderWidths),function(a){a.top=Math.round(g.y)+"px",a.left=Math.round(g.x)+"px";var b=Math.abs(g.x-h.x),c=Math.abs(g.y-h.y);a.width=Math.round(Math.max(b,0))+"px",a.height=Math.round(Math.max(c,0))+"px"}(this.displayRegion.style))},open:function(b){this.updateSize();var c=this.viewer.viewport.containerSize.times(this.sizeRatio),d=b.getTileSize(b.maxLevel);return this.minPixelRatio=d>c.x||d>c.y?Math.min(c.x,c.y)/d:this.viewer.minPixelRatio,a.Viewer.prototype.open.apply(this,[b])}})}(OpenSeadragon),function(a){var b={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right"}};a.extend(a,{getString:function(c){var d,e=c.split("."),f=null,g=arguments,h=b;for(d=0;d=c));b++);return Math.max(0,b-1)},getTileAtPoint:function(a,b){var c=b.times(this.dimensions.x).times(this.getLevelScale(a)),d=Math.floor(c.x/this.getTileSize(a)),e=Math.floor(c.y/this.getTileSize(a));return new $.Point(d,e)},getTileBounds:function(a,b,c){var d=this.dimensions.times(this.getLevelScale(a)),e=this.getTileSize(a),f=0===b?0:e*b-this.tileOverlap,g=0===c?0:e*c-this.tileOverlap,h=e+(0===b?1:2)*this.tileOverlap,i=e+(0===c?1:2)*this.tileOverlap,j=1/d.x;return h=Math.min(h,d.x-f),i=Math.min(i,d.y-g),new $.Rect(f*j,g*j,h*j,i*j)},getImageInfo:function(a){var b,c,d,e,f,g,h,i=this;a&&(f=a.split("/"),g=f[f.length-1],h=g.lastIndexOf("."),h>-1&&(f[f.length-1]=g.slice(0,h))),c=function(b){"string"==typeof b&&(b=$.parseXml(b));var c=$.TileSource.determineType(i,b,a);return c?(e=c.prototype.configure.apply(i,[b,a]),d=new c(e),i.ready=!0,void i.raiseEvent("ready",{tileSource:d})):void i.raiseEvent("open-failed",{message:"Unable to load TileSource",source:a})},a.match(/\.js$/)?(b=a.split("/").pop().replace(".js",""),$.jsonp({url:a,async:!1,callbackName:b,callback:c})):$.makeAjaxRequest(a,function(a){var b=processResponse(a);c(b)},function(b,c){var d;try{d="HTTP "+b.status+" attempting to load TileSource"}catch(e){var f;f="undefined"!=typeof c&&c.toString?c.toString():"Unknown error",d=f+" attempting to load TileSource"}i.raiseEvent("open-failed",{message:d,source:a})})},supports:function(){return!1},configure:function(){throw new Error("Method not implemented.")},getTileUrl:function(){throw new Error("Method not implemented.")},tileExists:function(a,b,c){var d=this.getNumTiles(a);return a>=this.minLevel&&a<=this.maxLevel&&b>=0&&c>=0&&b=0;c--)for(d=this.displayRects[c],e=d.minLevel;e<=d.maxLevel;e++)this._levelRects[e]||(this._levelRects[e]=[]),this._levelRects[e].push(d);a.TileSource.apply(this,[f])},a.extend(a.DziTileSource.prototype,a.TileSource.prototype,{supports:function(a){var b;return a.Image?b=a.Image.xmlns:a.documentElement&&"Image"==a.documentElement.localName&&(b=a.documentElement.namespaceURI),"http://schemas.microsoft.com/deepzoom/2008"==b||"http://schemas.microsoft.com/deepzoom/2009"==b},configure:function(d,e){var f;return f=a.isPlainObject(d)?c(this,d):b(this,d),e&&!f.tilesUrl&&(f.tilesUrl=e.replace(/([^\/]+)\.(dzi|xml|js)(\?.*|$)/,"$1_files/"),f.queryParams=-1!=e.search(/\.(dzi|xml|js)\?/)?e.match(/\?.*/):""),f},getTileUrl:function(a,b,c){return[this.tilesUrl,a,"/",b,"_",c,".",this.fileFormat,this.queryParams].join("")},tileExists:function(a,b,c){var d,e,f,g,h,i,j,k=this._levelRects[a];if(!k||!k.length)return!0;for(j=k.length-1;j>=0;j--)if(d=k[j],!(ad.maxLevel)&&(e=this.getLevelScale(a),f=d.x*e,g=d.y*e,h=f+d.width*e,i=g+d.height*e,f=Math.floor(f/this.tileSize),g=Math.floor(g/this.tileSize),h=Math.ceil(h/this.tileSize),i=Math.ceil(i/this.tileSize),b>=f&&h>b&&c>=g&&i>c))return!0;return!1}})}(OpenSeadragon),function(a){function b(b){if(!b||!b.documentElement)throw new Error(a.getString("Errors.Xml"));var d=b.documentElement,e=d.tagName,f=null;if("info"==e)try{return f={},c(d,f),f}catch(g){throw g instanceof Error?g:new Error(a.getString("Errors.IIIF"))}throw new Error(a.getString("Errors.IIIF"))}function c(b,d,e){var f,g;if(3==b.nodeType&&e)g=b.nodeValue.trim(),g.match(/^\d*$/)&&(g=Number(g)),d[e]?(a.isArray(d[e])||(d[e]=[d[e]]),d[e].push(g)):d[e]=g;else if(1==b.nodeType)for(f=0;f0?Math.max.apply(null,h):f,this.tile_width=b.tileSize,this.tile_height=b.tileSize}b.maxLevel||(b.maxLevel=this.scale_factors?Math.floor(Math.pow(Math.max.apply(null,this.scale_factors),.5)):Number(Math.ceil(Math.log(Math.max(this.width,this.height),2)))),a.TileSource.apply(this,[b])},a.extend(a.IIIFTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.protocol&&"http://iiif.io/api/image"==a.protocol?!0:!a["@context"]||"http://library.stanford.edu/iiif/image-api/1.1/context.json"!=a["@context"]&&"http://iiif.io/api/image/1/context.json"!=a["@context"]?a.profile&&0===a.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")?!0:a.identifier&&a.width&&a.height?!0:a.documentElement&&"info"==a.documentElement.tagName&&"http://library.stanford.edu/iiif/image-api/ns/"==a.documentElement.namespaceURI?!0:!1:!0},configure:function(c,d){if(a.isPlainObject(c))return c["@context"]?c:(c["@context"]="http://iiif.io/api/image/1.0/context.json",c["@id"]=d.replace("/info.json",""),c);var e=b(c);return e["@context"]="http://iiif.io/api/image/1.0/context.json",e["@id"]=d.replace("/info.xml",""),e},getTileSize:function(a){var b=Math.pow(2,this.maxLevel-a);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[b]&&(this.tileSize=this.tileSizePerScaleFactor[b]),this.tileSize},getTileUrl:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n="0",o=Math.pow(.5,this.maxLevel-a),p=Math.ceil(this.width*o),q=Math.ceil(this.height*o);return d=Math.ceil(this.getTileSize(a)/o),e=d,l=this["@context"].indexOf("/1.0/context.json")>-1||this["@context"].indexOf("/1.1/context.json")>-1||this["@context"].indexOf("/1/context.json")>-1?"native.jpg":"default.jpg",pf?e/256:f/256,c.maxLevel=Math.ceil(Math.log(d)/Math.log(2))-1,c.tileSize=256,c.width=e,c.height=f,a.TileSource.apply(this,[c])},a.extend(a.TmsTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.type&&"tiledmapservice"==a.type},configure:function(a){return a},getTileUrl:function(a,b,c){var d=this.getNumTiles(a).y-1;return this.tilesUrl+a+"/"+b+"/"+(d-c)+".png"}})}(OpenSeadragon),function(a){function b(b){var c,d,e=[];for(d=0;d");return e.sort(function(a,b){return a.height-b.height})}function c(b,c){if(!c||!c.documentElement)throw new Error(a.getString("Errors.Xml"));var e,f,g=c.documentElement,h=g.tagName,i=null,j=[];if("image"==h)try{for(i={type:g.getAttribute("type"),levels:[]},j=g.getElementsByTagName("level"),f=0;f0?(e=d.levels[d.levels.length-1].width,f=d.levels[d.levels.length-1].height):(e=0,f=0,a.console.error("No supported image formats found")),a.extend(!0,d,{width:e,height:f,tileSize:Math.max(f,e),tileOverlap:0,minLevel:0,maxLevel:d.levels.length>0?d.levels.length-1:0}),a.TileSource.apply(this,[d]),this.levels=d.levels},a.extend(a.LegacyTileSource.prototype,a.TileSource.prototype,{supports:function(a){return a.type&&"legacy-image-pyramid"==a.type||a.documentElement&&"legacy-image-pyramid"==a.documentElement.getAttribute("type")},configure:function(b){var e;return e=a.isPlainObject(b)?d(this,b):c(this,b)},getLevelScale:function(a){var b=0/0;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].width/this.levels[this.maxLevel].width),b},getNumTiles:function(b){var c=this.getLevelScale(b);return c?new a.Point(1,1):new a.Point(0,0)},getTileAtPoint:function(){return new a.Point(0,0)},getTileUrl:function(a){var b=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(b=this.levels[a].url),b}})}(OpenSeadragon),function(a){a.TileSourceCollection=function(b){var c;c=a.isPlainObject(b)?b:{tileSize:arguments[0],tileSources:arguments[1],rows:arguments[2],layout:arguments[3]},c.layout||(c.layout="horizontal");var d=0,e=1,f=Math.ceil(c.tileSources.length/c.rows),g=f>=c.rows?f:c.rows;for("horizontal"==c.layout?(c.width=c.tileSize*f,c.height=c.tileSize*c.rows):(c.height=c.tileSize*f,c.width=c.tileSize*c.rows),c.tileOverlap=-c.tileMargin,c.tilesPerRow=f;e0&&b(c))}function d(c){c.shouldFade=!0,c.fadeBeginTime=a.now()+c.fadeDelay,window.setTimeout(function(){b(c)},c.fadeDelay)}function e(b){b.shouldFade=!1,b.imgGroup&&a.setElementOpacity(b.imgGroup,1,!0)}function f(b,c){b.element.disabled||(c>=a.ButtonState.GROUP&&b.currentState==a.ButtonState.REST&&(e(b),b.currentState=a.ButtonState.GROUP),c>=a.ButtonState.HOVER&&b.currentState==a.ButtonState.GROUP&&(b.imgHover&&(b.imgHover.style.visibility=""),b.currentState=a.ButtonState.HOVER),c>=a.ButtonState.DOWN&&b.currentState==a.ButtonState.HOVER&&(b.imgDown&&(b.imgDown.style.visibility=""),b.currentState=a.ButtonState.DOWN))}function g(b,c){b.element.disabled||(c<=a.ButtonState.HOVER&&b.currentState==a.ButtonState.DOWN&&(b.imgDown&&(b.imgDown.style.visibility="hidden"),b.currentState=a.ButtonState.HOVER),c<=a.ButtonState.GROUP&&b.currentState==a.ButtonState.HOVER&&(b.imgHover&&(b.imgHover.style.visibility="hidden"),b.currentState=a.ButtonState.GROUP),c<=a.ButtonState.REST&&b.currentState==a.ButtonState.GROUP&&(d(b),b.currentState=a.ButtonState.REST))}a.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},a.Button=function(b){var c=this;a.EventSource.call(this),a.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null},b),this.element=b.element||a.makeNeutralElement("div"),b.element||(this.imgRest=a.makeTransparentImage(this.srcRest),this.imgGroup=a.makeTransparentImage(this.srcGroup),this.imgHover=a.makeTransparentImage(this.srcHover),this.imgDown=a.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,this.element.style.position="relative",a.setElementTouchActionNone(this.element),this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute",this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px",this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px",this.imgHover.style.visibility=this.imgDown.style.visibility="hidden",a.Browser.vendor==a.BROWSERS.FIREFOX&&a.Browser.version<3&&(this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top=""),this.element.appendChild(this.imgRest),this.element.appendChild(this.imgGroup),this.element.appendChild(this.imgHover),this.element.appendChild(this.imgDown)),this.addHandler("press",this.onPress),this.addHandler("release",this.onRelease),this.addHandler("click",this.onClick),this.addHandler("enter",this.onEnter),this.addHandler("exit",this.onExit),this.addHandler("focus",this.onFocus),this.addHandler("blur",this.onBlur),this.currentState=a.ButtonState.GROUP,this.fadeBeginTime=null,this.shouldFade=!1,this.element.style.display="inline-block",this.element.style.position="relative",this.element.title=this.tooltip,this.tracker=new a.MouseTracker({element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(b){b.insideElementPressed?(f(c,a.ButtonState.DOWN),c.raiseEvent("enter",{originalEvent:b.originalEvent})):b.buttonDownAny||f(c,a.ButtonState.HOVER)},focusHandler:function(a){this.enterHandler(a),c.raiseEvent("focus",{originalEvent:a.originalEvent})},exitHandler:function(b){g(c,a.ButtonState.GROUP),b.insideElementPressed&&c.raiseEvent("exit",{originalEvent:b.originalEvent})},blurHandler:function(a){this.exitHandler(a),c.raiseEvent("blur",{originalEvent:a.originalEvent})},pressHandler:function(b){f(c,a.ButtonState.DOWN),c.raiseEvent("press",{originalEvent:b.originalEvent})},releaseHandler:function(b){b.insideElementPressed&&b.insideElementReleased?(g(c,a.ButtonState.HOVER),c.raiseEvent("release",{originalEvent:b.originalEvent})):b.insideElementPressed?g(c,a.ButtonState.GROUP):f(c,a.ButtonState.HOVER)},clickHandler:function(a){a.quick&&c.raiseEvent("click",{originalEvent:a.originalEvent})},keyHandler:function(a){return 13===a.keyCode?(c.raiseEvent("click",{originalEvent:a.originalEvent}),c.raiseEvent("release",{originalEvent:a.originalEvent}),!1):!0}}).setTracking(!0),g(this,a.ButtonState.REST)},a.extend(a.Button.prototype,a.EventSource.prototype,{notifyGroupEnter:function(){f(this,a.ButtonState.GROUP)},notifyGroupExit:function(){g(this,a.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,a.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,a.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()}})}(OpenSeadragon),function(a){a.ButtonGroup=function(b){a.extend(!0,this,{buttons:[],clickTimeThreshold:a.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:a.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},b);var c,d=this.buttons.concat([]),e=this;if(this.element=b.element||a.makeNeutralElement("div"),!b.group)for(this.label=a.makeNeutralElement("label"),this.element.style.display="inline-block",this.element.appendChild(this.label),c=0;c0?c>-(f-h.x)&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.x<0&&0>c&&(this.element.style.marginLeft=c+2*b.delta.x+"px",d(this,h.x,c+2*b.delta.x)):-b.delta.y>0?e>-(g-h.y)&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y)):-b.delta.y<0&&0>e&&(this.element.style.marginTop=e+2*b.delta.y+"px",d(this,h.y,e+2*b.delta.y))),!1}function c(b){var c=Number(this.element.style.marginLeft.replace("px","")),e=Number(this.element.style.marginTop.replace("px","")),f=Number(this.element.style.width.replace("px","")),g=Number(this.element.style.height.replace("px","")),h=a.getElementSize(this.viewer.canvas);return this.element&&("horizontal"==this.scroll?b.scroll>0?c>-(f-h.x)&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0&&0>c&&(this.element.style.marginLeft=c-60*b.scroll+"px",d(this,h.x,c-60*b.scroll)):b.scroll<0?e>h.y-g&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll)):b.scroll>0&&0>e&&(this.element.style.marginTop=e+60*b.scroll+"px",d(this,h.y,e+60*b.scroll))),!1}function d(b,c,d){var e,f,g,h,i,j,k;for(e="horizontal"==b.scroll?b.panelWidth:b.panelHeight,f=Math.ceil(c/e)+5,g=Math.ceil((Math.abs(d)+c)/e)+1,f=g-f,f=0>f?0:f,j=f;g>j&&jj+g.x-this.panelWidth?(c=Math.min(c,h-g.x),this.element.style.marginLeft=-c+"px",d(this,g.x,-c)):j>c&&(c=Math.max(0,c-g.x/2),this.element.style.marginLeft=-c+"px",d(this,g.x,-c))):(c=Number(b)*(this.panelHeight+3),c>k+g.y-this.panelHeight?(c=Math.min(c,i-g.y),this.element.style.marginTop=-c+"px",d(this,g.y,-c)):k>c&&(c=Math.max(0,c-g.y/2),this.element.style.marginTop=-c+"px",d(this,g.y,-c))),this.currentPage=b,a.getElement(f.id+"-displayregion").focus(),e.call(this,{eventSource:this.innerTracker}))},update:function(){return h[this.id].animating?(a.console.log("image reference strip update"),!0):!1}})}(OpenSeadragon),function(a){a.DisplayRect=function(b,c,d,e,f,g){a.Rect.apply(this,[b,c,d,e]),this.minLevel=f,this.maxLevel=g},a.extend(a.DisplayRect.prototype,a.Rect.prototype)}(OpenSeadragon),function(a){function b(a,b){return(1-Math.exp(a*-b))/(1-Math.exp(-a))}a.Spring=function(b){var c=arguments;"object"!=typeof b&&(b={initial:c.length&&"number"==typeof c[0]?c[0]:0,springStiffness:c.length>1?c[1].springStiffness:5,animationTime:c.length>1?c[1].animationTime:1.5}),a.extend(!0,this,b),this.current={value:"number"==typeof this.initial?this.initial:0,time:a.now()},this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time}},a.Spring.prototype={resetTo:function(a){this.target.value=a,this.target.time=this.current.time,this.start.value=this.target.value,this.start.time=this.target.time},springTo:function(a){this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=a,this.target.time=this.start.time+1e3*this.animationTime},shiftBy:function(a){this.start.value+=a,this.target.value+=a},update:function(){this.current.time=a.now(),this.current.value=this.current.time>=this.target.time?this.target.value:this.start.value+(this.target.value-this.start.value)*b(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time))}}}(OpenSeadragon),function(a){function b(b){a.extend(!0,this,{timeout:a.DEFAULT_SETTINGS.timeout,jobId:null},b),this.image=null}function c(a,b,c){var d;a.jobsInProgress--,(!a.jobLimit||a.jobsInProgress0&&(d=a.jobQueue.shift(),d.start()),c(b.image)}b.prototype={start:function(){var a=this;this.image=new Image,this.crossOriginPolicy!==!1&&(this.image.crossOrigin=this.crossOriginPolicy),this.image.onload=function(){a.finish(!0)},this.image.onabort=this.image.onerror=function(){a.finish(!1)},this.jobId=window.setTimeout(function(){a.finish(!1)},this.timeout),this.image.src=this.src},finish:function(a){this.image.onload=this.image.onerror=this.image.onabort=null,a||(this.image=null),this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},a.ImageLoader=function(){a.extend(!0,this,{jobLimit:a.DEFAULT_SETTINGS.imageLoaderLimit,jobQueue:[],jobsInProgress:0})},a.ImageLoader.prototype={addJob:function(a){var d=this,e=function(b){c(d,b,a.callback)},f={src:a.src,crossOriginPolicy:a.crossOriginPolicy,callback:e},g=new b(f);!this.jobLimit||this.jobsInProgress0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),a.console.assert(b.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this.setHomeBounds(new a.Rect(0,0,1,b.y/b.x),b.x),this},setHomeBounds:function(b,c){a.console.assert(b,"[Viewport.setHomeBounds] bounds is required"),a.console.assert(b instanceof a.Rect,"[Viewport.setHomeBounds] bounds must be an OpenSeadragon.Rect"),a.console.assert(b.width>0,"[Viewport.setHomeBounds] bounds.width must be greater than 0"),a.console.assert(b.height>0,"[Viewport.setHomeBounds] bounds.height must be greater than 0"),this.homeBounds=b.clone(),this.contentSize=this.homeBounds.getSize().times(c),this.contentAspectX=this.contentSize.x/this.contentSize.y,this.contentAspectY=this.contentSize.y/this.contentSize.x,this.fitWidthBounds=new a.Rect(this.homeBounds.x,this.homeBounds.y,this.homeBounds.width,this.homeBounds.width),this.fitHeightBounds=new a.Rect(this.homeBounds.x,this.homeBounds.y,this.homeBounds.height,this.homeBounds.height),this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this.contentSize.clone(),contentFactor:c,homeBounds:this.homeBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var a,b=this.contentAspectX/this.getAspectRatio();return a=this.homeFillsViewer?b>=1?b:1:b>=1?1:b,a/this.homeBounds.width},getHomeBounds:function(){return this.homeBounds.clone()},goHome:function(a){return this.viewer&&this.viewer.raiseEvent("home",{immediately:a}),this.fitBounds(this.getHomeBounds(),a)},getMinZoom:function(){var a=this.getHomeZoom(),b=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*a;return Math.min(b,a)},getMaxZoom:function(){var a=this.maxZoomLevel;return a||(a=this.contentSize.x*this.maxZoomPixelRatio/this.containerSize.x,a/=this.homeBounds.width),Math.max(a,this.getHomeZoom())},getAspectRatio:function(){return this.containerSize.x/this.containerSize.y},getContainerSize:function(){return new a.Point(this.containerSize.x,this.containerSize.y)},getBounds:function(b){var c=this.getCenter(b),d=1/this.getZoom(b),e=d/this.getAspectRatio();return new a.Rect(c.x-d/2,c.y-e/2,d,e)},getCenter:function(b){var c,d,e,f,g,h,i,j,k=new a.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),l=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return b?k:this.zoomPoint?(c=this.pixelFromPoint(this.zoomPoint,!0),d=this.getZoom(),e=1/d,f=e/this.getAspectRatio(),g=new a.Rect(k.x-e/2,k.y-f/2,e,f),h=this.zoomPoint.minus(g.getTopLeft()).times(this.containerSize.x/g.width),i=h.minus(c),j=i.divide(this.containerSize.x*d),l.plus(j)):l},getZoom:function(a){return a?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyBoundaryConstraints:function(b,c){var d=0,e=0,f=new a.Rect(b.x,b.y,b.width,b.height),g=this.visibilityRatio*f.width,h=this.visibilityRatio*f.height;if(this.wrapHorizontal);else{var i=f.x+(f.width-g);this.homeBounds.x>i&&(d=this.homeBounds.x-i);var j=this.homeBounds.x+this.homeBounds.width,k=f.x+g;if(k>j){var l=j-k;d=d?(d+l)/2:l}}if(this.wrapVertical);else{var m=f.y+(f.height-h);this.homeBounds.y>m&&(e=this.homeBounds.y-m);var n=this.homeBounds.y+this.homeBounds.height,o=f.y+h;if(o>n){var p=n-o;e=e?(e+p)/2:p}}return(d||e)&&(f.x+=d,f.y+=e),this.viewer&&this.viewer.raiseEvent("constrain",{immediately:c}),f},applyConstraints:function(a){var b,c,d=this.getZoom(),e=Math.max(Math.min(d,this.getMaxZoom()),this.getMinZoom());return d!=e&&this.zoomTo(e,this.zoomPoint,a),b=this.getBounds(),c=this._applyBoundaryConstraints(b,a),(b.x!==c.x||b.y!==c.y||a)&&this.fitBounds(c,a),this},ensureVisible:function(a){return this.applyConstraints(a)},_fitBounds:function(b,c){c=c||{};var d,e,f,g,h,i,j=c.immediately||!1,k=c.constraints||!1,l=this.getAspectRatio(),m=b.getCenter(),n=new a.Rect(b.x,b.y,b.width,b.height);return n.getAspectRatio()>=l?(n.height=b.width/l,n.y=m.y-n.height/2):(n.width=b.height*l,n.x=m.x-n.width/2),k&&(h=n.getAspectRatio()),this.panTo(this.getCenter(!0),!0),this.zoomTo(this.getZoom(!0),null,!0),d=this.getBounds(),e=this.getZoom(),f=1/n.width,k&&(i=Math.max(Math.min(f,this.getMaxZoom()),this.getMinZoom()),f!==i&&(f=i,n.width=1/f,n.x=m.x-n.width/2,n.height=n.width/h,n.y=m.y-n.height/2),n=this._applyBoundaryConstraints(n,j)),f==e||n.width==d.width?this.panTo(k?n.getCenter():m,j):(g=d.getTopLeft().times(this.containerSize.x/d.width).minus(n.getTopLeft().times(this.containerSize.x/n.width)).divide(this.containerSize.x/d.width-this.containerSize.x/n.width),this.zoomTo(f,g,j))},fitBounds:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!1})},fitBoundsWithConstraints:function(a,b){return this._fitBounds(a,{immediately:b,constraints:!0})},fitVertically:function(a){var b=this.getCenter();return this.wrapHorizontal&&(b.x=(1+b.x%1)%1,this.centerSpringX.resetTo(b.x),this.centerSpringX.update()),this.wrapVertical&&(b.y=(this.contentAspectY+b.y%this.contentAspectY)%this.contentAspectY,this.centerSpringY.resetTo(b.y),this.centerSpringY.update()),this.fitBounds(this.fitHeightBounds,a)},fitHorizontally:function(a){var b=this.getCenter();return this.wrapHorizontal&&(b.x=(this.contentAspectX+b.x%this.contentAspectX)%this.contentAspectX,this.centerSpringX.resetTo(b.x),this.centerSpringX.update()),this.wrapVertical&&(b.y=(1+b.y%1)%1,this.centerSpringY.resetTo(b.y),this.centerSpringY.update()),this.fitBounds(this.fitWidthBounds,a)},panBy:function(b,c){var d=new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return b=b.rotate(-this.degrees,new a.Point(0,0)),this.panTo(d.plus(b),c)},panTo:function(a,b){return b?(this.centerSpringX.resetTo(a.x),this.centerSpringY.resetTo(a.y)):(this.centerSpringX.springTo(a.x),this.centerSpringY.springTo(a.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:a,immediately:b}),this},zoomBy:function(b,c,d){return c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)&&(c=c.rotate(-this.degrees,new a.Point(this.centerSpringX.target.value,this.centerSpringY.target.value))),this.zoomTo(this.zoomSpring.target.value*b,c,d)},zoomTo:function(b,c,d){return this.zoomPoint=c instanceof a.Point&&!isNaN(c.x)&&!isNaN(c.y)?c:null,d?this.zoomSpring.resetTo(b):this.zoomSpring.springTo(b),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:b,refPoint:c,immediately:d}),this},setRotation:function(a){return this.viewer&&this.viewer.drawer.canRotate()?(a=(a+360)%360,this.degrees=a,this.viewer.forceRedraw(),null!==this.viewer&&this.viewer.raiseEvent("rotate",{degrees:a}),this):this},getRotation:function(){return this.degrees},resize:function(b,c){var d,e=this.getBounds(),f=e;return this.containerSize=new a.Point(b.x,b.y),c&&(d=b.x/this.containerSize.x,f.width=e.width*d,f.height=f.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:b,maintain:c}),this.fitBounds(f,!0)},update:function(){var a,b,c,d,e=this.centerSpringX.current.value,f=this.centerSpringY.current.value,g=this.zoomSpring.current.value;return this.zoomPoint&&(a=this.pixelFromPoint(this.zoomPoint,!0)),this.zoomSpring.update(),this.zoomPoint&&this.zoomSpring.current.value!=g?(b=this.pixelFromPoint(this.zoomPoint,!0),c=b.minus(a),d=this.deltaPointsFromPixels(c,!0),this.centerSpringX.shiftBy(d.x),this.centerSpringY.shiftBy(d.y)):this.zoomPoint=null,this.centerSpringX.update(),this.centerSpringY.update(),this.centerSpringX.current.value!=e||this.centerSpringY.current.value!=f||this.zoomSpring.current.value!=g},deltaPixelsFromPoints:function(a,b){return a.times(this.containerSize.x*this.getZoom(b))},deltaPointsFromPixels:function(a,b){return a.divide(this.containerSize.x*this.getZoom(b))},pixelFromPoint:function(a,b){var c=this.getBounds(b);return a.minus(c.getTopLeft()).times(this.containerSize.x/c.width)},pointFromPixel:function(a,b){var c=this.getBounds(b);return a.divide(this.containerSize.x/c.width).plus(c.getTopLeft())},viewportToImageCoordinates:function(b,c){return 1==arguments.length?this.viewportToImageCoordinates(b.x,b.y):new a.Point(b*this.contentSize.x,c*this.contentSize.y*this.contentAspectX)},imageToViewportCoordinates:function(b,c){return 1==arguments.length?this.imageToViewportCoordinates(b.x,b.y):new a.Point(b/this.contentSize.x,c/this.contentSize.y/this.contentAspectX)},imageToViewportRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.imageToViewportRectangle(h.x,h.y,h.width,h.height)):(f=this.imageToViewportCoordinates(b,c),g=this.imageToViewportCoordinates(d,e),new a.Rect(f.x,f.y,g.x,g.y))},viewportToImageRectangle:function(b,c,d,e){var f,g,h;return 1==arguments.length?(h=b,this.viewportToImageRectangle(h.x,h.y,h.width,h.height)):(f=this.viewportToImageCoordinates(b,c),g=this.viewportToImageCoordinates(d,e),new a.Rect(f.x,f.y,g.x,g.y))},viewerElementToImageCoordinates:function(a){var b=this.pointFromPixel(a,!0);return this.viewportToImageCoordinates(b)},imageToViewerElementCoordinates:function(a){var b=this.imageToViewportCoordinates(a);return this.pixelFromPoint(b,!0)},windowToImageCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(b)},imageToWindowCoordinates:function(a){var b=this.imageToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(a){return this.pointFromPixel(a,!0)},viewportToViewerElementCoordinates:function(a){return this.pixelFromPoint(a,!0)},windowToViewportCoordinates:function(a){var b=a.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(b)},viewportToWindowCoordinates:function(a){var b=this.viewportToViewerElementCoordinates(a);return b.plus(OpenSeadragon.getElementPosition(this.viewer.element))},viewportToImageZoom:function(a){var b=this.viewer.source.dimensions.x,c=this.getContainerSize().x,d=c/b;return a*d},imageToViewportZoom:function(a){var b=this.viewer.source.dimensions.x,c=this.getContainerSize().x,d=b/c;return a*d}}}(OpenSeadragon),function(a){function b(b){b.updateAgain=!1;var d,e,g,h,i,k,l,m,n=null,p=!1,q=a.now(),r=(b.viewport.getContainerSize(),b.viewport.getBounds(!0)),s=r.getTopLeft(),t=r.getBottomRight(),u=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(0),!0).x*b._scale,v=Math.max(b.source.minLevel,Math.floor(Math.log(b.minZoomImageRatio)/Math.log(2))),w=Math.min(Math.abs(b.source.maxLevel),Math.abs(Math.floor(Math.log(u/b.minPixelRatio)/Math.log(2)))),x=b.viewport.degrees;for(s.x-=b._worldX,s.y-=b._worldY,t.x-=b._worldX,t.y-=b._worldY;b.lastDrawn.length>0;)d=b.lastDrawn.pop(),d.beingDrawn=!1;if(90===x||270===x){var y=r.rotate(x);s=y.getTopLeft(),t=y.getBottomRight()}else if(0!==x){var z=r.rotate(90);r.x-=z.width/2,r.y-=z.height/2,r.width+=z.width,r.height+=z.height,s=r.getTopLeft(),t=r.getBottomRight()}if(!(!b.wrapHorizontal&&(t.x<0||s.x>b._worldWidth)||!b.wrapVertical&&(t.y<0||s.y>b._worldHeight))){b.wrapHorizontal||(s.x=Math.max(s.x,0),t.x=Math.min(t.x,b._worldWidth)),b.wrapVertical||(s.y=Math.max(s.y,0),t.y=Math.min(t.y,b._worldHeight)),v=Math.min(v,w);var A;for(e=w;e>=v;e--){if(A=!1,g=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!0).x*b._scale,!p&&g>=b.minPixelRatio||e==v)A=!0,p=!0;else if(!p)continue;if(h=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(e),!1).x*b._scale,i=b.viewport.deltaPixelsFromPoints(b.source.getPixelRatio(Math.max(b.source.getClosestLevel(b.viewport.containerSize)-1,0)),!1).x*b._scale,k=b.immediateRender?1:i,l=Math.min(1,(g-.5)/.5),m=k/Math.abs(k-h),n=c(b,p,A,e,l,m,s,t,q,n),j(b.coverage,e))break}o(b,b.lastDrawn),n&&(f(b,n,q),b.updateAgain=!0)}}function c(a,b,c,e,f,g,h,i,j,k){var l,n,o,p,q,r=a.viewport.pixelFromPoint(a.viewport.getCenter());for(a.viewer&&a.viewer.raiseEvent("update-level",{havedrawn:b,level:e,opacity:f,visibility:g,topleft:h,bottomright:i,currenttime:j,best:k}),o=a.source.getTileAtPoint(e,h.divide(a._scale)),p=a.source.getTileAtPoint(e,i.divide(a._scale)),q=a.source.getNumTiles(e),m(a.coverage,e),a.wrapHorizontal||(p.x=Math.min(p.x,q.x-1)),a.wrapVertical||(p.y=Math.min(p.y,q.y-1)),l=o.x;l<=p.x;l++)for(n=o.y;n<=p.y;n++)k=d(a,c,b,l,n,e,f,g,r,q,j,k);return k}function d(a,b,c,d,f,g,j,m,o,p,q,r){var s=e(d,f,g,a.source,a.tilesMatrix,q,p,a._worldWidth,a._worldHeight),t=b;if(a.viewer&&a.viewer.raiseEvent("update-tile",{tile:s}),l(a.coverage,g,d,f,!1),!s.exists)return r;if(c&&!t&&(k(a.coverage,g,d,f)?l(a.coverage,g,d,f,!0):t=!0),!t)return r;if(h(s,a.source.tileOverlap,a.viewport,o,m,a),s.loaded){var u=i(a,s,d,f,g,j,q);u&&(a.updateAgain=!0)}else s.loading||(r=n(r,s));return r}function e(b,c,d,e,f,g,h,i,j){var k,l,m,n,o,p;return f[d]||(f[d]={}),f[d][b]||(f[d][b]={}),f[d][b][c]||(k=(h.x+b%h.x)%h.x,l=(h.y+c%h.y)%h.y,m=e.getTileBounds(d,k,l),n=e.tileExists(d,k,l),o=e.getTileUrl(d,k,l),m.x+=i*(b-k)/h.x,m.y+=j*(c-l)/h.y,f[d][b][c]=new a.Tile(d,b,c,m,n,o)),p=f[d][b][c],p.lastTouchTime=g,p}function f(a,b,c){b.loading=!0,a._imageLoader.addJob({src:b.url,crossOriginPolicy:a.crossOriginPolicy,callback:function(d){g(a,b,c,d)}})}function g(b,c,d,e){if(c.loading=!1,b.midUpdate)return void a.console.warn("Tile load callback in middle of drawing routine.");if(e){if(dh)return!0;return!1}function j(a,b,c,d){var e,f,g,h;if(!a[b])return!1;if(void 0===c||void 0===d){e=a[b];for(g in e)if(e.hasOwnProperty(g)){f=e[g];for(h in f)if(f.hasOwnProperty(h)&&!f[h])return!1}return!0}return void 0===a[b][c]||void 0===a[b][c][d]||a[b][c][d]===!0}function k(a,b,c,d){return void 0===c||void 0===d?j(a,b+1):j(a,b+1,2*c,2*d)&&j(a,b+1,2*c,2*d+1)&&j(a,b+1,2*c+1,2*d)&&j(a,b+1,2*c+1,2*d+1)}function l(b,c,d,e,f){return b[c]?(b[c][d]||(b[c][d]={}),void(b[c][d][e]=f)):void a.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",c)}function m(a,b){a[b]={}}function n(a,b){return a?b.visibility>a.visibility?b:b.visibility==a.visibility&&b.distance=0;d--){if(e=c[d],b._drawer.drawTile(e),e.beingDrawn=!0,b.debugMode)try{b._drawer.drawDebugInfo(e,c.length,d)}catch(f){a.console.error(f)}b.viewer&&b.viewer.raiseEvent("tile-drawn",{tile:e})}}a.TiledImage=function(b){a.console.assert(b.tileCache,"[TiledImage] options.tileCache is required"),a.console.assert(b.drawer,"[TiledImage] options.drawer is required"),a.console.assert(b.viewer,"[TiledImage] options.viewer is required"),a.console.assert(b.imageLoader,"[TiledImage] options.imageLoader is required"),this._tileCache=b.tileCache,delete b.tileCache,this._drawer=b.drawer,delete b.drawer,this._imageLoader=b.imageLoader,delete b.imageLoader,this._worldX=b.x||0,delete b.x,this._worldY=b.y||0,delete b.y,this.normHeight=b.source.dimensions.y/b.source.dimensions.x,b.width?(this._scale=b.width,delete b.width,b.height&&(a.console.error("specifying both width and height to a tiledImage is not supported"),delete b.height)):b.height?(this._scale=b.height/this.normHeight,delete b.height):this._scale=1,this._worldWidth=this._scale,this._worldHeight=this.normHeight*this._scale,a.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},lastDrawn:[],lastResetTime:0,midUpdate:!1,updateAgain:!0,minZoomImageRatio:a.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:a.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:a.DEFAULT_SETTINGS.wrapVertical,immediateRender:a.DEFAULT_SETTINGS.immediateRender,blendTime:a.DEFAULT_SETTINGS.blendTime,alwaysBlend:a.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:a.DEFAULT_SETTINGS.minPixelRatio,debugMode:a.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:a.DEFAULT_SETTINGS.crossOriginPolicy},b)},a.TiledImage.prototype={needsUpdate:function(){return this.updateAgain},reset:function(){return this._tileCache.clearTilesFor(this),this.lastResetTime=a.now(),this.updateAgain=!0,this},update:function(){return this.midUpdate=!0,b(this),this.midUpdate=!1,this},destroy:function(){this.reset()},getWorldBounds:function(){return new a.Rect(this._worldX,this._worldY,this._worldWidth,this._worldHeight)},getContentSize:function(){return new a.Point(this.source.dimensions.x,this.source.dimensions.y)}}}(OpenSeadragon),function(a){var b=function(b){a.console.assert(b,"[TileCache.cacheTile] params is required"),a.console.assert(b.tile,"[TileCache.cacheTile] params.tile is required"),a.console.assert(b.tiledImage,"[TileCache.cacheTile] params.tiledImage is required"),this.tile=b.tile,this.tiledImage=b.tiledImage};a.TileCache=function(b){b=b||{},this._tilesLoaded=[],this._maxImageCacheCount=b.maxImageCacheCount||a.DEFAULT_SETTINGS.maxImageCacheCount},a.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(c){a.console.assert(c,"[TileCache.cacheTile] params is required"),a.console.assert(c.tile,"[TileCache.cacheTile] params.tile is required"),a.console.assert(c.tiledImage,"[TileCache.cacheTile] params.tiledImage is required");var d=c.cutoff||0,e=this._tilesLoaded.length;if(this._tilesLoaded.length>=this._maxImageCacheCount){for(var f,g,h,i,j,k,l=null,m=-1,n=this._tilesLoaded.length-1;n>=0;n--)k=this._tilesLoaded[n],f=k.tile,f.level<=d||f.beingDrawn||(l?(i=f.lastTouchTime,g=l.lastTouchTime,j=f.level,h=l.level,(g>i||i==g&&j>h)&&(l=f,m=n)):(l=f,m=n));l&&m>=0&&(l.unload(),e=m)}this._tilesLoaded[e]=new b({tile:c.tile,tiledImage:c.tiledImage})},clearTilesFor:function(a){for(var b,c=0;c=this._items.length)throw new Error("Index bigger than number of layers.");c!==d&&-1!==d&&(this._items.splice(d,1),this._items.splice(c,0,b),this.raiseEvent("item-index-changed",{item:b,previousIndex:d,newIndex:c}))},removeItem:function(b){a.console.assert(b,"[World.removeItem] item is required");var c=this._items.indexOf(b);-1!==c&&(this._items.splice(c,1),this._figureSizes(),this.raiseEvent("remove-item",{item:b}))},resetItems:function(){for(var a=0;apa&&(oa.scrollX||oa.scrollY)){e=ua.select(aa.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=e[0][0].getScreenCTM();pa=!(i.f||i.e),e.remove()}return pa?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var u=n.getBoundingClientRect();return[t.clientX-u.left-n.clientLeft,t.clientY-u.top-n.clientTop]}function p(n){for(var t=-1,e=n.length,r=[];++t0&&(n=n.substring(0,o));var l=ka.get(n);return l&&(n=l,c=z),o?t?i:r:t?q:u}function C(n,t){return function(e){var r=ua.event;ua.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ua.event=r}}}function z(n,t){var e=C(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||r.compareDocumentPosition(t)&8)||e.call(t,n)}}function D(n,t){for(var e=0,r=n.length;r>e;e++)for(var i,u=n[e],a=0,o=u.length;o>a;a++)(i=u[a])&&t(i,a,e);return n}function j(n){return va(n,Aa),n}function L(){}function F(n,t,e){return new H(n,t,e)}function H(n,t,e){this.h=n,this.s=t,this.l=e}function P(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(a-u)*n/60:180>n?a:240>n?u+(a-u)*(240-n)/60:u}function i(n){return Math.round(r(n)*255)}var u,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+t):e+t-e*t,u=2*e-a,tt(i(n+120),i(n),i(n-120))}function R(n){return n>0?1:0>n?-1:0}function O(n){return Math.acos(Math.max(-1,Math.min(1,n)))}function Y(n){return n>1?Da/2:-1>n?-Da/2:Math.asin(n)}function U(n){return(Math.exp(n)-Math.exp(-n))/2}function I(n){return(Math.exp(n)+Math.exp(-n))/2}function V(n){return(n=Math.sin(n/2))*n}function X(n,t,e){return new Z(n,t,e)}function Z(n,t,e){this.h=n,this.c=t,this.l=e}function B(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),$(e,Math.cos(n*=La)*t,Math.sin(n)*t)}function $(n,t,e){return new J(n,t,e)}function J(n,t,e){this.l=n,this.a=t,this.b=e}function G(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=W(i)*Ra,r=W(r)*Oa,u=W(u)*Ya,tt(nt(3.2404542*i-1.5371385*r-.4985314*u),nt(-.969266*i+1.8760108*r+.041556*u),nt(.0556434*i-.2040259*r+1.0572252*u))}function K(n,t,e){return n>0?X(Math.atan2(e,t)*Fa,Math.sqrt(t*t+e*e),n):X(0/0,0/0,n)}function W(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function Q(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function nt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function tt(n,t,e){return new et(n,t,e)}function et(n,t,e){this.r=n,this.g=t,this.b=e}function rt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function it(n,t,e){var r,i,u,a=0,o=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(ct(i[0]),ct(i[1]),ct(i[2]))}return(u=Va.get(n))?t(u.r,u.g,u.b):(null!=n&&n.charAt(0)==="#"&&(n.length===4?(a=n.charAt(1),a+=a,o=n.charAt(2),o+=o,c=n.charAt(3),c+=c):n.length===7&&(a=n.substring(1,3),o=n.substring(3,5),c=n.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),c=parseInt(c,16)),t(a,o,c))}function ut(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),a=Math.max(n,t,e),o=a-u,c=(a+u)/2;return o?(i=.5>c?o/(a+u):o/(2-a-u),r=n==a?(t-e)/o+(e>t?6:0):t==a?(e-n)/o+2:(n-t)/o+4,r*=60):(r=0/0,i=c>0&&1>c?0:r),F(r,i,c)}function at(n,t,e){n=ot(n),t=ot(t),e=ot(e);var r=Q((.4124564*n+.3575761*t+.1804375*e)/Ra),i=Q((.2126729*n+.7151522*t+.072175*e)/Oa),u=Q((.0193339*n+.119192*t+.9503041*e)/Ya);return $(116*i-16,500*(r-i),200*(i-u))}function ot(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function ct(n){var t=parseFloat(n);return n.charAt(n.length-1)==="%"?Math.round(2.55*t):t}function lt(n){return"function"==typeof n?n:function(){return n}}function ft(n){return n}function st(n){return function(t,e,r){return arguments.length===2&&"function"==typeof e&&(r=e,e=null),ht(t,e,n,r)}}function ht(n,t,e,r){function i(){var n,t=c.status;if(!t&&c.responseText||t>=200&&300>t||304===t){try{n=e.call(u,c)}catch(r){return a.error.call(u,r),void 0}a.load.call(u,n)}else a.error.call(u,c)}var u={},a=ua.dispatch("progress","load","error"),o={},c=new(oa.XDomainRequest&&/^(http(s)?:)?\/\//.test(n)?XDomainRequest:XMLHttpRequest);return"onload"in c?c.onload=c.onerror=i:c.onreadystatechange=function(){c.readyState>3&&i()},c.onprogress=function(n){var t=ua.event;ua.event=n;try{a.progress.call(u,c)}finally{ua.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?o[n]:(null==t?delete o[n]:o[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(da(arguments)))}}),u.send=function(e,r,i){if(arguments.length===2&&"function"==typeof r&&(i=r,r=null),c.open(e,n,!0),null==t||"accept"in o||(o.accept=t+",*/*"),c.setRequestHeader)for(var a in o)c.setRequestHeader(a,o[a]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),c.send(null==r?null:r),u},u.abort=function(){return c.abort(),u},ua.rebind(u,a,"on"),null==r?u:u.get(gt(r))}function gt(n){return n.length===1?function(t,e){n(null==t?e:null)}:n}function pt(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var a=ua.xhr(n,t,u);return a.row=function(n){return arguments.length?a.response((e=n)==null?r:i(n)):e},a.row(e)}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function a(t){return t.map(o).join(n)}function o(n){return c.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var c=RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return a;if(i)return i=!1,u;var t=f;if(n.charCodeAt(t)===34){for(var e=t;e++f;){var r=n.charCodeAt(f++),o=1;if(10===r)i=!0;else if(13===r)i=!0,n.charCodeAt(f)===10&&(++f,++o);else if(r!==l)continue;return n.substring(t,f-o)}return n.substring(t)}for(var r,i,u={},a={},o=[],c=n.length,f=0,s=0;(r=e())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=e();(!t||(h=t(h,s++)))&&o.push(h)}return o},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new u,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(a).join("\n")},e}function dt(){var n=mt(),t=vt()-n;t>24?(isFinite(t)&&(clearTimeout($a),$a=setTimeout(dt,t)),Ba=0):(Ba=1,Ja(dt))}function mt(){for(var n=Date.now(),t=Xa;t;)n>=t.time&&(t.flush=t.callback(n-t.time)),t=t.next;return n}function vt(){for(var n,t=Xa,e=1/0;t;)t.flush?t=n?n.next=t.next:Xa=t.next:(t.time8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Mt(n,t){return t-(n?Math.ceil(Math.log(n)/Math.LN10):1)}function xt(n){return n+""}function bt(n,t){n&&uo.hasOwnProperty(n.type)&&uo[n.type](n,t)}function _t(n,t,e){var r,i=-1,u=n.length-e;for(t.lineStart();++i1||(1>lo&&(lo=1,fo=so=ho=go=0),po.point=function(i,u){i*=La;var a=Math.cos(u*=La);t=a*Math.cos(i),e=a*Math.sin(i),r=Math.sin(u),po.point=n})}function Ft(){po.point=Dt}function Ht(){return!0}function Pt(n,t,e,r,i){var u=[],a=[];if(n.forEach(function(n){if(!((t=n.length-1)<=0)){var t,e=n[0],r=n[t];if(zt(e,r)){i.lineStart();for(var o=0;t>o;++o)i.point((e=n[o])[0],e[1]);return i.lineEnd(),void 0}var c={point:e,points:n,other:null,visited:!1,entry:!0,subject:!0},l={point:e,points:[e],other:c,visited:!1,entry:!1,subject:!1};c.other=l,u.push(c),a.push(l),c={point:r,points:[r],other:null,visited:!1,entry:!1,subject:!0},l={point:r,points:[r],other:c,visited:!1,entry:!0,subject:!1},c.other=l,u.push(c),a.push(l)}}),a.sort(t),Rt(u),Rt(a),u.length){if(e)for(var o=1,c=!e(a[0].point),l=a.length;l>o;++o)a[o].entry=c=!c;for(var f,s,h,g=u[0];;){for(f=g;f.visited;)if((f=f.next)===g)return;s=f.points,i.lineStart();do{if(f.visited=f.other.visited=!0,f.entry){if(f.subject)for(var o=0;o=0;)i.point((h=s[o])[0],h[1])}else r(f.point,f.prev.point,-1,i);f=f.prev}f=f.other,s=f.points}while(!f.visited);i.lineEnd()}}}function Rt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r1&&2&t&&e.push(e.pop().concat(e.shift())),s.push(e.filter(Yt))}var s,h,g,p,d,m=t(r),v={point:i,lineStart:a,lineEnd:o,polygonStart:function(){v.point=c,v.lineStart=l,v.lineEnd=f,p=!1,g=h=0,s=[],r.polygonStart()},polygonEnd:function(){v.point=i,v.lineStart=a,v.lineEnd=o,s=ua.merge(s),s.length?Pt(s,Vt,null,e,r):(-ja>h||p&&-ja>g)&&(r.lineStart(),e(null,null,1,r),r.lineEnd()),r.polygonEnd(),s=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}},y=Ut(),M=t(y);return v}}function Yt(n){return n.length>1}function Ut(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:q,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function It(n,t){if(!(e=n.length))return 0;for(var e,r,i,u=0,a=0,o=n[0],c=o[0],l=o[1],f=Math.cos(l),s=Math.atan2(t*Math.sin(c)*f,Math.sin(l)),h=1-t*Math.cos(c)*f,g=s;++u2&&(a+=4*(r-s)):a+=Math.abs(h-2)0?Da:-Da,c=Math.abs(u-e);Math.abs(c-Da)0?Da/2:-Da/2),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(o,r),n.point(u,r),t=0):i!==o&&c>=Da&&(Math.abs(e-i)ja?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*a)):(t+r)/2}function Bt(n,t,e,r){var i;if(null==n)i=e*Da/2,r.point(-Da,i),r.point(0,i),r.point(Da,i),r.point(Da,0),r.point(Da,-i),r.point(0,-i),r.point(-Da,-i),r.point(-Da,0),r.point(-Da,i);else if(Math.abs(n[0]-t[0])>ja){var u=(n[0]u}function e(n){var e,u,c,l,f;return{lineStart:function(){l=c=!1,f=1},point:function(s,h){var g,p=[s,h],d=t(s,h),m=a?d?0:i(s,h):d?i(s+(0>s?Da:-Da),h):0;if(!e&&(l=c=d)&&n.lineStart(),d!==c&&(g=r(e,p),(zt(e,g)||zt(p,g))&&(p[0]+=ja,p[1]+=ja,d=t(p[0],p[1]))),d!==c)f=0,d?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(o&&e&&a^d){var v;m&u||!(v=r(p,e,!0))||(f=0,a?(n.lineStart(),n.point(v[0][0],v[0][1]),n.point(v[1][0],v[1][1]),n.lineEnd()):(n.point(v[1][0],v[1][1]),n.lineEnd(),n.lineStart(),n.point(v[0][0],v[0][1])))}!d||e&&zt(e,p)||n.point(p[0],p[1]),e=p,c=d,u=m},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return f|(l&&c)<<1}}}function r(n,t,e){var r=Et(n),i=Et(t),a=[1,0,0],o=At(r,i),c=kt(o,o),l=o[0],f=c-l*l;if(!f)return!e&&n;var s=u*c/f,h=-u*l/f,g=At(a,o),p=qt(a,s),d=qt(o,h);Nt(p,d);var m=g,v=kt(p,m),y=kt(m,m),M=v*v-y*(kt(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=qt(m,(-v-x)/y);if(Nt(b,p),b=Ct(b),!e)return b;var _,w=n[0],S=t[0],E=n[1],k=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=Math.abs(A-Da)A;if(!N&&E>k&&(_=E,E=k,k=_),q?N?E+k>0^b[1]<(Math.abs(b[0]-w)Da^(w<=b[0]&&b[0]<=S)){var T=qt(m,(-v+x)/y);return Nt(T,p),[b,Ct(T)]}}}function i(t,e){var r=a?n:Da-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),a=u>0,o=Math.abs(u)>ja,c=oe(n,6*La);return Ot(t,e,c)}function Jt(n,t,e,r){function i(r,i){return Math.abs(r[0]-n)0?0:3:Math.abs(r[0]-e)0?2:1:Math.abs(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return a(n.point,t.point)}function a(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}function o(i,u){var a=u[0]-i[0],o=u[1]-i[1],c=[0,1];return Math.abs(a)0&&(i[0]+=c[0]*a,i[1]+=c[0]*o),!0):!1}return function(c){function l(u){var a=i(u,-1),o=f([0===a||3===a?n:e,a>1?r:t]);return o}function f(n){for(var t=0,e=M.length,r=n[1],i=0;e>i;++i)for(var u,a=1,o=M[i],c=o.length,l=o[0];c>a;++a)u=o[a],l[1]<=r?u[1]>r&&s(l,u,n)>0&&++t:u[1]<=r&&s(l,u,n)<0&&--t,l=u;return 0!==t}function s(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}function h(u,o,c,l){var f=0,s=0;if(null==u||(f=i(u,c))!==(s=i(o,c))||a(u,o)<0^c>0){do l.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+c+4)%4)!==s)}else l.point(o[0],o[1])}function g(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function p(n,t){g(n,t)&&c.point(n,t)}function d(){T.point=v,M&&M.push(x=[]),A=!0,k=!1,S=E=0/0}function m(){y&&(v(b,_),w&&k&&q.rejoin(),y.push(q.buffer())),T.point=p,k&&c.lineEnd()}function v(n,t){n=Math.max(-vo,Math.min(vo,n)),t=Math.max(-vo,Math.min(vo,t));var e=g(n,t);if(M&&x.push([n,t]),A)b=n,_=t,w=e,A=!1,e&&(c.lineStart(),c.point(n,t));else if(e&&k)c.point(n,t);else{var r=[S,E],i=[n,t];o(r,i)?(k||(c.lineStart(),c.point(r[0],r[1])),c.point(i[0],i[1]),e||c.lineEnd()):e&&(c.lineStart(),c.point(n,t))}S=n,E=t,k=e}var y,M,x,b,_,w,S,E,k,A,N=c,q=Ut(),T={point:p,lineStart:d,lineEnd:m,polygonStart:function(){c=q,y=[],M=[]},polygonEnd:function(){c=N,(y=ua.merge(y)).length?(c.polygonStart(),Pt(y,u,l,h,c),c.polygonEnd()):f([n,t])&&(c.polygonStart(),c.lineStart(),h(null,null,1,c),c.lineEnd(),c.polygonEnd()),y=M=x=null}};return T}}function Gt(n,t,e){if(Math.abs(t)=n;var r=n/t;if(t>0){if(r>e[1])return!1;r>e[0]&&(e[0]=r)}else{if(r4*r&&d--){var x=a+h,b=o+g,_=c+p,w=Math.sqrt(x*x+b*b+_*_),S=Math.asin(_/=w),E=Math.abs(Math.abs(_)-1)r||Math.abs((v*q+y*T)/M-.5)>.3)&&(e(t,i,u,a,o,c,A,N,E,x/=w,b/=w,_,d,m),m.point(A,N),e(A,N,E,x,b,_,l,f,s,h,g,p,d,m))}}var r=.5,i=16;return t.precision=function(n){return arguments.length?(i=(r=n*n)>0&&16,t):Math.sqrt(r)},t}function Qt(n){return ne(function(){return n})()}function ne(n){function t(n){return n=a(n[0]*La,n[1]*La),[n[0]*f+o,c-n[1]*f]}function e(n){return n=a.invert((n[0]-o)/f,(c-n[1])/f),n&&[n[0]*Fa,n[1]*Fa]}function r(){a=Kt(u=re(d,m,v),i);var n=i(g,p);return o=s-n[0]*f,c=h+n[1]*f,t}var i,u,a,o,c,l=Wt(function(n,t){return n=i(n,t),[n[0]*f+o,c-n[1]*f]}),f=150,s=480,h=250,g=0,p=0,d=0,m=0,v=0,y=mo,M=ft,x=null,b=null;return t.stream=function(n){return te(u,y(l(M(n))))},t.clipAngle=function(n){return arguments.length?(y=null==n?(x=n,mo):$t((x=+n)*La),t):x},t.clipExtent=function(n){return arguments.length?(b=n,M=null==n?ft:Jt(n[0][0],n[0][1],n[1][0],n[1][1]),t):b},t.scale=function(n){return arguments.length?(f=+n,r()):f},t.translate=function(n){return arguments.length?(s=+n[0],h=+n[1],r()):[s,h]},t.center=function(n){return arguments.length?(g=n[0]%360*La,p=n[1]%360*La,r()):[g*Fa,p*Fa]},t.rotate=function(n){return arguments.length?(d=n[0]%360*La,m=n[1]%360*La,v=n.length>2?n[2]%360*La:0,r()):[d*Fa,m*Fa,v*Fa]},ua.rebind(t,l,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function te(n,t){return{point:function(e,r){r=n(e*La,r*La),e=r[0],t.point(e>Da?e-2*Da:-Da>e?e+2*Da:e,r[1])},sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function ee(n,t){return[n,t]}function re(n,t,e){return n?t||e?Kt(ue(n),ae(t,e)):ue(n):t||e?ae(t,e):ee}function ie(n){return function(t,e){return t+=n,[t>Da?t-2*Da:-Da>t?t+2*Da:t,e]}}function ue(n){var t=ie(n);return t.invert=ie(-n),t}function ae(n,t){function e(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*r+o*i;return[Math.atan2(c*u-f*a,o*r-l*i),Math.asin(Math.max(-1,Math.min(1,f*u+c*a)))]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),a=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*u-c*a;return[Math.atan2(c*u+l*a,o*r+f*i),Math.asin(Math.max(-1,Math.min(1,f*r-o*i)))]},e}function oe(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,a,o){null!=i?(i=ce(e,i),u=ce(e,u),(a>0?u>i:i>u)&&(i+=2*a*Da)):(i=n+2*a*Da,u=n);for(var c,l=a*t,f=i;a>0?f>u:u>f;f-=l)o.point((c=Ct([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function ce(n,t){var e=Et(t);e[0]-=n,Tt(e);var r=O(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-ja)%(2*Math.PI)}function le(n,t,e){var r=ua.range(n,t-ja,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function fe(n,t,e){var r=ua.range(n,t-ja,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function se(n){return n.source}function he(n){return n.target}function ge(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),a=Math.cos(r),o=Math.sin(r),c=i*Math.cos(n),l=i*Math.sin(n),f=a*Math.cos(e),s=a*Math.sin(e),h=2*Math.asin(Math.sqrt(V(r-t)+i*a*V(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*f,i=e*l+t*s,a=e*u+t*o;return[Math.atan2(i,r)*Fa,Math.atan2(a,Math.sqrt(r*r+i*i))*Fa]}:function(){return[n*Fa,t*Fa]};return p.distance=h,p}function pe(){function n(n,i){var u=Math.sin(i*=La),a=Math.cos(i),o=Math.abs((n*=La)-t),c=Math.cos(o);yo+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*u-e*a*c)*o),e*u+r*a*c),t=n,e=u,r=a}var t,e,r;Mo.point=function(i,u){t=i*La,e=Math.sin(u*=La),r=Math.cos(u),Mo.point=n},Mo.lineEnd=function(){Mo.point=Mo.lineEnd=q}}function de(n){var t=0,e=Da/3,r=ne(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Da/180,e=n[1]*Da/180):[180*(t/Da),180*(e/Da)]},i}function me(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),a-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),a=Math.sqrt(u)/i;return e.invert=function(n,t){var e=a-t;return[Math.atan2(n,e)/i,Y((u-(n*n+e*e)*i*i)/(2*i))]},e}function ve(){function n(n,t){bo+=i*n-r*t,r=n,i=t}var t,e,r,i;ko.point=function(u,a){ko.point=n,t=r=u,e=i=a},ko.lineEnd=function(){n(t,e)}}function ye(n,t){_o>n&&(_o=n),n>So&&(So=n),wo>t&&(wo=t),t>Eo&&(Eo=t)}function Me(){function n(n,t){a.push("M",n,",",t,u)}function t(n,t){a.push("M",n,",",t),o.point=e}function e(n,t){a.push("L",n,",",t)}function r(){o.point=n}function i(){a.push("Z")}var u=xe(4.5),a=[],o={point:n,lineStart:function(){o.point=t},lineEnd:r,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=r,o.point=n},pointRadius:function(n){return u=xe(n),o},result:function(){if(a.length){var n=a.join("");return a=[],n}}};return o}function xe(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function be(n,t){lo||(so+=n,ho+=t,++go)}function _e(){function n(n,r){var i=n-t,u=r-e,a=Math.sqrt(i*i+u*u);so+=a*(t+n)/2,ho+=a*(e+r)/2,go+=a,t=n,e=r}var t,e;if(1!==lo){if(!(1>lo))return;lo=1,so=ho=go=0}No.point=function(r,i){No.point=n,t=r,e=i}}function we(){No.point=be}function Se(){function n(n,t){var e=i*n-r*t;so+=e*(r+n),ho+=e*(i+t),go+=3*e,r=n,i=t}var t,e,r,i;2>lo&&(lo=2,so=ho=go=0),No.point=function(u,a){No.point=n,t=r=u,e=i=a},No.lineEnd=function(){n(t,e)}}function Ee(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,a,0,2*Da)}function e(t,e){n.moveTo(t,e),o.point=r}function r(t,e){n.lineTo(t,e)}function i(){o.point=t}function u(){n.closePath()}var a=4.5,o={point:t,lineStart:function(){o.point=e},lineEnd:i,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=i,o.point=t},pointRadius:function(n){return a=n,o},result:q};return o}function ke(n){var t=Wt(function(t,e){return n([t*Fa,e*Fa])});return function(n){return n=t(n),{point:function(t,e){n.point(t*La,e*La)},sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}}function Ae(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(n*u,r*a),Math.asin(r&&e*u/r)]},e}function Ne(n,t){function e(n,t){var e=Math.abs(Math.abs(t)-Da/2)1){o=t[1],u=n[c],c++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var l=2;l9&&(i=3*t/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));for(o=-1;++o<=c;)i=(n[Math.min(c,o+1)][0]-n[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}function nr(n){return n.length<3?Fe(n):n[0]+Ie(n,Qe(n))}function tr(n,t,e,r){var i,u,a,o,c,l,f;return i=r[n],u=i[0],a=i[1],i=r[t],o=i[0],c=i[1],i=r[e],l=i[0],f=i[1],(f-a)*(o-u)-(c-a)*(l-u)>0}function er(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function rr(n,t,e,r){var i=n[0],u=e[0],a=t[0]-i,o=r[0]-u,c=n[1],l=e[1],f=t[1]-c,s=r[1]-l,h=(o*(c-l)-s*(i-u))/(s*a-o*f);return[i+h*a,c+h*f]}function ir(n,t){var e={list:n.map(function(n,t){return{index:t,x:n[0],y:n[1]}}).sort(function(n,t){return n.yt.y?1:n.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(n,t){return{edge:n,side:t,vertex:null,l:null,r:null}},insert:function(n,t){t.l=n,t.r=n.r,n.r.l=t,n.r=t},leftBound:function(n){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,n));return t=t.l},del:function(n){n.l.r=n.r,n.r.l=n.l,n.edge=null},right:function(n){return n.r},left:function(n){return n.l},leftRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[n.side]},rightRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[Po[n.side]]}},i={bisect:function(n,t){var e={region:{l:n,r:t},ep:{l:null,r:null}},r=t.x-n.x,i=t.y-n.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=n.x*r+n.y*i+.5*(r*r+i*i),u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(n,t){var e=n.edge,r=t.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(Math.abs(i)<1e-10)return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,c=(r.c*e.a-e.c*r.a)/i,l=e.region.r,f=r.region.r;l.y=a.region.r.x;return s&&u.side==="l"||!s&&u.side==="r"?null:{x:o,y:c}},rightOf:function(n,t){var e=n.edge,r=e.region.r,i=t.x>r.x;if(i&&n.side==="l")return 1;if(!i&&n.side==="r")return 0;if(e.a===1){var u=t.y-r.y,a=t.x-r.x,o=0,c=0;if(!i&&e.b<0||i&&e.b>=0?c=o=u>=e.b*a:(c=t.x+t.y*e.b>e.c,e.b<0&&(c=!c),c||(o=1)),!o){var l=r.x-e.region.l.x;c=e.b*(a*a-u*u)h*h+g*g}return n.side==="l"?c:!c},endPoint:function(n,e,r){n.ep[e]=r,n.ep[Po[e]]&&t(n)},distance:function(n,t){var e=n.x-t.x,r=n.y-t.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(n,t,e){n.vertex=t,n.ystar=t.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(n.ystar>o.ystar||n.ystar==o.ystar&&t.x>o.vertex.x))break}i.splice(r,0,n)},del:function(n){for(var t=0,e=u.list,r=e.length;r>t&&e[t]!=n;++t);e.splice(t,1)},empty:function(){return u.list.length===0},nextEvent:function(n){for(var t=0,e=u.list,r=e.length;r>t;++t)if(e[t]==n)return e[t+1];return null},min:function(){var n=u.list[0];return{x:n.vertex.x,y:n.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,c,l,f,s,h,g,p,d,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||M.yg.y&&(p=h,h=g,g=p,y="r"),v=i.bisect(h,g),s=r.createHalfEdge(v,y),r.insert(l,s),i.endPoint(v,Po[y],m),d=i.intersect(l,s),d&&(u.del(l),u.insert(l,d,i.distance(d,h))),d=i.intersect(s,f),d&&u.insert(s,d,i.distance(d,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))t(o.edge)}function ur(n){return n.x}function ar(n){return n.y}function or(){return{leaf:!0,nodes:[],point:null,x:null,y:null}}function cr(n,t,e,r,i,u){if(!n(t,e,r,i,u)){var a=.5*(e+i),o=.5*(r+u),c=t.nodes;c[0]&&cr(n,c[0],e,r,a,o),c[1]&&cr(n,c[1],a,r,i,o),c[2]&&cr(n,c[2],e,o,a,u),c[3]&&cr(n,c[3],a,o,i,u)}}function lr(n,t){n=ua.rgb(n),t=ua.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,a=t.g-r,o=t.b-i;return function(n){return"#"+rt(Math.round(e+u*n))+rt(Math.round(r+a*n))+rt(Math.round(i+o*n))}}function fr(n){var t=[n.a,n.b],e=[n.c,n.d],r=hr(t),i=sr(t,e),u=hr(gr(e,t,-i))||0;t[0]*e[1]180?f+=360:f-l>180&&(l+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:pr(l,f)})):f&&r.push(r.pop()+"rotate("+f+")"),s!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:pr(s,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:pr(g[0],p[0])},{i:e-2,x:pr(g[1],p[1])})):(p[0]!=1||p[1]!=1)&&r.push(r.pop()+"scale("+p+")"),e=i.length,function(n){for(var t,u=-1;++ur;++r)if(a=f[r],a.x==e[0]){if(a.i)if(l[a.i+1]==null)for(l[a.i-1]+=a.x,l.splice(a.i,1),i=r+1;u>i;++i)f[i].i--;else for(l[a.i-1]+=a.x+l[a.i+1],l.splice(a.i,2),i=r+1;u>i;++i)f[i].i-=2;else if(l[a.i+1]==null)l[a.i]=a.x;else for(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1),i=r+1;u>i;++i)f[i].i--;f.splice(r,1),u--,r--}else a.x=pr(parseFloat(e[0]),parseFloat(a.x));for(;u>r;)a=f.pop(),l[a.i+1]==null?l[a.i]=a.x:(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1)),u--;return l.length===1?l[0]==null?(a=f[0].x,function(n){return a(n)+""}):function(){return t}:function(n){for(r=0;u>r;++r)l[(a=f[r]).i]=a.x(n);return l.join("")}}function yr(n,t){for(var e,r=ua.interpolators.length;--r>=0&&!(e=ua.interpolators[r](n,t)););return e}function Mr(n){return"transform"==n?dr:yr}function xr(n,t){var e,r=[],i=[],u=n.length,a=t.length,o=Math.min(n.length,t.length);for(e=0;o>e;++e)r.push(yr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;a>e;++e)i[e]=t[e];return function(n){for(e=0;o>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function Er(n){return n*n*n}function kr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Ar(n){return function(t){return Math.pow(t,n)}}function Nr(n){return 1-Math.cos(n*Da/2)}function qr(n){return Math.pow(2,10*(n-1))}function Tr(n){return 1-Math.sqrt(1-n*n)}function Cr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/(2*Da)*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,10*-r)*Math.sin(2*(r-e)*Da/t)}}function zr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Dr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function jr(n,t){n=ua.hcl(n),t=ua.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,a=t.c-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return B(e+u*n,r+a*n,i+o*n)+""}}function Lr(n,t){n=ua.hsl(n),t=ua.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,a=t.s-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return P(e+u*n,r+a*n,i+o*n)+""}}function Fr(n,t){n=ua.lab(n),t=ua.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,a=t.a-r,o=t.b-i;return function(n){return G(e+u*n,r+a*n,i+o*n)+""}}function Hr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Pr(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return(e-n)*t}}function Rr(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return Math.max(0,Math.min(1,(e-n)*t))}}function Or(n){for(var t=n.source,e=n.target,r=Ur(t,e),i=[t];t!==r;)t=t.parent,i.push(t);for(var u=i.length;e!==r;)i.splice(u,0,e),e=e.parent;return i}function Yr(n){for(var t=[],e=n.parent;null!=e;)t.push(n),n=e,e=e.parent;return t.push(n),t}function Ur(n,t){if(n===t)return n;for(var e=Yr(n),r=Yr(t),i=e.pop(),u=r.pop(),a=null;i===u;)a=i,i=e.pop(),u=r.pop();return a}function Ir(n){n.fixed|=2}function Vr(n){n.fixed&=-7}function Xr(n){n.fixed|=4,n.px=n.x,n.py=n.y}function Zr(n){n.fixed&=-5}function Br(n,t,e){var r=0,i=0;if(n.charge=0,!n.leaf)for(var u,a=n.nodes,o=a.length,c=-1;++ce;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function ui(n){return n.reduce(ai,0)}function ai(n,t){return n+t[1]}function oi(n,t){return ci(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function ci(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function li(n){return[ua.min(n),ua.max(n)]}function fi(n,t){return n.parent==t.parent?1:2}function si(n){var t=n.children;return t&&t.length?t[0]:n._tree.thread}function hi(n){var t,e=n.children;return e&&(t=e.length)?e[t-1]:n._tree.thread}function gi(n,t){var e=n.children;if(e&&(i=e.length))for(var r,i,u=-1;++u0&&(n=r);return n}function pi(n,t){return n.x-t.x}function di(n,t){return t.x-n.x}function mi(n,t){return n.depth-t.depth}function vi(n,t){function e(n,r){var i=n.children;if(i&&(a=i.length))for(var u,a,o=null,c=-1;++c=0;)t=i[u]._tree,t.prelim+=e,t.mod+=e,e+=t.shift+(r+=t.change)}function Mi(n,t,e){n=n._tree,t=t._tree;var r=e/(t.number-n.number);n.change+=r,t.change-=r,t.shift+=e,t.prelim+=e,t.mod+=e}function xi(n,t,e){return n._tree.ancestor.parent==t.parent?n._tree.ancestor:e}function bi(n,t){return n.value-t.value}function _i(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function wi(n,t){n._pack_next=t,t._pack_prev=n}function Si(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return i*i-e*e-r*r>.001}function Ei(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,i,u,a,o,c,l,f=1/0,s=-1/0,h=1/0,g=-1/0;if(e.forEach(ki),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(i=e[1],i.x=i.r,i.y=0,t(i),l>2))for(u=e[2],qi(r,i,u),t(u),_i(r,u),r._pack_prev=u,_i(u,i),i=r._pack_next,a=3;l>a;a++){qi(r,i,u=e[a]);var p=0,d=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,d++)if(Si(o,u)){p=1;break}if(1==p)for(c=r._pack_prev;c!==o._pack_prev&&!Si(c,u);c=c._pack_prev,m++);p?(m>d||d==m&&i.ra;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function ki(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ni(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,a=i.length;++ui&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Fi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Hi(n){return n.rangeExtent?n.rangeExtent():Fi(n.range())}function Pi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Ri(n,t){var e,r=0,i=n.length-1,u=n[r],a=n[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),(t=t(a-u))&&(n[r]=t.floor(u),n[i]=t.ceil(a)),n}function Oi(n,t,e,r){var i=[],u=[],a=0,o=Math.min(n.length,t.length)-1;for(n[o]2?Oi:Pi,c=r?Rr:Pr;return a=i(n,t,c,e),o=i(t,n,c,yr),u}function u(n){return a(n)}var a,o;return u.invert=function(n){return o(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Hr)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Xi(n,t)},u.tickFormat=function(t,e){return Zi(n,t,e)},u.nice=function(){return Ri(n,Ii),i()},u.copy=function(){return Yi(n,t,e,r)},i()}function Ui(n,t){return ua.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Ii(n){return n=Math.pow(10,Math.round(Math.log(n)/Math.LN10)-1),n&&{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}}function Vi(n,t){var e=Fi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Xi(n,t){return ua.range.apply(ua,Vi(n,t))}function Zi(n,t,e){var r=-Math.floor(Math.log(Vi(n,t)[2])/Math.LN10+.01);return ua.format(e?e.replace(no,function(n,t,e,i,u,a,o,c,l,f){return[t,e,i,u,a,o,c,l||"."+(r-2*("%"===f)),f].join("")}):",."+r+"f")}function Bi(n,t,e,r,i){function u(t){return n(e(t))}function a(){return e===$i?{floor:o,ceil:c}:{floor:function(n){return-c(-n)},ceil:function(n){return-o(-n)}}}function o(n){return Math.pow(t,Math.floor(Math.log(n)/Math.log(t)))}function c(n){return Math.pow(t,Math.ceil(Math.log(n)/Math.log(t)))}return u.invert=function(t){return r(n.invert(t))},u.domain=function(t){return arguments.length?(t[0]<0?(e=Gi,r=Ki):(e=$i,r=Ji),n.domain((i=t.map(Number)).map(e)),u):i},u.base=function(n){return arguments.length?(t=+n,u):t},u.nice=function(){return n.domain(Ri(i,a).map(e)),u},u.ticks=function(){var i=Fi(n.domain()),u=[];if(i.every(isFinite)){var a=Math.log(t),o=Math.floor(i[0]/a),c=Math.ceil(i[1]/a),l=r(i[0]),f=r(i[1]),s=t%1?2:t;if(e===Gi)for(u.push(-Math.pow(t,-o));o++0;h--)u.push(-Math.pow(t,-o)*h);else{for(;c>o;o++)for(var h=1;s>h;h++)u.push(Math.pow(t,o)*h);u.push(Math.pow(t,o))}for(o=0;u[o]f;c--);u=u.slice(o,c)}return u},u.tickFormat=function(n,i){if(arguments.length<2&&(i=Jo),!arguments.length)return i;var a,o=Math.log(t),c=Math.max(.1,n/u.ticks().length),l=e===Gi?(a=-1e-12,Math.floor):(a=1e-12,Math.ceil);return function(n){return n/r(o*l(e(n)/o+a))<=c?i(n):""}},u.copy=function(){return Bi(n.copy(),t,e,r,i)},Ui(u,n)}function $i(n){return Math.log(0>n?0:n)}function Ji(n){return Math.exp(n)}function Gi(n){return-Math.log(n>0?0:-n)}function Ki(n){return-Math.exp(-n)}function Wi(n,t,e){function r(t){return n(i(t))}var i=Qi(t),u=Qi(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Xi(e,n)},r.tickFormat=function(n,t){return Zi(e,n,t)},r.nice=function(){return r.domain(Ri(e,Ii))},r.exponent=function(a){return arguments.length?(i=Qi(t=a),u=Qi(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return Wi(n.copy(),t,e)},Ui(r,n)}function Qi(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function nu(n,t){function e(t){return a[((u.get(t)||u.set(t,n.push(t)))-1)%a.length]}function r(t,e){return ua.range(n.length).map(function(n){return t+e*n})}var u,a,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new i;for(var a,o=-1,c=r.length;++oe?l():(u.active=e,h.start.call(n,f,t),a.tween.forEach(function(e,r){(r=r.call(n,f,t))&&d.push(r)}),c(r)||ua.timer(c,0,o),1)}function c(r){if(u.active!==e)return l();for(var i=(r-g)/p,a=s(i),o=d.length;o>0;)d[--o].call(n,a);return i>=1?(l(),h.end.call(n,f,t),1):void 0}function l(){return--u.count?delete u[e]:delete n.__transition__,1}var f=n.__data__,s=a.ease,h=a.event,g=a.delay,p=a.duration,d=[];return r>=g?i(r):ua.timer(i,g,o),1},0,o),a}}function bu(n,t){n.attr("transform",function(n){return"translate("+t(n)+",0)"})}function _u(n,t){n.attr("transform",function(n){return"translate(0,"+t(n)+")"})}function wu(n,t,e){if(r=[],e&&t.length>1){for(var r,i,u,a=Fi(n.domain()),o=-1,c=t.length,l=(t[1]-t[0])/++e;++o0;)(u=+t[o]-i*l)>=a[0]&&r.push(u);for(--o,i=0;++i1?Date.UTC.apply(this,arguments):arguments[0])}function Eu(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new gc(e-1)),1),e}function u(n,e){return t(n=new gc(+n),e),n}function a(n,r,u){var a=i(n),o=[];if(u>1)for(;r>a;)e(a)%u||o.push(new Date(+a)),t(a,1);else for(;r>a;)o.push(new Date(+a)),t(a,1);return o}function o(n,t,e){try{gc=Su;var r=new Su;return r._=n,a(r,t,e)}finally{gc=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=a;var c=n.utc=ku(n);return c.floor=c,c.round=ku(r),c.ceil=ku(i),c.offset=ku(u),c.range=o,n}function ku(n){return function(t,e){try{gc=Su;var r=new Su;return r._=t,n(r,e)._}finally{gc=Date}}}function Au(n,t,e,r){for(var i,u,a=0,o=t.length,c=e.length;o>a;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(u=Cc[t.charAt(a++)],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function Nu(n){return RegExp("^(?:"+n.map(ua.requote).join("|")+")","i")}function qu(n){for(var t=new i,e=-1,r=n.length;++er?Array(e-r+1).join(t)+n:n}function Cu(n,t,e){Sc.lastIndex=0;var r=Sc.exec(t.substring(e));return r?e+=r[0].length:-1}function zu(n,t,e){wc.lastIndex=0;var r=wc.exec(t.substring(e));return r?e+=r[0].length:-1}function Du(n,t,e){Ac.lastIndex=0;var r=Ac.exec(t.substring(e));return r?(n.m=Nc.get(r[0].toLowerCase()),e+=r[0].length):-1}function ju(n,t,e){Ec.lastIndex=0;var r=Ec.exec(t.substring(e));return r?(n.m=kc.get(r[0].toLowerCase()),e+=r[0].length):-1}function Lu(n,t,e){return Au(n,""+Tc.c,t,e)}function Fu(n,t,e){return Au(n,""+Tc.x,t,e)}function Hu(n,t,e){return Au(n,""+Tc.X,t,e)}function Pu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+4));return r?(n.y=+r[0],e+=r[0].length):-1}function Ru(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.y=Ou(+r[0]),e+=r[0].length):-1}function Ou(n){return n+(n>68?1900:2e3)}function Yu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.m=r[0]-1,e+=r[0].length):-1}function Uu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.d=+r[0],e+=r[0].length):-1}function Iu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.H=+r[0],e+=r[0].length):-1}function Vu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.M=+r[0],e+=r[0].length):-1}function Xu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+2));return r?(n.S=+r[0],e+=r[0].length):-1}function Zu(n,t,e){zc.lastIndex=0;var r=zc.exec(t.substring(e,e+3));return r?(n.L=+r[0],e+=r[0].length):-1}function Bu(n,t,e){var r=Dc.get(t.substring(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}function $u(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return e+Tu(r,"0",2)+Tu(i,"0",2)}function Ju(n){return n.toISOString()}function Gu(n,t,e){function r(t){return n(t)}return r.invert=function(t){return Ku(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain(t),r):n.domain().map(Ku)},r.nice=function(n){return r.domain(Ri(r.domain(),function(){return n}))},r.ticks=function(e,i){var u=Fi(r.domain());if("function"!=typeof e){var a=u[1]-u[0],o=a/e,c=ua.bisect(Lc,o);if(c==Lc.length)return t.year(u,e);if(!c)return n.ticks(e).map(Ku);Math.log(o/Lc[c-1])n?-1:n>t?1:n>=t?0:0/0},ua.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ua.min=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++ir&&(e=r)}else{for(;++ir&&(e=r)}return e},ua.max=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++ie&&(e=r)}else{for(;++ie&&(e=r)}return e},ua.extent=function(n,t){var e,r,i,u=-1,a=n.length;if(arguments.length===1){for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},ua.sum=function(n,t){var e,r=0,i=n.length,u=-1;if(arguments.length===1)for(;++u1&&(t=t.map(e)),t=t.filter(n),t.length?ua.quantile(t.sort(ua.ascending),.5):void 0},ua.bisector=function(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n.call(t,t[u],u)r;){var u=r+i>>>1;er)for(;(i=n+r*++o)>t;)u.push(i/a);else for(;(i=n+r*++o)=a.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=a[c++],m=new i;++g=a.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,u={},a=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(ua.map,e,0),0)},u.key=function(n){return a.push(n),u},u.sortKeys=function(n){return o[a.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},ua.set=function(n){var t=new u;if(n)for(var e=0;e=0&&(r=n.substring(e+1),n=n.substring(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(arguments.length===2){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ua.event=null,ua.mouse=function(n){return g(n,f())};var pa=/WebKit/.test(oa.navigator.userAgent)?-1:0,da=d;try{da(aa.documentElement.childNodes)[0].nodeType}catch(ma){da=p}var va=[].__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]};ua.touches=function(n,t){return arguments.length<2&&(t=f().touches),t?da(t).map(function(t){var e=g(n,t);return e.identifier=t.identifier,e}):[]},ua.behavior.drag=function(){function n(){this.on("mousedown.drag",t).on("touchstart.drag",t)}function t(){function n(){var n=a.parentNode;return null!=f?ua.touches(n).filter(function(n){return n.identifier===f})[0]:ua.mouse(n)}function t(){if(!a.parentNode)return i();var t=n(),e=t[0]-h[0],r=t[1]-h[1];g|=e|r,h=t,l(),o({type:"drag",x:t[0]+u[0],y:t[1]+u[1],dx:e,dy:r})}function i(){o({type:"dragend"}),g&&(l(),ua.event.target===c&&s(p,"click")),p.on(null!=f?"touchmove.drag-"+f:"mousemove.drag",null).on(null!=f?"touchend.drag-"+f:"mouseup.drag",null)}var u,a=this,o=e.of(a,arguments),c=ua.event.target,f=ua.event.touches?ua.event.changedTouches[0].identifier:null,h=n(),g=0,p=ua.select(oa).on(null!=f?"touchmove.drag-"+f:"mousemove.drag",t).on(null!=f?"touchend.drag-"+f:"mouseup.drag",i,!0);r?(u=r.apply(a,arguments),u=[u.x-h[0],u.y-h[1]]):u=[0,0],null==f&&l(),o({type:"dragstart"})}var e=h(n,"drag","dragstart","dragend"),r=null;return n.origin=function(t){return arguments.length?(r=t,n):r},ua.rebind(n,e,"on")};var ya=function(n,t){return t.querySelector(n)},Ma=function(n,t){return t.querySelectorAll(n)},xa=aa.documentElement,ba=xa.matchesSelector||xa.webkitMatchesSelector||xa.mozMatchesSelector||xa.msMatchesSelector||xa.oMatchesSelector,_a=function(n,t){return ba.call(n,t)};"function"==typeof Sizzle&&(ya=function(n,t){return Sizzle(n,t)[0]||null},Ma=function(n,t){return Sizzle.uniqueSort(Sizzle(n,t))},_a=Sizzle.matchesSelector),ua.selection=function(){return Na};var wa=ua.selection.prototype=[];wa.select=function(n){var t,e,r,i,u=[];"function"!=typeof n&&(n=v(n));for(var a=-1,o=this.length;++a=0&&(e=n.substring(0,t),n=n.substring(t+1)),Sa.hasOwnProperty(e)?{space:Sa[e],local:n}:n}},wa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ua.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(M(t,n[t]));return this}return this.each(M(n,t))},ua.requote=function(n){return n.replace(Ea,"\\$&")};var Ea=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;wa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=n.trim().split(/^|\s+/g)).length,i=-1;if(t=e.classList){for(;++ir){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(S(e,n[e],t));return this}if(2>r)return oa.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(S(n,t,e))},wa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(E(t,n[t]));return this}return this.each(E(n,t))},wa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},wa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},wa.append=function(n){function t(){return this.appendChild(aa.createElementNS(this.namespaceURI,n))}function e(){return this.appendChild(aa.createElementNS(n.space,n.local))}return n=ua.ns.qualify(n),this.select(n.local?e:t)},wa.insert=function(n,t){function e(e,r){return this.insertBefore(aa.createElementNS(this.namespaceURI,n),t.call(this,e,r))}function r(e,r){return this.insertBefore(aa.createElementNS(n.space,n.local),t.call(this,e,r))}return n=ua.ns.qualify(n),"function"!=typeof t&&(t=v(t)),this.select(n.local?r:e)},wa.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},wa.data=function(n,t){function e(n,e){var r,u,a,o=n.length,s=e.length,h=Math.min(o,s),g=Array(s),p=Array(s),d=Array(o);if(t){var m,v=new i,y=new i,M=[];for(r=-1;++rr;++r)p[r]=k(e[r]);for(;o>r;++r)d[r]=n[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=n.parentNode,c.push(p),l.push(g),f.push(d)}var r,u,a=-1,o=this.length;if(!arguments.length){for(n=Array(o=(r=this[0]).length);++au;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return m(i)},wa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},wa.sort=function(n){n=N.apply(this,arguments);for(var t=-1,e=this.length;++tr){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(T(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(T(n,t,e))};var ka=ua.map({mouseenter:"mouseover",mouseleave:"mouseout"});ka.forEach(function(n){"on"+n in aa&&ka.remove(n)}),wa.each=function(n){return D(this,function(t,e,r){n.call(t,t.__data__,e,r)})},wa.call=function(n){var t=da(arguments);return n.apply(t[0]=this,t),this},wa.empty=function(){return!this.node()},wa.node=function(){for(var n=0,t=this.length;t>n;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null};var Aa=[];ua.selection.enter=j,ua.selection.enter.prototype=Aa,Aa.append=wa.append,Aa.insert=wa.insert,Aa.empty=wa.empty,Aa.node=wa.node,Aa.select=function(n){for(var t,e,r,i,u,a=[],o=-1,c=this.length;++oe-_){var u=n[0],o=t(n[0]);r(2*S),i(u,o),a(k.of(this,arguments))}_=e}}function d(){var n=ua.touches(this),t=n[0],e=m[t.identifier];if(u=n[1]){var u,o=m[u.identifier];t=[(t[0]+u[0])/2,(t[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r(ua.event.scale*v)}i(t,e),_=null,a(k.of(this,arguments))}var m,v,y,M,x,b,_,w=[0,0],S=1,E=Ta,k=h(n,"zoom");return n.translate=function(t){return arguments.length?(w=t.map(Number),u(),n):w},n.scale=function(t){return arguments.length?(S=+t,u(),n):S},n.scaleExtent=function(t){return arguments.length?(E=null==t?Ta:t.map(Number),n):E},n.x=function(t){return arguments.length?(M=t,y=t.copy(),w=[0,0],S=1,n):M},n.y=function(t){return arguments.length?(b=t,x=t.copy(),w=[0,0],S=1,n):b},ua.rebind(n,k,"on")};var qa,Ta=[0,1/0],Ca="onwheel"in aa?(qa=function(){return-ua.event.deltaY*(ua.event.deltaMode?120:1)},"wheel"):"onmousewheel"in aa?(qa=function(){return ua.event.wheelDelta},"mousewheel"):(qa=function(){return-ua.event.detail},"MozMousePixelScroll");L.prototype.toString=function(){return this.rgb()+""},ua.hsl=function(n,t,e){return arguments.length===1?n instanceof H?F(n.h,n.s,n.l):it(""+n,ut,F):F(+n,+t,+e)};var za=H.prototype=new L;za.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,this.l/n)},za.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,n*this.l)},za.rgb=function(){return P(this.h,this.s,this.l)};var Da=Math.PI,ja=1e-6,La=Da/180,Fa=180/Da;ua.hcl=function(n,t,e){return arguments.length===1?n instanceof Z?X(n.h,n.c,n.l):n instanceof J?K(n.l,n.a,n.b):K((n=at((n=ua.rgb(n)).r,n.g,n.b)).l,n.a,n.b):X(+n,+t,+e)};var Ha=Z.prototype=new L;Ha.brighter=function(n){return X(this.h,this.c,Math.min(100,this.l+Pa*(arguments.length?n:1)))},Ha.darker=function(n){return X(this.h,this.c,Math.max(0,this.l-Pa*(arguments.length?n:1)))},Ha.rgb=function(){return B(this.h,this.c,this.l).rgb()},ua.lab=function(n,t,e){return arguments.length===1?n instanceof J?$(n.l,n.a,n.b):n instanceof Z?B(n.l,n.c,n.h):at((n=ua.rgb(n)).r,n.g,n.b):$(+n,+t,+e)};var Pa=18,Ra=.95047,Oa=1,Ya=1.08883,Ua=J.prototype=new L;Ua.brighter=function(n){return $(Math.min(100,this.l+Pa*(arguments.length?n:1)),this.a,this.b)},Ua.darker=function(n){return $(Math.max(0,this.l-Pa*(arguments.length?n:1)),this.a,this.b)},Ua.rgb=function(){return G(this.l,this.a,this.b)},ua.rgb=function(n,t,e){return arguments.length===1?n instanceof et?tt(n.r,n.g,n.b):it(""+n,tt,P):tt(~~n,~~t,~~e)};var Ia=et.prototype=new L;Ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),tt(Math.min(255,Math.floor(t/n)),Math.min(255,Math.floor(e/n)),Math.min(255,Math.floor(r/n)))):tt(i,i,i)},Ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),tt(Math.floor(n*this.r),Math.floor(n*this.g),Math.floor(n*this.b))},Ia.hsl=function(){return ut(this.r,this.g,this.b)},Ia.toString=function(){return"#"+rt(this.r)+rt(this.g)+rt(this.b)};var Va=ua.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});Va.forEach(function(n,t){Va.set(n,it(t,tt,P))}),ua.functor=lt,ua.xhr=st(ft),ua.csv=pt(",","text/csv"),ua.tsv=pt(" ","text/tab-separated-values");var Xa,Za,Ba,$a;ua.timer=function(n,t,e){if(arguments.length<3){if(arguments.length<2)t=0;else if(!isFinite(t))return;e=Date.now()}var r=e+t,i={callback:n,time:r,next:null};Za?Za.next=i:Xa=i,Za=i,Ba||($a=clearTimeout($a),Ba=1,Ja(dt))},ua.timer.flush=function(){mt(),vt()};var Ja=oa.requestAnimationFrame||oa.webkitRequestAnimationFrame||oa.mozRequestAnimationFrame||oa.oRequestAnimationFrame||oa.msRequestAnimationFrame||function(n){setTimeout(n,17)},Ga=".",Ka=",",Wa=[3,3],Qa=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(yt);ua.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=ua.round(n,Mt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,Math.floor((0>=e?e+1:e-1)/3)*3))),Qa[8+e/3]},ua.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)},ua.format=function(n){var t=no.exec(n),e=t[1]||" ",r=t[2]||">",i=t[3]||"",u=t[4]||"",a=t[5],o=+t[6],c=t[7],l=t[8],f=t[9],s=1,h="",g=!1;switch(l&&(l=+l.substring(1)),(a||"0"===e&&"="===r)&&(a=e="0",r="=",c&&(o-=Math.floor((o-1)/4))),f){case"n":c=!0,f="g";break;case"%":s=100,h="%",f="f";break;case"p":s=100,h="%",f="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+f.toLowerCase());case"c":case"d":g=!0,l=0;break;case"s":s=-1,f="r"}"#"===u&&(u=""),"r"!=f||l||(f="g"),null!=l&&("g"==f?l=Math.max(1,Math.min(21,l)):("e"==f||"f"==f)&&(l=Math.max(0,Math.min(20,l)))),f=to.get(f)||xt;var p=a&&c;return function(n){if(g&&n%1)return"";var t=0>n||0===n&&0>1/n?(n=-n,"-"):i;if(0>s){var d=ua.formatPrefix(n,l);n=d.scale(n),h=d.symbol}else n*=s;n=f(n,l),!a&&c&&(n=eo(n));var m=u.length+n.length+(p?0:t.length),v=o>m?Array(m=o-m+1).join(e):"";return p&&(n=eo(v+n)),Ga&&n.replace(".",Ga),t+=u,("<"===r?t+n+v:">"===r?v+t+n:"^"===r?v.substring(0,m>>=1)+t+n+v.substring(m):t+(p?n:v+n))+h}};var no=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,to=ua.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ua.round(n,Mt(n,t))).toFixed(Math.max(0,Math.min(20,Mt(n*(1+1e-15),t))))}}),eo=ft;if(Wa){var ro=Wa.length;eo=function(n){for(var t=n.lastIndexOf("."),e=t>=0?"."+n.substring(t+1):(t=n.length,""),r=[],i=0,u=Wa[0];t>0&&u>0;)r.push(n.substring(t-=u,t+u)),u=Wa[i=(i+1)%ro];return r.reverse().join(Ka||"")+e}}ua.geo={},ua.geo.stream=function(n,t){n&&io.hasOwnProperty(n.type)?io[n.type](n,t):bt(n,t)};var io={Feature:function(n,t){bt(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*Da+n:n,co.lineStart=co.lineEnd=co.point=q}};ua.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>g&&(g=t)}function t(t,e){var r=Et([t*La,e*La]);if(v){var i=At(v,r),u=[i[1],-i[0],0],a=At(u,i);Tt(a),a=Ct(a);var c=t-p,l=c>0?1:-1,d=a[0]*Fa*l,m=Math.abs(c)>180;if(m^(d>l*p&&l*t>d)){var y=a[1]*Fa;y>g&&(g=y)}else if(d=(d+360)%360-180,m^(d>l*p&&l*t>d)){var y=-a[1]*Fa;s>y&&(s=y)}else s>e&&(s=e),e>g&&(g=e);m?p>t?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>p?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t)}else n(t,e);v=r,p=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,v=null}function i(n,e){if(v){var r=n-p;y+=Math.abs(r)>180?r+(r>0?360:-360):r}else d=n,m=e;co.point(n,e),t(n,e)}function u(){co.lineStart()}function a(){i(d,m),co.lineEnd(),Math.abs(y)>ja&&(f=-(h=180)),x[0]=f,x[1]=h,v=null}function o(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:noo?(f=-(h=180),s=-(g=90)):y>ja?g=90:-ja>y&&(s=-90),x[0]=f,x[1]=h}};return function(n){g=h=-(f=s=1/0),M=[],ua.geo.stream(n,b),M.sort(c);for(var t,e=1,r=M.length,i=M[0],u=[i];r>e;++e)t=M[e],l(t[0],i)||l(t[1],i)?(o(i[0],t[1])>o(i[0],i[1])&&(i[1]=t[1]),o(t[0],i[1])>o(i[0],i[1])&&(i[0]=t[0])):u.push(i=t);for(var a,t,p=-1/0,r=u.length-1,e=0,i=u[r];r>=e;i=t,++e)t=u[e],(a=o(i[1],t[0]))>p&&(p=a,f=t[0],h=i[1]);return M=x=null,[[f,s],[h,g]]}}(),ua.geo.centroid=function(n){lo=fo=so=ho=go=0,ua.geo.stream(n,po);var t;return fo&&Math.abs(t=Math.sqrt(so*so+ho*ho+go*go))>ja?[Math.atan2(ho,so)*Fa,Math.asin(Math.max(-1,Math.min(1,go/t)))*Fa]:void 0};var lo,fo,so,ho,go,po={sphere:function(){2>lo&&(lo=2,fo=so=ho=go=0)},point:Dt,lineStart:Lt,lineEnd:Ft,polygonStart:function(){2>lo&&(lo=2,fo=so=ho=go=0),po.lineStart=jt},polygonEnd:function(){po.lineStart=Lt}},mo=Ot(Ht,Xt,Bt),vo=1e9;ua.geo.projection=Qt,ua.geo.projectionMutator=ne,(ua.geo.equirectangular=function(){return Qt(ee)}).raw=ee.invert=ee,ua.geo.rotation=function(n){function t(t){return t=n(t[0]*La,t[1]*La),t[0]*=Fa,t[1]*=Fa,t}return n=re(n[0]%360*La,n[1]*La,n.length>2?n[2]*La:0),t.invert=function(t){return t=n.invert(t[0]*La,t[1]*La),t[0]*=Fa,t[1]*=Fa,t},t},ua.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=re(-n[0]*La,-n[1]*La,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Fa,n[1]*=Fa}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=oe((t=+r)*La,i*La),n):t},n.precision=function(r){return arguments.length?(e=oe(t*La,(i=+r)*La),n):i},n.angle(90)},ua.geo.distance=function(n,t){var e,r=(t[0]-n[0])*La,i=n[1]*La,u=t[1]*La,a=Math.sin(r),o=Math.cos(r),c=Math.sin(i),l=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*a)*e+(e=l*f-c*s*o)*e),c*f+l*s*o)},ua.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ua.range(Math.ceil(u/m)*m,i,m).map(h).concat(ua.range(Math.ceil(l/v)*v,c,v).map(g)).concat(ua.range(Math.ceil(r/p)*p,e,p).filter(function(n){return Math.abs(n%m)>ja}).map(f)).concat(ua.range(Math.ceil(o/d)*d,a,d).filter(function(n){return Math.abs(n%v)>ja}).map(s))}var e,r,i,u,a,o,c,l,f,s,h,g,p=10,d=p,m=90,v=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(g(c).slice(1),h(i).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],l=+t[0][1],c=+t[1][1],u>i&&(t=u,u=i,i=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[u,l],[i,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),n.precision(y)):[[r,o],[e,a]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(m=+t[0],v=+t[1],n):[m,v]},n.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],n):[p,d]},n.precision=function(t){return arguments.length?(y=+t,f=le(o,a,90),s=fe(r,e,y),h=le(l,c,90),g=fe(u,i,y),n):y},n.majorExtent([[-180,-90+ja],[180,90-ja]]).minorExtent([[-180,-80-ja],[180,80+ja]])},ua.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=se,i=he;return n.distance=function(){return ua.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},ua.geo.interpolate=function(n,t){return ge(n[0]*La,n[1]*La,t[0]*La,t[1]*La)},ua.geo.length=function(n){return yo=0,ua.geo.stream(n,Mo),yo};var yo,Mo={sphere:q,point:q,lineStart:pe,lineEnd:q,polygonStart:q,polygonEnd:q};(ua.geo.conicEqualArea=function(){return de(me)}).raw=me,ua.geo.albers=function(){return ua.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ua.geo.albersUsa=function(){function n(n){var u=n[0],a=n[1];return t=null,e(u,a),t||(r(u,a),t)||i(u,a),t}var t,e,r,i,u=ua.geo.albers(),a=ua.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o=ua.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?a:i>=.166&&.234>i&&r>=-.214&&-.115>r?o:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=a.stream(n),r=o.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),a.precision(t),o.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),a.scale(.35*t),o.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var l=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*l,s-.238*l],[f+.455*l,s+.238*l]]).stream(c).point,r=a.translate([f-.307*l,s+.201*l]).clipExtent([[f-.425*l+ja,s+.12*l+ja],[f-.214*l-ja,s+.234*l-ja]]).stream(c).point,i=o.translate([f-.205*l,s+.212*l]).clipExtent([[f-.214*l+ja,s+.166*l+ja],[f-.115*l-ja,s+.234*l-ja]]).stream(c).point,n},n.scale(1070)};var xo,bo,_o,wo,So,Eo,ko={point:q,lineStart:q,lineEnd:q,polygonStart:function(){bo=0,ko.lineStart=ve},polygonEnd:function(){ko.lineStart=ko.lineEnd=ko.point=q,xo+=Math.abs(bo/2)}},Ao={point:ye,lineStart:q,lineEnd:q,polygonStart:q,polygonEnd:q},No={point:be,lineStart:_e,lineEnd:we,polygonStart:function(){No.lineStart=Se},polygonEnd:function(){No.point=be,No.lineStart=_e,No.lineEnd=we}};ua.geo.path=function(){function n(n){return n&&ua.geo.stream(n,r(i.pointRadius("function"==typeof u?+u.apply(this,arguments):u))),i.result()}var t,e,r,i,u=4.5;return n.area=function(n){return xo=0,ua.geo.stream(n,r(ko)),xo},n.centroid=function(n){return lo=so=ho=go=0,ua.geo.stream(n,r(No)),go?[so/go,ho/go]:void 0},n.bounds=function(n){return So=Eo=-(_o=wo=1/0),ua.geo.stream(n,r(Ao)),[[_o,wo],[So,Eo]]},n.projection=function(e){return arguments.length?(r=(t=e)?e.stream||ke(e):ft,n):t},n.context=function(t){return arguments.length?(i=(e=t)==null?new Me:new Ee(t),n):e},n.pointRadius=function(t){return arguments.length?(u="function"==typeof t?t:+t,n):u},n.projection(ua.geo.albersUsa()).context(null)};var qo=Ae(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ua.geo.azimuthalEqualArea=function(){return Qt(qo)}).raw=qo;var To=Ae(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},ft);(ua.geo.azimuthalEquidistant=function(){return Qt(To)}).raw=To,(ua.geo.conicConformal=function(){return de(Ne)}).raw=Ne,(ua.geo.conicEquidistant=function(){return de(qe)}).raw=qe;var Co=Ae(function(n){return 1/n},Math.atan);(ua.geo.gnomonic=function(){return Qt(Co)}).raw=Co,Te.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Da/2]},(ua.geo.mercator=function(){return Ce(Te)}).raw=Te;var zo=Ae(function(){return 1},Math.asin);(ua.geo.orthographic=function(){return Qt(zo)}).raw=zo;var Do=Ae(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ua.geo.stereographic=function(){return Qt(Do)}).raw=Do,ze.invert=function(n,t){return[Math.atan2(U(n),Math.cos(t)),Y(Math.sin(t)/I(n))]},(ua.geo.transverseMercator=function(){return Ce(ze)}).raw=ze,ua.geom={},ua.svg={},ua.svg.line=function(){return De(ft)};var jo=ua.map({linear:Fe,"linear-closed":He,"step-before":Pe,"step-after":Re,basis:Xe,"basis-open":Ze,"basis-closed":Be,bundle:$e,cardinal:Ue,"cardinal-open":Oe,"cardinal-closed":Ye,monotone:nr});jo.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Lo=[0,2/3,1/3,0],Fo=[0,1/3,2/3,0],Ho=[0,1/6,2/3,1/6];ua.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i,u,a,o,c,l,f,s,h,g,p,d=lt(e),m=lt(r),v=n.length,y=v-1,M=[],x=[],b=0;if(d===je&&r===Le)t=n;else for(u=0,t=[];v>u;++u)t.push([+d.call(this,i=n[u],u),+m.call(this,i,u)]);for(u=1;v>u;++u)(t[u][1]u;++u)u!==b&&(c=t[u][1]-t[b][1],o=t[u][0]-t[b][0],M.push({angle:Math.atan2(c,o),index:u}));for(M.sort(function(n,t){return n.angle-t.angle}),g=M[0].angle,h=M[0].index,s=0,u=1;y>u;++u){if(a=M[u].index,g==M[u].angle){if(o=t[h][0]-t[b][0],c=t[h][1]-t[b][1],l=t[a][0]-t[b][0],f=t[a][1]-t[b][1],o*o+c*c>=l*l+f*f){M[u].index=-1;continue}M[s].index=-1}g=M[u].angle,s=u,h=a}for(x.push(b),u=0,a=0;2>u;++a)M[a].index>-1&&(x.push(M[a].index),u++);for(p=x.length;y>a;++a)if(!(M[a].index<0)){for(;!tr(x[p-2],x[p-1],M[a].index,t);)--p;x[p++]=M[a].index}var _=[];for(u=p-1;u>=0;--u)_.push(n[x[u]]);return _}var e=je,r=Le;return arguments.length?t(n):(t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t)},ua.geom.polygon=function(n){return n.area=function(){for(var t=0,e=n.length,r=n[e-1][1]*n[0][0]-n[e-1][0]*n[0][1];++to;o++)e.push([i,t[o],t[o+1]])}),e},ua.geom.voronoi=function(n){function t(n){var t,r,a,o=n.map(function(){return[]}),c=lt(i),l=lt(u),f=n.length,s=1e6;if(c===je&&l===Le)t=n;else for(t=[],a=0;f>a;++a)t.push([+c.call(this,r=n[a],a),+l.call(this,r,a)]);if(ir(t,function(n){var t,e,r,i,u,a;n.a===1&&n.b>=0?(t=n.ep.r,e=n.ep.l):(t=n.ep.l,e=n.ep.r),n.a===1?(u=t?t.y:-s,r=n.c-n.b*u,a=e?e.y:s,i=n.c-n.b*a):(r=t?t.x:-s,u=n.c-n.a*r,i=e?e.x:s,a=n.c-n.a*i);var c=[r,u],l=[i,a];o[n.region.l.index].push(c,l),o[n.region.r.index].push(c,l)}),o=o.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(n){return Math.atan2(n[0]-r,n[1]-i) +}),a=ua.range(n.length).sort(function(n,t){return u[n]-u[t]});return a.filter(function(n,t){return!t||u[n]-u[a[t-1]]>ja}).map(function(t){return n[t]})}),o.forEach(function(n,e){var r=n.length;if(!r)return n.push([-s,-s],[-s,s],[s,s],[s,-s]);if(!(r>2)){var i=t[e],u=n[0],a=n[1],o=i[0],c=i[1],l=u[0],f=u[1],h=a[0],g=a[1],p=Math.abs(h-l),d=g-f;if(Math.abs(d)c?-s:s;n.push([-s,m],[s,m])}else if(ja>p){var v=l>o?-s:s;n.push([v,-s],[v,s])}else{var m=(l-o)*(g-f)>(h-l)*(f-c)?s:-s,y=Math.abs(d)-p;Math.abs(y)d?m:-m,m]):(y>0&&(m*=-1),n.push([-s,m],[s,m]))}}}),e)for(a=0;f>a;++a)e(o[a]);for(a=0;f>a;++a)o[a].point=n[a];return o}var e,r=null,i=je,u=Le;return arguments.length?t(n):(t.x=function(n){return arguments.length?(i=n,t):i},t.y=function(n){return arguments.length?(u=n,t):u},t.size=function(n){return arguments.length?(null==n?e=null:(r=[+n[0],+n[1]],e=ua.geom.polygon([[0,0],[0,r[1]],r,[r[0],0]]).clip),t):r},t.links=function(n){var t,e,r,a=n.map(function(){return[]}),o=[],c=lt(i),l=lt(u),f=n.length;if(c===je&&l===Le)t=n;else for(r=0;f>r;++r)t.push([+c.call(this,e=n[r],r),+l.call(this,e,r)]);return ir(t,function(t){var e=t.region.l.index,r=t.region.r.index;a[e][r]||(a[e][r]=a[r][e]=!0,o.push({source:n[e],target:n[r]}))}),o},t.triangles=function(n){if(i===je&&u===Le)return ua.geom.delaunay(n);var t,e,r,a,o,c=lt(i),l=lt(u);for(a=0,t=[],o=n.length;o>a;++a)e=[+c.call(this,r=n[a],a),+l.call(this,r,a)],e.data=r,t.push(e);return ua.geom.delaunay(t).map(function(n){return n.map(function(n){return n.data})})},t)};var Po={l:"r",r:"l"};ua.geom.quadtree=function(n,t,e,r,i){function u(n){function u(n,t,e,r,i,u,a,o){if(!isNaN(e)&&!isNaN(r))if(n.leaf){var c=n.x,f=n.y;if(null!=c)if(Math.abs(c-e)+Math.abs(f-r)<.01)l(n,t,e,r,i,u,a,o);else{var s=n.point;n.x=n.y=n.point=null,l(n,s,c,f,i,u,a,o),l(n,t,e,r,i,u,a,o)}else n.x=e,n.y=r,n.point=t}else l(n,t,e,r,i,u,a,o)}function l(n,t,e,r,i,a,o,c){var l=.5*(i+o),f=.5*(a+c),s=e>=l,h=r>=f,g=(h<<1)+s;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=or()),s?i=l:o=l,h?a=f:c=f,u(n,t,e,r,i,a,o,c)}var f,s,h,g,p,d,m,v,y,M=lt(o),x=lt(c);if(null!=t)d=t,m=e,v=r,y=i;else if(v=y=-(d=m=1/0),s=[],h=[],p=n.length,a)for(g=0;p>g;++g)f=n[g],f.xv&&(v=f.x),f.y>y&&(y=f.y),s.push(f.x),h.push(f.y);else for(g=0;p>g;++g){var b=+M(f=n[g],g),_=+x(f,g);d>b&&(d=b),m>_&&(m=_),b>v&&(v=b),_>y&&(y=_),s.push(b),h.push(_)}var w=v-d,S=y-m;w>S?y=m+w:v=d+S;var E=or();if(E.add=function(n){u(E,n,+M(n,++g),+x(n,g),d,m,v,y)},E.visit=function(n){cr(n,E,d,m,v,y)},g=-1,null==t){for(;++g=0?n.substring(0,t):n,r=t>=0?n.substring(t+1):"in";return e=Uo.get(e)||Yo,r=Io.get(r)||ft,br(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},ua.interpolateHcl=jr,ua.interpolateHsl=Lr,ua.interpolateLab=Fr,ua.interpolateRound=Hr,ua.layout={},ua.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++e(i-e)*o){var c=t.charge*o*o;return n.px-=u*c,n.py-=a*c,!0}if(t.point&&isFinite(o)){var c=t.pointCharge*o*o;n.px-=u*c,n.py-=a*c}}return!t.charge}}function t(n){n.px=ua.event.x,n.py=ua.event.y,o.resume()}var e,r,i,u,a,o={},c=ua.dispatch("start","tick","end"),l=[1,1],f=.9,s=Vo,h=Xo,g=-30,p=.1,d=.8,m=[],v=[];return o.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,o,s,h,d,y,M,x,b=m.length,_=v.length;for(e=0;_>e;++e)o=v[e],s=o.source,h=o.target,M=h.x-s.x,x=h.y-s.y,(d=M*M+x*x)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,M*=d,x*=d,h.x-=M*(y=s.weight/(h.weight+s.weight)),h.y-=x*y,s.x+=M*(y=1-y),s.y+=x*y);if((y=r*p)&&(M=l[0]/2,x=l[1]/2,e=-1,y))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ua.timer(o.tick)),o):r},o.start=function(){function n(n,r){for(var i,u=t(e),a=-1,o=u.length;++ar;++r)c[r]=[];for(r=0;d>r;++r){var n=v[r];c[n.source.index].push(n.target),c[n.target.index].push(n.source)}}return c[e]}var e,r,c,f,p=m.length,d=v.length,y=l[0],M=l[1];for(e=0;p>e;++e)(f=m[e]).index=e,f.weight=0;for(e=0;d>e;++e)f=v[e],typeof f.source=="number"&&(f.source=m[f.source]),typeof f.target=="number"&&(f.target=m[f.target]),++f.source.weight,++f.target.weight;for(e=0;p>e;++e)f=m[e],isNaN(f.x)&&(f.x=n("x",y)),isNaN(f.y)&&(f.y=n("y",M)),isNaN(f.px)&&(f.px=f.x),isNaN(f.py)&&(f.py=f.y);if(i=[],"function"==typeof s)for(e=0;d>e;++e)i[e]=+s.call(this,v[e],e);else for(e=0;d>e;++e)i[e]=s;if(u=[],"function"==typeof h)for(e=0;d>e;++e)u[e]=+h.call(this,v[e],e);else for(e=0;d>e;++e)u[e]=h;if(a=[],"function"==typeof g)for(e=0;p>e;++e)a[e]=+g.call(this,m[e],e);else for(e=0;p>e;++e)a[e]=g;return o.resume()},o.resume=function(){return o.alpha(.1)},o.stop=function(){return o.alpha(0)},o.drag=function(){return e||(e=ua.behavior.drag().origin(ft).on("dragstart.force",Ir).on("drag.force",t).on("dragend.force",Vr)),arguments.length?(this.on("mouseover.force",Xr).on("mouseout.force",Zr).call(e),void 0):e},ua.rebind(o,c,"on")};var Vo=20,Xo=1;ua.layout.hierarchy=function(){function n(t,a,o){var c=i.call(e,t,a);if(t.depth=a,o.push(t),c&&(l=c.length)){for(var l,f,s=-1,h=t.children=[],g=0,p=a+1;++sg;++g)for(i.call(n,l[0][g],p=d[g],f[0][g][1]),h=1;m>h;++h)i.call(n,l[h][g],p+=f[h-1][g][1],f[h][g][1]);return o}var t=ft,e=ei,r=ri,i=ti,u=Qr,a=ni;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:Bo.get(t)||ei,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:$o.get(t)||ri,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(a=t,n):a},n.out=function(t){return arguments.length?(i=t,n):i},n};var Bo=ua.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(ii),u=n.map(ui),a=ua.range(r).sort(function(n,t){return i[n]-i[t]}),o=0,c=0,l=[],f=[];for(t=0;r>t;++t)e=a[t],c>o?(o+=u[e],l.push(e)):(c+=u[e],f.push(e));return f.reverse().concat(l)},reverse:function(n){return ua.range(n.length).reverse()},"default":ei}),$o=ua.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,a=[],o=0,c=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)c[e]=(o-a[e])/2;return c},wiggle:function(n){var t,e,r,i,u,a,o,c,l,f=n.length,s=n[0],h=s.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,o=s[e][0]-s[e-1][0];f>t;++t){for(r=0,a=(n[t][e][1]-n[t][e-1][1])/(2*o);t>r;++r)a+=(n[r][e][1]-n[r][e-1][1])/o;u+=a*n[t][e][1]}g[e]=c-=i?u/i*o:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,i=n.length,u=n[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:ri});ua.layout.histogram=function(){function n(n,u){for(var a,o,c=[],l=n.map(e,this),f=r.call(this,l,u),s=i.call(this,f,l,u),u=-1,h=l.length,g=s.length-1,p=t?1:1/h;++u0)for(u=-1;++u=f[0]&&o<=f[1]&&(a=c[ua.bisect(s,o,1,g)-1],a.y+=p,a.push(n[u]));return c}var t=!0,e=Number,r=li,i=oi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=lt(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return ci(n,t)}:lt(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ua.layout.tree=function(){function n(n,i){function u(n,t){var r=n.children,i=n._tree;if(r&&(a=r.length)){for(var a,c,l,f=r[0],s=f,h=-1;++h0&&(Mi(xi(o,n,r),n,i),l+=i,f+=i),s+=o._tree.mod,l+=u._tree.mod,h+=c._tree.mod,f+=a._tree.mod;o&&!hi(a)&&(a._tree.thread=o,a._tree.mod+=s-f),u&&!si(c)&&(c._tree.thread=u,c._tree.mod+=l-h,r=n)}return r}var c=t.call(this,n,i),l=c[0];vi(l,function(n,t){n._tree={ancestor:n,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),u(l),a(l,-l._tree.prelim);var f=gi(l,di),s=gi(l,pi),h=gi(l,mi),g=f.x-e(f,s)/2,p=s.x+e(s,f)/2,d=h.depth||1;return vi(l,function(n){n.x=(n.x-g)/(p-g)*r[0],n.y=n.depth/d*r[1],delete n._tree}),c}var t=ua.layout.hierarchy().sort(null).value(null),e=fi,r=[1,1];return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(r=t,n):r},$r(n,t)},ua.layout.pack=function(){function n(n,i){var u=t.call(this,n,i),a=u[0];a.x=0,a.y=0,vi(a,function(n){n.r=Math.sqrt(n.value)}),vi(a,Ei);var o=r[0],c=r[1],l=Math.max(2*a.r/o,2*a.r/c);if(e>0){var f=e*l/2;vi(a,function(n){n.r+=f}),vi(a,Ei),vi(a,function(n){n.r-=f}),l=Math.max(2*a.r/o,2*a.r/c)}return Ni(a,o/2,c/2,1/l),u}var t=ua.layout.hierarchy().sort(bi),e=0,r=[1,1];return n.size=function(t){return arguments.length?(r=t,n):r},n.padding=function(t){return arguments.length?(e=+t,n):e},$r(n,t)},ua.layout.cluster=function(){function n(n,i){var u,a=t.call(this,n,i),o=a[0],c=0;vi(o,function(n){var t=n.children;t&&t.length?(n.x=Ci(t),n.y=Ti(t)):(n.x=u?c+=e(n,u):0,n.y=0,u=n)});var l=zi(o),f=Di(o),s=l.x-e(l,f)/2,h=f.x+e(f,l)/2;return vi(o,function(n){n.x=(n.x-s)/(h-s)*r[0],n.y=(1-(o.y?n.y/o.y:1))*r[1]}),a}var t=ua.layout.hierarchy().sort(null).value(null),e=fi,r=[1,1];return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(r=t,n):r},$r(n,t)},ua.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var a,o,c,l=s(e),f=[],h=u.slice(),p=1/0,d="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?e.depth&1?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),f.area=0;(c=h.length)>0;)f.push(a=h[c-1]),f.area+=a.area,"squarify"!==g||(o=r(f,d))<=p?(h.pop(),p=o):(f.area-=f.pop().area,i(f,d,l,!1),d=Math.min(l.dx,l.dy),f.length=f.area=0,p=1/0);f.length&&(i(f,d,l,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,a=s(t),o=r.slice(),c=[];for(n(o,a.dx*a.dy/t.value),c.area=0;u=o.pop();)c.push(u),c.area+=u.area,u.z!=null&&(i(c,u.z?a.dx:a.dy,a,!o.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,a=-1,o=n.length;++ae&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*p/r,r/(t*u*p)):1/0}function i(n,t,e,r){var i,u=-1,a=n.length,o=e.x,l=e.y,f=t?c(n.area/t):0;if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=Math.random()*2-1,r=Math.random()*2-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=ua.random.normal.apply(ua,arguments);return function(){return Math.exp(n())}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t/n}}},ua.scale={},ua.scale.linear=function(){return Yi([0,1],[0,1],yr,!1)},ua.scale.log=function(){return Bi(ua.scale.linear().domain([0,Math.LN10]),10,$i,Ji,[1,10])};var Jo=ua.format(".0e");ua.scale.pow=function(){return Wi(ua.scale.linear(),1,[0,1])},ua.scale.sqrt=function(){return ua.scale.pow().exponent(.5)},ua.scale.ordinal=function(){return nu([],{t:"range",a:[[]]})},ua.scale.category10=function(){return ua.scale.ordinal().range(Go)},ua.scale.category20=function(){return ua.scale.ordinal().range(Ko)},ua.scale.category20b=function(){return ua.scale.ordinal().range(Wo)},ua.scale.category20c=function(){return ua.scale.ordinal().range(Qo)};var Go=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ko=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],Wo=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Qo=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];ua.scale.quantile=function(){return tu([],[])},ua.scale.quantize=function(){return eu(0,1,[0,1])},ua.scale.threshold=function(){return ru([.5],[0,1])},ua.scale.identity=function(){return iu([0,1])},ua.svg.arc=function(){function n(){var n=t.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+nc,o=i.apply(this,arguments)+nc,c=(a>o&&(c=a,a=o,o=c),o-a),l=Da>c?"0":"1",f=Math.cos(a),s=Math.sin(a),h=Math.cos(o),g=Math.sin(o);return c>=tc?n?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":n?"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+l+",0 "+n*f+","+n*s+"Z":"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L0,0"+"Z"}var t=uu,e=au,r=ou,i=cu;return n.innerRadius=function(e){return arguments.length?(t=lt(e),n):t},n.outerRadius=function(t){return arguments.length?(e=lt(t),n):e},n.startAngle=function(t){return arguments.length?(r=lt(t),n):r},n.endAngle=function(t){return arguments.length?(i=lt(t),n):i},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+nc;return[Math.cos(u)*n,Math.sin(u)*n]},n};var nc=-Da/2,tc=2*Da-1e-6;ua.svg.line.radial=function(){var n=De(lu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},Pe.reverse=Re,Re.reverse=Pe,ua.svg.area=function(){return fu(ft)},ua.svg.area.radial=function(){var n=fu(lu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ua.svg.chord=function(){function n(n,o){var c=t(this,u,n,o),l=t(this,a,n,o);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?i(c.r,c.p1,c.r,c.p0):i(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+i(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=o.call(n,i,r),a=c.call(n,i,r)+nc,f=l.call(n,i,r)+nc;return{r:u,a0:a,a1:f,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Da)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=se,a=he,o=su,c=ou,l=cu;return n.radius=function(t){return arguments.length?(o=lt(t),n):o},n.source=function(t){return arguments.length?(u=lt(t),n):u},n.target=function(t){return arguments.length?(a=lt(t),n):a},n.startAngle=function(t){return arguments.length?(c=lt(t),n):c},n.endAngle=function(t){return arguments.length?(l=lt(t),n):l},n},ua.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),a=e.call(this,n,i),o=(u.y+a.y)/2,c=[u,{x:u.x,y:o},{x:a.x,y:o},a];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=se,e=he,r=hu;return n.source=function(e){return arguments.length?(t=lt(e),n):t},n.target=function(t){return arguments.length?(e=lt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ua.svg.diagonal.radial=function(){var n=ua.svg.diagonal(),t=hu,e=n.projection;return n.projection=function(n){return arguments.length?e(gu(t=n)):t},n},ua.svg.symbol=function(){function n(n,r){return(ec.get(t.call(this,n,r))||mu)(e.call(this,n,r))}var t=du,e=pu;return n.type=function(e){return arguments.length?(t=lt(e),n):t},n.size=function(t){return arguments.length?(e=lt(t),n):e},n};var ec=ua.map({circle:mu,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*uc)),e=t*uc;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/ic),e=t*ic/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/ic),e=t*ic/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ua.svg.symbolTypes=ec.keys();var rc,ic=Math.sqrt(3),uc=Math.tan(30*La),ac=[],oc=0,cc={ease:kr,delay:0,duration:250};ac.call=wa.call,ac.empty=wa.empty,ac.node=wa.node,ua.transition=function(n){return arguments.length?rc?n.transition():n:Na.transition()},ua.transition.prototype=ac,ac.select=function(n){var t,e,r,i=this.id,u=[];"function"!=typeof n&&(n=v(n));for(var a=-1,o=this.length;++au;u++){i.push(t=[]);for(var e=this[u],o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return vu(i,this.id,this.time).ease(this.ease())},ac.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):D(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},ac.attr=function(n,t){function e(){this.removeAttribute(o)}function r(){this.removeAttributeNS(o.space,o.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(o);return e!==n&&(t=a(e,n),function(n){this.setAttribute(o,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(o.space,o.local);return e!==n&&(t=a(e,n),function(n){this.setAttributeNS(o.space,o.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var a=Mr(n),o=ua.ns.qualify(n);return yu(this,"attr."+n,t,o.local?u:i)},ac.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=ua.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},ac.style=function(n,t,e){function r(){this.style.removeProperty(n)}function i(t){return null==t?r:(t+="",function(){var r,i=oa.getComputedStyle(this,null).getPropertyValue(n);return i!==t&&(r=a(i,t),function(t){this.style.setProperty(n,r(t),e)})})}var u=arguments.length;if(3>u){if("string"!=typeof n){2>u&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}var a=Mr(n);return yu(this,"style."+n,t,i)},ac.styleTween=function(n,t,e){function r(r,i){var u=t.call(this,r,i,oa.getComputedStyle(this,null).getPropertyValue(n));return u&&function(t){this.style.setProperty(n,u(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},ac.text=function(n){return yu(this,"text",n,Mu)},ac.remove=function(){return this.each("end.transition",function(){var n;!this.__transition__&&(n=this.parentNode)&&n.removeChild(this)})},ac.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=ua.ease.apply(ua,arguments)),D(this,function(e){e.__transition__[t].ease=n}))},ac.delay=function(n){var t=this.id;return D(this,"function"==typeof n?function(e,r,i){e.__transition__[t].delay=n.call(e,e.__data__,r,i)|0}:(n|=0,function(e){e.__transition__[t].delay=n}))},ac.duration=function(n){var t=this.id;return D(this,"function"==typeof n?function(e,r,i){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,i)|0)}:(n=Math.max(1,0|n),function(e){e.__transition__[t].duration=n}))},ac.each=function(n,t){var e=this.id;if(arguments.length<2){var r=cc,i=rc;rc=e,D(this,function(t,r,i){cc=t.__transition__[e],n.call(t,t.__data__,r,i)}),cc=r,rc=i}else D(this,function(r){r.__transition__[e].event.on(n,t)});return this},ac.transition=function(){for(var n,t,e,r,i=this.id,u=++oc,a=[],o=0,c=this.length;c>o;o++){a.push(n=[]);for(var t=this[o],l=0,f=t.length;f>l;l++)(e=t[l])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,xu(e,l,u,r)),n.push(e)}return vu(a,u)},ua.svg.axis=function(){function n(n){n.each(function(){var n,s=ua.select(this),h=null==l?e.ticks?e.ticks.apply(e,c):e.domain():l,g=null==t?e.tickFormat?e.tickFormat.apply(e,c):String:t,p=wu(e,h,f),d=s.selectAll(".tick.minor").data(p,String),m=d.enter().insert("line",".tick").attr("class","tick minor").style("opacity",1e-6),v=ua.transition(d.exit()).style("opacity",1e-6).remove(),y=ua.transition(d).style("opacity",1),M=s.selectAll(".tick.major").data(h,String),x=M.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),b=ua.transition(M.exit()).style("opacity",1e-6).remove(),_=ua.transition(M).style("opacity",1),w=Hi(e),S=s.selectAll(".domain").data([0]),E=(S.enter().append("path").attr("class","domain"),ua.transition(S)),k=e.copy(),A=this.__chart__||k;this.__chart__=k,x.append("line"),x.append("text");var N=x.select("line"),q=_.select("line"),T=M.select("text").text(g),C=x.select("text"),z=_.select("text");switch(r){case"bottom":n=bu,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),C.attr("y",Math.max(i,0)+o),q.attr("x2",0).attr("y2",i),z.attr("x",0).attr("y",Math.max(i,0)+o),T.attr("dy",".71em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+a+"V0H"+w[1]+"V"+a);break;case"top":n=bu,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),C.attr("y",-(Math.max(i,0)+o)),q.attr("x2",0).attr("y2",-i),z.attr("x",0).attr("y",-(Math.max(i,0)+o)),T.attr("dy","0em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+-a+"V0H"+w[1]+"V"+-a);break;case"left":n=_u,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),C.attr("x",-(Math.max(i,0)+o)),q.attr("x2",-i).attr("y2",0),z.attr("x",-(Math.max(i,0)+o)).attr("y",0),T.attr("dy",".32em").style("text-anchor","end"),E.attr("d","M"+-a+","+w[0]+"H0V"+w[1]+"H"+-a);break;case"right":n=_u,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),C.attr("x",Math.max(i,0)+o),q.attr("x2",i).attr("y2",0),z.attr("x",Math.max(i,0)+o).attr("y",0),T.attr("dy",".32em").style("text-anchor","start"),E.attr("d","M"+a+","+w[0]+"H0V"+w[1]+"H"+a)}if(e.ticks)x.call(n,A),_.call(n,k),b.call(n,k),m.call(n,A),y.call(n,k),v.call(n,k);else{var D=k.rangeBand()/2,j=function(n){return k(n)+D};x.call(n,j),_.call(n,j)}})}var t,e=ua.scale.linear(),r=lc,i=6,u=6,a=6,o=3,c=[10],l=null,f=0;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in fc?t+"":lc,n):r},n.ticks=function(){return arguments.length?(c=arguments,n):c},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+t,u=r>1?+e:i,a=r>0?+arguments[r]:i,n},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(t){return arguments.length?(f=+t,n):f},n};var lc="bottom",fc={top:1,right:1,bottom:1,left:1};ua.svg.brush=function(){function n(u){u.each(function(){var u,a=ua.select(this),l=a.selectAll(".background").data([0]),s=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(f,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),l.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),s.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return sc[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",n.empty()?"none":null),h.exit().remove(),o&&(u=Hi(o),l.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),c&&(u=Hi(c),l.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),t(a)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)][0]+","+s[+/^s/.test(n)][1]+")"})}function e(n){n.select(".extent").attr("x",s[0][0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1][0]-s[0][0])}function r(n){n.select(".extent").attr("y",s[0][1]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1][1]-s[0][1])}function i(){function i(){var n=ua.event.changedTouches; +return n?ua.touches(y,n)[0]:ua.mouse(y)}function f(){ua.event.keyCode==32&&(E||(m=null,k[0]-=s[1][0],k[1]-=s[1][1],E=2),l())}function h(){ua.event.keyCode==32&&2==E&&(k[0]+=s[1][0],k[1]+=s[1][1],E=0,l())}function g(){var n=i(),u=!1;v&&(n[0]+=v[0],n[1]+=v[1]),E||(ua.event.altKey?(m||(m=[(s[0][0]+s[1][0])/2,(s[0][1]+s[1][1])/2]),k[0]=s[+(n[0]l?(i=r,r=l):i=l),s[0][e]!==r||s[1][e]!==i?(u=null,s[0][e]=r,s[1][e]=i,!0):void 0}function d(){g(),b.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ua.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),x({type:"brushend"}),l()}var m,v,y=this,M=ua.select(ua.event.target),x=a.of(y,arguments),b=ua.select(y),_=M.datum(),w=!/^(n|s)$/.test(_)&&o,S=!/^(e|w)$/.test(_)&&c,E=M.classed("extent"),k=i(),A=ua.select(oa).on("mousemove.brush",g).on("mouseup.brush",d).on("touchmove.brush",g).on("touchend.brush",d).on("keydown.brush",f).on("keyup.brush",h);if(E)k[0]=s[0][0]-k[0],k[1]=s[0][1]-k[1];else if(_){var N=+/w$/.test(_),q=+/^n/.test(_);v=[s[1-N][0]-k[0],s[1-q][1]-k[1]],k[0]=s[N][0],k[1]=s[q][1]}else ua.event.altKey&&(m=k.slice());b.style("pointer-events","none").selectAll(".resize").style("display",null),ua.select("body").style("cursor",M.style("cursor")),x({type:"brushstart"}),g(),l()}var u,a=h(n,"brushstart","brush","brushend"),o=null,c=null,f=hc[0],s=[[0,0],[0,0]];return n.x=function(t){return arguments.length?(o=t,f=hc[!o<<1|!c],n):o},n.y=function(t){return arguments.length?(c=t,f=hc[!o<<1|!c],n):c},n.extent=function(t){var e,r,i,a,l;return arguments.length?(u=[[0,0],[0,0]],o&&(e=t[0],r=t[1],c&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(l=e,e=r,r=l),s[0][0]=0|e,s[1][0]=0|r),c&&(i=t[0],a=t[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),s[0][1]=0|i,s[1][1]=0|a),n):(t=u||s,o&&(e=t[0][0],r=t[1][0],u||(e=s[0][0],r=s[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(l=e,e=r,r=l))),c&&(i=t[0][1],a=t[1][1],u||(i=s[0][1],a=s[1][1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),o&&c?[[e,i],[r,a]]:o?[e,r]:c&&[i,a])},n.clear=function(){return u=null,s[0][0]=s[0][1]=s[1][0]=s[1][1]=0,n},n.empty=function(){return o&&s[0][0]===s[1][0]||c&&s[0][1]===s[1][1]},ua.rebind(n,a,"on")};var sc={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},hc=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];ua.time={};var gc=Date,pc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Su.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){dc.setUTCDate.apply(this._,arguments)},setDay:function(){dc.setUTCDay.apply(this._,arguments)},setFullYear:function(){dc.setUTCFullYear.apply(this._,arguments)},setHours:function(){dc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){dc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){dc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){dc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){dc.setUTCSeconds.apply(this._,arguments)},setTime:function(){dc.setTime.apply(this._,arguments)}};var dc=Date.prototype,mc="%a %b %e %X %Y",vc="%m/%d/%Y",yc="%H:%M:%S",Mc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],xc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],bc=["January","February","March","April","May","June","July","August","September","October","November","December"],_c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];ua.time.year=Eu(function(n){return n=ua.time.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ua.time.years=ua.time.year.range,ua.time.years.utc=ua.time.year.utc.range,ua.time.day=Eu(function(n){var t=new gc(1970,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ua.time.days=ua.time.day.range,ua.time.days.utc=ua.time.day.utc.range,ua.time.dayOfYear=function(n){var t=ua.time.year(n);return Math.floor((n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},pc.forEach(function(n,t){n=n.toLowerCase(),t=7-t;var e=ua.time[n]=Eu(function(n){return(n=ua.time.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+Math.floor(t)*7)},function(n){var e=ua.time.year(n).getDay();return Math.floor((ua.time.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ua.time[n+"s"]=e.range,ua.time[n+"s"].utc=e.utc.range,ua.time[n+"OfYear"]=function(n){var e=ua.time.year(n).getDay();return Math.floor((ua.time.dayOfYear(n)+(e+t)%7)/7)}}),ua.time.week=ua.time.sunday,ua.time.weeks=ua.time.sunday.range,ua.time.weeks.utc=ua.time.sunday.utc.range,ua.time.weekOfYear=ua.time.sundayOfYear,ua.time.format=function(n){function t(t){for(var r,i,u,a=[],o=-1,c=0;++o=12?"PM":"AM"},S:function(n,t){return Tu(n.getSeconds(),t,2)},U:function(n,t){return Tu(ua.time.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Tu(ua.time.mondayOfYear(n),t,2)},x:ua.time.format(vc),X:ua.time.format(yc),y:function(n,t){return Tu(n.getFullYear()%100,t,2)},Y:function(n,t){return Tu(n.getFullYear()%1e4,t,4)},Z:$u,"%":function(){return"%"}},Cc={a:Cu,A:zu,b:Du,B:ju,c:Lu,d:Uu,e:Uu,H:Iu,I:Iu,L:Zu,m:Yu,M:Vu,p:Bu,S:Xu,x:Fu,X:Hu,y:Ru,Y:Pu},zc=/^\s*\d+/,Dc=ua.map({am:0,pm:1});ua.time.format.utc=function(n){function t(n){try{gc=Su;var t=new gc;return t._=n,e(t)}finally{gc=Date}}var e=ua.time.format(n);return t.parse=function(n){try{gc=Su;var t=e.parse(n);return t&&t._}finally{gc=Date}},t.toString=e.toString,t};var jc=ua.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");ua.time.format.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Ju:jc,Ju.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Ju.toString=jc.toString,ua.time.second=Eu(function(n){return new gc(Math.floor(n/1e3)*1e3)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*1e3)},function(n){return n.getSeconds()}),ua.time.seconds=ua.time.second.range,ua.time.seconds.utc=ua.time.second.utc.range,ua.time.minute=Eu(function(n){return new gc(Math.floor(n/6e4)*6e4)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*6e4)},function(n){return n.getMinutes()}),ua.time.minutes=ua.time.minute.range,ua.time.minutes.utc=ua.time.minute.utc.range,ua.time.hour=Eu(function(n){var t=n.getTimezoneOffset()/60;return new gc((Math.floor(n/36e5-t)+t)*36e5)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*36e5)},function(n){return n.getHours()}),ua.time.hours=ua.time.hour.range,ua.time.hours.utc=ua.time.hour.utc.range,ua.time.month=Eu(function(n){return n=ua.time.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ua.time.months=ua.time.month.range,ua.time.months.utc=ua.time.month.utc.range;var Lc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Fc=[[ua.time.second,1],[ua.time.second,5],[ua.time.second,15],[ua.time.second,30],[ua.time.minute,1],[ua.time.minute,5],[ua.time.minute,15],[ua.time.minute,30],[ua.time.hour,1],[ua.time.hour,3],[ua.time.hour,6],[ua.time.hour,12],[ua.time.day,1],[ua.time.day,2],[ua.time.week,1],[ua.time.month,1],[ua.time.month,3],[ua.time.year,1]],Hc=[[ua.time.format("%Y"),Ht],[ua.time.format("%B"),function(n){return n.getMonth()}],[ua.time.format("%b %d"),function(n){return n.getDate()!=1}],[ua.time.format("%a %d"),function(n){return n.getDay()&&n.getDate()!=1}],[ua.time.format("%I %p"),function(n){return n.getHours()}],[ua.time.format("%I:%M"),function(n){return n.getMinutes()}],[ua.time.format(":%S"),function(n){return n.getSeconds()}],[ua.time.format(".%L"),function(n){return n.getMilliseconds()}]],Pc=ua.scale.linear(),Rc=Wu(Hc);Fc.year=function(n,t){return Pc.domain(n.map(na)).ticks(t).map(Qu)},ua.time.scale=function(){return Gu(ua.scale.linear(),Fc,Rc)};var Oc=Fc.map(function(n){return[n[0].utc,n[1]]}),Yc=[[ua.time.format.utc("%Y"),Ht],[ua.time.format.utc("%B"),function(n){return n.getUTCMonth()}],[ua.time.format.utc("%b %d"),function(n){return n.getUTCDate()!=1}],[ua.time.format.utc("%a %d"),function(n){return n.getUTCDay()&&n.getUTCDate()!=1}],[ua.time.format.utc("%I %p"),function(n){return n.getUTCHours()}],[ua.time.format.utc("%I:%M"),function(n){return n.getUTCMinutes()}],[ua.time.format.utc(":%S"),function(n){return n.getUTCSeconds()}],[ua.time.format.utc(".%L"),function(n){return n.getUTCMilliseconds()}]],Uc=Wu(Yc);return Oc.year=function(n,t){return Pc.domain(n.map(ea)).ticks(t).map(ta)},ua.time.scale.utc=function(){return Gu(ua.scale.linear(),Oc,Uc)},ua.text=st(function(n){return n.responseText}),ua.json=function(n,t){return ht(n,"application/json",ra,t)},ua.html=function(n,t){return ht(n,"text/html",ia,t)},ua.xml=st(function(n){return n.responseXML}),ua}(); +/*! Tiny Pub/Sub - v0.7.0 - 2013-01-29 +* https://github.com/cowboy/jquery-tiny-pubsub +* Copyright (c) 2013 "Cowboy" Ben Alman; Licensed MIT */ +(function(n){var u=n({});n.subscribe=function(){u.on.apply(u,arguments)},n.unsubscribe=function(){u.off.apply(u,arguments)},n.publish=function(){u.trigger.apply(u,arguments)}})(jQuery); +/*! URI.js v1.13.2 http://medialize.github.io/URI.js/ */ +/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ +(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.IPv6=n(f)})(this,function(f){var n=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var h=g.length,d=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[h-1]&&""===g[h-2]&&g.pop();h=g.length;-1!==g[h-1].indexOf(".")&&(d=7);var m;for(m=0;mf;f++)if("0"===h[0]&&1f&&(h=k,f=n)):"0"===g[m]&&(u=!0,k=m,n=1);n>f&&(h=k,f=n);1=l&&c>>10&1023|55296),a=56320|a&1023);return b+=D(a)}).join("")}function w(a, +b){return a+22+75*(26>a)-((0!=b)<<5)}function r(a,b,c){var d=0;a=c?z(a/H):a>>1;for(a+=z(a/b);a>v*t>>1;d+=p)a=z(a/v);return z(d+(v+1)*a/(a+x))}function k(b){var c=[],d=b.length,l,e=0,B=E,k=F,g,v,f,h,u;g=b.lastIndexOf(a);0>g&&(g=0);for(v=0;v=d&&n("invalid-input");h=b.charCodeAt(g++);h=10>h-48?h-22:26>h-65?h-65:26>h-97?h-97:p;(h>=p||h>z((q-e)/l))&&n("overflow");e+=h*l;u=f<=k?s:f>=k+t?t: +f-k;if(hz(q/h)&&n("overflow");l*=h}l=c.length+1;k=r(e-v,l,0==v);z(e/l)>q-B&&n("overflow");B+=z(e/l);e%=l;c.splice(e++,0,B)}return m(c)}function u(b){var c,l,e,B,g,k,v,h,f,u=[],m,y,A;b=d(b);m=b.length;c=E;l=0;g=F;for(k=0;kf&&u.push(D(f));for((e=B=u.length)&&u.push(a);e=c&&fz((q-l)/y)&&n("overflow");l+=(v-c)*y;c=v;for(k=0;kq&&n("overflow"),f==c){h=l;for(v=p;;v+=p){f=v<=g?s:v>=g+t?t:v-g; +if(h= 0x80 (not a basic code point)", +"invalid-input":"Invalid input"},v=p-s,z=Math.floor,D=String.fromCharCode,G;e={version:"1.2.3",ucs2:{decode:d,encode:m},decode:k,encode:u,toASCII:function(a){return h(a,function(a){return c.test(a)?"xn--"+u(a):a})},toUnicode:function(a){return h(a,function(a){return b.test(a)?k(a.slice(4).toLowerCase()):a})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return e});else if(y&&!y.nodeType)if(A)A.exports=e;else for(G in e)e.hasOwnProperty(G)&&(y[G]=e[G]);else f.punycode= +e})(this); +(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.SecondLevelDomains=n(f)})(this,function(f){var n=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", +bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", +cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", +et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ", +ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ", +kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ", +mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ", +pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ", +sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ", +na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", +rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", +tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", +us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(h){var d=h.lastIndexOf(".");if(0>=d||d>=h.length-1)return!1; +var f=h.lastIndexOf(".",d-1);if(0>=f||f>=d-1)return!1;var n=g.list[h.slice(d+1)];return n?0<=n.indexOf(" "+h.slice(f+1,d)+" "):!1},is:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1||0<=f.lastIndexOf(".",d-1))return!1;var m=g.list[f.slice(d+1)];return m?0<=m.indexOf(" "+f.slice(0,d)+" "):!1},get:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1)return null;var m=f.lastIndexOf(".",d-1);if(0>=m||m>=d-1)return null;var n=g.list[f.slice(d+1)];return!n||0>n.indexOf(" "+f.slice(m+ +1,d)+" ")?null:f.slice(m+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=n);return this}};return g}); +(function(f,n){"object"===typeof exports?module.exports=n(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],n):f.URI=n(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,n,g,h){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function m(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, +"\\$1")}function w(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function r(a){return"Array"===w(a)}function k(a,b){var c,d;if(r(b)){c=0;for(d=b.length;c]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters= +/[^a-zA-Z0-9\.-]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:d.domAttributes[b]}};d.encode=A;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=A;d.decode=decodeURIComponent};d.characters= +{pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}};d.encodeQuery= +function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;bd)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var l=c.start||d.findUri.start,e=c.end||d.findUri.end,f=c.trim||d.findUri.trim,k=/[a-z0-9-]=["']?$/i;for(l.lastIndex=0;;){var g=l.exec(a);if(!g)break;g=g.index;if(c.ignoreHtml){var h= +a.slice(Math.max(g-3,0),g);if(h&&k.test(h))continue}var h=g+a.slice(g).search(e),u=a.slice(g,h).replace(f,"");c.ignore&&c.ignore.test(u)||(h=g+u.length,u=b(u,g,h,a),a=a.slice(0,g)+u+a.slice(h),l.lastIndex=g+u.length)}l.lastIndex=0;return a};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+ +a+'" contains characters other than [A-Z0-9.-]');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),a;h.URI===this&&(h.URI=C);return this};e.build=function(a){if(!0===a)this._deferred_build= +!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new d(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};p={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};t=function(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}};for(s in p)e[s]=t(p[s]);p={query:"?",fragment:"#"};t=function(a, +b){return function(c,d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}};for(s in p)e[s]=t(s,p[s]);p={search:["?","query"],hash:["#","fragment"]};t=function(a,b){return function(c,d){var e=this[a](c,d);return"string"===typeof e&&e.length?b+e:e}};for(s in p)e[s]=t(p[s][1],p[s][0]);e.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}this._parts.path= +a?d.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var l=a instanceof d,e="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(e=d.getDomAttribute(a),a=a[e]||"",e=!1);!l&&e&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(l||e)for(c in l=l?a._parts:a,l)q.call(this._parts,c)&&(this._parts[c]=l[c]);else throw new TypeError("invalid input"); +this.build(!b);return this};e.is=function(a){var b=!1,c=!1,e=!1,f=!1,k=!1,h=!1,u=!1,p=!this._parts.urn;this._parts.hostname&&(p=!1,c=d.ip4_expression.test(this._parts.hostname),e=d.ip6_expression.test(this._parts.hostname),b=c||e,k=(f=!b)&&g&&g.has(this._parts.hostname),h=f&&d.idn_expression.test(this._parts.hostname),u=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return p;case "absolute":return!p;case "domain":case "name":return f;case "sld":return k; +case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return e;case "idn":return h;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return u}return null};var x=e.protocol,H=e.port,F=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return x.call(this, +a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return H.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};d.parseHost(a,c);a=c.hostname}return F.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this; +if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=d.buildUserinfo(this._parts);return c.substring(0, +c.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){var c;if(void 0===a)return this.path()+this.search()+this.hash();c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length- +1;return this._parts.hostname.substring(0,c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=RegExp("^"+m(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g); +if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=RegExp(m(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"": +this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf("."),c=this._parts.hostname.substring(c+1);return!0!==b&&g&&g.list[c.toLowerCase()]?g.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&g.is(a))c=RegExp(m(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname|| +this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=RegExp(m(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0, +c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=RegExp("^"+m(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; +var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var e=RegExp(m(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);c?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),e=c.lastIndexOf("."); +if(-1===e)return"";c=c.substring(e+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())e=a?RegExp(m(c)+"$"):RegExp(m("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}e&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!b);return this};e.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(d);void 0!==a&&"number"!==typeof a&& +(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(r(b)){e=[];a=0;for(var k=b.length;ag||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[d]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:c,modifiers:f,action:e}}function F(a,b,d,c,e){q[a+":"+d]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,d){a=a instanceof Array?a:[a];for(var c=0;c 0) { + group.push(child = remaining[n - 1]); + remaining.pop(); + } + + position(group, node.type, rect); + children.forEach(function(child, index) { + child.address = node.address.concat("." + child.type + (index + 1)); + }) + children.forEach(calculateLayout); + } + } + + // Positions the specified row of nodes. Modifies `rect`. + function position(group, groupType, rect) { + // console.log('%c\n'+' parent ' + groupType + ' rect is: ', 'background: #222; color: #EFEFEF; font-family: helvetica neue; font-size:20px; padding: 0 7px 3px 0;'); + // console.log(rect); + var i = -1, + row = (groupType === "row") ? false : true, // for ternary statements later, specifies whether that particular child is a row or not. Allows easy, centralised description of the parameter calculations that can be switched from row to column. + n = group.length, + x = rect.x, + y = rect.y, + o; + var offset = 0; + while (++i < n) { + o = group[n-(i+1)], + d = divisor(o, row, rect, group, n), + o.id = typeof o.id !== 'undefined' ? o.id : genUuid(), + o.x = row ? x : x + offset, + o.y = row ? y + offset : y, + o.dx = row ? rect.dx : rect.dx/d, + o.dy = row ? rect.dy/d : rect.dy, + offset += row ? o.dy : o.dx; + // console.log({x:o.x, y: o.y, width:o.dx, height: o.dy}); + } + } + + function divisor(node, row, rect, group, n) { + + var old = false, + dimension = row ? 'dy' : 'dx', + total = rect[dimension], + divisor; + // if not already set, divide equally. + group.forEach(function(item) { + if (!item[dimension] === undefined) { + old = true; + } + }); + + if (old) { + console.log('preserved'); + var sum = group.reduce( + function(previousValue, currentValue, index, array) { + return previousValue[dimension] + currentValue[dimension]; + }); + console.log('sum: ' + sum); + + divisor = (node[dimension]/sum)*total; + console.log("divisor: "+divisor); + return divisor; + } else { + return n; + } + } + + function isfahan(configObject) { + var nodes = hierarchy(configObject.layoutDescription), + root = nodes[0]; + size = (function(containerSelector) { + var width = jQuery(containerSelector).width(); + var height = jQuery(containerSelector).height(); + + return [width, height]; + })(configObject.containerSelector); + root.x = 0; + root.y = 0; + root.dx = containerSize(containerId)[0]; + root.dy = containerSize(containerId)[1]; + root.address = root.type + "1"; + root.id = root.id || genUuid(); + + calculateLayout(root); + isfahan.padding(padding); + nodes = nodes.map(function(node) { + return merge(node, pad(node)); + }); + + return nodes; + } + + isfahan.size = function(x) { + if (!arguments.length) return containerSize; + containerSize = x; + return isfahan; + }; + + isfahan.round = function(x) { + if (!arguments.length) return round != Number; + round = x ? Math.round : Number; + return isfahan; + }; + + isfahan.padding = function(x) { + if (!arguments.length) return padding; + + function padFunction(node) { + var p = x.call(isfahan, node, node.depth); + console.log(p); + return p == null + ? d3_layout_cellPadNull(node) + : d3_layout_cellPad(node, typeof p === "number" ? [p, p, p, p] : p); + } + + function padConstant(node) { + return d3_layout_cellPad(node, x); + } + + var type; + pad = (padding = x) == null ? d3_layout_cellPadNull + : (type = typeof x) === "function" ? padFunction + : type === "number" ? (x = [x, x, x, x], padConstant) + : padConstant; + return isfahan; + }; + + function genUuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + } + + function d3_layout_cellPadNull(node) { + return {x: node.x, y: node.y, dx: node.dx, dy: node.dy}; + } + + function d3_layout_cellPad(node, padding) { + var x = node.x + padding[3], + y = node.y + padding[0], + dx = node.dx - padding[1] - padding[3], + dy = node.dy - padding[0] - padding[2]; + if (dx < 0) { x += dx / 2; dx = 0; } + if (dy < 0) { y += dy / 2; dy = 0; } + return {x: x, y: y, dx: dx, dy: dy}; + } + + function merge(target, source) { + + /* Merges two (or more) objects, + giving the last one precedence */ + + if ( typeof target !== 'object' ) { + target = {}; + } + + for (var property in source) { + + if ( source.hasOwnProperty(property) ) { + + var sourceProperty = source[ property ]; + + if ( typeof sourceProperty === 'object' ) { + target[ property ] = util.merge( target[ property ], sourceProperty ); + continue; + } + + target[ property ] = sourceProperty; + + } + + } + + for (var a = 2, l = arguments.length; a < l; a++) { + merge(target, arguments[a]); + } + + return target; + }; + + // return d3.rebind(isfahan, hierarchy,"sort", "children", "value"); + return isfahan(configObject); +}; + +// i18next, v1.8.2 +// Copyright (c)2015 Jan Mühlemann (jamuhl). +// Distributed under MIT license +// http://i18next.com +!function(a){function b(a,b){if(!b||"function"==typeof b)return a;for(var c in b)a[c]=b[c];return a}function c(a,b){for(var d in b)d in a?c(a[d],b[d]):a[d]=b[d];return a}function d(a,b,c){var d,e=0,f=a.length,g=void 0===f||"[object Array]"!==Object.prototype.toString.apply(a)||"function"==typeof a;if(c)if(g){for(d in a)if(b.apply(a[d],c)===!1)break}else for(;f>e&&b.apply(a[e++],c)!==!1;);else if(g){for(d in a)if(b.call(a[d],d,a[d])===!1)break}else for(;f>e&&b.call(a[e],e,a[e++])!==!1;);return a}function e(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return Q[a]}):a}function f(a){var b=function(a){if(window.XMLHttpRequest)return a(null,new XMLHttpRequest);if(window.ActiveXObject)try{return a(null,new ActiveXObject("Msxml2.XMLHTTP"))}catch(b){return a(null,new ActiveXObject("Microsoft.XMLHTTP"))}return a(new Error)},c=function(a){if("string"==typeof a)return a;var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b.join("&")},d=function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},e=function(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a=d(a);var c,e,f,g,h,i,j,k="",l=0;do c=a.charCodeAt(l++),e=a.charCodeAt(l++),f=a.charCodeAt(l++),g=c>>2,h=(3&c)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k+=b.charAt(g)+b.charAt(h)+b.charAt(i)+b.charAt(j),c=e=f="",g=h=i=j="";while(l1&&(d+=d.indexOf("?")>-1?"&"+k:"?"+k),e.jsonp){var l=document.getElementsByTagName("head")[0],m=document.createElement("script");return m.type="text/javascript",m.src=d,void l.appendChild(m)}}b(function(b,c){if(b)return h(b);c.open(a,d,e.async);for(var f in j)j.hasOwnProperty(f)&&c.setRequestHeader(f,j[f]);c.onreadystatechange=function(){if(4===c.readyState){var a=c.responseText||"";if(!h)return;h(c.status,{text:function(){return a},json:function(){try{return JSON.parse(a)}catch(b){return T.error("Can not parse JSON. URL: "+d),{}}}})}},c.send(i)})},h={authBasic:function(a,b){g.headers.Authorization="Basic "+e(a+":"+b)},connect:function(a,b,c){return g("CONNECT",a,b,c)},del:function(a,b,c){return g("DELETE",a,b,c)},get:function(a,b,c){return g("GET",a,b,c)},head:function(a,b,c){return g("HEAD",a,b,c)},headers:function(a){g.headers=a||{}},isAllowed:function(a,b,c){this.options(a,function(a,d){c(-1!==d.text().indexOf(b))})},options:function(a,b,c){return g("OPTIONS",a,b,c)},patch:function(a,b,c){return g("PATCH",a,b,c)},post:function(a,b,c){return g("POST",a,b,c)},put:function(a,b,c){return g("PUT",a,b,c)},trace:function(a,b,c){return g("TRACE",a,b,c)}},i=a.type?a.type.toLowerCase():"get";h[i](a.url,a,function(b,c){200===b||0===b&&c.text()?a.success(c.json(),b,null):a.error(c.text(),b,null)})}function g(a,b){"function"==typeof a&&(b=a,a={}),a=a||{},T.extend(P,a),delete P.fixLng,P.functions&&(delete P.functions,T.extend(T,a.functions)),"string"==typeof P.ns&&(P.ns={namespaces:[P.ns],defaultNs:P.ns}),"string"==typeof P.fallbackNS&&(P.fallbackNS=[P.fallbackNS]),("string"==typeof P.fallbackLng||"boolean"==typeof P.fallbackLng)&&(P.fallbackLng=[P.fallbackLng]),P.interpolationPrefixEscaped=T.regexEscape(P.interpolationPrefix),P.interpolationSuffixEscaped=T.regexEscape(P.interpolationSuffix),P.lng||(P.lng=T.detectLanguage()),M=T.toLanguages(P.lng),H=M[0],T.log("currentLng set to: "+H),P.useCookie&&T.cookie.read(P.cookieName)!==H&&T.cookie.create(P.cookieName,H,P.cookieExpirationTime,P.cookieDomain),P.detectLngFromLocalStorage&&"undefined"!=typeof document&&window.localStorage&&T.localStorage.setItem("i18next_lng",H);var c=B;a.fixLng&&(c=function(a,b){return b=b||{},b.lng=b.lng||c.lng,B(a,b)},c.lng=H),W.setCurrentLng(H),I&&P.setJqueryExt&&u();var d;if(I&&I.Deferred&&(d=I.Deferred()),!P.resStore){var e=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var f=0,g=P.preload.length;g>f;f++)for(var h=T.toLanguages(P.preload[f]),i=0,j=h.length;j>i;i++)e.indexOf(h[i])<0&&e.push(h[i]);return J.sync.load(e,P,function(a,e){K=e,N=!0,b&&b(c),d&&d.resolve(c)}),d?d.promise():void 0}return K=P.resStore,N=!0,b&&b(c),d&&d.resolve(c),d?d.promise():void 0}function h(a,b){"string"==typeof a&&(a=[a]);for(var c=0,d=a.length;d>c;c++)P.preload.indexOf(a[c])<0&&P.preload.push(a[c]);return g(b)}function i(a,b,c,d){"string"!=typeof b?(c=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{},d?T.deepExtend(K[a][b],c):T.extend(K[a][b],c),P.useLocalStorage&&O._storeLocal(K)}function j(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{};var c=K[a][b]||{},d=!1;for(var e in c)c.hasOwnProperty(e)&&(d=!0);return d}function k(a,b){return"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},T.extend({},K[a][b])}function l(a,b){"string"!=typeof b&&(b=P.ns.defaultNs),K[a]=K[a]||{},K[a][b]={},P.useLocalStorage&&O._storeLocal(K)}function m(a,b,c,d){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b),K[a]=K[a]||{},K[a][b]=K[a][b]||{};for(var e=c.split(P.keyseparator),f=0,g=K[a][b];e[f];)f==e.length-1?g[e[f]]=d:(null==g[e[f]]&&(g[e[f]]={}),g=g[e[f]]),f++;P.useLocalStorage&&O._storeLocal(K)}function n(a,b,c){"string"!=typeof b?(resource=b,b=P.ns.defaultNs):P.ns.namespaces.indexOf(b)<0&&P.ns.namespaces.push(b);for(var d in c)"string"==typeof c[d]&&m(a,b,d,c[d])}function o(a){P.ns.defaultNs=a}function p(a,b){q([a],b)}function q(a,b){var c={dynamicLoad:P.dynamicLoad,resGetPath:P.resGetPath,getAsync:P.getAsync,customLoad:P.customLoad,ns:{namespaces:a,defaultNs:""}},d=T.toLanguages(P.lng);"string"==typeof P.preload&&(P.preload=[P.preload]);for(var e=0,f=P.preload.length;f>e;e++)for(var g=T.toLanguages(P.preload[e]),h=0,i=g.length;i>h;h++)d.indexOf(g[h])<0&&d.push(g[h]);for(var j=[],k=0,l=d.length;l>k;k++){var m=!1,n=K[d[k]];if(n)for(var o=0,p=a.length;p>o;o++)n[a[o]]||(m=!0);else m=!0;m&&j.push(d[k])}j.length?J.sync._fetch(j,c,function(c,d){var e=a.length*j.length;T.each(a,function(a,c){P.ns.namespaces.indexOf(c)<0&&P.ns.namespaces.push(c),T.each(j,function(a,f){K[f]=K[f]||{},K[f][c]=d[f][c],e--,0===e&&b&&(P.useLocalStorage&&J.sync._storeLocal(K),b())})})}):b&&b()}function r(a,b,c){return"function"==typeof b?(c=b,b={}):b||(b={}),b.lng=a,g(b,c)}function s(){return H}function t(a){K={},r(H,a)}function u(){function a(a,b,c){if(0!==b.length){var d="text";if(0===b.indexOf("[")){var e=b.split("]");b=e[1],d=e[0].substr(1,e[0].length-1)}b.indexOf(";")===b.length-1&&(b=b.substr(0,b.length-2));var f;if("html"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.html(I.t(b,f));else if("text"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.text()},c):c,a.text(I.t(b,f));else if("prepend"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.prepend(I.t(b,f));else if("append"===d)f=P.defaultValueFromContent?I.extend({defaultValue:a.html()},c):c,a.append(I.t(b,f));else if(0===d.indexOf("data-")){var g=d.substr("data-".length);f=P.defaultValueFromContent?I.extend({defaultValue:a.data(g)},c):c;var h=I.t(b,f);a.data(g,h),a.attr(d,h)}else f=P.defaultValueFromContent?I.extend({defaultValue:a.attr(d)},c):c,a.attr(d,I.t(b,f))}}function b(b,c){var d=b.attr(P.selectorAttr);if(d||"undefined"==typeof d||d===!1||(d=b.text()||b.val()),d){var e=b,f=b.data("i18n-target");if(f&&(e=b.find(f)||b),c||P.useDataAttrOptions!==!0||(c=b.data("i18n-options")),c=c||{},d.indexOf(";")>=0){var g=d.split(";");I.each(g,function(b,d){""!==d&&a(e,d,c)})}else a(e,d,c);P.useDataAttrOptions===!0&&b.data("i18n-options",c)}}I.t=I.t||B,I.fn.i18n=function(a){return this.each(function(){b(I(this),a);var c=I(this).find("["+P.selectorAttr+"]");c.each(function(){b(I(this),a)})})}}function v(a,b,c,d){if(!a)return a;if(d=d||b,a.indexOf(d.interpolationPrefix||P.interpolationPrefix)<0)return a;var e=d.interpolationPrefix?T.regexEscape(d.interpolationPrefix):P.interpolationPrefixEscaped,f=d.interpolationSuffix?T.regexEscape(d.interpolationSuffix):P.interpolationSuffixEscaped,g="HTML"+f,h=b.replace&&"object"==typeof b.replace?b.replace:b;return T.each(h,function(b,h){var i=c?c+P.keyseparator+b:b;"object"==typeof h&&null!==h?a=v(a,h,i,d):d.escapeInterpolation||P.escapeInterpolation?(a=a.replace(new RegExp([e,i,g].join(""),"g"),T.regexReplacementEscape(h)),a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(T.escape(h)))):a=a.replace(new RegExp([e,i,f].join(""),"g"),T.regexReplacementEscape(h))}),a}function w(a,b){var c=",",d="{",e="}",f=T.extend({},b);for(delete f.postProcess;-1!=a.indexOf(P.reusePrefix)&&(L++,!(L>P.maxRecursion));){var g=a.lastIndexOf(P.reusePrefix),h=a.indexOf(P.reuseSuffix,g)+P.reuseSuffix.length,i=a.substring(g,h),j=i.replace(P.reusePrefix,"").replace(P.reuseSuffix,"");if(g>=h)return T.error("there is an missing closing in following translation value",a),"";if(-1!=j.indexOf(c)){var k=j.indexOf(c);if(-1!=j.indexOf(d,k)&&-1!=j.indexOf(e,k)){var l=j.indexOf(d,k),m=j.indexOf(e,l)+e.length;try{f=T.extend(f,JSON.parse(j.substring(l,m))),j=j.substring(0,k)}catch(n){}}}var o=E(j,f);a=a.replace(i,T.regexReplacementEscape(o))}return a}function x(a){return a.context&&("string"==typeof a.context||"number"==typeof a.context)}function y(a){return void 0!==a.count&&"string"!=typeof a.count}function z(a){return void 0!==a.indefinite_article&&"string"!=typeof a.indefinite_article&&a.indefinite_article}function A(a,b){b=b||{};var c=C(a,b),d=F(a,b);return void 0!==d||d===c}function B(a,b){return b=b||{},N?(L=0,E.apply(null,arguments)):(T.log("i18next not finished initialization. you might have called t function before loading resources finished."),b.defaultValue||"")}function C(a,b){return void 0!==b.defaultValue?b.defaultValue:a}function D(){for(var a=[],b=1;b1)for(var d=0;d-1&&(e=c.split(P.nsseparator),i=e[0],c=e[1]),void 0===g&&P.sendMissing&&"function"==typeof P.missingKeyHandler&&(b.lng?P.missingKeyHandler(h[0],i,c,f,h):P.missingKeyHandler(P.lng,i,c,f,h));var j;j="string"==typeof P.postProcess&&""!==P.postProcess?[P.postProcess]:"array"==typeof P.postProcess||"object"==typeof P.postProcess?P.postProcess:[],"string"==typeof b.postProcess&&""!==b.postProcess?j=j.concat([b.postProcess]):("array"==typeof b.postProcess||"object"==typeof b.postProcess)&&(j=j.concat(b.postProcess)),void 0!==g&&j.length&&j.forEach(function(a){X[a]&&(g=X[a](g,c,b))});var k=f;if(f.indexOf(P.nsseparator)>-1&&(e=f.split(P.nsseparator),k=e[1]),k===c&&P.parseMissingKey&&(f=P.parseMissingKey(f)),void 0===g&&(f=v(f,b),f=w(f,b),j.length)){var l=C(c,b);j.forEach(function(a){X[a]&&(g=X[a](l,c,b))})}return void 0!==g?g:f}function F(a,b){b=b||{};var c,d,e=C(a,b),f=M;if(!K)return e;if("cimode"===f[0].toLowerCase())return e;if(b.lngs&&(f=b.lngs),b.lng&&(f=T.toLanguages(b.lng,b.fallbackLng),!K[f[0]])){var g=P.getAsync;P.getAsync=!1,J.sync.load(f,P,function(a,b){T.extend(K,b),P.getAsync=g})}var h=b.ns||P.ns.defaultNs;if(a.indexOf(P.nsseparator)>-1){var i=a.split(P.nsseparator);h=i[0],a=i[1]}if(x(b)){c=T.extend({},b),delete c.context,c.defaultValue=P.contextNotFound;var j=h+P.nsseparator+a+"_"+b.context;if(d=B(j,c),d!=P.contextNotFound)return v(d,{context:b.context})}if(y(b,f[0])){c=T.extend({lngs:[f[0]]},b),delete c.count,c._origLng=c._origLng||c.lng||f[0],delete c.lng,c.defaultValue=P.pluralNotFound;var k;if(W.needsPlural(f[0],b.count)){k=h+P.nsseparator+a+P.pluralSuffix;var l=W.get(f[0],b.count);l>=0?k=k+"_"+l:1===l&&(k=h+P.nsseparator+a)}else k=h+P.nsseparator+a;if(d=B(k,c),d!=P.pluralNotFound)return v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});if(!(f.length>1))return c.lng=c._origLng,delete c._origLng,d=B(h+P.nsseparator+a,c),v(d,{count:b.count,interpolationPrefix:b.interpolationPrefix,interpolationSuffix:b.interpolationSuffix});var m=f.slice();if(m.shift(),b=T.extend(b,{lngs:m}),b._origLng=c._origLng,delete b.lng,d=B(h+P.nsseparator+a,b),d!=P.pluralNotFound)return d}if(z(b)){var n=T.extend({},b);delete n.indefinite_article,n.defaultValue=P.indefiniteNotFound;var o=h+P.nsseparator+a+(b.count&&!y(b,f[0])||!b.count?P.indefiniteSuffix:"");if(d=B(o,n),d!=P.indefiniteNotFound)return d}for(var p,q=a.split(P.keyseparator),r=0,s=f.length;s>r&&void 0===p;r++){for(var t=f[r],u=0,A=K[t]&&K[t][h];q[u];)A=A&&A[q[u]],u++;if(void 0!==A){var D=Object.prototype.toString.apply(A);if("string"==typeof A)A=v(A,b),A=w(A,b);else if("[object Array]"!==D||P.returnObjectTrees||b.returnObjectTrees){if(null===A&&P.fallbackOnNull===!0)A=void 0;else if(null!==A)if(P.returnObjectTrees||b.returnObjectTrees){if("[object Number]"!==D&&"[object Function]"!==D&&"[object RegExp]"!==D){var G="[object Array]"===D?[]:{};T.each(A,function(c){G[c]=E(h+P.nsseparator+a+P.keyseparator+c,b)}),A=G}}else P.objectTreeKeyHandler&&"function"==typeof P.objectTreeKeyHandler?A=P.objectTreeKeyHandler(a,A,t,h,b):(A="key '"+h+":"+a+" ("+t+")' returned an object instead of string.",T.log(A))}else A=A.join("\n"),A=v(A,b),A=w(A,b);"string"==typeof A&&""===A.trim()&&P.fallbackOnEmpty===!0&&(A=void 0),p=A}}if(void 0===p&&!b.isFallbackLookup&&(P.fallbackToDefaultNS===!0||P.fallbackNS&&P.fallbackNS.length>0)){if(b.isFallbackLookup=!0,P.fallbackNS.length){for(var H=0,I=P.fallbackNS.length;I>H;H++)if(p=F(P.fallbackNS[H]+P.nsseparator+a,b),p||""===p&&P.fallbackOnEmpty===!1){var L=p.indexOf(P.nsseparator)>-1?p.split(P.nsseparator)[1]:p,N=e.indexOf(P.nsseparator)>-1?e.split(P.nsseparator)[1]:e;if(L!==N)break}}else p=F(a,b);b.isFallbackLookup=!1}return p}function G(){var a,b=P.lngWhitelist||[],c=[];if("undefined"!=typeof window&&!function(){for(var a=window.location.search.substring(1),b=a.split("&"),d=0;d0){var f=b[d].substring(0,e);f==P.detectLngQS&&c.push(b[d].substring(e+1))}}}(),P.useCookie&&"undefined"!=typeof document){var d=T.cookie.read(P.cookieName);d&&c.push(d)}if(P.detectLngFromLocalStorage&&"undefined"!=typeof window&&window.localStorage&&c.push(T.localStorage.getItem("i18next_lng")),"undefined"!=typeof navigator){if(navigator.languages)for(var e=0;e-1){var f=e.split("-");e=P.lowerCaseLng?f[0].toLowerCase()+"-"+f[1].toLowerCase():f[0].toLowerCase()+"-"+f[1].toUpperCase()}if(0===b.length||b.indexOf(e)>-1){a=e;break}}}(),a||(a=P.fallbackLng[0]),a}Array.prototype.indexOf||(Array.prototype.indexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>0&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=c;arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!=d&&d!=1/0&&d!=-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d))));for(var e=d>=0?Math.min(d,c-1):c-Math.abs(d);e>=0;e--)if(e in b&&b[e]===a)return e;return-1}),"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var H,I=a.jQuery||a.Zepto,J={},K={},L=0,M=[],N=!1,O={};"undefined"!=typeof module&&module.exports?module.exports=J:(I&&(I.i18n=I.i18n||J),a.i18n=a.i18n||J),O={load:function(a,b,c){b.useLocalStorage?O._loadLocal(a,b,function(d,e){for(var f=[],g=0,h=a.length;h>g;g++)e[a[g]]||f.push(a[g]);f.length>0?O._fetch(f,b,function(a,b){T.extend(e,b),O._storeLocal(b),c(null,e)}):c(null,e)}):O._fetch(a,b,function(a,b){c(null,b)})},_loadLocal:function(a,b,c){var d={},e=(new Date).getTime();if(window.localStorage){var f=a.length;T.each(a,function(a,g){var h=T.localStorage.getItem("res_"+g);h&&(h=JSON.parse(h),h.i18nStamp&&h.i18nStamp+b.localStorageExpirationTime>e&&(d[g]=h)),f--,0===f&&c(null,d)})}},_storeLocal:function(a){if(window.localStorage)for(var b in a)a[b].i18nStamp=(new Date).getTime(),T.localStorage.setItem("res_"+b,JSON.stringify(a[b]))},_fetch:function(a,b,c){var d=b.ns,e={};if(b.dynamicLoad){var f=function(a,b){c(null,b)};if("function"==typeof b.customLoad)b.customLoad(a,d.namespaces,b,f);else{var g=v(b.resGetPath,{lng:a.join("+"),ns:d.namespaces.join("+")});T.ajax({url:g,success:function(a){T.log("loaded: "+g),f(null,a)},error:function(a,b,c){T.log("failed loading: "+g),f("failed loading resource.json error: "+c)},dataType:"json",async:b.getAsync})}}else{var h,i=d.namespaces.length*a.length;T.each(d.namespaces,function(d,f){T.each(a,function(a,d){var g=function(a,b){a&&(h=h||[],h.push(a)),e[d]=e[d]||{},e[d][f]=b,i--,0===i&&c(h,e)};"function"==typeof b.customLoad?b.customLoad(d,f,b,g):O._fetchOne(d,f,b,g)})})}},_fetchOne:function(a,b,c,d){var e=v(c.resGetPath,{lng:a,ns:b});T.ajax({url:e,success:function(a){T.log("loaded: "+e),d(null,a)},error:function(a,b,c){if(b&&200==b||a&&a.status&&200==a.status)T.error("There is a typo in: "+e);else if(b&&404==b||a&&a.status&&404==a.status)T.log("Does not exist: "+e);else{var f=b?b:a&&a.status?a.status:null;T.log(f+" when loading "+e)}d(c,{})},dataType:"json",async:c.getAsync})},postMissing:function(a,b,c,d,e){var f={};f[c]=d;var g=[];if("fallback"===P.sendMissingTo&&P.fallbackLng[0]!==!1)for(var h=0;hh;h++)g.push({lng:e[h],url:v(P.resPostPath,{lng:e[h],ns:b})});for(var j=0,k=g.length;k>j;j++){var l=g[j];T.ajax({url:l.url,type:P.sendType,data:f,success:function(){T.log("posted missing key '"+c+"' to: "+l.url);for(var a=c.split("."),e=0,f=K[l.lng][b];a[e];)f=f[a[e]]=e===a.length-1?d:f[a[e]]||{},e++},error:function(){T.log("failed posting missing key '"+c+"' to: "+l.url)},dataType:"json",async:P.postAsync})}},reload:t};var P={lng:void 0,load:"all",preload:[],lowerCaseLng:!1,returnObjectTrees:!1,fallbackLng:["dev"],fallbackNS:[],detectLngQS:"setLng",detectLngFromLocalStorage:!1,ns:{namespaces:["translation"],defaultNs:"translation"},fallbackOnNull:!0,fallbackOnEmpty:!1,fallbackToDefaultNS:!1,nsseparator:":",keyseparator:".",selectorAttr:"data-i18n",debug:!1,resGetPath:"locales/__lng__/__ns__.json",resPostPath:"locales/add/__lng__/__ns__",getAsync:!0,postAsync:!0,resStore:void 0,useLocalStorage:!1,localStorageExpirationTime:6048e5,dynamicLoad:!1,sendMissing:!1,sendMissingTo:"fallback",sendType:"POST",interpolationPrefix:"__",interpolationSuffix:"__",defaultVariables:!1,reusePrefix:"$t(",reuseSuffix:")",pluralSuffix:"_plural",pluralNotFound:["plural_not_found",Math.random()].join(""),contextNotFound:["context_not_found",Math.random()].join(""),escapeInterpolation:!1,indefiniteSuffix:"_indefinite",indefiniteNotFound:["indefinite_not_found",Math.random()].join(""),setJqueryExt:!0,defaultValueFromContent:!0,useDataAttrOptions:!1,cookieExpirationTime:void 0,useCookie:!0,cookieName:"i18next",cookieDomain:void 0,objectTreeKeyHandler:void 0,postProcess:void 0,parseMissingKey:void 0,missingKeyHandler:O.postMissing,shortcutFunction:"sprintf"},Q={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},R={create:function(a,b,c,d){var e;if(c){var f=new Date;f.setTime(f.getTime()+60*c*1e3),e="; expires="+f.toGMTString()}else e="";d=d?"domain="+d+";":"",document.cookie=a+"="+b+e+";"+d+"path=/"},read:function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d-1){var c=a.split("-");b=P.lowerCaseLng?c[0].toLowerCase()+"-"+c[1].toLowerCase():c[0].toLowerCase()+"-"+c[1].toUpperCase()}else b=P.lowerCaseLng?a.toLowerCase():a;return b}var c=this.log,d=[],e=P.lngWhitelist||!1,f=function(a){!e||e.indexOf(a)>-1?d.push(a):c("rejecting non-whitelisted language: "+a)};if("string"==typeof a&&a.indexOf("-")>-1){var g=a.split("-");"unspecific"!==P.load&&f(b(a)),"current"!==P.load&&f(b(g[this.getCountyIndexOfLng(a)]))}else f(b(a));for(var h=0;h1)},2:function(a){return Number(1!=a)},3:function(){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:a%100>=3&&10>=a%100?3:a%100>=11?4:5)},6:function(a){return Number(1==a?0:a>=2&&4>=a?1:2)},7:function(a){return Number(1==a?0:a%10>=2&&4>=a%10&&(10>a%100||a%100>=20)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(a>=2)},10:function(a){return Number(1==a?0:2==a?1:7>a?2:11>a?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:a>2&&20>a?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:a%10>=2&&(10>a%100||a%100>=20)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(1==a?1:2)},19:function(a){return Number(1==a?0:0===a||a%100>1&&11>a%100?1:a%100>10&&20>a%100?2:3)},20:function(a){return Number(1==a?0:0===a||a%100>0&&20>a%100?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},W={rules:function(){var a,b={};for(a=U.length;a--;)b[U[a][0]]={name:U[a][1],numbers:U[a][2],plurals:V[U[a][3]]};return b}(),addRule:function(a,b){W.rules[a]=b},setCurrentLng:function(a){if(!W.currentRule||W.currentRule.lng!==a){var b=a.split("-");W.currentRule={lng:a,rule:W.rules[b[0]]}}},needsPlural:function(a,b){var c,d=a.split("-");return c=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[d[T.getCountyIndexOfLng(a)]],c&&c.numbers.length<=1?!1:1!==this.get(a,b)},get:function(a,b){function c(b,c){var d;if(d=W.currentRule&&W.currentRule.lng===a?W.currentRule.rule:W.rules[b]){var e;e=d.plurals(d.noAbs?c:Math.abs(c));var f=d.numbers[e];return 2===d.numbers.length&&1===d.numbers[0]&&(2===f?f=-1:1===f&&(f=1)),f}return 1===c?"1":"-1"}var d=a.split("-");return c(d[T.getCountyIndexOfLng(a)],b)}},X={},Y=function(a,b){X[a]=b},Z=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function b(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.format=function(c,d){var e,f,g,h,i,j,k,l=1,m=c.length,n="",o=[];for(f=0;m>f;f++)if(n=a(c[f]),"string"===n)o.push(c[f]);else if("array"===n){if(h=c[f],h[2])for(e=d[l],g=0;g=0?"+"+e:e,j=h[4]?"0"==h[4]?"0":h[4].charAt(1):" ",k=h[6]-String(e).length,i=h[6]?b(j,k):"",o.push(h[5]?e+i:i+e)}return o.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(b)))throw"[sprintf] huh?";if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw"[sprintf] huh?";for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw"[sprintf] huh?";f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";d.push(c)}b=b.substring(c[0].length)}return d},c}(),$=function(a,b){return b.unshift(a),Z.apply(null,b)};Y("sprintf",function(a,b,c){return c.sprintf?"[object Array]"===Object.prototype.toString.apply(c.sprintf)?$(a,c.sprintf):"object"==typeof c.sprintf?Z(a,c.sprintf):a:a}),J.init=g,J.setLng=r,J.preload=h,J.addResourceBundle=i,J.hasResourceBundle=j,J.getResourceBundle=k,J.addResource=m,J.addResources=n,J.removeResourceBundle=l,J.loadNamespace=p,J.loadNamespaces=q,J.setDefaultNamespace=o,J.t=B,J.translate=B,J.exists=A,J.detectLanguage=T.detectLanguage,J.pluralExtensions=W,J.sync=O,J.functions=T,J.lng=s,J.addPostProcessor=Y,J.applyReplacement=T.applyReplacement,J.options=P}("undefined"==typeof exports?window:exports); +window.Mirador = window.Mirador || function(config) { + + // pass the config through the save and restore process, + // returning the config that will, in fact, populate the + // application. + Mirador.saveController = new Mirador.SaveController(config); + + config = Mirador.saveController.currentConfig; + + // initialise application + Mirador.viewer = new Mirador.Viewer(config); +}; + +(function($) { + + /** + * Default values for settings + */ + $.DEFAULT_SETTINGS = { + + 'workspaceType': 'singleObject', + + 'saveSession' : true, //whether or not to store session to local storage + + 'workspaces' : { + 'singleObject': { + 'label': 'Single Object', + 'addNew': false, + 'move': false, + 'iconClass': 'image' + }, + 'compare': { + 'label': 'Compare', + 'iconClass': 'columns' + }, + 'bookReading': { + 'defaultWindowOptions': { + }, + 'label': 'Book Reading', + 'addNew': true, + 'move': false, + 'iconClass': 'book' + } + }, + + 'layout': '1x1', + + 'openManifestsPage' : false, //defaults to false, whether or not Mirador should display the manifests page, + //only valid if no windowObjects have been initialized + //if there are multiple slots, it will be bound to the first slot and the selected manifest will open in that slot + + 'windowObjects' : [ + /** within a single object, the following options: + * "loadedManifest": [manifestURI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json" + * "canvasID": [canvas URI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/canvas/canvas-12" + * + * "availableViews" : defaults to ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], any subset removes others + * "viewType" : one of [_'ThumbnailsView'_, 'ImageView', 'ScrollView', 'BookView'] - if using availableViews, must be in subset + * + * "bottomPanel" : [_true_, false] whether or not to make the bottom panel available in this window + * "bottomPanelVisible" : [_true_, false] whether or not to make the bottom panel visible in this window on load. This setting is dependent + * on bottomPanel being true + * "sidePanel" : [_true_, false] whether or not to make the side panel available in this window + * "sidePanelOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied + * { + * "toc" : [_true_, false] + * "annotations" : [true, _false_] + * } + * "sidePanelVisible" : [_true_, false] whether or not to make the side panel visible in this window on load. This setting is dependent + * on sidePanel being true + * "overlay" : [_true_, false] whether or not to make the overlay available/visible in this window + * + * "annotationLayer" : [_true_, false] whether or not to make annotation layer available in this window + * "annotationCreation" : [_true_, false] whether or not to make annotation creation available in this window, + * only valid if annotationLayer is set to True and an annotationEndpoint is defined. + * This setting does NOT affect whether or not a user can edit an individual annotation that has already been created. + * "annotationState" : [_'annoOff'_, 'annoOnCreateOff', 'annoOnCreateOn'] whether or not to turn on the annotation layer on window load + * + * "fullScreen" : [_true_, false] whether or not to make the fullScreen HUD button visible to user + * + * "displayLayout" : [_true_, false], whether or not to display all layout options, removing individual menu options is separate + * "layoutOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied + * { + * "newObject" : [_true_, false] + * "close" : [_true_, false] + * "slotRight" : [_true_, false] + * "slotLeft" : [_true_, false] + * "slotAbove" : [_true_, false] + * "slotBelow" : [_true_, false] + * } + * "windowOptions" : [data specific to the view type, such as OSD bounds and zoom level - automatically saved in SaveController] + * "id" : [unique window ID - set by application and automatically saved in SaveController] + **/ + ], + + 'defaultWindowSettings': { + + }, + + 'availableAnnotationModes': [ + + ], + + 'availableAnnotationDrawingTools': [ + + ], + + 'availableCanvasTools': [ + + ], + + // main (top) menu + //we don't actually take the height into account for the mirador-viewer div, so don't use for now + 'mainMenuSettings': { + 'show': true, + 'buttons' : { + 'bookmark' : true, + 'layout' : true, + 'options' : false, + 'fullScreenViewer': true + } + //'height': 25, + //'width': '100%' + }, + + 'workspacePanelSettings': { + 'maxRows': 5, + 'maxColumns': 5, + 'preserveWindows': true + }, + + //true or false. controls display of "Add new object from URL" on manifest listing page + 'showAddFromURLBox' : true, + + 'buildPath' : 'build/mirador/', + + 'i18nPath' : 'locales/', + + 'imagesPath' : 'images/', + + 'logosPath' : 'images/logos/', + + 'repoImages' : { + 'other': 'iiif_logo.png' + }, + + /** + * Annotation backend that have instance-specific configuration data as a hash, e.g.: + * { + * name: 'backend name', + * module: 'NameEndpoint', + * options: + * { 'url': '', + * 'storeId': 123, + * 'APIKey': '23983hf98j3f9283jf2983fj' + * } + * } + **/ + 'annotationEndpoint': {}, + + 'jsonStorageEndpoint': { + 'name': 'JSONBlob API Endpoint', + 'module': 'JSONBlobAPI', + 'options': { + 'ssl': true, + 'port': '443', + 'host': 'jsonblob.com' + } + }, + + 'sharingEndpoint': { + 'url': '', + 'storeId': 123, + 'APIKey': '23983hf98j3f9283jf2983fj' + }, + + // linked image views configuration + 'lockController' : { + 'lockProfile' : 'lazyZoom', + 'notifyMaxMin' : true + } + }; + +}(Mirador)); + +(function($) { + + $.Viewer = function(options) { + + jQuery.extend(true, this, { + id: options.id, + hash: options.id, + data: null, + element: null, + canvas: null, + workspaceType: null, + layout: null, + workspace: null, + mainMenu: null, + workspaceAutoSave: null, + windowSize: {}, + resizeRatio: {}, + currentWorkspaceVisible: true, + overlayStates: { + 'workspacePanelVisible': false, + 'manifestsPanelVisible': false, + 'optionsPanelVisible': false, + 'bookmarkPanelVisible': false + }, + manifests: [] + }, $.DEFAULT_SETTINGS, options); + + // get initial manifests + this.element = this.element || jQuery('#' + this.id); + + if (this.data) { + this.init(); + } + }; + + $.Viewer.prototype = { + + init: function() { + var _this = this; + + //add background and positioning information on the root element that is provided in config + // var backgroundImage = _this.buildPath + _this.imagesPath + 'debut_dark.png'; + var backgroundImage = asset_path('debut_dark.png')'; + this.element.css('background-color', '#333').css('background-image','url('+backgroundImage+')').css('background-position','left top') + .css('background-repeat','repeat').css('position','fixed'); + + //initialize i18next + // i18n.init({debug: false, getAsync: false, resGetPath: _this.buildPath + _this.i18nPath+'__lng__/__ns__.json'}); + + //register Handlebars helper + Handlebars.registerHelper('t', function(i18n_key) { + var result = i18n.t(i18n_key); + return new Handlebars.SafeString(result); + }); + + //check all buttons in mainMenu. If they are all set to false, then don't show mainMenu + var showMainMenu = false; + jQuery.each(this.mainMenuSettings.buttons, function(key, value) { + if (value) { showMainMenu = true; } + }); + //even if buttons are available, developer can override and set show to false + if (this.mainMenuSettings.show === false) { + showMainMenu = false; + } + + // add main menu + if (showMainMenu) { + this.mainMenu = new $.MainMenu({ parent: this, appendTo: this.element }); + } + + // add viewer area + this.canvas = jQuery('
          ') + .addClass('mirador-viewer') + .appendTo(this.element); + + if (!showMainMenu) { + this.canvas.css("top", "0px"); + } + + // add workspace configuration + this.layout = typeof this.layout !== 'string' ? JSON.stringify(this.layout) : this.layout; + this.workspace = new $.Workspace({ + layoutDescription: this.layout.charAt(0) === '{' ? JSON.parse(this.layout) : $.layoutDescriptionFromGridString(this.layout), + parent: this, + appendTo: this.element.find('.mirador-viewer') + }); + + this.workspacePanel = new $.WorkspacePanel({ + appendTo: this.element.find('.mirador-viewer'), + parent: this, + maxRows: this.workspacePanelSettings.maxRows, + maxColumns: this.workspacePanelSettings.maxColumns, + preserveWindows: this.workspacePanelSettings.preserveWindows, + workspace: this.workspace + }); + + this.manifestsPanel = new $.ManifestsPanel({ parent: this, appendTo: this.element.find('.mirador-viewer') }); + this.bookmarkPanel = new $.BookmarkPanel({ parent: this, appendTo: this.element.find('.mirador-viewer'), jsonStorageEndpoint: this.jsonStorageEndpoint }); + + // set this to be displayed + this.set('currentWorkspaceVisible', true); + + this.bindEvents(); + // retrieve manifests + this.getManifestsData(); + + if (this.windowObjects.length === 0 && this.openManifestsPage) { + this.workspace.slots[0].addItem(); + } + }, + + bindEvents: function() { + var _this = this; + // check that windows are loading first to set state of slot? + jQuery.subscribe('manifestReceived', function(event, newManifest) { + if (_this.windowObjects) { + var check = jQuery.grep(_this.windowObjects, function(object, index) { + return object.loadedManifest === newManifest.uri; + }); + jQuery.each(check, function(index, config) { + _this.loadManifestFromConfig(config); + }); + } + }); + + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + var _this = this; + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + jQuery.publish(prop + '.set', value); + }, + + // Sets state of overlays that layer over the UI state + toggleOverlay: function(state) { + var _this = this; + // first confirm all others are off + jQuery.each(this.overlayStates, function(oState, value) { + if (state !== oState) { + _this.set(oState, false, {parent: 'overlayStates'}); + } + }); + var currentState = this.get(state, 'overlayStates'); + this.set(state, !currentState, {parent: 'overlayStates'}); + }, + + toggleLoadWindow: function() { + this.toggleOverlay('manifestsPanelVisible'); + }, + + toggleWorkspacePanel: function() { + this.toggleOverlay('workspacePanelVisible'); + }, + + toggleBookmarkPanel: function() { + this.toggleOverlay('bookmarkPanelVisible'); + }, + + enterFullscreen: function() { + var el = this.element[0]; + if (el.requestFullscreen) { + el.requestFullscreen(); + } else if (el.mozRequestFullScreen) { + el.mozRequestFullScreen(); + } else if (el.webkitRequestFullscreen) { + el.webkitRequestFullscreen(); + } else if (el.msRequestFullscreen) { + el.msRequestFullscreen(); + } + }, + + exitFullscreen: function() { + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen(); + } + }, + + isFullscreen: function() { + var $fullscreen = $(fullscreenElement()); + return ($fullscreen.length > 0); + }, + + fullscreenElement: function() { + return (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement); + }, + + getManifestsData: function() { + var _this = this; + + _this.data.forEach(function(manifest) { + if (manifest.hasOwnProperty('manifestUri')) { + var url = manifest.manifestUri; + _this.addManifestFromUrl(url, manifest.location ? manifest.location : ''); + } else if (manifest.hasOwnProperty('collectionUri')) { + jQuery.getJSON(manifest.collectionUri).done(function (data, status, jqXHR) { + if (data.hasOwnProperty('manifests')){ + jQuery.each(data.manifests, function (ci, mfst) { + _this.addManifestFromUrl(mfst['@id'], ''); + }); + } + }).fail(function(jqXHR, status, error) { + console.log(jqXHR, status, error); + }); + } + }); + }, + + hasWidgets: function(collection) { + return ( + typeof collection.widgets !== 'undefined' && + collection.widgets && + !jQuery.isEmptyObject(collection.widgets) && + collection.widgets.length > 0 + ); + }, + + addManifestFromUrl: function(url, location) { + var _this = this, + manifest; + + if (!_this.manifests[url]) { + manifest = new $.Manifest(url, location); + _this.manifests[url] = manifest; + _this.manifests.push(manifest); + jQuery.publish('manifestQueued', manifest, location); + manifest.request.done(function() { + jQuery.publish('manifestReceived', manifest); + }); + } + }, + + loadManifestFromConfig: function(options) { + // check if there are available slots, otherwise don't process this object from config + //if we have more windowObjects that slots in the layout, return + var slotAddress = options.slotAddress ? options.slotAddress : this.workspace.getAvailableSlot() ? this.workspace.getAvailableSlot().layoutAddress : null; + if (!slotAddress) { + return; + } + var windowConfig = { + manifest: this.manifests[options.loadedManifest], + currentFocus : options.viewType, + focusesOriginal : options.availableViews, + currentCanvasID : options.canvasID, + id : options.id, + focusOptions : options.windowOptions, + bottomPanelAvailable : options.bottomPanel, + bottomPanelVisible : options.bottomPanelVisible, + sidePanelAvailable : options.sidePanel, + sidePanelOptions : options.sidePanelOptions, + sidePanelVisible : options.sidePanelVisible, + overlayAvailable : options.overlay, + annotationLayerAvailable : options.annotationLayer, + annotationCreationAvailable : options.annotationCreation, + annotationState : options.annotationState, + fullScreenAvailable : options.fullScreen, + slotAddress: slotAddress, + displayLayout : options.displayLayout, + layoutOptions: options.layoutOptions + }; + + this.workspace.addWindow(windowConfig); + } + }; + +}(Mirador)); + +(function($) { + + $.Workspace = function(options) { + + jQuery.extend(true, this, { + workspaceSlotCls: 'slot', + focusedSlot: null, + slots: [], + windows: [], + appendTo: null, + parent: null, + layoutDescription: null + }, options); + + this.element = this.element || jQuery('
          '); + this.init(); + + }; + + $.Workspace.prototype = { + init: function () { + this.element.appendTo(this.appendTo); + if (this.type === "none") { + this.parent.toggleSwitchWorkspace(); + return; + } + + this.calculateLayout(); + + this.bindEvents(); + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + var _this = this; + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + jQuery.publish(prop + '.set', value); + }, + + calculateLayout: function(resetting) { + var _this = this, + layout; + + _this.layout = layout = new Isfahan({ + containerId: _this.element.attr('id'), + layoutDescription: _this.layoutDescription, + configuration: null, + padding: 3 + }); + + var data = layout.filter( function(d) { + return !d.children; + }); + + // Data Join. + var divs = d3.select("#" + _this.element.attr('id')).selectAll(".layout-slot") + .data(data, function(d) { return d.id; }); + + // Implicitly updates the existing elements. + // Must come before the enter function. + divs.call(cell).each(function(d) { + _this.slots.forEach(function(slot) { + if (slot.slotID === d.id) { + slot.layoutAddress = d.address; + } + }); + }); + + // Enter + divs.enter().append("div") + .attr("class", "layout-slot") + .attr("data-layout-slot-id", function(d) { return d.id; }) + .call(cell) + .each(function(d) { + var appendTo = _this.element.children('div').filter('[data-layout-slot-id="'+ d.id+'"]')[0]; + _this.slots.push(new $.Slot({ + slotID: d.id, + layoutAddress: d.address, + focused: true, + parent: _this, + appendTo: appendTo + })); + }); + + // Exit + divs.exit() + .remove("div") + .each(function(d) { + var slotMap = _this.slots.reduce(function(map, temp_slot) { + if (d.id === temp_slot.slotID) { + map[d.id] = temp_slot; + } + return map; + }, {}), + slot = slotMap[d.id]; + + if (slot && slot.window && !resetting) { + jQuery.publish("windowRemoved", slot.window.id); + } + + _this.slots.splice(_this.slots.indexOf(slot), 1); + }); + + function cell() { + this + .style("left", function(d) { return d.x + "px"; }) + .style("top", function(d) { return d.y + "px"; }) + .style("width", function(d) { return Math.max(0, d.dx ) + "px"; }) + .style("height", function(d) { return Math.max(0, d.dy ) + "px"; }); + } + + var root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + jQuery.publish("layoutChanged", root); + }, + + split: function(targetSlot, direction) { + var _this = this, + node = jQuery.grep(_this.layout, function(node) { return node.id === targetSlot.slotID; })[0]; + nodeIndex = node.parent ? node.parent.children.indexOf(node) : 0, + nodeIsNotRoot = node.parent; + + function addSibling(node, indexDifference) { + if (nodeIsNotRoot) { + var siblingIndex = nodeIndex + indexDifference, + newSibling = _this.newNode(node.type, node); + + node.parent.children.splice(siblingIndex, 0, newSibling); + _this.layout.push(newSibling); + return newSibling; + } + + // handles the case where the root needs to be mutated. + node.type = node.type === 'row' ? 'column' : 'row'; + mutateAndAdd(node, indexDifference); + } + + function mutateAndAdd(node, indexDifference) { + // Locally mutate the tree to accomodate a + // sibling of another kind, transforming + // both the target node and its parent. + var newParent = _this.newNode(node.type, node.parent); + + // Flip its type while keeping + // the same id. + node.type = node.type === 'row' ? 'column' : 'row'; + + // Create a new node (which will be childless) + // that is also a sibling of this node. + newSibling = _this.newNode(node.type, newParent); + + // maintain array ordering. + newParent.children = []; + newParent.children.push(node); // order matters, place node first. + newParent.children.splice(indexDifference, 0, newSibling); // order matters, so put new sibling on one side or the other. + if (nodeIsNotRoot) { + newParent.parent = node.parent; + // replace the old node in its parent's child + // array with the new parent. + newParent.parent.children[nodeIndex] = newParent; + } + + node.parent = newParent; + _this.layout.push(newParent, newSibling); + } + + if (node.type === 'column') { + // Since it is a column: + // + // If adding to a side, simply + // add a sibling. + // Left means before, right means after. + if (direction === 'r' || direction === 'l') { + indexDifference = direction === 'r' ? 1 : 0; + addSibling(node, indexDifference); + } + // If adding above or below, the + // operation must be changed to mutating + // the structure. + // Up means before, Down means after. + else { + indexDifference = direction === 'd' ? 1 : 0; + mutateAndAdd(node, indexDifference); + } + } else { + // Since it is a row: + // + // If adding to a side, mutate the + // structure. + // Left means before, right means after. + if (direction === 'r' || direction === 'l') { + indexDifference = direction === 'r' ? 1 : 0; + mutateAndAdd(node, indexDifference); + } + // If adding above or below, the + // operations must be switched to adding + // a sibling. + // Up means before, Down means after. + else { + indexDifference = direction === 'd' ? 1 : 0; + addSibling(node, indexDifference); + } + } + + // Recalculate the layout. + // The original hierarchical structure is + // accessible from the root node. Passing + // it back through the layout code will + // recalculate everything else needed for + // the redraw. + var root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + _this.layoutDescription = root; + _this.calculateLayout(); + + }, + + splitRight: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'r'); + }, + + splitLeft: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'l'); + }, + + splitUp: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'u'); + }, + + splitDown: function(targetSlot) { + var _this = this; + _this.split(targetSlot, 'd'); + }, + + removeNode: function(targetSlot) { + // de-mutate the tree structure. + var _this = this, + node = jQuery.grep(_this.layout, function(node) { return node.id === targetSlot.slotID; })[0], + nodeIndex = node.parent.children.indexOf(node), + parentIndex, + remainingNode, + root = jQuery.grep(_this.layout, function(node) { return !node.parent;})[0]; + + if (node.parent.children.length === 2) { + // de-mutate the tree without destroying + // the children of the remaining node, + // which in this case means changing their + // IDs. + node.parent.children.splice(nodeIndex,1); + remainingNode = node.parent.children[0]; + + remainingNode.parent.id = remainingNode.id; + delete node.parent; + } else if (node.parent.children.length === 1) { + } else { + // If the node is one of more than 2 siblings, + // simply splice it out of the parent's children + // array. + node.parent.children.splice(nodeIndex, 1); + } + + _this.layoutDescription = root; + _this.calculateLayout(); + }, + + newNode: function(type, parent) { + if (typeof parent === 'undefined') { + return { + type: type, + id: $.genUUID() + }; + } else { + return { + type: type, + id: $.genUUID(), + parent: parent + }; + } + }, + + getSlotFromAddress: function(address) { + var _this = this; + return _this.slots.filter(function(slot) { + return slot.layoutAddress === address; + })[0]; + }, + + resetLayout: function(layoutDescription) { + this.layoutDescription = layoutDescription; + this.calculateLayout(true); + this.placeWindows(); + }, + + placeWindows: function() { + // take the windows array and place + // as many windows into places as can + // fit. + var _this = this, + deletedWindows; + + if (_this.windows.length > _this.slots.length) { + // splice modifies the original array and + // returns the deleted items, + // so we can just perform a forEach on the + // return value, and have the saveController + // remove these windows in response to the event + // (which otherwise it would not do). + // + // The event was not called in the calculateLayout + // function because we need the other windows to remain, + // so we filter them here. + _this.windows.splice(0, _this.windows.length -_this.slots.length).forEach(function(removedWindow){ + jQuery.publish('windowRemoved', removedWindow.id); + }); + } + + _this.windows.forEach(function(window) { + var slot = _this.getAvailableSlot(); + slot.window = window; + + window.update({ + id: window.id, + slotAddress: slot.layoutAddress, + parent: slot, + appendTo: slot.element, + currentCanvasID: window.currentCanvasID, + currentFOcus: window.currentFocus + }); + }); + }, + + getAvailableSlot: function() { + return this.slots.filter(function(slot) { + return !slot.window; + })[0]; + }, + + bindEvents: function() { + var _this = this; + + d3.select(window).on('resize', function(event) { + _this.calculateLayout(); + }); + + jQuery.subscribe('resizeMirador', function(event) { + _this.calculateLayout(); + }); + + jQuery.subscribe('manifestQueued', function(event, manifestPromise) { + // Trawl windowObjects preemptively for slotAddresses and + // notify those slots to display a "loading" state. + // Similar to the operation of the manifestLoadStatusIndicator + // and its associated manifestList controller. + var targetSlot; + + if (_this.parent.windowObjects) { + var check = _this.parent.windowObjects.forEach(function(windowConfig, index) { + // windowConfig.slotAddress will give the slot; + // change the state on that slot to be "loading" + if (windowConfig.slotAddress) { + targetSlot = _this.getSlotFromAddress(windowConfig.slotAddress); + } else { + targetSlot = _this.focusedSlot || _this.slots.filter(function(slot) { + return slot.hasOwnProperty('window') ? true : false; + })[0]; + } + }); + } + }); + + jQuery.subscribe('windowRemoved', function(event, windowId) { + _this.windows = jQuery.grep(_this.windows, function(window) { + return window.id !== windowId; + }); + }); + }, + + clearSlot: function(slotId) { + if (this.slots[slodId].windowElement) { + this.slots[slotId].windowElement.remove(); + } + this.slots[slotId].window = null; + }, + + addItem: function(slot) { + this.focusedSlot = slot; + this.parent.toggleLoadWindow(); + }, + + addWindow: function(windowConfig) { + // Windows can be added from a config, + // from a saved state, (in both those cases they are in the form of "windowObjects") + // from the workspace windows list after a grid layout change, + // from the manifests panel in image mode, + // or from the manifests panel in thumbnail mode. + var _this = this, + newWindow, + targetSlot; + + jQuery.each(_this.parent.overlayStates, function(oState, value) { + // toggles the other top-level panels closed and focuses the + // workspace. For instance, after selecting an object from the + // manifestPanel. + _this.parent.set(oState, false, {parent: 'overlayStates'}); + }); + + if (windowConfig.slotAddress) { + targetSlot = _this.getSlotFromAddress(windowConfig.slotAddress); + } else { + targetSlot = _this.focusedSlot || _this.getAvailableSlot(); + } + + windowConfig.appendTo = targetSlot.element; + windowConfig.parent = targetSlot; + + if (!targetSlot.window) { + windowConfig.slotAddress = targetSlot.layoutAddress; + windowConfig.id = windowConfig.id || $.genUUID(); + + jQuery.publish("windowSlotAdded", {id: windowConfig.id, slotAddress: windowConfig.slotAddress}); + + newWindow = new $.Window(windowConfig); + _this.windows.push(newWindow); + + targetSlot.window = newWindow; + + jQuery.publish("windowAdded", {id: windowConfig.id, slotAddress: windowConfig.slotAddress}); + + jQuery.publish(('currentCanvasIDUpdated.' + windowConfig.id), windowConfig.currentCanvasID); + } else { + targetSlot.window.element.remove(); + targetSlot.window.update(windowConfig); + jQuery.publish(('currentCanvasIDUpdated.' + windowConfig.id), windowConfig.currentCanvasID); + // The target slot already has a window in it, so just update that window instead, + // using the appropriate saving functions, etc. This obviates the need changing the + // parent, slotAddress, setting a new ID, and so on. + } + } + }; +}(Mirador)); + +(function($) { + + $.BookmarkPanel = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null + }, options); + + this.init(); + + }; + + $.BookmarkPanel.prototype = { + init: function () { + this.element = jQuery(this.template()).appendTo(this.appendTo); + saveModule = this.jsonStorageEndpoint.module, + saveOptions = this.jsonStorageEndpoint.options; + this.storageModule = new $[saveModule](saveOptions); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + // handle subscribed events + jQuery.subscribe('bookmarkPanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + jQuery.subscribe('saveControllerConfigUpdated', function() { + _this.storageModule.save(Mirador.saveController.currentConfig) + .then(function(blobId) { + var bookmarkURL = window.location.href.replace(window.location.hash, '') + "?json="+blobId; + _this.element.find('#share-url').val(bookmarkURL).focus().select(); + }); + }); + }, + + hide: function() { + jQuery(this.element).hide({effect: "slide", direction: "up", duration: 300, easing: "swing"}); + }, + + show: function() { + jQuery(this.element).show({effect: "slide", direction: "up", duration: 300, easing: "swing"}); + }, + + template: Handlebars.compile([ + '
          ', + '

          {{t "bookmarkTitle"}}

          ', + '', + '{{t "url"}}: ', + '', + '', + '
          ' + ].join('')) + }; + +}(Mirador)); + +(function($) { + // Keeps track of the control context and switches out + // keyboard control mappings accordingly. + + $.ControlHarness = function(options) { + + jQuery.extend(true, this, { + contexts: null, + activeContext: null + }, options); + + this.init(); + }; + + $.ControlHarness.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + // workspace is changed: + // slot is added/removed: + // window is opened/closed: + // different top-level menus are opened (load manifest/choose workspace, etc.): + // item is selected from manifest menu. + // item is hovered over with the mouse. + // deliberately moving "up" "down" "left" and "right" through + // the command contexts. + }, + + switchActiveContext: function() { + + }, + + addContext: function(ctxId) { + + }, + + removeContext: function(ctxId) { + + } + + }; + +}(Mirador)); + + +(function($) { + + $.MainMenu = function(options) { + + jQuery.extend(true, this, { + parent: null, //viewer + element: null, + mainMenuHeight: null, + mainMenuWidth: null, + windowOptionsMenu: null, + loadWindow: null, + clearLocalStorage: '', + viewerCls: 'mirador-viewer', + mainMenuBarCls: 'mirador-main-menu-bar', + mainMenuCls: 'mirador-main-menu', + windowOptionsMenuCls: 'mirador-window-options-menu', + clearLocalStorageCls: 'clear-local-storage', + clearLocalStorageDialogCls: 'mirador-main-menu-clear-local-storage', + collectionsListingCls: 'mirador-listing-collections' + }, options); + + this.element = this.element || jQuery('
          '); + + this.init(); + + }; + + + $.MainMenu.prototype = { + + init: function() { + //this.mainMenuHeight = this.parent.mainMenuSettings.height; + //this.mainMenuWidth = this.parent.mainMenuSettings.width; + this.element + .addClass(this.mainMenuBarCls) + //.height(this.mainMenuHeight) + //.width(this.mainMenuWidth) + .appendTo(this.appendTo); + + this.element.append(this.template({ + mainMenuCls: this.mainMenuCls, + showBookmark : this.parent.mainMenuSettings.buttons.bookmark, + showLayout : this.parent.mainMenuSettings.buttons.layout, + showOptions: this.parent.mainMenuSettings.buttons.options, + showFullScreenViewer : this.parent.mainMenuSettings.buttons.fullScreenViewer, + userButtons: this.parent.mainMenuSettings.userButtons, + userLogo: this.parent.mainMenuSettings.userLogo + })); + + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + //change 'change-layout' to mouseover events rather than click? + this.element.find('.change-layout').on('click', function() { + _this.parent.toggleWorkspacePanel(); + }); + this.element.find('.bookmark-workspace').on('click', function() { _this.parent.toggleBookmarkPanel(); + }); + // when options are implemented, this will need to do something + this.element.find('.window-options').on('click', function() { }); + this.element.find('.fullscreen-viewer').on('click', function() { + _this.parent.fullscreenElement() ? _this.parent.exitFullscreen() : _this.parent.enterFullscreen(); + }); + }, + + template: Handlebars.compile([ + '{{#if userLogo}}', + '', + '{{/if}}', + '', + '{{#if userButtons}}', + '{{userbtns userButtons}}', + '{{/if}}' + ].join('')) + }; + + /* Helper methods for processing userButtons provided in configuration */ + + /* Processes userButtons configuration setting * + **************************************************** + * userButtons, if present, should be an array * + * * + * Its elements should be objects, which can * + * have the following attributes: * + * * + * label: text label assigned to the link * + * created. (required) * + * attributes: HTML attributes to add to the * + * button. If there is a "callback" * + * attribute for the button, this MUST * + * exist and MUST contain an "id" value * + * li_attributes: HTML attributes to add to the * + * list item containing the button. * + * iconClass: class or space-separated list of * + * classes. If present, an empty span with * + * these classes will be prepended to the * + * content of the link element + * sublist: Sublist of buttons, to be implemented * + * as a dropdown via CSS/JS * + * ul_attributes: HTML attributes to add to the * + * sublist UL contained in the button. * + * Ignored if button isn't representing * + * a sublist. * + * * + * NOTE: sublist dropdown functionality is not yet * + * implemented * + ****************************************************/ + var processUserButtons = function (btns) { + var output = []; + var btn; + var btns_len = btns.length; + + for (var i = 0; i < btns_len; i++){ + output.push(processUserBtn(btns[i])); + } + return output; + }; + + var processUserBtn = function (btn) { + var $li = jQuery('
        • '); + var $a = jQuery(''); + var $sub_ul; + + try { + /* Enclosing
        • for button */ + if (btn.li_attributes){ + $li.attr(btn.li_attributes); + } + + /* Link for button. */ + if (!btn.label) { + throw "userButtons must have labels"; + } + + $a.text(btn.label); + + if (btn.iconClass) { + $a.prepend(' '); + } + + if (btn.attributes){ + $a.attr(btn.attributes); + } + + $li.append($a); + + /* Sublist if present */ + if (btn.sublist) { + $sub_ul = jQuery('
            '); + if (btn.ul_attributes){ + $sub_ul.attr(btn.ul_attributes); + } + /* Recurse! */ + $sub_ul.append(processUserButtons(btn.sublist)); + + $li.append($sub_ul); + } + + return $li; + } + catch (err) { + console && console.log && console.log(err); + return jQuery(); + } + }; + + Handlebars.registerHelper('userbtns', function (userButtons) { + return new Handlebars.SafeString( + jQuery('
              ').append(processUserButtons(userButtons)).get(0).outerHTML + ); + }); + + Handlebars.registerHelper('userlogo', function (userLogo) { + return new Handlebars.SafeString( + processUserBtn(userLogo).get(0).outerHTML + ); + }); + +}(Mirador)); + +(function ($) { + $.ManifestList = function(options) { + this.appendTo = options.appendTo; + this.manifests = options.manifests; + this.init(); + }; + + $.ManifestList.prototype = { + + init: function() { + this.element = jQuery('
              ').addClass('manifest-load-status-indicator').prependTo(this.appendTo); + this.element.append('

              '); + this.bindEvents(); + }, + + render: function() { + var _this = this; + + var pending = _this.manifests.filter(function(d,i) { + return d.request.state() === 'pending'; + }), + rejected = _this.manifests.filter(function(d,i) { + return d.request.state() === 'rejected'; + }), + resolved = _this.manifests.filter(function(d,i) { + return d.request.state() === 'resolved'; + }); + + // pending, failed, or complete + var requests = d3.select(_this.element[0]) + .selectAll('div.pending') + .data(pending); + + // add new requests to the queue. + requests.enter() + .insert('div', ':nth-child(2)') + .classed('request-status-bar', true) + .classed('pending', true) + .style('left', '3000px') + .transition() + .duration(300) + .style('left', '0'); + + requests.exit() + .classed('pending', false) + .transition() + .duration(300) + .style('opacity', 0) + .remove(); + + d3.select(_this.element.find('h3')[0]) + .text(function() { + var count = pending.length; + return "Loading " + count + " Items..."; + }); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('manifestQueued', function(manifest) { + _this.render(); + }); + jQuery.subscribe('manifestReceived', function(manifest) { + _this.render(); + }); + }, + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + } + }; + +})(Mirador); + +(function($) { + + $.ManifestListItem = function(options) { + + jQuery.extend(true, this, { + element: null, + parent: null, + manifest: null, + loadStatus: null, + thumbHeight: 80, + urlHeight: 150, + resultsWidth: 0, // based on screen width + maxPreviewImagesWidth: 0, + repoWidth: 80, + metadataWidth: 450, + margin: 15, + remainingWidth: 20, + imagesTotalWidth: 0, + tplData: null, + allImages: [], + remaining: 0 + }, options); + + this.init(); + + }; + + $.ManifestListItem.prototype = { + + init: function() { + var _this = this; + //need a better way of calculating this because JS can't get width and margin of hidden elements, so must manually set that info + //ultimately use 95% of space available, since sometimes it still displays too many images + this.maxPreviewImagesWidth = this.resultsWidth - (this.repoWidth + this.margin + this.metadataWidth + this.margin + this.remainingWidth); + this.maxPreviewImagesWidth = this.maxPreviewImagesWidth * 0.95; + + Handlebars.registerHelper('pluralize', function(count, singular, plural) { + if (count === 1) { + return singular; + } else { + return plural; + } + }); + + this.fetchTplData(this.manifestId); + this.element = jQuery(this.template(this.tplData)).prependTo(this.parent.manifestListElement).hide().fadeIn('slow'); + + this.bindEvents(); + }, + + fetchTplData: function() { + var _this = this, + location = _this.manifest.location, + manifest = _this.manifest.jsonLd; + + this.tplData = { + label: manifest.label, + repository: location, + canvasCount: manifest.sequences[0].canvases.length, + images: [] + }; + + this.tplData.repoImage = (function() { + var repo = _this.tplData.repository; + if (manifest.logo) { + if (typeof manifest.logo === "string") + return manifest.logo; + if (typeof manifest.logo['@id'] !== 'undefined') + return manifest.logo['@id']; + } + if (_this.tplData.repository === '(Added from URL)') { + repo = ''; + } + var imageName = $.viewer.repoImages[repo || 'other'] || $.viewer.repoImages.other; + + // return $.viewer.buildPath + $.viewer.logosPath + imageName; + // return '/assets/logos/' + imageName; + return asset_path(imageName); + })(); + + for ( var i=0; i < manifest.sequences[0].canvases.length; i++) { + var canvas = manifest.sequences[0].canvases[i]; + if (canvas.width === 0) { + continue; + } + + var aspectRatio = canvas.height/canvas.width, + width = (_this.thumbHeight/aspectRatio); + url = _this.manifest.getThumbnailForCanvas(canvas, width); + + _this.allImages.push({ + url: url, + width: width, + height: _this.thumbHeight, + id: canvas['@id'], + index: i + }); + } + + jQuery.each(_this.allImages, function(index, value) { + var width = value.width; + + _this.imagesTotalWidth += (width + _this.margin); + if (_this.imagesTotalWidth >= _this.maxPreviewImagesWidth) { + _this.imagesTotalWidth -= (width + _this.margin); + return false; + } + _this.tplData.images.push(value); + }); + + _this.remaining = this.tplData.remaining = (function() { + var remaining = _this.allImages.length - _this.tplData.images.length; + if (remaining > 0) { + return remaining; + } + })(); + + }, + + render: function() { + + }, + + bindEvents: function() { + var _this = this; + + this.element.find('img').on('load', function() { + //if img width is not equal to the width in the html, change height + jQuery(this).hide().fadeIn(600); + }); + + this.element.on('click', function() { + var windowConfig = { + manifest: _this.manifest, + currentCanvasID: null, + currentFocus: 'ThumbnailsView' + }; + $.viewer.workspace.addWindow(windowConfig); + }); + + this.element.find('.preview-image').on('click', function(e) { + e.stopPropagation(); + var windowConfig = { + manifest: _this.manifest, + currentCanvasID: jQuery(this).attr('data-image-id'), + currentFocus: 'ImageView' + }; + $.viewer.workspace.addWindow(windowConfig); + }); + + jQuery.subscribe('manifestPanelWidthChanged', function(event, newWidth){ + var newMaxPreviewWidth = newWidth - (_this.repoWidth + _this.margin + _this.metadataWidth + _this.margin + _this.remainingWidth); + newMaxPreviewWidth = newMaxPreviewWidth * 0.95; + + //width of browser window has been made smaller + if (newMaxPreviewWidth < _this.maxPreviewImagesWidth ) { + while (_this.imagesTotalWidth >= newMaxPreviewWidth) { + image = _this.tplData.images.pop(); + _this.imagesTotalWidth -= (image.width + _this.margin); + + //remove image from dom + _this.element.find('img[data-image-id="'+image.id+'"]').remove(); + } + //check if need to add ellipsis + if (_this.remaining === 0 && _this.allImages.length - _this.tplData.images.length > 0) { + _this.element.find('.preview-images').after(''); + } + _this.remaining = _this.allImages.length - _this.tplData.images.length; + + } else if (newMaxPreviewWidth > _this.maxPreviewImagesWidth) { + //width of browser window has been made larger + var currentLastImage = _this.tplData.images[_this.tplData.images.length-1], + index = currentLastImage ? currentLastImage.index+1 : 0, + image = _this.allImages[index]; + if (image) { + while (_this.imagesTotalWidth + image.width + _this.margin < newMaxPreviewWidth) { + _this.tplData.images.push(image); + _this.imagesTotalWidth += (image.width + _this.margin); + + //add image to dom + _this.element.find('.preview-images').append(''); + + //get next image + index++; + image = _this.allImages[index]; + if (!image) { + break; + } + } + //check if need to remove ellipsis + if (_this.remaining > 0 && _this.allImages.length - _this.tplData.images.length === 0) { + _this.element.find('.remaining').remove(); + } + _this.remaining = _this.allImages.length - _this.tplData.images.length; + } + } + _this.maxPreviewImagesWidth = newMaxPreviewWidth; + }); + }, + + hide: function() { + var _this = this; + }, + + show: function() { + var _this = this; + }, + + template: Handlebars.compile([ + '
            • ', + '
              ', + 'repoImg', + '
              ', + '', + '
              ', + '{{#each images}}', + '', + '{{/each}}', + '
              ', + '{{#if remaining}}', + '', + '{{/if}}', + '
            • ' + ].join('')) + }; + +}(Mirador)); + + +(function ($) { + $.ManifestLoadStatusIndicator = function(options) { + + this.appendTo = options.appendTo; + this.manifests = options.manifests; + this.init(); + }; + + $.ManifestLoadStatusIndicator.prototype = { + + init: function() { + this.element = jQuery('
              ').addClass('manifest-load-status-indicator').prependTo(this.appendTo); + this.element.append('

              '); + this.bindEvents(); + }, + + render: function() { + var _this = this; + + //console.log(_this.manifests.length); + var pending = _this.manifests.filter(function(d,i) { + return d.request.state() === 'pending'; + }), + rejected = _this.manifests.filter(function(d,i) { + return d.request.state() === 'rejected'; + }), + resolved = _this.manifests.filter(function(d,i) { + return d.request.state() === 'resolved'; + }); + + // pending, failed, or complete + var requests = d3.select(_this.element[0]) + .selectAll('div.pending') + .data(pending); + + //console.log(pending); + + // add new requests to the queue. + requests.enter() + .insert('div', ':nth-child(2)') + .classed('request-status-bar', true) + .classed('pending', true) + .style('left', '3000px') + .transition() + .duration(300) + .style('left', '0'); + + requests.exit() + .classed('pending', false) + .transition() + .duration(300) + .style('opacity', 0) + .remove(); + + d3.select(_this.element.find('h3')[0]) + .text(function() { + var count = pending.length; + return "Loading " + count + " Items..."; + }); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('manifestQueued', function(manifest) { + //console.log('queued'); + _this.render(); + }); + jQuery.subscribe('manifestReceived', function(manifest) { + //console.log('received'); + _this.render(); + }); + }, + + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + } + }; + +})(Mirador); + +(function($) { + + $.ManifestsPanel = function(options) { + + jQuery.extend(true, this, { + element: null, + listItems: null, + appendTo: null, + parent: null, + manifestListItems: [], + manifestListElement: null, + manifestLoadStatusIndicator: null, + resultsWidth: 0 + }, options); + + var _this = this; + _this.init(); + + }; + + $.ManifestsPanel.prototype = { + + init: function() { + this.element = jQuery(this.template({ + showURLBox : this.parent.showAddFromURLBox + })).appendTo(this.appendTo); + this.manifestListElement = this.element.find('ul'); + + //this code gives us the max width of the results area, used to determine how many preview images to show + //cloning the element and adjusting the display and visibility means it won't break the normal flow + var clone = this.element.clone().css("visibility","hidden").css("display", "block").appendTo(this.appendTo); + this.resultsWidth = clone.find('.select-results').outerWidth(); + this.controlsHeight = clone.find('.manifest-panel-controls').outerHeight(); + this.paddingListElement = this.controlsHeight; + this.manifestListElement.css("padding-bottom", this.paddingListElement); + clone.remove(); + + // this.manifestLoadStatusIndicator = new $.ManifestLoadStatusIndicator({ + // manifests: this.parent.manifests, + // appendTo: this.element.find('.select-results') + // }); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + // handle interface events + this.element.find('form#url-load-form').on('submit', function(event) { + event.preventDefault(); + var url = jQuery(this).find('input').val(); + _this.parent.addManifestFromUrl(url, "(Added from URL)"); + //console.log('trying to add from URL'); + }); + + this.element.find('.remove-object-option').on('click', function() { + _this.parent.toggleLoadWindow(); + }); + + // handle subscribed events + jQuery.subscribe('manifestsPanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + jQuery.subscribe('manifestReceived', function(event, newManifest) { + _this.manifestListItems.push(new $.ManifestListItem({ parent: _this, manifest: newManifest, resultsWidth: _this.resultsWidth })); + _this.element.find('#manifest-search').keyup(); + }); + + // Filter manifests based on user input + this.element.find('#manifest-search').on('keyup input', function() { + if (this.value.length > 0) { + _this.element.find('.items-listing li').show().filter(function() { + return jQuery(this).text().toLowerCase().indexOf(_this.element.find('#manifest-search').val().toLowerCase()) === -1; + }).hide(); + } else { + _this.element.find('.items-listing li').show(); + } + }); + + this.element.find('#manifest-search-form').on('submit', function(event) { + event.preventDefault(); + }); + + jQuery(window).resize($.throttle(function(){ + var clone = _this.element.clone().css("visibility","hidden").css("display", "block").appendTo(_this.appendTo); + _this.resultsWidth = clone.find('.select-results').outerWidth(); + clone.remove(); + jQuery.publish("manifestPanelWidthChanged", _this.resultsWidth); + }, 50, true)); + }, + + hide: function() { + var _this = this; + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + var _this = this; + + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + }, + + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + + +(function($) { + + $.WorkspacePanel = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + workspace: null, + maxRows: null, + maxColumns: null + }, options); + + this.init(); + + }; + + $.WorkspacePanel.prototype = { + init: function () { + var _this = this, + templateData = { + rows: $.layoutDescriptionFromGridString(_this.maxColumns + 'x' + _this.maxRows).children.map(function(column, rowIndex) { + column.columns = column.children.map(function(row, columnIndex) { + row.gridString = (rowIndex+1) + 'x' + (columnIndex+1); + return row; + }); + return column; + }) + }; + + this.element = jQuery(this.template(templateData)).appendTo(this.appendTo); + // var backgroundImage = _this.parent.buildPath + _this.parent.imagesPath + 'debut_dark.png'; + var backgroundImage = asset_path('debut_dark.png')'; + this.element.css('background-image','url('+backgroundImage+')').css('background-repeat','repeat'); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + jQuery.subscribe('workspacePanelVisible.set', function(_, stateValue) { + if (stateValue) { _this.show(); return; } + _this.hide(); + }); + + _this.element.find('.grid-item').on('click', function() { + var gridString = jQuery(this).data('gridstring'); + _this.onSelect(gridString); + }); + + _this.element.find('.grid-item').on('mouseover', function() { + var gridString = jQuery(this).data('gridstring'); + _this.onHover(gridString); + }); + + _this.element.find('.select-grid').on('mouseout', function() { + _this.element.find('.grid-item').removeClass('hovered'); + _this.element.find('.grid-instructions').show(); + _this.element.find('.grid-text').hide(); + }); + }, + + onSelect: function(gridString) { + var _this = this; + var layoutDescription = $.layoutDescriptionFromGridString(gridString); + _this.workspace.resetLayout(layoutDescription); + _this.parent.toggleWorkspacePanel(); + }, + + onHover: function(gridString) { + var _this = this, + highestRow = gridString.charAt(0), + highestColumn = gridString.charAt(2), + gridItems = _this.element.find('.grid-item'); + gridItems.removeClass('hovered'); + gridItems.filter(function(index) { + var element = jQuery(this); + var change = element.data('gridstring').charAt(0) <= highestRow && element.data('gridstring').charAt(2)<=highestColumn; + return change; + }).addClass('hovered'); + _this.element.find('.grid-instructions').hide(); + _this.element.find('.grid-text').text(gridString).show(); + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 160, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 160, easing: "easeInCubic"}); + }, + + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + + +(function($){ + + $.Manifest = function(manifestUri, location) { + if (manifestUri.indexOf('info.json') !== -1) { + // The following is an ugly hack. We need to finish the + // Manifesto utility library. + // See: https://github.com/IIIF/manifesto + // + // If manifestUri is not a string, then + // it's an object, namely a light-weight + // dummy manifest wrapped around the + // contents of an an info.json response. + // + // The wrapper is still going to need these + // accessor methods. We can just set the + // jsonLd directly, and the request needs to + // be a jQuery deferred object that is completed + // imediately upon creation. This allows + // components listening for this request to finish + // to react immediately without having to be + // re-written. + jQuery.extend(true, this, { + jsonLd: null, + location: location, + uri: manifestUri, + request: null + }); + + this.initFromInfoJson(manifestUri); + } else { + jQuery.extend(true, this, { + jsonLd: null, + location: location, + uri: manifestUri, + request: null + }); + + this.init(manifestUri); + } + }; + + $.Manifest.prototype = { + init: function(manifestUri) { + var _this = this; + this.request = jQuery.ajax({ + url: manifestUri, + dataType: 'json', + async: true + }); + + this.request.done(function(jsonLd) { + _this.jsonLd = jsonLd; + }); + }, + initFromInfoJson: function(infoJsonUrl) { + var _this = this; + this.request = jQuery.ajax({ + url: infoJsonUrl, + dataType: 'json', + async: true + }); + + this.request.done(function(jsonLd) { + _this.jsonLd = _this.generateInfoWrapper(jsonLd); + }); + }, + getThumbnailForCanvas : function(canvas, width) { + var version = "1.1", + service, + thumbnailUrl; + + // Ensure width is an integer... + width = parseInt(width, 10); + + // Respecting the Model... + if (canvas.hasOwnProperty('thumbnail')) { + // use the thumbnail image, prefer via a service + if (typeof(canvas.thumbnail) == 'string') { + thumbnailUrl = canvas.thumbnail; + } else if (canvas.thumbnail.hasOwnProperty('service')) { + // Get the IIIF Image API via the @context + service = canvas.thumbnail.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } else { + thumbnailUrl = canvas.thumbnail['@id']; + } + } else { + // No thumbnail, use main image + var resource = canvas.images[0].resource; + service = resource['default'] ? resource['default'].service : resource.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } + return thumbnailUrl; + }, + getCanvases : function() { + var _this = this; + return _this.jsonLd.sequences[0].canvases; + }, + getAnnotationsListUrl: function(canvasId) { + var _this = this; + var canvas = jQuery.grep(_this.getCanvases(), function(canvas, index) { + return canvas['@id'] === canvasId; + })[0]; + + if (canvas && canvas.otherContent) { + return canvas.otherContent[0]['@id']; + } else { return false; } + }, + getStructures: function() { + var _this = this; + return _this.jsonLd.structures; + }, + generateInfoWrapper: function(infoJson) { + // Takes in info.json and creates the + // dummy manifest wrapper around it + // that will allow it to behave like a + // manifest with one canvas in it, with + // one image on it. Some of the metadata + // of the image will be used as the + // label, and so on, of the manifest. + var dummyManifest = { + '@context': "http://www.shared-canvas.org/ns/context.json", + '@id': infoJson['@id'], + '@type': 'sc:Manifest', + label: infoJson['@id'].split('/')[infoJson['@id'].split('/').length -1], + sequences: [ + { + '@id': infoJson['@id'] + '/sequence/1', + '@type': 'sc:Sequence', + canvases: [ + { + '@id': infoJson['@id'] + '/sequence/1/canvas/1', + '@type': 'sc:Canvas', + width: infoJson.width, + height: infoJson.height, + images: [ + { + '@id': infoJson['@id'] + '/sequence/1/canvas/1/image/1', + '@type': 'sc:image', + 'motivation': 'sc:painting', + resource: { + '@id': infoJson, + '@type': "dctypes:Image", + format: "image/jpeg", + height: infoJson.width, + width: infoJson.height, + service: { + '@id': infoJson['@id'], + '@context': infoJson['@context'], + 'profile': infoJson.profile + } + } + } + ] + } + ] + } + ] + }; + + return dummyManifest; + } + }; + +}(Mirador)); + +(function($) { + + $.AnnotationTooltip = function(options) { + + jQuery.extend(this, { + element: null, + parent: null, + annotations: [], + windowId: "" + }, options); + + this.init(); + }; + + $.AnnotationTooltip.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + }, + + getEditor: function(annotation) { + var annoText = "", + tags = [], + _this = this; + + if (!jQuery.isEmptyObject(annotation)) { + if (jQuery.isArray(annotation.resource)) { + jQuery.each(annotation.resource, function(index, value) { + if (value['@type'] === "oa:Tag") { + tags.push(value.chars); + } else { + annoText = value.chars; + } + }); + } else { + annoText = annotation.resource.chars; + } + } + + return this.editorTemplate({content : annoText, + tags : tags.join(" "), + id : jQuery.isEmptyObject(annotation) ? "" : annotation['@id'], + windowId : _this.windowId + }); + }, + + getViewer: function(annotations) { + var annoText, + tags = [], + _this = this, + htmlAnnotations = [], + id; + + jQuery.each(annotations, function(index, annotation) { + tags = []; + if (jQuery.isArray(annotation.resource)) { + jQuery.each(annotation.resource, function(index, value) { + if (value['@type'] === "oa:Tag") { + tags.push(value.chars); + } else { + annoText = value.chars; + } + }); + } else { + annoText = annotation.resource.chars; + } + var username = ""; + if (annotation.annotatedBy && annotation.annotatedBy.name) { + username = annotation.annotatedBy.name; + } + //if it is a manifest annotation, don't allow editing or deletion + //otherwise, check annotation in endpoint + var showUpdate = false; + if (annotation.endpoint !== 'manifest') { + showUpdate = annotation.endpoint.userAuthorize('update', annotation); + } + var showDelete = false; + if (annotation.endpoint !== 'manifest') { + showDelete = annotation.endpoint.userAuthorize('delete', annotation); + } + htmlAnnotations.push({ + annoText : annoText, + tags : tags, + id : annotation['@id'], + username : username, + showUpdate : showUpdate, + showDelete : showDelete + }); + }); + + var template = this.viewerTemplate({annotations : htmlAnnotations, + windowId : _this.windowId}); + return template; + //return combination of all of them + }, + + //when this is being used to edit an existing annotation, insert them into the inputs + editorTemplate: Handlebars.compile([ + '
              ', + '', + '', + '
              ', + // need to add a delete, if permissions allow + '
              ', + '{{t "cancel"}}', + '{{t "save"}}', + '
              ', + '
              ', + '' + ].join('')), + + viewerTemplate: Handlebars.compile([ + '
              ', + '{{#each annotations}}', + '
              ', + '
              ', + '{{#if showUpdate}}{{t "edit"}}{{/if}}', + '{{#if showDelete}}{{t "delete"}}{{/if}}', + '
              ', + '
              ', + '{{#if username}}

              {{username}}:

              {{/if}}', + '

              {{{annoText}}}

              ', + '
              ', + '
              ', + '{{#each tags}}', + '{{this}}', + '{{/each}}', + '
              ', + '
              ', + '{{/each}}', + '
              ' + ].join('')) + }; + +}(Mirador)); + +/* + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(options, successCallback, errorCallback) + * create(oaAnnotation, successCallback, errorCallback) + * update(oaAnnotation, successCallback, errorCallback) + * deleteAnnotation(annotationID, successCallback, errorCallback) (delete is a reserved word) + * TODO: + * read() //not currently used + * + * Optional, if endpoint is not OA compliant: + * getAnnotationInOA(endpointAnnotation) + * getAnnotationInEndpoint(oaAnnotation) + */ +(function($){ + + $.CatchEndpoint = function(options) { + + jQuery.extend(this, { + token: null, + prefix: null, + dfd: null, + context_id: "None", + collection_id: "None", + userid: "test@mirador.org", + username: "mirador-test", + annotationsList: [], //OA list for Mirador use + annotationsListCatch: null, //internal list for module use + windowID: null + }, options); + + this.init(); + }; + + $.CatchEndpoint.prototype = { + //Set up some options for catch + init: function() { + this.catchOptions = { + user: { + id: this.userid, + name: this.username + }, + permissions: { + 'read': [], + 'update': [this.userid], + 'delete': [this.userid], + 'admin': [this.userid] + } + }; + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + //Search endpoint for all annotations with a given URI + search: function(options, successCallback, errorCallback) { + var _this = this; + this.annotationsList = []; //clear out current list + + jQuery.ajax({ + url: this.prefix+"/search", + type: 'GET', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: { + uri: options.uri, + userid : options.userid ? options.userid : undefined, + username : options.username ? options.username : undefined, + text : options.text ? options.text : undefined, + tag : options.tag ? options.tag : undefined, + parentid : options.parentid ? options.parentid : undefined, + contextId: _this.context_id, + collectionId: _this.collection_id, + media: options.media ? options.media : "image", + limit: options.limit ? options.limit : -1 + }, + + contentType: "application/json; charset=utf-8", + success: function(data) { + //check if a function has been passed in, otherwise, treat it as a normal search + if (typeof successCallback === "function") { + successCallback(data); + } else { + _this.annotationsListCatch = data.rows; + jQuery.each(_this.annotationsListCatch, function(index, value) { + _this.annotationsList.push(_this.getAnnotationInOA(value)); + }); + _this.dfd.resolve(true); + jQuery.publish('catchAnnotationsLoaded.'+_this.windowID, _this.annotationsListCatch); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } else { + console.log("There was an error searching this endpoint"); + } + } + + }); + }, + + deleteAnnotation: function(annotationID, successCallback, errorCallback) { + var _this = this; + jQuery.ajax({ + url: this.prefix+"/destroy/"+annotationID, + type: 'DELETE', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + jQuery.publish('catchAnnotationDeleted.'+_this.windowID, annotationID); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + + }); + }, + + update: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation), + _this = this, + annotationID = annotation.id; + + jQuery.ajax({ + url: this.prefix+"/update/"+annotationID, + type: 'POST', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + jQuery.publish('catchAnnotationUpdated.'+_this.windowID, annotation); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //takes OA Annotation, gets Endpoint Annotation, and saves + //if successful, MUST return the OA rendering of the annotation + create: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation); + this.createCatchAnnotation(annotation, successCallback, errorCallback); + }, + + createCatchAnnotation: function(catchAnnotation, successCallback, errorCallback) { + var _this = this; + + jQuery.ajax({ + url: this.prefix+"/create", + type: 'POST', + dataType: 'json', + headers: { + "x-annotator-auth-token": this.token + }, + data: JSON.stringify(catchAnnotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(_this.getAnnotationInOA(data)); + } + jQuery.publish('catchAnnotationCreated.'+_this.windowID, data); + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + userAuthorize: function(action, annotation) { + var token, tokens, _i, _len; + //if this is an instructor, they have access to student annotations + if (this.roles && (this.roles.indexOf('Instructor') !== -1 || this.roles.indexOf('Administrator') !== -1)){ + return true; + } + //otherwise check annotation permissions + if (annotation.permissions) { + var permissionUserIds = annotation.permissions[action] || []; + //if no userids set for a permission, it is open to everyone + if (permissionUserIds.length === 0) { + return true; + } + //otherwise compare userid of annotation to current userid + if (permissionUserIds.indexOf(this.userid) !== -1) { + return true; + } + return false; + } else if (annotation.user) { + //if no permissions, just check userids + return this.userid === annotation.user.userid; + } + //otherwise, just return true + return true; + }, + + //Convert Endpoint annotation to OA + getAnnotationInOA: function(annotation) { + var id, + motivation = [], + resource = [], + on, + annotatedBy; + //convert annotation to OA format + + id = annotation.id; //need to make URI + + if (annotation.tags.length > 0) { + motivation.push("oa:tagging"); + jQuery.each(annotation.tags, function(index, value) { + resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + if (annotation.parent && annotation.parent !== "0") { + motivation.push("oa:replying"); + on = annotation.parent; //need to make URI + } else { + motivation.push("oa:commenting"); + on = { "@type" : "oa:SpecificResource", + "source" : annotation.uri, + "selector" : { + "@type" : "oa:FragmentSelector", + "value" : "xywh="+annotation.rangePosition.x+","+annotation.rangePosition.y+","+annotation.rangePosition.width+","+annotation.rangePosition.height + }, + "scope": { + "@context" : "http://www.harvard.edu/catch/oa.json", + "@type" : "catch:Viewport", + "value" : "xywh="+annotation.bounds.x+","+annotation.bounds.y+","+annotation.bounds.width+","+annotation.bounds.height + } + }; + } + resource.push( { + "@type" : "dctypes:Text", + "format" : "text/html", + "chars" : annotation.text + }); + + annotatedBy = { "@id" : annotation.user.id, + "name" : annotation.user.name}; + + var oaAnnotation = { + "@context" : "http://iiif.io/api/presentation/2/context.json", + "@id" : String(id), + "@type" : "oa:Annotation", + "motivation" : motivation, + "resource" : resource, + "on" : on, + "annotatedBy" : annotatedBy, + "annotatedAt" : annotation.created, + "serializedAt" : annotation.updated, + "permissions" : annotation.permissions, + "endpoint" : this + }; + return oaAnnotation; + }, + + // Converts OA Annotation to endpoint format + getAnnotationInEndpoint: function(oaAnnotation) { + var annotation = {}, + tags = [], + text; + + if (oaAnnotation["@id"]) { + annotation.id = oaAnnotation["@id"]; + } + + annotation.media = "image"; + jQuery.each(oaAnnotation.resource, function(index, value) { + if (value['@type'] === 'oa:Tag') { + tags.push(value.chars); + } else if (value['@type'] === 'dctypes:Text') { + text = value.chars; + } + }); + annotation.tags = tags; + annotation.text = text; + + annotation.uri = oaAnnotation.on.source; + annotation.contextId = this.context_id; + annotation.collectionId = this.collection_id; + + var region = oaAnnotation.on.selector.value; + var regionArray = region.split('=')[1].split(','); + annotation.rangePosition = {"x":regionArray[0], "y":regionArray[1], "width":regionArray[2], "height":regionArray[3]}; + + var imageUrl = $.Iiif.getImageUrl(this.parent.imagesList[$.getImageIndexById(this.parent.imagesList, oaAnnotation.on.source)]); + imageUrl = imageUrl + "/" + regionArray.join(',') + "/full/0/native.jpg"; + annotation.thumb = imageUrl; + + region = oaAnnotation.on.scope.value; + regionArray = region.split('=')[1].split(','); + annotation.bounds = {"x":regionArray[0], "y":regionArray[1], "width":regionArray[2], "height":regionArray[3]}; + + annotation.updated = new Date().toISOString(); + if (oaAnnotation.annotatedAt) { + annotation.created = oaAnnotation.annotatedAt; + } else { + annotation.created = annotation.updated; + } + // this needs to come from LTI annotation.user.id, annotation.user.name + annotation.user = {}; + if (oaAnnotation.annotatedBy) { + annotation.user.name = oaAnnotation.annotatedBy.name; + annotation.user.id = oaAnnotation.annotatedBy['@id']; + } else { + annotation.user = this.catchOptions.user; + } + annotation.permissions = this.catchOptions.permissions; + annotation.archived = false; + annotation.ranges = []; + annotation.parent = "0"; + return annotation; + } + }; + +}(Mirador)); + +/* + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(options, successCallback, errorCallback) + * create(oaAnnotation, successCallback, errorCallback) + * update(oaAnnotation, successCallback, errorCallback) + * deleteAnnotation(annotationID, successCallback, errorCallback) (delete is a reserved word) + * TODO: + * read() //not currently used + * + * Optional, if endpoint is not OA compliant: + * getAnnotationInOA(endpointAnnotation) + * getAnnotationInEndpoint(oaAnnotation) + */ +(function($){ + + $.Endpoint = function(options) { + + jQuery.extend(this, { + dfd: null, + annotationsList: [], //OA list for Mirador use + windowID: null, + parent: null + }, options); + + this.init(); + }; + + $.Endpoint.prototype = { + init: function() { + //whatever initialization your endpoint needs + }, + + //Search endpoint for all annotations with a given URI in options + search: function(options, successCallback, errorCallback) { + var _this = this; + + //use options.uri + jQuery.ajax({ + url: '', + type: 'GET', + dataType: 'json', + headers: { }, + data: { }, + contentType: "application/json; charset=utf-8", + success: function(data) { + //check if a function has been passed in, otherwise, treat it as a normal search + if (typeof successCallback === "function") { + successCallback(data); + } else { + jQuery.each(data, function(index, value) { + _this.annotationsList.push(_this.getAnnotationInOA(value)); + }); + _this.dfd.resolve(true); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //Delete an annotation by endpoint identifier + deleteAnnotation: function(annotationID, successCallback, errorCallback) { + var _this = this; + jQuery.ajax({ + url: '', + type: 'DELETE', + dataType: 'json', + headers: { }, + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //Update an annotation given the OA version + update: function(oaAnnotation, successCallback, errorCallback) { + var annotation = this.getAnnotationInEndpoint(oaAnnotation), + _this = this; + + jQuery.ajax({ + url: '', + type: 'POST', + dataType: 'json', + headers: { }, + data: '', + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + //takes OA Annotation, gets Endpoint Annotation, and saves + //if successful, MUST return the OA rendering of the annotation + create: function(oaAnnotation, successCallback, errorCallback) { + var _this = this; + + jQuery.ajax({ + url: '', + type: 'POST', + dataType: 'json', + headers: { }, + data: '', + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(_this.getAnnotationInOA(data)); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } + } + }); + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + //Convert Endpoint annotation to OA + getAnnotationInOA: function(annotation) { + }, + + // Converts OA Annotation to endpoint format + getAnnotationInEndpoint: function(oaAnnotation) { + } + }; + +}(Mirador)); + +(function($) { + + // Takes a list of oa:annotations passed + // by reference and renders their regions, + // registering updates. + + $.OsdCanvasRenderer = function(options) { + + jQuery.extend(this, { + osd: null, + osdViewer: null, + elements: null, + list: null, + parent: null, //annotationsLayer + annoTooltips: {}, + tooltips: null, + overlays: [], + inEditOrCreateMode: false + }, options); + + this.bindEvents(); + }; + + $.OsdCanvasRenderer.prototype = { + parseRegion: function(url) { + var regionString; + if (typeof url === 'object') { + regionString = url.selector.value; + } else { + regionString = url.split('#')[1]; + } + var regionArray = regionString.split('=')[1].split(','); + return regionArray; + }, + + getOsdFrame: function(region) { + var rectX = region[0], + rectY = region[1], + rectW = region[2], + rectH = region[3]; + + return this.osdViewer.viewport.imageToViewportRectangle(rectX,rectY,rectW,rectH); + + }, + + render: function() { + var _this = this; + _this.hideAll(), + this.overlays = []; + + var deferreds = jQuery.map(this.list, function(annotation) { + var deferred = jQuery.Deferred(), + region = _this.parseRegion(annotation.on), + osdOverlay = document.createElement('div'); + osdOverlay.className = 'annotation'; + osdOverlay.id = annotation['@id']; + _this.osdViewer.addHandler("add-overlay", function() { + deferred.resolve(); + }); + _this.osdViewer.addOverlay({ + element: osdOverlay, + location: _this.getOsdFrame(region) + }); + _this.overlays.push(jQuery(osdOverlay)); + return deferred; + }); + //this still doesn't take into account the actual appending of the overlays to the DOM + //so not quite there yet + jQuery.when.apply(jQuery, deferreds).done(function() { + jQuery.publish('overlaysRendered.' + _this.parent.windowId); + }); + + this.tooltips = jQuery(this.osdViewer.element).qtip({ + overwrite : false, + content: { + text : '' + }, + position : { + target : 'mouse', + my: 'bottom left', + at: 'top right', + adjust : { + mouse: false, + method: 'shift' + }, + //when the side panel is active and visible, it messes up the offset for the qtip + //which means that qtips will disappear for annotations that are on the far right side of the canvas + //so we need the container and viewport to be the element that encompasses everything, + //which can be the window or slot. we need a better way of getting this element + //because this is brittle + container: _this.parent.parent.parent.element, //window's element + viewport: _this.parent.parent.parent.element //window's element + }, + style : { + classes : 'qtip-bootstrap qtip-viewer' + }, + show: { + delay: 20, + event: false + }, + hide: { + fixed: true, + delay: 50, + event: false + }, + events: { + show: function(event, api) { + _this.setTooltipContent(event, api); + }, + visible: function(event, api) { + _this.removeAnnotationEvents(event, api); + _this.annotationEvents(event, api); + }, + move: function(event, api) { + _this.removeAnnotationEvents(event, api); + _this.annotationEvents(event, api); + _this.annotationSaveEvent(event, api); + }, + hidden: function(event, api) { + if (jQuery('.qtip:visible').length === 0) { + jQuery(_this.osdViewer.canvas).find('.annotation').removeClass('hovered');//.css('border-color', 'deepSkyBlue'); + } + } + } + }); + }, + + setTooltipContent: function(event, api) { + var overlays = this.getOverlaysFromElement(jQuery(event.originalEvent.currentTarget), event.originalEvent), + _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), //pass permissions + annotations = []; + + jQuery.each(overlays, function(index, overlay) { + annotations.push(_this.getAnnoFromRegion(overlay.id)[0]); + }); + api.set({'content.text' : annoTooltip.getViewer(annotations)}); + jQuery.publish('tooltipViewerSet.'+_this.parent.windowId); + }, + + getAnnoFromRegion: function(regionId) { + return this.list.filter(function(annotation) { + return annotation['@id'] === regionId; + }); + }, + + showTooltipsFromMousePosition: function(event) { + var overlays = this.getOverlaysFromMousePosition(event); + var api = jQuery(this.osdViewer.element).qtip('api'); + if (api) { + if (overlays.length === 0) { + api.hide(event); + } else if (api.elements.tooltip && api.elements.tooltip.is(':visible')) { + this.setTooltipContent(event, api); + api.cache.origin = event; + api.reposition(event, true); + } else { + api.show(event); + } + } + }, + + getOverlaysFromMousePosition: function(event) { + var position = OpenSeadragon.getMousePosition(event); + var _this = this, + overlays = jQuery(_this.osdViewer.canvas).find('.annotation').map(function() { + var self = jQuery(this), + offset = self.offset(), + l = offset.left, + t = offset.top, + h = self.height(), + w = self.width(), + x = position.x, + y = position.y, + maxx = l+w, + maxy = t+h; + return (y <= maxy && y >= t) && (x <= maxx && x >= l) ? this : null; + }); + return overlays; + }, + getOverlaysFromElement: function(element, event) { + var _this = this, + overlays = this.getOverlaysFromMousePosition(event); + jQuery(_this.osdViewer.canvas).find('.annotation.hovered').removeClass('hovered');//.css('border-color', 'deepSkyBlue'); + overlays.addClass('hovered'); + /*jQuery.each(overlays, function(index, value) { + jQuery(value).css('border-color', _this.getRandomColor()); + });*/ + return overlays; + }, + + getRandomColor: function() { + var colors = this.hsvToRgb(Math.random() * 360, 50, 100); + //return "#" + Math.floor(Math.random() * 0xFFFFFF).toString(16); + return 'rgb('+colors[0]+','+colors[1]+','+colors[2]+')'; + }, + + /** + * From: http://snipplr.com/view.php?codeview&id=14590 + * HSV to RGB color conversion + * + * H runs from 0 to 360 degrees + * S and V run from 0 to 100 + * + * Ported from the excellent java algorithm by Eugene Vishnevsky at: + * http://www.cs.rit.edu/~ncs/color/t_convert.html + */ + hsvToRgb: function(h, s, v) { + var r, g, b; + var i; + var f, p, q, t; + + // Make sure our arguments stay in-range + h = Math.max(0, Math.min(360, h)); + s = Math.max(0, Math.min(100, s)); + v = Math.max(0, Math.min(100, v)); + + // We accept saturation and value arguments from 0 to 100 because that's + // how Photoshop represents those values. Internally, however, the + // saturation and value are calculated from a range of 0 to 1. We make + // That conversion here. + s /= 100; + v /= 100; + + if(s === 0) { + // Achromatic (grey) + r = g = b = v; + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + } + + h /= 60; // sector 0 to 5 + i = Math.floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch(i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + default: // case 5: + r = v; + g = p; + b = q; + } + + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + }, + + bindEvents: function() { + var _this = this; + + jQuery(this.osdViewer.canvas).parent().on('mousemove', $.throttle(function(event) { + if (!_this.inEditOrCreateMode) { + _this.showTooltipsFromMousePosition(event); + } + }, 200, true)); + + this.osdViewer.addHandler('zoom', $.debounce(function(){ + _this.hideVisibleTooltips(); + }, 200, true)); + + jQuery.subscribe('removeTooltips.' + _this.parent.windowId, function() { + jQuery(_this.osdViewer.canvas).find('.annotation').qtip('destroy', true); + }); + + jQuery.subscribe('disableTooltips.' + _this.parent.windowId, function() { + _this.inEditOrCreateMode = true; + }); + + jQuery.subscribe('enableTooltips.' + _this.parent.windowId, function() { + _this.inEditOrCreateMode = false; + }); + + jQuery.subscribe('removeOverlay.' + _this.parent.windowId, function(event, annoId) { + //remove this annotation's overlay from osd + _this.osdViewer.removeOverlay(jQuery(_this.osdViewer.element).find(".annotation#"+annoId)[0]); + }); + + }, + + hideVisibleTooltips: function() { + jQuery('.qtip-viewer').qtip('hide'); + }, + + update: function() { + this.render(); + }, + + hideAll: function() { + this.osdViewer.clearOverlays(); + }, + + getElements: function() { + this.elements = this.osdViewer.currentOverlays.reduce(function(result, currentOverlay) { + currentOverlay = jQuery(currentOverlay); + return result.add(currentOverlay); + }); + return elements; + }, + + //change content of this tooltip, and disable hiding it, until user clicks save or cancel + //disable all other qtips until editing this is done + freezeQtip: function(api, oaAnno, annoTooltip) { + this.inEditOrCreateMode = true; + jQuery.publish('disableRectTool.'+this.parent.windowId); + api.set({'content.text' : annoTooltip.getEditor(oaAnno), + 'hide.event' : false}); + jQuery.publish('annotationEditorAvailable.'+this.parent.windowId); + //add rich text editor + tinymce.init({ + selector : 'form.annotation-tooltip textarea', + plugins: "image link media", + menubar: false, + statusbar: false, + toolbar_items_size: 'small', + toolbar: "bold italic | bullist numlist | link image media | removeformat", + setup : function(editor) { + editor.on('init', function(args) { + tinymce.execCommand('mceFocus', false, args.target.id); //make sure tinymce focuses on the editor after initialization + }); + } + }); + jQuery(api.elements.tooltip).removeClass("qtip-viewer"); //so it is not affected by zoom event raised in OSD + this.osdViewer.zoomPerClick = 1; + this.osdViewer.zoomPerScroll = 1; + }, + + //reenable all other qtips + //update content of this qtip to make it a viewer, not editor + //and reset hide event + unFreezeQtip: function(api, oaAnno, annoTooltip) { + this.inEditOrCreateMode = false; + jQuery.publish('enableRectTool.'+this.parent.windowId); + api.set({'content.text' : annoTooltip.getViewer([oaAnno]), + 'hide.event' : 'mouseleave'}).hide(); + jQuery(api.elements.tooltip).addClass("qtip-viewer"); //re-add class so it is affected by zoom event raised in OSD + this.osdViewer.zoomPerClick = 2; + this.osdViewer.zoomPerScroll = 1.2; + }, + + removeAnnotationEvents: function(tooltipevent, api) { + var _this = this, + editorSelector = '#annotation-editor-'+_this.parent.windowId, + viewerSelector = '#annotation-viewer-'+_this.parent.windowId; + jQuery(viewerSelector+' a.delete').off("click"); + jQuery(viewerSelector+' a.edit').off("click"); + jQuery(editorSelector+' a.save').off("click"); + jQuery(editorSelector+' a.cancel').off("click"); + }, + + annotationEvents: function(tooltipevent, api) { + var _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), + selector = '#annotation-viewer-'+_this.parent.windowId; + jQuery(selector+' a.delete').on("click", function(event) { + event.preventDefault(); + + if (!window.confirm("Do you want to delete this annotation?")) { + return false; + } + + var display = jQuery(this).parents('.annotation-display'), + id = display.attr('data-anno-id'); + //oaAnno = _this.getAnnoFromRegion(id)[0]; + jQuery.publish('annotationDeleted.'+_this.parent.windowId, [id]); + + //hide tooltip so event handlers don't get messed up + api.hide(); + display.remove(); //remove this annotation display from dom + }); + + jQuery(selector+' a.edit').on("click", function(event) { + event.preventDefault(); + + var display = jQuery(this).parents('.annotation-display'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + _this.freezeQtip(api, oaAnno, annoTooltip); + }); + }, + + annotationSaveEvent: function(event, api) { + var _this = this, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}), + selector = '#annotation-editor-'+_this.parent.windowId; + + jQuery(selector).on("submit", function(event) { + event.preventDefault(); + jQuery(selector+' a.save').click(); + }); + + jQuery(selector+' a.save').on("click", function(event) { + event.preventDefault(); + + var display = jQuery(this).parents('.annotation-tooltip'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + //check if new resourceText is empty?? + var tagText = jQuery(this).parents('.annotation-editor').find('.tags-editor').val(), + resourceText = tinymce.activeEditor.getContent(), + tags = []; + tagText = $.trimString(tagText); + if (tagText) { + tags = tagText.split(/\s+/); + } + + var bounds = _this.osdViewer.viewport.getBounds(true); + var scope = _this.osdViewer.viewport.viewportToImageRectangle(bounds); + //bounds is giving negative values? + //update scope + oaAnno.on.scope.value = "xywh="+Math.round(scope.x)+","+Math.round(scope.y)+","+Math.round(scope.width)+","+Math.round(scope.height); //osd bounds + + var motivation = [], + resource = []; + + //remove all tag-related content in annotation + oaAnno.motivation = jQuery.grep(oaAnno.motivation, function(value) { + return value !== "oa:tagging"; + }); + oaAnno.resource = jQuery.grep(oaAnno.resource, function(value) { + return value["@type"] !== "oa:Tag"; + }); + //re-add tagging if we have them + if (tags.length > 0) { + oaAnno.motivation.push("oa:tagging"); + jQuery.each(tags, function(index, value) { + oaAnno.resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + jQuery.each(oaAnno.resource, function(index, value) { + if (value["@type"] === "dctypes:Text") { + value.chars = resourceText; + } + }); + //save to endpoint + jQuery.publish('annotationUpdated.'+_this.parent.windowId, [oaAnno]); + + _this.unFreezeQtip(api, oaAnno, annoTooltip); + }); + + jQuery(selector+' a.cancel').on("click", function(event) { + event.preventDefault(); + var display = jQuery(this).parents('.annotation-tooltip'), + id = display.attr('data-anno-id'), + oaAnno = _this.getAnnoFromRegion(id)[0]; + + _this.unFreezeQtip(api, oaAnno, annoTooltip); + }); + + } + }; +})(Mirador); + +(function($) { + // Takes an openSeadragon canvas and calls + // provided callbacks at different stages + // of a rectangle creation event. + + $.OsdRegionRectTool = function(options) { + jQuery.extend(this, { + osdRectTool: null, + osd: null, + osdViewer: null, + mouseStart: null, + rectangle: null, + rectClass: null, + osdOverlay: null, + dragging: false, + rectangleDrawn: false, + disableRectTool: false, + parent: null + }, options); + + this.init(); + }; + + $.OsdRegionRectTool.prototype = { + + init: function() { + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + jQuery.subscribe('disableRectTool.' + _this.parent.windowId, function() { + _this.disableRectTool = true; + }); + + jQuery.subscribe('enableRectTool.' + _this.parent.windowId, function() { + _this.disableRectTool = false; + }); + }, + + reset: function(osdViewer) { + this.dragging = false; + this.osdOverlay = null; + this.rectangle = null; + this.mouseStart = null; + this.osdViewer = osdViewer; + }, + + enterEditMode: function() { + var _this = this; + this.setOsdFrozen(true); + this.osdViewer.addHandler("canvas-drag", _this.startRectangle, {recttool: _this}); + this.osdViewer.addHandler("canvas-drag-end", _this.finishRectangle, {recttool: _this}); + this.onModeEnter(); + }, + + exitEditMode: function(event) { + var _this = this; + this.setOsdFrozen(false); + this.osdViewer.removeHandler('canvas-drag', _this.startRectangle); + this.osdViewer.removeHandler('canvas-drag-end', _this.finishRectangle); + this.onModeExit(); + }, + + setOsdFrozen: function(freeze) { + if (freeze) { + // Control the openSeadragon canvas behaviour + // so that it doesn't move around while we're + // trying to edit our rectangle. + this.osdViewer.panHorizontal = false; + this.osdViewer.panVertical = false; + } else { + this.osdViewer.panHorizontal = true; + this.osdViewer.panVertical = true; + } + }, + + /* + * Here is a different way of checking if the mouse is inside the image. The response to the user feels slower + * so it doesn't feel as great. + startRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (!_this.dragging) { + _this.dragging = true; + var currentMouse = _this.osdViewer.viewport.pointFromPixel(event.position); + if (_this.isMouseInImage(currentMouse)) { + _this.mouseStart = currentMouse; + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } + } else { + var mouseNow = _this.osdViewer.viewport.pointFromPixel(event.position); + if (_this.isMouseInImage(mouseNow)) { + if (_this.mouseStart) { + _this.updateRectangle(_this.mouseStart, mouseNow); + _this.onDraw(); + } else { + _this.mouseStart = mouseNow; + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } + } + } + },*/ + + startRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (!_this.rectangleDrawn && !_this.disableRectTool) { + if (!_this.dragging) { + _this.dragging = true; + _this.mouseStart = _this.getMousePositionInImage(_this.osdViewer.viewport.pointFromPixel(event.position)); + _this.createRectangle(_this.mouseStart); + _this.onDrawStart(); + } else { + var mouseNow = _this.getMousePositionInImage(_this.osdViewer.viewport.pointFromPixel(event.position)); + _this.updateRectangle(_this.mouseStart, mouseNow); + _this.onDraw(); + } + } + }, + + createRectangle: function(mouseStart) { + var x = mouseStart.x, + y = mouseStart.y, + width = 0, + height = 0; + this.rectangle = new OpenSeadragon.Rect(x, y, width, height); + this.osdOverlay = document.createElement('div'); + this.osdOverlay.className = 'osd-select-rectangle'; + this.osdViewer.addOverlay({ + element: this.osdOverlay, + location: this.rectangle + }); + }, + + updateRectangle: function(mouseStart, mouseNow) { + var topLeft = { + x:Math.min(mouseStart.x, mouseNow.x), + y:Math.min(mouseStart.y, mouseNow.y) + }, + bottomRight = { + x:Math.max(mouseStart.x, mouseNow.x), + y:Math.max(mouseStart.y, mouseNow.y) + }; + + this.rectangle.x = topLeft.x; + this.rectangle.y = topLeft.y; + this.rectangle.width = bottomRight.x - topLeft.x; + this.rectangle.height = bottomRight.y - topLeft.y; + + this.osdViewer.updateOverlay(this.osdOverlay, this.rectangle); + }, + + finishRectangle: function(event) { + var _this = this.userData.recttool; //osd userData + if (_this.rectangle) { + _this.dragging = false; + var osdImageRect = _this.osdViewer.viewport.viewportToImageRectangle(_this.rectangle); + var canvasRect = { + x: parseInt(osdImageRect.x, 10), + y: parseInt(osdImageRect.y, 10), + width: Math.max(parseInt(osdImageRect.width, 10), 1), //don't allow 0 pixel width or height + height: Math.max(parseInt(osdImageRect.height, 10), 1) //don't allow 0 pixel width or height + }; + _this.rectangleDrawn = true; + var tooltip = _this.onDrawFinish(canvasRect); + //show after creation so we don't have to wait for user to make sure mouse is inside overlay + tooltip.qtip('show'); + _this.rectangle = null; + _this.mouseStart = null; + } + }, + + getMousePositionInImage: function(mousePosition) { + if (mousePosition.x < 0) { + mousePosition.x = 0; + } + if (mousePosition.x > 1) { + mousePosition.x = 1; + } + if (mousePosition.y < 0) { + mousePosition.y = 0; + } + if (mousePosition.y > (1/this.osdViewer.source.aspectRatio)) { + mousePosition.y = (1/this.osdViewer.source.aspectRatio); + } + return mousePosition; + }, + + isMouseInImage: function(mousePosition) { + if (mousePosition.x < 0) { + return false; + } + if (mousePosition.x > 1) { + return false; + } + if (mousePosition.y < 0) { + return false; + } + if (mousePosition.y > (1/this.osdViewer.source.aspectRatio)) { + return false; + } + return true; + }, + + //Currently the rect is + // kept in openSeaDragon format until it is returned on "onDrawFinish". + // The intent here is to update the annotation continuously rather than + // only on the end of the draw event so rendering is always handled by + // renderer instead of only at the end of the process, since different + // rendering methods may be used. + + onDrawFinishOld: function(canvasRect) { + var parent = this.parent, + _this = this; + + var topLeftImagePoint = new OpenSeadragon.Point(canvasRect.x, canvasRect.y); + + }, + + onDrawFinish: function(canvasRect) { + var _this = this, + parent = this.parent, + annoTooltip = new $.AnnotationTooltip({"windowId" : _this.parent.windowId}); //pass permissions + var tooltip = jQuery(this.osdOverlay).qtip({ + content: { + text : annoTooltip.getEditor({}) + }, + position : { + my: 'bottom left', + at: 'top right', + adjust : { + method: 'flipinvert' + }, + //when the side panel is active and visible, it messes up the offset for the qtip + //which means that qtips will disappear for annotations that are on the far right side of the canvas + //so we need the container and viewport to be the element that encompasses everything, + //which can be the window or slot. we need a better way of getting this element + //because this is brittle + container: _this.parent.parent.parent.element, //window's element + viewport: _this.parent.parent.parent.element //window's element + }, + style : { + classes : 'qtip-bootstrap' + }, + show: { + event: false + }, + hide: { + fixed: true, + delay: 300, + event: false + }, + events: { + render: function(event, api) { + + jQuery.publish('annotationEditorAvailable.'+parent.windowId); + + //disable all tooltips for overlays + jQuery.publish('disableTooltips.'+parent.windowId); + //disable zooming + _this.osdViewer.zoomPerClick = 1; + _this.osdViewer.zoomPerScroll = 1; + + var selector = '#annotation-editor-'+parent.windowId; + + tinymce.init({ + selector : selector+' textarea', + plugins: "image link media", + menubar: false, + statusbar: false, + toolbar_items_size: 'small', + toolbar: "bold italic | bullist numlist | link image media | removeformat", + setup : function(editor) { + editor.on('init', function(args) { + tinymce.execCommand('mceFocus', false, args.target.id); //make sure tinymce focuses on the editor after initialization + }); + } + }); + + jQuery(selector).on("submit", function(event) { + event.preventDefault(); + jQuery(selector+' a.save').click(); + }); + + jQuery(selector+' a.cancel').on("click", function(event) { + event.preventDefault(); + //add check so that dialog box only pops up if there is stuff in the editor + var content = tinymce.activeEditor.getContent(); + if (content) { + if (!window.confirm("Do you want to cancel this annotation?")) { + return false; + } + } + api.destroy(); + _this.rectangleDrawn = false; + _this.osdViewer.removeOverlay(_this.osdOverlay); + //reenable viewer tooltips + jQuery.publish('enableTooltips.'+parent.windowId); + _this.osdViewer.zoomPerClick = 2; + _this.osdViewer.zoomPerScroll = 1.2; + }); + + jQuery(selector+' a.save').on("click", function(event) { + event.preventDefault(); + var tagText = jQuery(this).parents('.annotation-editor').find('.tags-editor').val(), + resourceText = tinymce.activeEditor.getContent(), + tags = []; + tagText = $.trimString(tagText); + if (tagText) { + tags = tagText.split(/\s+/); + } + + var bounds = _this.osdViewer.viewport.getBounds(true); + var scope = _this.osdViewer.viewport.viewportToImageRectangle(bounds); + //bounds is giving negative values? + + var motivation = [], + resource = [], + on; + + if (tags && tags.length > 0) { + motivation.push("oa:tagging"); + jQuery.each(tags, function(index, value) { + resource.push({ + "@type":"oa:Tag", + "chars":value + }); + }); + } + motivation.push("oa:commenting"); + on = { "@type" : "oa:SpecificResource", + "source" : parent.parent.canvasID, + "selector" : { + "@type" : "oa:FragmentSelector", + "value" : "xywh="+canvasRect.x+","+canvasRect.y+","+canvasRect.width+","+canvasRect.height + }, + "scope": { + "@context" : "http://www.harvard.edu/catch/oa.json", + "@type" : "catch:Viewport", + "value" : "xywh="+Math.round(scope.x)+","+Math.round(scope.y)+","+Math.round(scope.width)+","+Math.round(scope.height) //osd bounds + } + }; + resource.push( { + "@type" : "dctypes:Text", + "format" : "text/html", + "chars" : resourceText + }); + var oaAnno = { + "@context" : "http://iiif.io/api/presentation/2/context.json", + "@type" : "oa:Annotation", + "motivation" : motivation, + "resource" : resource, + "on" : on + }; + //save to endpoint + jQuery.publish('annotationCreated.'+parent.windowId, [oaAnno, _this.osdOverlay]); + + //update content of this qtip to make it a viewer, not editor + api.destroy(); + _this.rectangleDrawn = false; + //reenable viewer tooltips + jQuery.publish('enableTooltips.'+parent.windowId); + _this.osdViewer.zoomPerClick = 2; + _this.osdViewer.zoomPerScroll = 1.2; + }); + } + } + }); + return tooltip; + }, + + onDrawStart: function() { // use new $.oaAnnotation() to create new + // annotation and pass it around for updating + }, + + onModeEnter: function() { // do reasonable things to the renderer to make + // things intelligible + }, + + onModeExit: function() { + // do reasonable things to renderer to return to "normal". + }, + + onDraw: function() { + // update annotation + } + + // MIGHT BE NICE IF...: + // + // If the user is mid-drag and hits the side of the + // canvas, the canvas auto-pans and auto-zooms out + // to accomodate the rectangle. + // + // The size of the rectangle just before colliding with + // the canvas is auto-saved, so that the canvas can shrink + // back down again if the user starts shrinking it in + // mid-drag, allowing the auto-shrinking to stop when + // the original size of the rectangle is reached again. + // + // The existing rectangles should also be moveable by + // shift-clicking and dragging them, showing the + // cross-hair cursor type. + +// osdRegionRectTool = { +// enterEditMode: enterEditMode, +// exitEditMode: exitEditMode +// }; +// +// return osdRegionRectTool; + + }; +}(Mirador)); + +/* + * Edited version of https://github.com/IIIF/mirador/blob/9e3c6bbb894e044d01ad51aae1b70309939de5a9/js/src/annotations/catchEndpoint.js + * This module tries to store the annotation as is in a RDF store but some fiddeling is required. Fidles are: + * + * - delete annotation fails if id has a / in it so have to send sanatised ids to mirador + * - mirador requires an endpoint variable in the annotation pointing to this class. + * + * Note: this endpoint doesn't currently support authentication, just returns allow all + * + * All Endpoints need to have at least the following: + * annotationsList - current list of OA Annotations + * dfd - Deferred Object + * init() + * search(uri) + * create(oaAnnotation, returnSuccess, returnError) + * update(oaAnnotation, returnSuccess, returnError) + * deleteAnnotation(annotationID, returnSuccess, returnError) (delete is a reserved word) + * TODO: + * There is a bug in that if you create an annotation and then delete it (without moving pages) then click either the write annotation button + * or try to create a new annotation the deleted annotation re-appears. Changing pages fixes the issue as the annoation is delete from the annotation store + * + */ +(function($){ + + $.SimpleASEndpoint = function(options) { + + jQuery.extend(this, { + token: null, + // prefix: 'annotation', /**/ + uri: null, + url: options.url, + dfd: null, + annotationsList: [], //OA list for Mirador use + idMapper: {} // internal list for module use to map id to URI + }, options); + + this.init(); + }; + + $.SimpleASEndpoint.prototype = { + //Any set up for this endpoint, and triggers a search of the URI passed to object + init: function() { + this.catchOptions = { + user: { + id: this.userid, + name: this.username + }, + permissions: { + 'read': [], + 'update': [this.userid], + 'delete': [this.userid], + 'admin': [this.userid] + } + }; + this.search({ uri: this.uri }); + }, + + //Search endpoint for all annotations with a given URI + search: function(options, successCallback, errorCallback) { + var _this = this; + + this.annotationsList = []; //clear out current list + jQuery.ajax({ + url: _this.url + "/search", // this.prefix+ + type: 'GET', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: { + uri: options.uri, + media: "image", + limit: 10000 + }, + + contentType: "application/json; charset=utf-8", + success: function(data) { + if (typeof successCallback === "function") { + successCallback(data); + } else { + _this.annotationsList = data; // gmr + jQuery.each(_this.annotationsList, function(index, value) { + value.fullId = value["@id"]; + value["@id"] = $.genUUID(); + _this.idMapper[value["@id"]] = value.fullId; + value.endpoint = _this; + }); + _this.dfd.resolve(false); + } + }, + error: function() { + if (typeof errorCallback === "function") { + errorCallback(); + } else { + console.log("The request for annotations has caused an error for endpoint: "+ options.uri); + } + } + + }); + }, + + deleteAnnotation: function(annotationID, returnSuccess, returnError) { + var _this = this; + jQuery.ajax({ + url: _this.url + "/destroy?uri=" + _this.idMapper[annotationID], // this.prefix+ + type: 'DELETE', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: { + uri: annotationID, + }, + contentType: "application/json; charset=utf-8", + success: function(data) { + returnSuccess(); + }, + error: function() { + returnError(); + } + + }); + }, + + update: function(oaAnnotation, returnSuccess, returnError) { + var annotation = oaAnnotation, + _this = this; + // slashes don't work in JQuery.find which is used for delete + // so need to switch http:// id to full id and back again for delete. + shortId = annotation["@id"]; + annotation["@id"] = annotation.fullId; + annotationID = annotation.fullId;//annotation["@id"]; + delete annotation.fullId; + delete annotation.endpoint; + jQuery.ajax({ + url: _this.url + "/update/"+annotationID, //this.prefix+ + type: 'POST', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + /* this returned data doesn't seem to be used anywhere */ + returnSuccess(); + }, + error: function() { + returnError(); + } + }); + // this is what updates the viewer + annotation.endpoint = _this; + annotation.fullId = annotation["@id"]; + annotation["@id"] = shortId; + }, + + create: function(oaAnnotation, returnSuccess, returnError) { + var annotation = oaAnnotation, + _this = this; + + jQuery.ajax({ + url: _this.url + "/create", //this.prefix+ + type: 'POST', + dataType: 'json', + headers: { + //"x-annotator-auth-token": this.token + }, + data: JSON.stringify(annotation), + contentType: "application/json; charset=utf-8", + success: function(data) { + data.fullId = data["@id"]; + data["@id"] = $.genUUID(); + data.endpoint = _this; + _this.idMapper[data["@id"]] = data.fullId; + + returnSuccess(data); + }, + error: function() { + returnError(); + } + }); + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + userAuthorize: function(action, annotation) { + return true; // allow all + } + }; +}(Mirador)); + +(function($) { + + $.WorkspaceLockController = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WorkspaceLockController.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.Slot = function(options) { + + jQuery.extend(true, this, { + workspaceSlotCls: 'slot', + slotID: null, + layoutAddress: null, + focused: null, + appendTo: null, + parent: null, + window: null, + windowElement: null + }, options); + + this.init(); + + }; + + $.Slot.prototype = { + init: function () { + this.element = jQuery(this.template({ + workspaceSlotCls: this.workspaceSlotCls, + slotID: this.slotId + })); + this.element.appendTo(this.appendTo); + + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this, + dropTarget = this.element.find('.dropMask'); + + this.element.find('.addItemLink').on('click', function(){ _this.addItem(); }); + this.element.find('.remove-slot-option').on('click', function(){ + _this.parent.removeNode(_this); + }); + jQuery.subscribe('windowRemoved', function(event, id) { + if (_this.window && _this.window.id === id) { + // This prevents the save controller + // from attempting to re-save the window + // after having already removed it. + _this.clearSlot(); + } + }); + this.element.on('dragover', function(e) { + e.preventDefault(); + dropTarget.show(); + }); + dropTarget.on('dragenter', function(e) { + e.preventDefault(); + _this.element.addClass('draggedOver'); + }); + dropTarget.on('dragleave', function(e) { + e.preventDefault(); + _this.element.removeClass('draggedOver'); + dropTarget.hide(); + }); + this.element.on('drop', function(e) { + _this.dropItem(e); + }); + + jQuery.subscribe('layoutChanged', function(event, layoutRoot) { + if (_this.parent.slots.length <= 1) { + _this.element.find('.remove-slot-option').hide(); + } else { + _this.element.find('.remove-slot-option').show(); + } + + // Must reset the slotAddress of the window. + if (_this.window) { + _this.window.slotAddress = _this.layoutAddress; + jQuery.publish('windowSlotAddressUpdated', { + id: _this.window.id, + slotAddress: _this.window.slotAddress + }); + } + }); + }, + + dropItem: function(e) { + var _this = this; + + e.preventDefault(); + e.originalEvent.dataTransfer.items[0].getAsString(function(url){ + var manifestUrl = $.getQueryParams(url).manifest, + canvasId = $.getQueryParams(url).canvas, + imageInfoUrl = $.getQueryParams(url).image, + windowConfig; + + if (typeof $.viewer.manifests[manifestUrl] !== 'undefined') { + windowConfig = { + manifest: $.viewer.manifests[manifestUrl], + slotAddress: _this.getAddress() + }; + + if (canvasId) { + // If the canvasID is defined, we need to both add + // it to the windowConfig and tell it to open in + // image view. If we don't specify the focus, the + // window will open in thumbnail view with the + // chosen page highlighted. + windowConfig.currentCanvasID = canvasId; + windowConfig.currentFocus = 'ImageView'; + } + + $.viewer.workspace.addWindow(windowConfig); + + } else if (typeof imageInfoUrl !== 'undefined') { + if (!$.viewer.manifests[imageInfoUrl]) { + $.viewer.addManifestFromUrl(imageInfoUrl, "(Added from URL)"); + } + } else { + if (!$.viewer.manifests[imageInfoUrl]) { + $.viewer.addManifestFromUrl(manifestUrl, "(Added from URL)"); + } + } + + jQuery.subscribe('manifestReceived', function(event, manifest) { + var windowConfig; + if (manifest.jsonLd['@id'] === manifestUrl || manifest.jsonLd['@id']+'/info.json' === imageInfoUrl) { + // There are many manifests that may be received + // while we are waiting for this one, so we + // need to make sure the event actually refers to the + // manifest we've just dropped. + + windowConfig = { + manifest: manifest, + slotAddress: _this.getAddress() + }; + + if (manifest.jsonLd['@id']+'/info.json' === imageInfoUrl) { + // If this was added from a naked info.json, pick the + // first (and only) page from the synthetic manifest. + canvasId = manifest.jsonLd.sequences[0].canvases[0]['@id']; + } + + if (canvasId) { + // If the canvasID is defined, we need to both add + // it to the windowConfig and tell it to open in + // image view. If we don't specify the focus, the + // window will open in thumbnail view with the + // chosen page highlighted. + windowConfig.currentCanvasID = canvasId; + windowConfig.currentFocus = 'ImageView'; + } + + $.viewer.workspace.addWindow(windowConfig); + } + }); + }); + }, + + clearSlot: function() { + if (this.window) { + this.window.element.remove(); + delete this.window; + } + }, + + getAddress: function() { + return this.layoutAddress; + }, + + addItem: function() { + var _this = this; + _this.focused = true; + + _this.parent.addItem(_this); + }, + + // template should be based on workspace type + template: Handlebars.compile([ + '
              ', + '
              ', + // '', + // '', + // '', + // accessbility-wise it's really bad practice to have h1 tags be used like this + // most screen reader users get a sense of where they are based on header tags + // if these are merely h1 tags for aesthetic purposes, it might be better to make them specific classes + '

              ', + '+', + '
              ', + '', + '
              ', + '

              ', + '

              {{t "addItem"}}

              ', + '

              Drop to Load Manifest

              ', + '
              ', + '', + ' {{t "close"}}', + '', + '
              ' + ].join('')) + }; + +}(Mirador)); + + +(function($) { + + $.Window = function(options) { + + jQuery.extend(this, { + element: null, + scrollImageRatio: 0.9, + manifest: null, + currentCanvasID: null, + focusImages: [], + imagesList: null, + annotationsList: [], + endpoint: null, + slotAddress: null, + currentImageMode: 'ImageView', + imageModes: ['ImageView', 'BookView'], + currentFocus: 'ThumbnailsView', + focusesOriginal: ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], + focuses: ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], + focusModules: {'ThumbnailsView': null, 'ImageView': null, 'ScrollView': null, 'BookView': null}, + focusOverlaysAvailable: { + 'ThumbnailsView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'' : false} + }, + 'ImageView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'ThumbnailsView' : true} + }, + 'ScrollView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'' : false} + }, + 'BookView': { + 'overlay' : {'MetadataView' : false}, + 'bottomPanel' : {'ThumbnailsView' : true} + } + }, + focusOptions: null, + id : null, + sidePanel: null, //the actual module for the side panel + sidePanelAvailable: true, + sidePanelOptions: { + "toc" : true, + "annotations" : false + }, + sidePanelVisible: true, + annotationsAvailable: { + 'ThumbnailsView' : false, + 'ImageView' : true, + 'ScrollView' : false, + 'BookView' : false + }, + bottomPanel: null, //the actual module for the bottom panel + bottomPanelAvailable: true, + bottomPanelVisible: true, + overlay: null, + annotationLayerAvailable: true, + annotationCreationAvailable: true, + annoEndpointAvailable : false, + annotationState : 'annoOff', + fullScreenAvailable : true, + displayLayout: true, + layoutOptions : { + "newObject" : true, + "close" : true, + "slotRight" : true, + "slotLeft" : true, + "slotAbove" : true, + "slotBelow" : true + } + }, options); + + this.init(); + this.bindAnnotationEvents(); + + }; + + $.Window.prototype = { + init: function () { + var _this = this, + manifest = _this.manifest.jsonLd, + focusState = _this.currentFocus, + templateData = {}; + + //make sure annotations list is cleared out when changing objects within window + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + //unsubscribe from stale events as they will be updated with new module calls + jQuery.unsubscribe(('currentCanvasIDUpdated.' + _this.id)); + + _this.removeBookView(); + + //remove any imageModes that are not available as a focus + this.imageModes = jQuery.map(this.imageModes, function(value, index) { + if (jQuery.inArray(value, _this.focuses) === -1) return null; + return value; + }); + + _this.imagesList = _this.manifest.getCanvases(); + if (!_this.currentCanvasID) { + _this.currentCanvasID = _this.imagesList[0]['@id']; + } + + this.annoEndpointAvailable = !jQuery.isEmptyObject($.viewer.annotationEndpoint); + if (!this.annotationLayerAvailable) { + this.annotationCreationAvailable = false; + this.annoEndpointAvailable = false; + this.annotationState = 'annoOff'; + } + _this.getAnnotations(); + + //check config + if (typeof this.bottomPanelAvailable !== 'undefined' && !this.bottomPanelAvailable) { + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].bottomPanel = {'' : false}; + }); + } + + templateData.sidePanel = this.sidePanelAvailable; + if (this.sidePanelAvailable) { + templateData.sidePanel = !Object.keys(this.sidePanelOptions).every(function(element, index, array) { + return _this.sidePanelOptions[element] === false; + }); + } + if (typeof this.overlayAvailable !== 'undefined' && !this.overlayAvailable) { + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].overlay = {'' : false}; + }); + } else { + templateData.MetadataView = true; + } + + //determine if any buttons should be hidden in template + jQuery.each(this.focuses, function(index, value) { + templateData[value] = true; + }); + templateData.title = manifest.label; + templateData.displayLayout = this.displayLayout; + templateData.layoutOptions = this.layoutOptions; + // if displayLayout is true, but all individual options are set to false, set displayLayout to false + if (this.displayLayout) { + templateData.displayLayout = !Object.keys(this.layoutOptions).every(function(element, index, array) { + return _this.layoutOptions[element] === false; + }); + } + _this.element = jQuery(this.template(templateData)).appendTo(_this.appendTo); + + //clear any existing objects + _this.clearViews(); + _this.clearPanelsAndOverlay(); + + //attach view and toggle view, which triggers the attachment of panels or overlays + _this.bindNavigation(); + switch(focusState) { + case 'ThumbnailsView': + _this.toggleThumbnails(_this.currentCanvasID); + break; + case 'ImageView': + _this.toggleImageView(_this.currentCanvasID); + break; + case 'BookView': + _this.toggleBookView(_this.currentCanvasID); + break; + case 'ScrollView': + _this.toggleScrollView(_this.currentCanvasID); + break; + default: + break; + } + + if ($.viewer.workspace.slots.length <= 1) { + _this.element.find('.remove-object-option').hide(); + } + + this.bindEvents(); + + if (this.imagesList.length === 1) { + this.bottomPanelVisibility(false); + } else { + this.bottomPanelVisibility(this.bottomPanelVisible); + } + this.sidePanelVisibility(this.sidePanelVisible, '0s'); + }, + + update: function(options) { + jQuery.extend(this, options); + if (this.focusOptions) { + this.focusOptions.osdBounds = null; + this.focusOptions.zoomLevel = null; + } + this.init(); + }, + + // spawnInWorkspace: function() { + + // }, + + // reset whether BookView is available every time as a user might switch between paged and non-paged objects within a single slot/window + removeBookView: function() { + var _this = this; + this.focuses = this.focusesOriginal; + var manifest = this.manifest.jsonLd; + if (manifest.sequences[0].viewingHint) { + if (manifest.sequences[0].viewingHint.toLowerCase() !== 'paged') { + //disable bookview for this object because it's not a paged object + this.focuses = jQuery.grep(this.focuses, function(value) { + return value !== 'BookView'; + }); + } + } + }, + + bindEvents: function() { + var _this = this; + + //this event should trigger from layout + jQuery(window).resize($.debounce(function(){ + if (_this.focusModules.ScrollView) { + var containerHeight = _this.element.find('.view-container').height(); + var triggerShow = false; + if (_this.currentFocus === "ScrollView") { + triggerShow = true; + } + _this.focusModules.ScrollView.reloadImages(Math.floor(containerHeight * _this.scrollImageRatio), triggerShow); + } + }, 300)); + + jQuery.subscribe('bottomPanelSet.' + _this.id, function(event, visible) { + var panel = _this.element.find('.bottomPanel'); + if (visible === true) { + panel.css({transform: 'translateY(0)'}); + } else { + panel.css({transform: 'translateY(100%)'}); + } + }); + + jQuery.subscribe('layoutChanged', function(event, layoutRoot) { + if ($.viewer.workspace.slots.length <= 1) { + _this.element.find('.remove-object-option').hide(); + } else { + _this.element.find('.remove-object-option').show(); + } + }); + + jQuery.subscribe('sidePanelStateUpdated.' + this.id, function(event, state) { + if (state.open) { + _this.element.find('.fa-list').switchClass('fa-list', 'fa-caret-down'); + _this.element.find('.mirador-icon-toc').addClass('selected'); + _this.element.find('.view-container').removeClass('maximised'); + } else { + _this.element.find('.mirador-icon-toc').removeClass('selected'); + _this.element.find('.fa-caret-down').switchClass('fa-caret-down', 'fa-list'); + _this.element.find('.view-container').addClass('maximised'); + } + }); + + // TODO: temporary logic to minimize side panel if only tab is toc and toc is empty + jQuery.subscribe('sidePanelVisibilityByTab.' + this.id, function(event, visible) { + _this.sidePanelVisibility(visible, '0s'); + }); + + }, + + bindAnnotationEvents: function() { + var _this = this; + jQuery.subscribe('annotationCreated.'+_this.id, function(event, oaAnno, osdOverlay) { + var annoID; + //first function is success callback, second is error callback + _this.endpoint.create(oaAnno, function(data) { + //the success callback expects the OA annotation be returned + annoID = String(data['@id']); //just in case it returns a number + _this.annotationsList.push(data); + //update overlay so it can be a part of the annotationList rendering + jQuery(osdOverlay).removeClass('osd-select-rectangle').addClass('annotation').attr('id', annoID); + jQuery.publish(('annotationListLoaded.' + _this.id)); + }, + function() { + //provide useful feedback to user + console.log("There was an error saving this new annotation"); + //remove this overlay because we couldn't save annotation + jQuery(osdOverlay).remove(); + }); + }); + + jQuery.subscribe('annotationUpdated.'+_this.id, function(event, oaAnno) { + //first function is success callback, second is error callback + _this.endpoint.update(oaAnno, function() { + jQuery.each(_this.annotationsList, function(index, value) { + if (value['@id'] === oaAnno['@id']) { + _this.annotationsList[index] = oaAnno; + return false; + } + }); + jQuery.publish(('annotationListLoaded.' + _this.id)); + }, + function() { + console.log("There was an error updating this annotation"); + }); + }); + + jQuery.subscribe('annotationDeleted.'+_this.id, function(event, annoId) { + //remove from endpoint + //first function is success callback, second is error callback + _this.endpoint.deleteAnnotation(annoId, function() { + _this.annotationsList = jQuery.grep(_this.annotationsList, function(e){ return e['@id'] !== annoId; }); + jQuery.publish(('annotationListLoaded.' + _this.id)); + jQuery.publish(('removeOverlay.' + _this.id), annoId); + }, + function() { + // console.log("There was an error deleting this annotation"); + }); + }); + + jQuery.subscribe('updateAnnotationList.'+_this.id, function(event) { + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + _this.getAnnotations(); + }); + }, + + clearViews: function() { + var _this = this; + jQuery.each(_this.focusModules, function(key, value) { + _this.focusModules[key] = null; + }); + }, + + clearPanelsAndOverlay: function() { + this.sidePanel = null; + this.bottomPanel = null; + this.overlay = null; + }, + + // only panels and overlay available to this view, make rest hidden while on this view + updatePanelsAndOverlay: function(state) { + var _this = this; + + jQuery.each(this.focusOverlaysAvailable[state], function(panelType, viewOptions) { + jQuery.each(viewOptions, function(view, displayed) { + //instantiate any panels that exist for this view but are still null + if (view !== '' && _this[panelType] === null) { + _this[panelType] = new $[view]({ + manifest: _this.manifest, + appendTo: _this.element.find('.'+panelType), + parent: _this, + panel: true, + canvasID: _this.currentCanvasID, + imagesList: _this.imagesList, + thumbInfo: {thumbsHeight: 80, listingCssCls: 'panel-listing-thumbs', thumbnailCls: 'panel-thumbnail-view'} + }); + } + + //refresh displayed in case TableOfContents module changed it + displayed = _this.focusOverlaysAvailable[state][panelType][view]; + + //toggle any valid panels + if (view !== '' && displayed) { + _this.togglePanels(panelType, displayed, view, state); + } + + //hide any panels instantiated but not available to this view + if (view === '' && _this[panelType]) { + _this.togglePanels(panelType, displayed, view, state); + } + + //lastly, adjust height for non-existent panels + if (view === '') { + _this.adjustFocusSize(panelType, displayed); + } + + //update current image for all valid panels + }); + }); + + //update panels with current image + if (this.bottomPanel) { this.bottomPanel.updateFocusImages(this.focusImages); } + }, + + updateSidePanel: function() { + if (!this.sidePanelAvailable) { + return; + } + var _this = this, + tocAvailable = _this.sidePanelOptions.toc, + annotationsTabAvailable = _this.sidePanelOptions.annotations, + hasStructures = true; + + var structures = _this.manifest.getStructures(); + if (!structures || structures.length === 0) { + hasStructures = false; + } + + if (this.sidePanel === null) { + this.sidePanel = new $.SidePanel({ + parent: _this, + appendTo: _this.element.find('.sidePanel'), + manifest: _this.manifest, + canvasID: _this.currentCanvasID, + tocTabAvailable: tocAvailable, + annotationsTabAvailable: annotationsTabAvailable, + hasStructures: hasStructures + }); + } else { + this.sidePanel.update('annotations', annotationsTabAvailable); + } + }, + + get: function(prop, parent) { + if (parent) { + return this[parent][prop]; + } + return this[prop]; + }, + + set: function(prop, value, options) { + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + }, + + /*setTOCBoolean: function(boolValue) { + var _this = this; + jQuery.each(this.focusOverlaysAvailable, function(key, value) { + _this.focusOverlaysAvailable[key].sidePanel.TableOfContents = boolValue; + }); + //remove thumbnail icon if not available for this object + if (!boolValue) { + this.element.find('.mirador-icon-toc').hide(); + } + },*/ + + togglePanels: function(panelType, panelState, viewType, focusState) { + //update state in focusOverlaysAvailable + this.focusOverlaysAvailable[focusState][panelType][viewType] = panelState; + this[panelType].toggle(panelState); + this.adjustFocusSize(panelType, panelState); + }, + + sidePanelVisibility: function(visible, transitionDuration) { + var _this = this; + _this.sidePanelVisible = visible, + tocIconElement = this.element.find('.mirador-icon-toc'), + sidePanelElement = this.element.find('.sidePanel'), + viewContainerElement = this.element.find('.view-container'); + + sidePanelElement.css('transition-duration', transitionDuration); + viewContainerElement.css('transition', transitionDuration); + if (visible && sidePanelElement.hasClass('minimized')) { + tocIconElement.find('.fa-list').switchClass('fa-list', 'fa-caret-down'); + tocIconElement.addClass('selected').css('background','#efefef'); + sidePanelElement.removeClass('minimized').width(280).css('border-right', '1px solid lightgray'); + viewContainerElement.css('margin-left', 280); + } else if (!visible && !sidePanelElement.hasClass('minimized')) { + tocIconElement.find('.fa-caret-down').switchClass('fa-caret-down', 'fa-list'); + tocIconElement.removeClass('selected').css('background', '#fafafa'); + viewContainerElement.css('margin-left', 0); + sidePanelElement.addClass('minimized').css('border', 'none').width(0); + } + jQuery.publish(('windowUpdated'), { + id: _this.id, + sidePanelVisible: visible + }); + }, + + bottomPanelVisibility: function(visible) { + var _this = this; + _this.bottomPanelVisible = visible; + jQuery.publish(('bottomPanelSet.' + _this.id), visible); + jQuery.publish(('windowUpdated'), { + id: _this.id, + bottomPanelVisible: visible + }); + }, + + adjustFocusSize: function(panelType, panelState) { + if (panelType === 'bottomPanel') { + this.focusModules[this.currentFocus].adjustHeight('focus-max-height', panelState); + } else if (panelType === 'sidePanel') { + this.focusModules[this.currentFocus].adjustWidth('focus-max-width', panelState); + } else {} + }, + + toggleMetadataOverlay: function(focusState) { + var _this = this; + var currentState = this.focusOverlaysAvailable[focusState].overlay.MetadataView; + if (currentState) { + this.element.find('.mirador-icon-metadata-view').removeClass('selected'); + } else { + this.element.find('.mirador-icon-metadata-view').addClass('selected'); + } + //set overlay for all focus types to same value + jQuery.each(this.focusOverlaysAvailable, function(focusType, options) { + if (focusState !== focusType) { + this.overlay.MetadataView = !currentState; + } + }); + //and then do toggling for current focus + this.togglePanels('overlay', !currentState, 'MetadataView', focusState); + }, + + toggleFocus: function(focusState, imageMode) { + var _this = this; + + this.currentFocus = focusState; + if (imageMode && jQuery.inArray(imageMode, this.imageModes) > -1) { + this.currentImageMode = imageMode; + } + //set other focusStates to false (toggle to display none) + jQuery.each(this.focusModules, function(focusKey, module) { + if (module && focusState !== focusKey) { + module.toggle(false); + } + }); + this.focusModules[focusState].toggle(true); + this.updateManifestInfo(); + this.updatePanelsAndOverlay(focusState); + this.updateSidePanel(); + jQuery.publish("focusUpdated"); + jQuery.publish("windowUpdated", { + id: _this.id, + viewType: _this.currentFocus, + canvasID: _this.currentCanvasID, + imageMode: _this.currentImageMode, + loadedManifest: _this.manifest.jsonLd['@id'], + slotAddress: _this.slotAddress + }); + }, + + toggleThumbnails: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ThumbnailsView === null) { + this.focusModules.ThumbnailsView = new $.ThumbnailsView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + canvasID: this.currentCanvasID, + imagesList: this.imagesList + }); + } else { + var view = this.focusModules.ThumbnailsView; + view.updateImage(canvasID); + } + this.toggleFocus('ThumbnailsView', ''); + }, + + toggleImageView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ImageView === null) { + this.focusModules.ImageView = new $.ImageView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + windowId: this.id, + canvasID: canvasID, + imagesList: this.imagesList, + osdOptions: this.focusOptions, + bottomPanelAvailable: this.bottomPanelAvailable, + annotationLayerAvailable: this.annotationLayerAvailable, + annotationCreationAvailable: this.annotationCreationAvailable, + annoEndpointAvailable: this.annoEndpointAvailable, + annotationState : this.annotationState, + fullScreenAvailable: this.fullScreenAvailable + }); + } else { + var view = this.focusModules.ImageView; + view.updateImage(canvasID); + } + this.toggleFocus('ImageView', 'ImageView'); + }, + + toggleBookView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.BookView === null) { + this.focusModules.BookView = new $.BookView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + windowId: this.id, + canvasID: canvasID, + imagesList: this.imagesList, + osdOptions: this.focusOptions, + bottomPanelAvailable: this.bottomPanelAvailable, + fullScreenAvailable: this.fullScreenAvailable + }); + } else { + var view = this.focusModules.BookView; + view.updateImage(canvasID); + } + this.toggleFocus('BookView', 'BookView'); + }, + + toggleScrollView: function(canvasID) { + this.currentCanvasID = canvasID; + if (this.focusModules.ScrollView === null) { + var containerHeight = this.element.find('.view-container').height(); + this.focusModules.ScrollView = new $.ScrollView({ + manifest: this.manifest, + appendTo: this.element.find('.view-container'), + parent: this, + canvasID: this.currentCanvasID, + imagesList: this.imagesList, + thumbInfo: {thumbsHeight: Math.floor(containerHeight * this.scrollImageRatio), listingCssCls: 'scroll-listing-thumbs', thumbnailCls: 'scroll-view'} + }); + } else { + var view = this.focusModules.ScrollView; + view.updateImage(canvasID); + } + this.toggleFocus('ScrollView', ''); + }, + + updateFocusImages: function(imageList) { + this.focusImages = imageList; + }, + + setCurrentCanvasID: function(canvasID) { + var _this = this; + this.currentCanvasID = canvasID; + jQuery.publish('removeTooltips.' + _this.id); + jQuery.unsubscribe(('annotationListLoaded.' + _this.id)); + while(_this.annotationsList.length > 0) { + _this.annotationsList.pop(); + } + this.getAnnotations(); + switch(this.currentImageMode) { + case 'ImageView': + this.toggleImageView(this.currentCanvasID); + break; + case 'BookView': + this.toggleBookView(this.currentCanvasID); + break; + default: + break; + } + jQuery.publish(('currentCanvasIDUpdated.' + _this.id), canvasID); + }, + + replaceWindow: function(newSlotAddress, newElement) { + this.slotAddress = newSlotAddress; + this.appendTo = newElement; + this.update(); + }, + + setCursorFrameStart: function(canvasID) { + }, + + updateManifestInfo: function() { + var _this = this; + this.element.find('.window-manifest-navigation').children().removeClass('selected'); + switch(_this.currentFocus) { + case 'ThumbnailsView': + //hide thumbnails button and highlight currentImageMode? + _this.element.find('.mirador-icon-thumbs-view').addClass('selected'); + break; + case 'ImageView': + //highlight Single Image View option + _this.element.find('.mirador-icon-image-view').addClass('selected'); + break; + case 'BookView': + //highlight Book View option + _this.element.find('.mirador-icon-image-view').addClass('selected'); + break; + case 'ScrollView': + //highlight Scroll View option + _this.element.find('.mirador-icon-thumbs-view').addClass('selected'); + break; + default: + break; + } + + if (this.focusOverlaysAvailable[this.currentFocus].overlay.MetadataView) { + this.element.find('.mirador-icon-metadata-view').addClass('selected'); + } + }, + + /* + Merge all annotations for current image/canvas from various sources + Pass to any widgets that will use this list + */ + getAnnotations: function() { + //first look for manifest annotations + var _this = this, + url = _this.manifest.getAnnotationsListUrl(_this.currentCanvasID); + + if (url !== false) { + jQuery.get(url, function(list) { + _this.annotationsList = _this.annotationsList.concat(list.resources); + jQuery.each(_this.annotationsList, function(index, value) { + //if there is no ID for this annotation, set a random one + if (typeof value['@id'] === 'undefined') { + value['@id'] = $.genUUID(); + } + //indicate this is a manifest annotation - which affects the UI + value.endpoint = "manifest"; + }); + jQuery.publish('annotationListLoaded.' + _this.id); + }); + } + + // next check endpoint + if (this.annoEndpointAvailable) { + var dfd = jQuery.Deferred(), + module = $.viewer.annotationEndpoint.module, + options = $.viewer.annotationEndpoint.options; //grab anything from the config that should be passed directly to the endpoint + options.name = $.viewer.annotationEndpoint.name; + // One annotation endpoint per window, the endpoint + // is a property of the instance. + if ( _this.endpoint && _this.endpoint !== null ) { + _this.endpoint.set('dfd', dfd); + } else { + options.dfd = dfd; + options.windowID = _this.id; + options.parent = _this; + _this.endpoint = new $[module](options); + } + _this.endpoint.search({ "uri" : _this.currentCanvasID}); + + dfd.done(function(loaded) { + _this.annotationsList = _this.annotationsList.concat(_this.endpoint.annotationsList); + // clear out some bad data + _this.annotationsList = jQuery.grep(_this.annotationsList, function (value, index) { + if (typeof value.on === "undefined") { + return false; + } + return true; + }); + jQuery.publish('annotationListLoaded.' + _this.id); + }); + } + }, + + // based on currentFocus + bindNavigation: function() { + var _this = this; + + this.element.find('.mirador-icon-image-view').on('mouseenter', + function() { + _this.element.find('.image-list').stop().slideFadeToggle(300); + }).on('mouseleave', + function() { + _this.element.find('.image-list').stop().slideFadeToggle(300); + }); + + this.element.find('.mirador-icon-window-menu').on('mouseenter', + function() { + _this.element.find('.slot-controls').stop().slideFadeToggle(300); + }).on('mouseleave', + function() { + _this.element.find('.slot-controls').stop().slideFadeToggle(300); + }); + + this.element.find('.single-image-option').on('click', function() { + _this.toggleImageView(_this.currentCanvasID); + }); + + this.element.find('.book-option').on('click', function() { + _this.toggleBookView(_this.currentCanvasID); + }); + + this.element.find('.scroll-option').on('click', function() { + _this.toggleScrollView(_this.currentCanvasID); + }); + + this.element.find('.thumbnails-option').on('click', function() { + _this.toggleThumbnails(_this.currentCanvasID); + }); + + this.element.find('.mirador-icon-metadata-view').on('click', function() { + _this.toggleMetadataOverlay(_this.currentFocus); + }); + + this.element.find('.mirador-icon-toc').on('click', function() { + _this.sidePanelVisibility(!_this.sidePanelVisible, '0.3s'); + }); + + this.element.find('.new-object-option').on('click', function() { + _this.parent.addItem(); + }); + + this.element.find('.remove-object-option').on('click', function() { + $.viewer.workspace.removeNode(_this.parent); + }); + + this.element.find('.add-slot-right').on('click', function() { + $.viewer.workspace.splitRight(_this.parent); + }); + + this.element.find('.add-slot-left').on('click', function() { + $.viewer.workspace.splitLeft(_this.parent); + }); + + this.element.find('.add-slot-below').on('click', function() { + $.viewer.workspace.splitDown(_this.parent); + }); + + this.element.find('.add-slot-above').on('click', function() { + $.viewer.workspace.splitUp(_this.parent); + }); + }, + + // template should be based on workspace type + template: Handlebars.compile([ + '' + ].join('')) + }; + +}(Mirador)); + +(function($) { + + $.AnnotationsLayer = function(options) { + + jQuery.extend(true, this, { + parent: null, + annotationsList: null, + viewer: null, + renderer: null, + rectTool: null, + selected: null, + hovered: null, + windowId: null, + mode: 'default', + element: null + }, options); + + this.init(); + }; + + $.AnnotationsLayer.prototype = { + + init: function() { + var _this = this; + jQuery.unsubscribe(('modeChange.' + _this.windowId)); + + this.createRenderer(); + this.bindEvents(); + }, + + bindEvents: function() { + var _this = this; + + jQuery.subscribe('modeChange.' + _this.windowId, function(event, modeName) { + _this.mode = modeName; + _this.modeSwitch(); + }); + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + _this.annotationsList = _this.parent.parent.annotationsList; + _this.updateRenderer(); + }); + }, + + createRenderer: function() { + var _this = this; + this.renderer = new $.OsdCanvasRenderer({ + osd: $.OpenSeadragon, + osdViewer: _this.viewer, + list: _this.annotationsList, // must be passed by reference. + visible: false, + parent: _this + }); + this.modeSwitch(); + }, + + updateRenderer: function() { + this.renderer.list = this.annotationsList; + this.modeSwitch(); + }, + + modeSwitch: function() { + //console.log(this.mode); + if (this.mode === 'displayAnnotations') { this.enterDisplayAnnotations(); } + else if (this.mode === 'editingAnnotations') { this.enterEditAnnotations(); } + else if (this.mode === 'default') { this.enterDefault(); } + else {} + }, + + + enterDisplayAnnotations: function() { + var _this = this; + //console.log('triggering annotation loading and display'); + if (this.rectTool) { + this.rectTool.exitEditMode(); + } + this.renderer.render(); + }, + + enterEditAnnotations: function() { + var _this = this; + if (!this.rectTool) { + this.rectTool = new $.OsdRegionRectTool({ + osd: OpenSeadragon, + osdViewer: _this.viewer, + rectType: 'oa', // does not do anything yet. + parent: _this + }); + } else { + this.rectTool.reset(_this.viewer); + } + this.renderer.render(); + this.rectTool.enterEditMode(); + }, + + enterDefault: function() { + if (this.rectTool) { + this.rectTool.exitEditMode(); + } + this.renderer.hideAll(); + } + + }; + +}(Mirador)); + +(function($) { + + $.AnnotationsTab = function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + visible: null + }, options); + + this.init(); + }; + + $.AnnotationsTab.prototype = { + init: function() { + var _this = this; + this.windowId = this.parent.id; + + this.state({ + id: 'annotationsTab', + visible: this.visible, + annotationLists: [], + selectedList: null, + empty: true, + focusedList: null + }, true); + + this.listenForActions(); + this.render(this.state()); + this.loadTabComponents(); + this.bindEvents(); + }, + state: function(state, initial) { + if (!arguments.length) return this.annoTabState; + this.annoTabState = state; + + if (!initial) { + jQuery.publish('annotationsTabStateUpdated.' + this.windowId, this.annoTabState); + } + + return this.annoTabState; + }, + loadTabComponents: function() { + var _this = this; + + }, + tabStateUpdated: function(visible) { + var state = this.state(); + state.visible = state.visible ? false : true; + + this.state(state); + }, + annotationListLoaded: function() { + var _this = this, + annotationSources = [], + state = this.state(); + for(var i = 0; i < _this.parent.annotationsList.length; i++) + { + + if(typeof _this.parent.annotationsList[i].endpoint === 'string'){ + + annotationSources.push('manifest'); + + }else{ + + annotationSources.push(_this.parent.annotationsList[i].endpoint.name); + + } + + } + + // make unique + annotationSources = annotationSources.filter(function(itm,i,annotationSources){ + return i==annotationSources.indexOf(itm); + }); + + state.annotationLists = annotationSources.map(function(annotationSource) { + //var s = (annotationSource === state.selectedList ? true : false); + return { + annotationSource: annotationSource, + layer: null, + selected: (annotationSource === state.selectedList ? true : false), + focused: false + }; + }); + + if(state.annotationLists.length){ + state.empty = false; + } + + this.state(state); + }, + deselectList: function(listId) { + var _this = this; + var state = this.state(); + state.selectedList = null; + state.annotationLists.forEach(function(list){ list.selected = false; }); + this.state(state); + }, + selectList: function(listId) { + var _this = this; + var state = this.state(); + state.selectedList = listId; + state.annotationLists.forEach(function(list){ list.selected = list.annotationSource === listId ? true : false; }); + this.state(state); + }, + focusList: function(listId) { + var state = this.state(); + state.focusedList = listId; + state.annotationLists.forEach(function(list){ list.focused = list.annotationSource === listId ? true : false;}); + this.state(state); + }, + toggle: function() {}, + listenForActions: function() { + var _this = this; + + jQuery.subscribe('annotationsTabStateUpdated.' + _this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('tabStateUpdated.' + _this.windowId, function(_, data) { + _this.tabStateUpdated(data.annotationsTab); + }); + + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(_, data) { + _this.annotationListLoaded(); + }); + + jQuery.subscribe('currentCanvasIDUpdated.' + _this.windowId, function(event) { + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + _this.annotationListLoaded(); + }); + + _this.selectList(_this.state().selectedList); + + }); + + jQuery.subscribe('listSelected.' + _this.windowId, function(event, listId) { + _this.selectList(listId); + }); + + jQuery.subscribe('listDeselected.' + _this.windowId, function(event, listId) { + _this.deselectList(listId); + }); + + }, + bindEvents: function() { + var _this = this, + listItems = this.element.find('.annotationListItem'); + + listItems.on('click', function(event) { + //event.stopImmediatePropagation(); + var listClicked = jQuery(this).data('id'); + if(_this.state().selectedList === listClicked){ + //_this.deselectList(listClicked); + jQuery.publish('listDeselected.' + _this.windowId, listClicked); + }else{ + //_this.selectList(listClicked); + jQuery.publish('listSelected.' + _this.windowId, listClicked); + } + + }); + + }, + render: function(state) { + var _this = this, + templateData = { + annotationSources: state.annotationLists + }; + if (!this.element) { + this.element = jQuery(_this.template(templateData)).appendTo(_this.appendTo); + } else { + _this.appendTo.find(".annotationsPanel").remove(); + this.element = jQuery(_this.template(templateData)).appendTo(_this.appendTo); + } + _this.bindEvents(); + + + if (state.visible) { + this.element.show(); + } else { + this.element.hide(); + } + }, + template: Handlebars.compile([ + '
              ', + '
                ', + '{{#each annotationSources}}', + '
              • ', + '{{this.annotationSource}}', + '
              • ', + '{{/each}}', + '
              ', + '
              ', + ].join('')) + }; + +}(Mirador)); + +(function($) { + + $.BookView = function(options) { + + jQuery.extend(this, { + currentImg: null, + windowId: null, + currentImgIndex: 0, + stitchList: [], + canvasID: null, + imagesList: [], + element: null, + focusImages: [], + manifest: null, + viewingDirection: 'left-to-right', + viewingHint: 'paged', + osd: null, + osdCls: 'mirador-osd', + osdOptions: { + osdBounds: null, + zoomLevel: null + }, + parent: null, + stitchTileMargin: 10 + }, options); + + this.init(); + }; + + + $.BookView.prototype = { + + init: function() { + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + if (!this.osdOptions) { + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + } + + this.currentImg = this.imagesList[this.currentImgIndex]; + + this.element = jQuery(this.template()).appendTo(this.appendTo); + this.hud = new $.Hud({ + parent: this, + element: this.element, + bottomPanelAvailable: this.bottomPanelAvailable, + windowId: this.windowId, + annotationLayerAvailable: false, + fullScreenAvailable : this.fullScreenAvailable + }); + + if (this.manifest.jsonLd.sequences[0].viewingDirection) { + this.viewingDirection = this.manifest.jsonLd.sequences[0].viewingDirection.toLowerCase(); + } + if (this.manifest.jsonLd.sequences[0].viewingHint) { + this.viewingHint = this.manifest.jsonLd.sequences[0].viewingHint.toLowerCase(); + } + + this.stitchList = this.getStitchList(); + this.createOpenSeadragonInstance(); + }, + + template: Handlebars.compile([ + '
              ', + '
              ' + ].join('')), + + setBounds: function() { + var _this = this; + this.osdOptions.osdBounds = this.osd.viewport.getBounds(true); + jQuery.publish("imageBoundsUpdated", { + id: _this.parent.id, + osdBounds: { + x: _this.osdOptions.osdBounds.x, + y: _this.osdOptions.osdBounds.y, + width: _this.osdOptions.osdBounds.width, + height: _this.osdOptions.osdBounds.height + } + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + }, + + updateImage: function(canvasID) { + this.canvasID = canvasID; + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + this.currentImg = this.imagesList[this.currentImgIndex]; + var newList = this.getStitchList(); + var is_same = this.stitchList.length == newList.length && this.stitchList.every(function(element, index) { + return element === newList[index]; + }); + if (!is_same) { + this.stitchList = newList; + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + this.osd.close(); + this.createOpenSeadragonInstance(); + } + }, + + createOpenSeadragonInstance: function() { + var uniqueID = $.genUUID(), + osdId = 'mirador-osd-' + uniqueID, + osdToolBarId = osdId + '-toolbar', + elemOsd, + tileSources = [], + _this = this, + toolbarID = 'osd-toolbar-' + uniqueID, + dfd = jQuery.Deferred(); + + this.element.find('.' + this.osdCls).remove(); + + jQuery.each(this.stitchList, function(index, image) { + var imageUrl = $.Iiif.getImageUrl(image), + infoJsonUrl = imageUrl + '/info.json'; + + jQuery.getJSON(infoJsonUrl).done(function (data, status, jqXHR) { + tileSources.splice(index, 0, data); + if (tileSources.length === _this.stitchList.length ) { dfd.resolve(); } + }); + }); + + dfd.done(function () { + var aspectRatio = tileSources[0].height / tileSources[0].width; + + elemOsd = + jQuery('
              ') + .addClass(_this.osdCls) + .attr('id', osdId) + .appendTo(_this.element); + + _this.osd = $.OpenSeadragon({ + 'id': elemOsd.attr('id'), + 'toolbarID' : toolbarID + }); + + _this.osd.addHandler('open', function(){ + _this.addLayer(tileSources.slice(1), aspectRatio); + var addItemHandler = function( event ) { + _this.osd.world.removeHandler( "add-item", addItemHandler ); + if (_this.osdOptions.osdBounds) { + var rect = new OpenSeadragon.Rect(_this.osdOptions.osdBounds.x, _this.osdOptions.osdBounds.y, _this.osdOptions.osdBounds.width, _this.osdOptions.osdBounds.height); + _this.osd.viewport.fitBounds(rect, true); + } else { + _this.osd.viewport.goHome(true); + } + }; + + _this.osd.world.addHandler( "add-item", addItemHandler ); + + _this.osd.addHandler('zoom', $.debounce(function(){ + _this.setBounds(); + }, 300)); + + _this.osd.addHandler('pan', $.debounce(function(){ + _this.setBounds(); + }, 300)); + }); + + _this.osd.open(tileSources[0], {opacity:1, x:0, y:0, width:1}); + }); + + }, + + addLayer: function(tileSources, aspectRatio) { + var _this = this; + jQuery.each(tileSources, function(index, value) { + var newAR = (value.height / value.width); + var options = { + tileSource: value, + opacity: 1, + x: 1.01, + y: 0, + width: aspectRatio / newAR + }; + _this.osd.addTiledImage(options); + }); + }, + + // next two pages for paged objects + // need next single page for lining pages up + // don't need for continuous or individuals + next: function() { + var next; + if (this.currentImgIndex % 2 === 0) { + next = this.currentImgIndex + 1; + } else { + next = this.currentImgIndex + 2; + } + if (next < this.imagesList.length) { + this.parent.setCurrentCanvasID(this.imagesList[next]['@id']); + } + }, + + // previous two pages for paged objects + // need previous single page for lining things up + // don't need for continuous or individuals + previous: function() { + var prev; + if (this.currentImgIndex % 2 === 0) { + prev = this.currentImgIndex - 2; + } else { + prev = this.currentImgIndex - 1; + } + if (prev >= 0) { + this.parent.setCurrentCanvasID(this.imagesList[prev]['@id']); + } + }, + + getStitchList: function() { + // Need to check metadata for object type and viewing direction + // Default to 'paged' and 'left-to-right' + // Set index(es) for any other images to stitch with selected image + var stitchList = [], + leftIndex = [], + rightIndex = [], + topIndex = [], + bottomIndex = [], + _this = this; + + this.focusImages = []; + + if (this.viewingHint === 'individuals') { + // don't do any stitching, display like an imageView + stitchList = [this.currentImg]; + } else if (this.viewingHint === 'paged') { + // determine the other image for this pair based on index and viewingDirection + if (this.currentImgIndex === 0 || this.currentImgIndex === this.imagesList.length-1) { + //first page (front cover) or last page (back cover), display on its own + stitchList = [this.currentImg]; + } else if (this.currentImgIndex % 2 === 0) { + // even, get previous page. set order in array based on viewingDirection + switch (this.viewingDirection) { + case "left-to-right": + leftIndex[0] = this.currentImgIndex-1; + stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg]; + break; + case "right-to-left": + rightIndex[0] = this.currentImgIndex-1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]]; + break; + case "top-to-bottom": + topIndex[0] = this.currentImgIndex-1; + stitchList = [this.imagesList[this.currentImgIndex-1], this.currentImg]; + break; + case "bottom-to-top": + bottomIndex[0] = this.currentImgIndex-1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex-1]]; + break; + default: + break; + } + } else { + // odd, get next page + switch (this.viewingDirection) { + case "left-to-right": + rightIndex[0] = this.currentImgIndex+1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]]; + break; + case "right-to-left": + leftIndex[0] = this.currentImgIndex+1; + stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg]; + break; + case "top-to-bottom": + bottomIndex[0] = this.currentImgIndex+1; + stitchList = [this.currentImg, this.imagesList[this.currentImgIndex+1]]; + break; + case "bottom-to-top": + topIndex[0] = this.currentImgIndex+1; + stitchList = [this.imagesList[this.currentImgIndex+1], this.currentImg]; + break; + default: + break; + } + } + } else if (this.viewingHint === 'continuous') { + // TODO: stitch all images together per the viewingDirection + } else { + // undefined viewingHint, don't do anything + } + + //set the focusImages for highlighting in panels + jQuery.each(stitchList, function(index, image) { + _this.focusImages.push(image['@id']); + }); + this.parent.updateFocusImages(this.focusImages); + return stitchList; + } + }; + +}(Mirador)); + +(function($) { + + $.ContextControls = function(options) { + + jQuery.extend(this, { + parent: null, //hud + element: null, + container: null, + mode: null, + windowId: null, + annoEndpointAvailable: false, + annotationCreationAvailable: true + }, options); + + this.init(); + }; + + $.ContextControls.prototype = { + + init: function() { + this.element = jQuery(this.template({ + showEdit : this.annotationCreationAvailable + })).appendTo(this.container); + this.hide(); + this.bindEvents(); + }, + + show: function() { + this.element.fadeIn("200"); + }, + + hide: function(complete) { + this.element.fadeOut("200", complete); + }, + + bindEvents: function() { + var _this = this; + + this.container.find('.mirador-osd-close').on('click', function() { + _this.parent.annoState.displayOff(); + }); + + this.container.find('.mirador-osd-back').on('click', function() { + _this.element.remove(); + _this.element = jQuery(_this.template()).appendTo(_this.container); + _this.bindEvents(); + }); + + this.container.find('.mirador-osd-edit-mode').on('click', function() { + if (_this.parent.annoState.current === 'annoOnCreateOff') { + _this.parent.annoState.createOn(); + } else if (_this.parent.annoState.current === 'annoOnCreateOn') { + _this.parent.annoState.createOff(); + } + }); + this.container.find('.mirador-osd-refresh-mode').on('click', function() { + //update annotation list from endpoint + jQuery.publish('updateAnnotationList.'+_this.windowId); + }); + + }, + + template: Handlebars.compile([ + '
              ', + '', + '', + '', + '{{#if showEdit}}', + '', + '', + '', + '{{/if}}', + '', + '', + '', + /*'', + '', + '',*/ + /*'', + '', + '',*/ + /*'', + '', + '',*/ + '
              ' + ].join('')), + + // for accessibility, make sure to add aria-labels just like above + editorTemplate: Handlebars.compile([ + '' + ].join('')) + }; +}(Mirador)); + +(function($) { + + $.Hud = function(options) { + + jQuery.extend(this, { + element: null, + parent: null, + windowId: null, + annoState: null, + showAnnotations: true, + annoEndpointAvailable: false, + fullScreenAvailable: true + }, options); + + this.init(); + }; + + $.Hud.prototype = { + + init: function() { + this.createStateMachine(); + + this.element = jQuery(this.template({ + showNextPrev : this.parent.imagesList.length !== 1, + showBottomPanel : typeof this.bottomPanelAvailable === 'undefined' ? true : this.bottomPanelAvailable, + showAnno : this.annotationLayerAvailable, + showFullScreen : this.fullScreenAvailable + })).appendTo(this.element); + + if (this.annotationLayerAvailable && this.annoEndpointAvailable) { + this.contextControls = new $.ContextControls({ + element: null, + container: this.parent.element, + mode: 'displayAnnotations', + parent: this, + windowId: this.windowId, + annotationCreationAvailable: this.annotationCreationAvailable + }); + } + + this.bindEvents(); + + if (typeof this.bottomPanelAvailable !== 'undefined' && !this.bottomPanelAvailable) { + this.parent.parent.bottomPanelVisibility(false); + } else { + this.parent.parent.bottomPanelVisibility(this.parent.parent.bottomPanelVisible); + } + }, + + bindEvents: function() { + var _this = this, + firstCanvasId = _this.parent.imagesList[0]['@id'], + lastCanvasId = _this.parent.imagesList[_this.parent.imagesList.length-1]['@id']; + + this.parent.element.find('.mirador-osd-next').on('click', function() { + _this.parent.next(); + }); + + this.parent.element.find('.mirador-osd-previous').on('click', function() { + _this.parent.previous(); + }); + + this.parent.element.find('.mirador-osd-annotations-layer').on('click', function() { + if (_this.annoState.current === 'none') { + _this.annoState.startup(this); + } + if (_this.annoState.current === 'annoOff') { + _this.annoState.displayOn(this); + } else { + _this.annoState.displayOff(this); + } + }); + + this.parent.element.find('.mirador-osd-go-home').on('click', function() { + _this.parent.osd.viewport.goHome(); + }); + + this.parent.element.find('.mirador-osd-up').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(0, -panBy.y)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-right').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(panBy.x, 0)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-down').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(0, panBy.y)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-left').on('click', function() { + var panBy = _this.getPanByValue(); + var osd = _this.parent.osd; + osd.viewport.panBy(new OpenSeadragon.Point(-panBy.x, 0)); + osd.viewport.applyConstraints(); + }); + this.parent.element.find('.mirador-osd-zoom-in').on('click', function() { + var osd = _this.parent.osd; + if ( osd.viewport ) { + osd.viewport.zoomBy( + osd.zoomPerClick / 1.0 + ); + osd.viewport.applyConstraints(); + } + }); + this.parent.element.find('.mirador-osd-zoom-out').on('click', function() { + var osd = _this.parent.osd; + if ( osd.viewport ) { + osd.viewport.zoomBy( + 1.0 / osd.zoomPerClick + ); + osd.viewport.applyConstraints(); + } + }); + + this.parent.element.find('.mirador-osd-fullscreen').on('click', function() { + if (OpenSeadragon.isFullScreen()) { + OpenSeadragon.exitFullScreen(); + } else { + OpenSeadragon.requestFullScreen(_this.parent.parent.element[0]); + } + }); + + jQuery(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange", function() { + _this.fullScreen(); + }); + + this.parent.element.find('.mirador-osd-toggle-bottom-panel').on('click', function() { + var visible = !_this.parent.parent.bottomPanelVisible; + _this.parent.parent.bottomPanelVisibility(visible); + }); + + jQuery.subscribe('bottomPanelSet.' + _this.windowId, function(event, visible) { + var dodgers = _this.parent.element.find('.mirador-osd-toggle-bottom-panel, .mirador-pan-zoom-controls'); + var arrows = _this.parent.element.find('.mirador-osd-next, .mirador-osd-previous'); + if (visible === true) { + dodgers.css({transform: 'translateY(-130px)'}); + arrows.css({transform: 'translateY(-65px)'}); + } else { + dodgers.css({transform: 'translateY(0)'}); + arrows.css({transform: 'translateY(0)'}); + } + }); + + jQuery.subscribe('currentCanvasIDUpdated.' + _this.windowId, function(event, canvasId) { + // If it is the first canvas, hide the "go to previous" button, otherwise show it. + if (canvasId === firstCanvasId) { + _this.parent.element.find('.mirador-osd-previous').hide(); + _this.parent.element.find('.mirador-osd-next').show(); + } else if (canvasId === lastCanvasId) { + _this.parent.element.find('.mirador-osd-next').hide(); + _this.parent.element.find('.mirador-osd-previous').show(); + } else { + _this.parent.element.find('.mirador-osd-next').show(); + _this.parent.element.find('.mirador-osd-previous').show(); + } + // If it is the last canvas, hide the "go to previous" button, otherwise show it. + }); + }, + + createStateMachine: function() { + //add more to these as AnnoState becomes more complex + var _this = this, + duration = "200"; + //initial state is 'none' + this.annoState = StateMachine.create({ + events: [ + { name: 'startup', from: 'none', to: 'annoOff' }, + { name: 'displayOn', from: 'annoOff', to: 'annoOnCreateOff' }, + { name: 'refreshCreateOff', from: 'annoOnCreateOff', to: 'annoOnCreateOff' }, + { name: 'createOn', from: ['annoOff','annoOnCreateOff'], to: 'annoOnCreateOn' }, + { name: 'refreshCreateOn', from: 'annoOnCreateOn', to: 'annoOnCreateOn' }, + { name: 'createOff', from: 'annoOnCreateOn', to: 'annoOnCreateOff' }, + { name: 'displayOff', from: ['annoOnCreateOn','annoOnCreateOff'], to: 'annoOff' } + ], + callbacks: { + onstartup: function(event, from, to) { + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + ondisplayOn: function(event, from, to) { + if (_this.annoEndpointAvailable) { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeOut(duration, function() { + _this.contextControls.show(); + }); + } else { + _this.parent.element.find('.mirador-osd-annotations-layer').addClass("selected"); + } + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + onrefreshCreateOff: function(event, from, to) { + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + oncreateOn: function(event, from, to) { + function enableEditingAnnotations() { + _this.parent.element.find('.mirador-osd-edit-mode').addClass("selected"); + jQuery.publish('modeChange.' + _this.windowId, 'editingAnnotations'); + } + if (_this.annoEndpointAvailable) { + if (from === "annoOff") { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeOut(duration, function() { + _this.contextControls.show(); + enableEditingAnnotations(); + }); + } else { + enableEditingAnnotations(); + } + } + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + onrefreshCreateOn: function(event, from, to) { + jQuery.publish('modeChange.' + _this.windowId, 'editingAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + oncreateOff: function(event, from, to) { + _this.parent.element.find('.mirador-osd-edit-mode').removeClass("selected"); + jQuery.publish('modeChange.' + _this.windowId, 'displayAnnotations'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + }, + ondisplayOff: function(event, from, to) { + if (_this.annoEndpointAvailable) { + _this.parent.element.find('.mirador-osd-edit-mode').removeClass("selected"); + _this.contextControls.hide(function() { + _this.parent.element.find('.mirador-osd-annotations-layer').fadeIn(duration); + } + ); + } else { + _this.parent.element.find('.mirador-osd-annotations-layer').removeClass("selected"); + } + jQuery.publish('modeChange.' + _this.windowId, 'default'); + jQuery.publish(('windowUpdated'), { + id: _this.windowId, + annotationState: to + }); + } + } + }); + }, + + getPanByValue: function() { + var bounds = this.parent.osd.viewport.getBounds(true); + //for now, let's keep 50% of the image on the screen + var panBy = { + "x" : bounds.width * 0.5, + "y" : bounds.height * 0.5 + }; + return panBy; + }, + + fullScreen: function() { + var replacementButton, + bottomPanelHeight = this.parent.parent.element.find('.bottomPanel').innerHeight(); + + if (!OpenSeadragon.isFullScreen()) { + replacementButton = jQuery(''); + this.parent.element.find('.mirador-osd-fullscreen').empty().append(replacementButton); + this.parent.element.find('.mirador-osd-toggle-bottom-panel').show(); + this.parent.parent.bottomPanelVisibility(true); + } else { + + replacementButton = jQuery(''); + this.parent.element.find('.mirador-osd-fullscreen').empty().append(replacementButton); + this.parent.element.find('.mirador-osd-toggle-bottom-panel').hide(); + this.parent.parent.bottomPanelVisibility(false); + } + }, + + template: Handlebars.compile([ + '{{#if showNextPrev}}', + '', + '', + '', + '{{/if}}', + '{{#if showFullScreen}}', + '', + '', + '', + '{{/if}}', + '{{#if showAnno}}', + '', + '', + '', + '{{/if}}', + '{{#if showNextPrev}}', + '', + '', + '', + '{{/if}}', + '{{#if showBottomPanel}}', + '', + '', + '', + '{{/if}}', + '' + ].join('')) + + }; + +}(Mirador)); + +(function($) { + + $.ImageView = function(options) { + + jQuery.extend(this, { + currentImg: null, + windowId: null, + currentImgIndex: 0, + canvasID: null, + imagesList: [], + element: null, + elemOsd: null, + parent: null, + manifest: null, + osd: null, + fullscreen: null, + osdOptions: { + osdBounds: null, + zoomLevel: null + }, + osdCls: 'mirador-osd', + elemAnno: null, + annoCls: 'annotation-canvas', + annotationLayerAvailable: null, + annotationsLayer: null + }, options); + + this.init(); + }; + + $.ImageView.prototype = { + + init: function() { + // check (for thumbnail view) if the canvasID is set. + // If not, make it page/item 1. + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + if (!this.osdOptions) { + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + } + this.currentImg = this.imagesList[this.currentImgIndex]; + this.element = jQuery(this.template()).appendTo(this.appendTo); + this.elemAnno = jQuery('
              ') + .addClass(this.annoCls) + .appendTo(this.element); + this.createOpenSeadragonInstance($.Iiif.getImageUrl(this.currentImg)); + this.parent.updateFocusImages([this.canvasID]); + // The hud controls are consistent + // throughout any updates to the osd canvas. + this.hud = new $.Hud({ + parent: this, + element: this.element, + bottomPanelAvailable: this.bottomPanelAvailable, + windowId: this.windowId, + annotationLayerAvailable: this.annotationLayerAvailable, + annotationCreationAvailable: this.annotationCreationAvailable, + annoEndpointAvailable: this.annoEndpointAvailable, + fullScreenAvailable : this.fullScreenAvailable + }); + + this.bindEvents(); + }, + + template: Handlebars.compile([ + '
              ', + '
              ' + ].join('')), + + bindEvents: function() { + var _this = this; + jQuery.subscribe('fitBounds.' + _this.parent.id, function(event, bounds) { + var rect = _this.osd.viewport.imageToViewportRectangle(Number(bounds.x), Number(bounds.y), Number(bounds.width), Number(bounds.height)); + _this.osd.viewport.fitBoundsWithConstraints(rect, false); + }); + + }, + + setBounds: function() { + var _this = this; + this.osdOptions.osdBounds = this.osd.viewport.getBounds(true); + jQuery.publish("imageBoundsUpdated", { + id: _this.parent.id, + osdBounds: { + x: _this.osdOptions.osdBounds.x, + y: _this.osdOptions.osdBounds.y, + width: _this.osdOptions.osdBounds.width, + height: _this.osdOptions.osdBounds.height + } + }); + var rectangle = this.osd.viewport.viewportToImageRectangle(this.osdOptions.osdBounds); + jQuery.publish("imageRectangleUpdated", { + id: _this.parent.id, + osdBounds: { + x: Math.round(rectangle.x), + y: Math.round(rectangle.y), + width: Math.round(rectangle.width), + height: Math.round(rectangle.height) + } + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.element).hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + jQuery(this.element).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + }, + + createOpenSeadragonInstance: function(imageUrl) { + var infoJsonUrl = imageUrl + '/info.json', + uniqueID = $.genUUID(), + osdID = 'mirador-osd-' + uniqueID, + infoJson, + _this = this; + + this.element.find('.' + this.osdCls).remove(); + + jQuery.getJSON(infoJsonUrl).done(function (infoJson, status, jqXHR) { + _this.elemOsd = + jQuery('
              ') + .addClass(_this.osdCls) + .attr('id', osdID) + .appendTo(_this.element); + + _this.osd = $.OpenSeadragon({ + 'id': osdID, + 'tileSources': infoJson, + 'uniqueID' : uniqueID + }); + + _this.osd.addHandler('open', function(){ + jQuery.publish('osdOpen.'+_this.windowId); + if (_this.osdOptions.osdBounds) { + var rect = new OpenSeadragon.Rect(_this.osdOptions.osdBounds.x, _this.osdOptions.osdBounds.y, _this.osdOptions.osdBounds.width, _this.osdOptions.osdBounds.height); + _this.osd.viewport.fitBounds(rect, true); + } else { + //else reset bounds for this image + _this.setBounds(); + } + + _this.addAnnotationsLayer(_this.elemAnno); + + // if current annoState is 'none' that means it has been initialized but not used + // use annotationState to choose event + if (_this.hud.annoState.current === 'none') { + _this.hud.annoState.startup(null); + if (_this.annotationState === 'annoOnCreateOff') { + _this.hud.annoState.displayOn(null); + } else if (_this.annotationState === 'annoOnCreateOn') { + _this.hud.annoState.createOn(null); + } + } else { + // if the current state is not 'none' then we need to update the annotations layer, + // with the current state, for the new canvas + if (_this.hud.annoState.current === 'annoOnCreateOff') { + _this.hud.annoState.refreshCreateOff(null); + } else if (_this.hud.annoState.current === 'annoOnCreateOn') { + _this.hud.annoState.refreshCreateOn(null); + } + } + + // A hack. Pop the osd overlays layer after the canvas so + // that annotations appear. + jQuery(_this.osd.canvas).children().first().remove().appendTo(_this.osd.canvas); + + _this.osd.addHandler('zoom', $.debounce(function() { + _this.setBounds(); + }, 500)); + + _this.osd.addHandler('pan', $.debounce(function(){ + _this.setBounds(); + }, 500)); + }); + }); + }, + + addAnnotationsLayer: function(element) { + var _this = this; + _this.annotationsLayer = new $.AnnotationsLayer({ + parent: _this, + annotationsList: _this.parent.annotationsList || [], + viewer: _this.osd, + windowId: _this.windowId, + element: element + }); + }, + + updateImage: function(canvasID) { + if (this.canvasID !== canvasID) { + this.canvasID = canvasID; + this.currentImgIndex = $.getImageIndexById(this.imagesList, canvasID); + this.currentImg = this.imagesList[this.currentImgIndex]; + this.osdOptions = { + osdBounds: null, + zoomLevel: null + }; + this.osd.close(); + this.createOpenSeadragonInstance($.Iiif.getImageUrl(this.currentImg)); + this.parent.updateFocusImages([canvasID]); + } else { + this.parent.updateFocusImages([canvasID]); + } + }, + + next: function() { + var next = this.currentImgIndex + 1; + + if (next < this.imagesList.length) { + this.parent.setCurrentCanvasID(this.imagesList[next]['@id']); + } + }, + + previous: function() { + var prev = this.currentImgIndex - 1; + + if (prev >= 0) { + this.parent.setCurrentCanvasID(this.imagesList[prev]['@id']); + } + } + }; + +}(Mirador)); + +(function($) { + + $.MetadataView = function(options) { + + jQuery.extend(this, { + manifest: null, + element: null, + parent: null, + metadataTypes: null, + metadataListingCls: 'metadata-listing' + }, options); + + this.init(); + }; + + + $.MetadataView.prototype = { + + init: function() { + var _this = this, + tplData = { + metadataListingCls: this.metadataListingCls + }; + + _this.manifest = _this.manifest.jsonLd; + this.metadataTypes = {}; + + this.metadataTypes.details = _this.getMetadataDetails(_this.manifest); + this.metadataTypes.rights = _this.getMetadataRights(_this.manifest); + this.metadataTypes.links = _this.getMetadataLinks(_this.manifest); + + //vvvvv This is *not* how this should be done. + jQuery.each(this.metadataTypes, function(metadataKey, metadataValue) { + tplData[metadataKey] = []; + + jQuery.each(metadataValue, function(key, value) { + if (typeof value === 'object') { + value = _this.stringifyObject(value); + } + + if (typeof value === 'string' && value !== '') { + tplData[metadataKey].push({ + label: _this.extractLabelFromAttribute(key), + value: (metadataKey === 'links') ? value : _this.addLinksToUris(value) + }); + } + }); + }); + + if (_this.manifest.logo) { + var logo = ''; + if (typeof _this.manifest.logo === "string") { + logo = _this.manifest.logo; + } else if (typeof _this.manifest.logo['@id'] !== 'undefined') { + logo = _this.manifest.logo['@id']; + } + tplData.logo = logo; + } + + this.element = jQuery(this.template(tplData)).appendTo(this.appendTo); + this.bindEvents(); + }, + + // Base code from https://github.com/padolsey/prettyprint.js. Modified to fit Mirador needs + stringifyObject: function(obj, nestingMargin) { + var type = typeof obj, + _this = this, + str, + first = true, + increment = 15, + delimiter = '
              '; + + if (obj instanceof RegExp) { + return '/' + obj.source + '/'; + } + + if (typeof nestingMargin === 'undefined') { + nestingMargin = 0; + } + + if (obj instanceof Array) { + str = '[ '; + jQuery.each(obj, function (i, item) { + str += (i === 0 ? '' : ', ') + _this.stringifyObject(item, nestingMargin + increment); + }); + return str + ' ]'; + } + + if (typeof obj === 'object') { + str = '
              '; + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + str += (first ? '' : delimiter) + i + ': ' + _this.stringifyObject(obj[i], nestingMargin + increment); + first = false; + } + } + + return str + '
              '; + } + return obj.toString(); + }, + + stringifyRelated: function(obj) { + var _this = this, + str, + next, + label, + format; + if (obj instanceof Array) { + str = ''; + jQuery.each(obj, function (i, item) { + next = _this.stringifyRelated(item); + if (next !== '') str += (i === 0 ? '' : '
              ') + next; + }); + return str; + } + + if (typeof obj === 'object' && '@id' in obj) { + label = ('label' in obj)? obj.label : obj['@id']; + format = ('format' in obj && obj.format !== 'text/html')? '(' + obj.format + ')' : ''; + return '' + label + ' ' + format; + } + + return _this.addLinksToUris(obj.toString()); + }, + + getMetadataDetails: function(jsonLd) { + // TODO: This should not default to English + var mdList = { + 'label': '' + jsonLd.label + '' || '', + 'description': jsonLd.description || '' + }; + var value = ""; + var label = ""; + if (typeof mdList.description == "object") { + jQuery.each(mdList.description, function(index, item) { + if (typeof item == "string") { + value += item; + value += "
              "; + } else { + // {@value: ..., @language: ...} + if (item['@language'] == "en") { + value += item['@value']; + value += "
              "; + } + } + }); + mdList.description = value; + } + + if (jsonLd.metadata) { + value = ""; + label = ""; + jQuery.each(jsonLd.metadata, function(index, item) { + if (typeof item.label === "string") { + label = item.label; + } else { + jQuery.each(item.label, function(i2, what) { + // {@value: ..., @language: ...} + if (what['@language'] === "en") { + label = what['@value']; + } + }); + } + if (typeof item.value === "string") { + value = item.value; + } else { + jQuery.each(item.value, function(i3, what) { + // {@value: ..., @language: ...} + if (what['@language'] === "en") { + value = what['@value']; + } + }); + } + mdList[label] = value; + }); + } + + return mdList; + }, + + getMetadataRights: function(jsonLd) { + return { + 'license': jsonLd.license || '', + 'attribution': jsonLd.attribution || '' + }; + }, + + getMetadataLinks: function(jsonLd) { + // #414 + return { + 'related': this.stringifyRelated(jsonLd.related || ''), + 'seeAlso': this.stringifyRelated(jsonLd.seeAlso || ''), + 'within': this.stringifyObject(jsonLd.within || '') + }; + }, + + extractLabelFromAttribute: function(attr) { + var label = attr; + + label = label.replace(/^@/, ''); + label = label.replace(/([A-Z])/g, ' $1'); + label = label.replace(/\s{2,}/g, ' '); + label = label.replace(/\w\S*/g, function(txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); + + return label; + }, + + bindEvents: function() { + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + show: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.show({effect: "slide", direction: "right", duration: 300, easing: "swing"}); + }, + + hide: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.hide({effect: "slide", direction: "right", duration: 300, easing: "swing"}); + }, + + addLinksToUris: function(text) { + // http://stackoverflow.com/questions/8188645/javascript-regex-to-match-a-url-in-a-field-of-text + var regexUrl = /(http|ftp|https):\/\/[\w\-]+(\.[\w\-]+)+([\w.,@?\^=%&:\/~+#\-]*[\w@?\^=%&\/~+#\-])?/gi, + textWithLinks = text, + matches; + + if (typeof text === 'string') { + matches = text.match(regexUrl); + + if (matches) { + jQuery.each(matches, function(index, match) { + textWithLinks = textWithLinks.replace(match, '' + match + ''); + }); + } + } + + return textWithLinks; + }, + + template: Handlebars.compile([ + '
              {{t "details"}}:
              ', + '
              ', + '{{#each details}}', + '', + '{{/each}}', + '
              ', + '
              {{t "rights"}}:
              ', + '{{#if rights}}', + '
              ', + '{{#each rights}}', + '', + '{{/each}}', + '{{#if logo}}', + '', + '{{/if}}', + '
              ', + '{{else}}', + '
              ', + '', + '
              ', + '{{/if}}', + '{{#if links}}', + '
              {{t "links"}}:
              ', + '
              ', + '{{#each links}}', + '', + '{{/each}}', + // '{{#if relatedLinks}}', + // '
              {{label}}:
              {{{value}}}
              ', + // '{{/if}}', + '', + '{{/if}}' + + ].join(''), { noEscape: true }) + + }; + +}(Mirador)); + +(function($) { + + $.WidgetScale = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetScale.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.ScrollView = function(options) { + + jQuery.extend(this, { + currentImgIndex: 0, + canvasID: null, + focusImages: [], + manifest: null, + element: null, + imagesList: [], + appendTo: null, + thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'}, + parent: null, + panel: false, + lazyLoadingFactor: 1.5 //should be >= 1 + }, options); + + jQuery.extend($.ScrollView.prototype, $.ThumbnailsView.prototype); + this.init(); + }; + +}(Mirador)); + +(function($) { + + $.SidePanel= function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + panelState: {}, + tocTabAvailable: false, + annotationsTabAvailable: false, + layersTabAvailable: false, + toolsTabAvailable: false, + hasStructures: false + }, options); + + this.init(); + }; + + $.SidePanel.prototype = { + init: function() { + var _this = this; + this.windowId = this.parent.id; + + this.state({ + tabs : [ + { + name : 'toc', + options : { + available: _this.tocTabAvailable, + id:'tocTab', + label:'Index' + } + }, + /*{ + name : 'annotations', + options : { + available: _this.annotationsTabAvailable, + id:'annotationsTab', + label:'Annotations' + } + },*/ + /*{ + name : 'layers', + options : { + available: _this.layersTabAvailable, + id:'layersTab', + label:'Layers' + } + }, + { + name : 'tools', + options : { + available: _this.toolsTabAvailable, + id:'toolsTab', + label:'Tools' + } + }*/ + ], + width: 280, + open: true + }, true); + + this.listenForActions(); + this.render(this.state()); + + this.loadSidePanelComponents(); + }, + + loadSidePanelComponents: function() { + var _this = this; + + new $.Tabs({ + windowId: this.parent.id, + appendTo: this.appendTo, + tabs : this.panelState.tabs, + parent : this + }); + + if (this.tocTabAvailable) { + new $.TableOfContents({ + manifest: this.manifest, + appendTo: this.element.find('.tabContentArea'), + parent: this.parent, + panel: true, + canvasID: this.parent.currentCanvasID + }); + } + if (_this.annotationsTabAvailable) { + new $.AnnotationsTab({ + manifest: _this.manifest, + parent: this.parent, + appendTo: _this.element.find('.tabContentArea'), + tabs: _this.state.tabs + }); + } + + }, + + update: function(name, availability) { + var state = this.panelState; + jQuery.each(state.tabs, function(index, value) { + if (value.name === name) { + value.options.available = availability; + } + }); + this.state(state); + }, + + state: function(state, initial) { + if (!arguments.length) return this.panelState; + jQuery.extend(true, this.panelState, state); + + if (!initial) { + jQuery.publish('sidePanelStateUpdated.' + this.windowId, this.panelState); + } + + /*var enableSidePanel = false; + jQuery.each(this.panelState.tabs, function(index, value) { + if (value.options.available) { + enableSidePanel = true; + } + }); + + this.toggle(enableSidePanel);*/ + + return this.panelState; + }, + + panelToggled: function() { + var state = this.state(), + open = !state.open; + + state.open = open; + this.state(state); + }, + + // doesn't do anything right now + // getTemplateData: function() { + // return { + // annotationsTab: this.state().annotationsTab, + // tocTab: this.state().tocTab + // }; + // }, + + listenForActions: function() { + var _this = this; + jQuery.subscribe('sidePanelStateUpdated.' + this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('sidePanelResized', function() { + }); + + jQuery.subscribe('sidePanelToggled.' + this.windowId, function() { + _this.panelToggled(); + }); + + jQuery.subscribe('annotationListLoaded.' + _this.windowId, function(event) { + if (_this.parent.annotationsAvailable[_this.parent.currentFocus]) { + if (_this.parent.annotationsList.length > 0) { + _this.update('annotations', true); + } + } + }); + + }, + + render: function(renderingData) { + var _this = this; + + if (!this.element) { + this.element = this.appendTo; + jQuery(_this.template(renderingData)).appendTo(_this.appendTo); + return; + } + + if (renderingData.open) { + this.appendTo.removeClass('minimized'); + } else { + this.appendTo.addClass('minimized'); + } + }, + + template: Handlebars.compile([ + '
              ', + '
                ', + '
              ', + '
              ' + ].join('')), + + toggle: function (enableSidePanel) { + if (!enableSidePanel) { + jQuery(this.appendTo).hide(); + this.parent.element.find('.view-container').addClass('focus-max-width'); + this.parent.element.find('.mirador-icon-toc').hide(); + } else { + jQuery(this.appendTo).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + this.parent.element.find('.view-container').removeClass('focus-max-width'); + this.parent.element.find('.mirador-icon-toc').show(); + } + } + }; + +}(Mirador)); + +(function($) { + + $.WidgetStatusBar = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetStatusBar.prototype = { + + }; + +}(Mirador)); + + +(function($) { + + $.Tabs = function(options) { + jQuery.extend(true, this, { + element: null, + appendTo: null, + windowId: null, + tabState: {}, + tabs: [] + }, options); + + this.init(); + }; + + $.Tabs.prototype = { + init: function() { + var _this = this; + + this.state({ + tabs : this.tabs, + //tabs: [{id:'tocTab', label:'Indices'}, {id:'annotationsTab', label:'Annotations'}], + //tabs: [{id:'tocTab', label:'Indices'}], + selectedTabIndex: 0 + }, true); + this.listenForActions(); + this.render(this.state()); + this.bindEvents(); + }, + state: function(state, initial) { + if (!arguments.length) return this.tabState; + jQuery.extend(true, this.tabState, state); + + if (!initial) { + jQuery.publish('tabStateUpdated.' + this.windowId, this.tabState); + } + + return this.tabState; + }, + tabSelected: function(index) { + var state = this.state(); + state.selectedTabIndex = index; + this.state(state); + }, + getTemplateData: function() { + return { + annotationsTab: this.state().annotationsTab, + tocTab: this.state().tocTab + }; + }, + listenForActions: function() { + var _this = this; + + jQuery.subscribe('tabStateUpdated.' + this.windowId, function(_, data) { + _this.render(data); + }); + + jQuery.subscribe('tabSelected.' + this.windowId, function(_, data) { + _this.tabSelected(data); + }); + + jQuery.subscribe('tabFocused.', function() { + }); + }, + bindEvents: function() { + var _this = this; + + this.element.find('.tab').on('click', function(event) { + jQuery.publish('tabSelected.' + _this.windowId, jQuery( ".tabGroup li" ).index( this )); + }); + }, + render: function(renderingData) { + var _this = this; + + if (!this.element) { + var displayLabels = false; + var tabs = jQuery.grep(renderingData.tabs, function(value, index) { + return value.options.available; + }); + renderingData.tabs = tabs; + if(renderingData.tabs.length === 1){ + // TODO: temporary logic to minimize side panel if only tab is toc and toc is empty + if (renderingData.tabs[0].name === 'toc' && !_this.parent.hasStructures) { + jQuery.publish("sidePanelVisibilityByTab." + _this.windowId, false); + } + + // don't show button if only one tab + renderingData.tabs = []; + } + //TODO: add text if there is one label or no content within this tab + this.element = jQuery(_this.template(renderingData)).prependTo(_this.appendTo); + return; + } + + this.element.find('.tab').removeClass('selected'); + var tabClass = '.' + renderingData.tabs[renderingData.selectedTabIndex].options.id; + this.element.find(tabClass).addClass('selected'); + + }, + template: Handlebars.compile([ + '
                ', + '{{#each tabs}}', + '
              • ', + '{{this.options.label}}', + '
              • ', + '{{/each}}', + '
              ', + ].join('')), + toggle: function () {} + }; + +}(Mirador)); + +(function($) { + + $.ThumbnailsView = function(options) { + + jQuery.extend(this, { + currentImgIndex: 0, + canvasID: null, + focusImages: [], + manifest: null, + element: null, + imagesList: [], + appendTo: null, + thumbInfo: {thumbsHeight: 150, listingCssCls: 'listing-thumbs', thumbnailCls: 'thumbnail-view'}, + defaultThumbHeight: 150, + parent: null, + panel: false, + lazyLoadingFactor: 1.5 //should be >= 1 + }, options); + + this.init(); + }; + + + $.ThumbnailsView.prototype = { + + init: function() { + if (this.canvasID !== null) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, this.canvasID); + } + + this.loadContent(); + this.bindEvents(); + }, + + loadContent: function() { + var _this = this, + tplData = { + defaultHeight: this.thumbInfo.thumbsHeight, + listingCssCls: this.thumbInfo.listingCssCls, + thumbnailCls: this.thumbInfo.thumbnailCls + }; + + tplData.thumbs = jQuery.map(this.imagesList, function(canvas, index) { + if (canvas.width === 0) { + return {}; + } + + var aspectRatio = canvas.height/canvas.width, + width = (_this.thumbInfo.thumbsHeight/aspectRatio), + thumbnailUrl = $.getThumbnailForCanvas(canvas, width); + + return { + thumbUrl: thumbnailUrl, + title: canvas.label, + id: canvas['@id'], + width: width, + highlight: _this.currentImgIndex === index ? 'highlight' : '' + }; + }); + + this.element = jQuery(_this.template(tplData)).appendTo(this.appendTo); + }, + + updateImage: function(canvasId) { + this.currentImgIndex = $.getImageIndexById(this.imagesList, canvasId); + this.element.find('.highlight').removeClass('highlight'); + this.element.find("img[data-image-id='"+canvasId+"']").addClass('highlight'); + this.element.find("img[data-image-id='"+canvasId+"']").parent().addClass('highlight'); + }, + + updateFocusImages: function(focusList) { + var _this = this; + this.element.find('.highlight').removeClass('highlight'); + jQuery.each(focusList, function(index, canvasId) { + _this.element.find("img[data-image-id='"+canvasId+"']").addClass('highlight'); + _this.element.find("img[data-image-id='"+canvasId+"']").parent().addClass('highlight'); + }); + }, + + currentImageChanged: function() { + var _this = this, + target = _this.element.find('.highlight'), + scrollPosition; + + if (this.parent.currentFocus === 'BookView') { + scrollPosition = _this.element.scrollLeft() + (target.position().left + (target.next().width() + target.outerWidth())/2) - _this.element.width()/2; + } else { + + scrollPosition = _this.element.scrollLeft() + (target.position().left + target.width()/2) - _this.element.width()/2; + } + _this.element.scrollTo(scrollPosition, 900); + }, + + bindEvents: function() { + var _this = this; + _this.element.find('img').on('load', function() { + jQuery(this).hide().fadeIn(750); + }); + + jQuery(_this.element).scroll(function() { + _this.loadImages(); + }); + + jQuery.subscribe('windowResize', $.debounce(function(){ + _this.loadImages(); + }, 100)); + + //add any other events that would trigger thumbnail display (resize, etc) + + _this.element.find('.thumbnail-image').on('click', function() { + var canvasID = jQuery(this).attr('data-image-id'); + _this.parent.setCurrentCanvasID(canvasID); + }); + + jQuery.subscribe(('currentCanvasIDUpdated.' + _this.parent.id), function(event) { + _this.currentImageChanged(); + }); + }, + + toggle: function(stateValue) { + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + loadImages: function() { + var _this = this; + jQuery.each(_this.element.find("img"), function(key, value) { + if ($.isOnScreen(value, _this.lazyLoadingFactor) && !jQuery(value).attr("src")) { + var url = jQuery(value).attr("data"); + _this.loadImage(value, url); + } + }); + }, + + loadImage: function(imageElement, url) { + var _this = this, + imagePromise = $.createImagePromise(url); + + imagePromise.done(function(image) { + jQuery(imageElement).attr('src', image); + }); + }, + + reloadImages: function(newThumbHeight, triggerShow) { + var _this = this; + this.thumbInfo.thumbsHeight = newThumbHeight; + + jQuery.each(this.imagesList, function(index, image) { + var aspectRatio = image.height/image.width, + width = (_this.thumbInfo.thumbsHeight/aspectRatio), + newThumbURL = $.getThumbnailForCanvas(image, width), + id = image['@id']; + var imageElement = _this.element.find('img[data-image-id="'+id+'"]'); + imageElement.attr('data', newThumbURL).attr('height', _this.thumbInfo.thumbsHeight).attr('width', width).attr('src', ''); + }); + if (triggerShow) { + this.show(); + } + }, + + template: Handlebars.compile([ + '
              ', + '
                ', + '{{#thumbs}}', + '
              • ', + '', + '
                {{title}}
                ', + '
              • ', + '{{/thumbs}}', + '
              ', + '
              ' + ].join('')), + + hide: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + element.hide({effect: "fade", duration: 300, easing: "easeOutCubic"}); + }, + + show: function() { + var element = jQuery(this.element); + if (this.panel) { + element = element.parent(); + } + var _this = this; + element.show({ + effect: "fade", + duration: 300, + easing: "easeInCubic", + complete: function() { + _this.loadImages(); + } + }); + }, + + adjustWidth: function(className, hasClass) { + if (hasClass) { + this.parent.element.find('.view-container').removeClass(className); + } else { + this.parent.element.find('.view-container').addClass(className); + } + }, + + adjustHeight: function(className, hasClass) { + if (hasClass) { + this.element.removeClass(className); + } else { + this.element.addClass(className); + } + } + + }; + + + +}(Mirador)); + +(function($) { + + $.TableOfContents = function(options) { + + jQuery.extend(true, this, { + element: null, + appendTo: null, + parent: null, + manifest: null, + structures: null, + previousSelectedElements: [], + selectedElements: [], + openElements: [], + hoveredElement: [], + ranges: [], + selectContext: null, + tocData: {}, + active: null + }, options); + + this.init(); + + }; + + $.TableOfContents.prototype = { + init: function () { + var _this = this; + _this.structures = _this.manifest.getStructures(); + if (!_this.structures || _this.structures.length === 0) { + this.element = jQuery(this.emptyTemplate()).appendTo(this.appendTo); + } else { + this.ranges = this.setRanges(); + this.element = jQuery(this.template({ ranges: this.getTplData() })).appendTo(this.appendTo); + this.tocData = this.initTocData(); + this.selectedElements = $.getRangeIDByCanvasID(_this.structures, _this.parent.currentCanvasID); + this.element.find('.has-child ul').hide(); + this.render(); + } + this.bindEvents(); + }, + + setRanges: function() { + var _this = this, + ranges = []; + jQuery.each(_this.structures, function(index, range) { + if (range['@type'] === 'sc:Range') { + ranges.push({ + id: range['@id'], + canvases: range.canvases, + within: range.within, + label: range.label + }); + } + }); + + return ranges; + + }, + + tabStateUpdated: function(data) { + if (data.tabs[data.selectedTabIndex].options.id === 'tocTab') { + this.element.show(); + } else { + this.element.hide(); + } + }, + + getTplData: function() { + var _this = this, + ranges = _this.extractRangeTrees(_this.ranges); + + if (ranges.length < 2) { + ranges = ranges[0].children; + } + + return ranges; + }, + + initTocData: function() { + var _this = this, + tocData = {}; + + jQuery.each(_this.ranges, function(index, item) { + var rangeID = item.id, + attrString = '[data-rangeid="' + rangeID +'"]'; + + tocData[item.id] = { + element: _this.element.find(attrString).closest('li') //, + // open: false, + // selected: false, + // hovered: false + }; + }); + + return tocData; + }, + + extractRangeTrees: function(rangeList) { + var tree, parent; + // Recursively build tree/table of contents data structure + // Begins with the list of topmost categories + function unflatten(flatRanges, parent, tree) { + // To aid recursion, define the tree if it does not exist, + // but use the tree that is being recursively built + // by the call below. + tree = typeof tree !== 'undefined' ? tree : []; + parent = typeof parent !== 'undefined' ? parent : {id: "root", label: "Table of Contents" }; + var children = jQuery.grep(flatRanges, function(child) { if (!child.within) { child.within = 'root'; } return child.within == parent.id; }); + if ( children.length ) { + if ( parent.id === 'root') { + // If there are children and their parent's + // id is a root, bind them to the tree object. + // + // This begins the construction of the object, + // and all non-top-level children are now + // bound the these base nodes set on the tree + // object. + children.forEach(function(child) { + child.level = 0; + }); + tree = children; + } else { + // If the parent does not have a top-level id, + // bind the children to the parent node in this + // recursion level before handing it over for + // another spin. + // + // Because "child" is passed as + // the second parameter in the next call, + // in the next iteration "parent" will be the + // first child bound here. + children.forEach(function(child) { + child.level = parent.level+1; + }); + parent.children = children; + } + // The function cannot continue to the return + // statement until this line stops being called, + // which only happens when "children" is empty. + jQuery.each( children, function( index, child ){ unflatten( flatRanges, child ); } ); + } + return tree; + } + + return unflatten(rangeList); + }, + + render: function() { + var _this = this, + toDeselect = jQuery.map(_this.previousSelectedElements, function(rangeID) { + return _this.tocData[rangeID].element.toArray(); + }), + toSelect = jQuery.map(_this.selectedElements, function(rangeID) { + return _this.tocData[rangeID].element.toArray(); + }), + toOpen = jQuery.map(_this.selectedElements, function(rangeID) { + if ((jQuery.inArray(rangeID, _this.openElements) < 0) && (jQuery.inArray(rangeID, _this.previousSelectedElements) < 0)) { + return _this.tocData[rangeID].element.toArray(); + } + }), + toClose = jQuery.map(_this.previousSelectedElements, function(rangeID) { + if ((jQuery.inArray(rangeID, _this.openElements) < 0) && (jQuery.inArray(rangeID, _this.selectedElements) < 0)) { + return _this.tocData[rangeID].element.toArray(); + } + }); + + // Deselect elements + jQuery(toDeselect).removeClass('selected'); + + // Select new elements + jQuery(toSelect).addClass('selected'); + + // Scroll to new elements + scroll(); + + // Open new ones + jQuery(toOpen).toggleClass('open').find('ul:first').slideFadeToggle(); + // Close old ones (find way to keep scroll position). + jQuery(toClose).toggleClass('open').find('ul:first').slideFadeToggle(400, 'swing', scroll); + + // Get the sum of the outer height of all elements to be removed. + // Subtract from current parent height to retreive the new height. + // Scroll with respect to this. + scroll(); + + function scroll() { + var head = _this.element.find('.selected').first(); + if (head.length > 0) { + _this.element.scrollTo(head, 400); + } + } + + }, + + bindEvents: function() { + var _this = this; + // var eventString = _this.parent.id + + jQuery.subscribe('focusChanged', function(_, manifest, focusFrame) { + }); + + jQuery.subscribe('cursorFrameUpdated', function(_, manifest, cursorBounds) { + }); + + jQuery.subscribe('tabStateUpdated.' + _this.parent.id, function(_, data) { + _this.tabStateUpdated(data); + }); + + jQuery.subscribe(('currentCanvasIDUpdated.' + _this.parent.id), function(event, canvasID) { + if (!_this.structures) { return; } + _this.setSelectedElements($.getRangeIDByCanvasID(_this.structures, canvasID)); + _this.render(); + }); + + _this.element.find('.toc-link').on('click', function(event) { + event.stopPropagation(); + // The purpose of the immediate event is to update the data on the parent + // by calling its "set" function. + // + // The parent (window) then emits an event notifying all panels of + // the update, so they can respond in their own unique ways + // without window having to know anything about their DOMs or + // internal structure. + var rangeID = jQuery(this).data().rangeid, + canvasID = jQuery.grep(_this.structures, function(item) { return item['@id'] == rangeID; })[0].canvases[0], + isLeaf = jQuery(this).closest('li').hasClass('leaf-item'); + + // if ( _this.parent.currentFocus === 'ThumbnailsView' & !isLeaf) { + // _this.parent.setCursorFrameStart(canvasID); + // } else { + _this.parent.setCurrentCanvasID(canvasID); + // } + }); + + _this.element.find('.toc-caret').on('click', function(event) { + event.stopPropagation(); + + var rangeID = jQuery(this).parent().data().rangeid; + _this.setOpenItem(rangeID); + + // For now it's alright if this data gets lost in the fray. + jQuery(this).closest('li').toggleClass('open').find('ul:first').slideFadeToggle(); + + // The parent (window) then emits an event notifying all panels of + // the update, so they can respond in their own unique ways + // without window having to know anything about their DOMs or + // internal structure. + }); + + }, + + setActive: function(active) { + var _this = this; + _this.active = active; + }, + + setOpenItem: function(rangeID) { + var _this = this; + + if (jQuery.inArray(rangeID, _this.openElements)<0) { + _this.openElements.push(rangeID); + } else { + _this.openElements.splice(jQuery.inArray(rangeID, _this.openElements), 1); + } + }, + + // focusCursorFrame: function() { + // console.log('focusCursorFrame'); + // }, + + // hoverItem: function() { + // console.log('hoverItem'); + // }, + + setSelectedElements: function(rangeIDs) { + var _this = this; + + _this.previousSelectedElements = _this.selectedElements; + _this.selectedElements = rangeIDs; + }, + + // returnToPlace: function() { + // console.log('returnToPlace'); + // }, + + emptyTemplate: Handlebars.compile([ + '
                ', + '
              • ', + '

                No index available

                ', + '
              ', + ].join('')), + + template: function(tplData) { + + var template = Handlebars.compile([ + '
                ', + '{{#nestedRangeLevel ranges}}', + '
              • ', + '{{{tocLevel id label level children}}}', + '{{#if children}}', + '
                  ', + '{{{nestedRangeLevel children}}}', + '
                ', + '{{/if}}', + '
              • ', + '{{/nestedRangeLevel}}', + '
              ' + ].join('')); + + var previousTemplate; + + Handlebars.registerHelper('nestedRangeLevel', function(children, options) { + var out = ''; + + if (options.fn !== undefined) { + previousTemplate = options.fn; + } + + children.forEach(function(child) { + out = out + previousTemplate(child); + }); + + return out; + }); + + Handlebars.registerHelper('tocLevel', function(id, label, level, children) { + var caret = '', + cert = ''; + return '' + caret + cert + '' + label + ''; + }); + + return template(tplData); + }, + + toggle: function(stateValue) { + if (!this.structures) { stateValue = false; } + if (stateValue) { + this.show(); + } else { + this.hide(); + } + }, + + hide: function() { + jQuery(this.appendTo).hide(); + this.parent.element.find('.view-container').addClass('focus-max-width'); + }, + + show: function() { + jQuery(this.appendTo).show({effect: "fade", duration: 300, easing: "easeInCubic"}); + this.parent.element.find('.view-container').removeClass('focus-max-width'); + } + + }; + +}(Mirador)); + +(function($) { + + $.WidgetViewport = function(options) { + + jQuery.extend(true, this, { + + }, $.DEFAULT_SETTINGS, options); + + }; + + $.WidgetViewport.prototype = { + + }; + +}(Mirador)); + + + +(function($) { + + $.Iiif = { + + getImageUrl: function(image) { + + if (!image.images[0].resource.service) { + id = image.images[0].resource['default'].service['@id']; + id = id.replace(/\/$/, ""); + return id; + } + var id = image.images[0].resource.service['@id']; + id = id.replace(/\/$/, ""); + + return id; + }, + + getVersionFromContext: function(context) { + if (context == "http://iiif.io/api/image/2/context.json") { + return "2.0"; + } else { + return "1.1"; + } + }, + + makeUriWithWidth: function(uri, width, version) { + uri = uri.replace(/\/$/, ''); + if (version[0] == '1') { + return uri + '/full/' + width + ',/0/native.jpg'; + } else { + return uri + '/full/' + width + ',/0/default.jpg'; + } + }, + + getImageHostUrl: function(json) { + var regex, + matches = []; + + if (!json.hasOwnProperty('image_host')) { + + json.image_host = json.tilesUrl || json['@id'] || ''; + + if (json.hasOwnProperty('identifier')) { + regex = new RegExp('/?' + json.identifier + '/?$', 'i'); + json.image_host = json.image_host.replace(regex, ''); + + } else { + regex = new RegExp('(.*)\/(.*)$'); + matches = regex.exec(json.image_host); + + if (matches.length > 1) { + json.image_host = matches[1]; + json.identifier = matches[2]; + } + } + } + + return json.image_host; + } + + }; + +}(Mirador)); + + +// for scroll view +// source: http://stackoverflow.com/questions/14035083/jquery-bind-event-on-scroll-stops +jQuery.fn.scrollStop = function(callback) { + $(this).scroll(function() { + var self = this, + $this = $(self); + + if ($this.data('scrollTimeout')) { + clearTimeout($this.data('scrollTimeout')); + } + + $this.data('scrollTimeout', setTimeout(callback, 250, self)); + }); +}; + + +// for resize events +// source: https://github.com/f/jquery.resizestop +(function($) { + var slice = Array.prototype.slice; + + // Special event definition + $.extend($.event.special, { + resizestop: { + add: function(handle) { + var handler = handle.handler; + + $(this).resize(function(e) { + clearTimeout(handler._timer); + e.type = 'resizestop'; + + var _proxy = $.proxy(handler, this, e); + handler._timer = setTimeout(_proxy, handle.data || 200); + }); + } + }, + + resizestart: { + add: function(handle) { + var handler = handle.handler; + + $(this).on('resize', function(e) { + clearTimeout(handler._timer); + + if (!handler._started) { + e.type = 'resizestart'; + handler.apply(this, arguments); + handler._started = true; + } + + handler._timer = setTimeout($.proxy(function() { + handler._started = false; + }, this), handle.data || 300); + }); + } + } + }); + + // binding and currying the shortcuts. + $.extend($.fn, { + resizestop: function() { + $(this).on.apply(this, ["resizestop"].concat(slice.call(arguments))); + }, + resizestart: function() { + $(this).on.apply(this, ["resizestart"].concat(slice.call(arguments))); + } + }); +})(jQuery); +(function($){ + + var JSONBLOB_API_ENDPOINT = '/api/jsonBlob'; + + function getAPIUri(host, port, ssl, body) { + + var proto = 'http'; + port = port ? port : '80'; + + if ( ssl ) { + proto = 'https'; + port = port ? port : '443'; + } + + host = host ? host : 'jsonblob.com'; + + var path = JSONBLOB_API_ENDPOINT; + + // If the body is a string, this is a blob GET operation, + // otherwise it's a POST + if ( typeof body === 'string' || body instanceof String ){ + path += '/' + body; + } + + return proto + '://' + host + ':' + port + path; + } + + function initSettings(method, host, port, ssl, requestBody) { + + var ajaxSettings = { + type: method, + url: getAPIUri(host, port, ssl, requestBody), + contentType: 'application/json; charset=UTF-8', + accept: 'application/json', + dataType: 'json', + processData: false + }; + + // POST The data + if ( typeof requestBody !== 'string' && !(requestBody instanceof String) ) { + ajaxSettings.data = JSON.stringify(requestBody); + } + + return ajaxSettings; + } + + function syncRequest(method, host, port, ssl, requestBody) { + var result; + var settings = initSettings(method, host, port, ssl, requestBody); + settings.async = false; + settings.success = function(data, textStatus, request) { + result = data; + }; + jQuery.ajax(settings); + return result; + } + + function asyncRequest(method, host, port, ssl, requestBody, cb) { + var settings = initSettings(method, host, port, ssl, requestBody); + settings.success = cb; + jQuery.ajax(settings); + } + + $.JSONBlobAPI = function(options) { + this.options = options; + }; + + + $.JSONBlobAPI.prototype = { + readSync: function(blobId) { + return syncRequest('GET', this.options.host, this.options.port, this.options.ssl, blobId); + }, + save: function(blob) { + var deferred = jQuery.Deferred(); + asyncRequest('POST', this.options.host, this.options.port, this.options.ssl, blob, function(data, textStatus, request) { + var blobid = request.getResponseHeader('X-Jsonblob'); + deferred.resolve(blobid); + }); + return deferred.promise(); + } + }; + +}(Mirador)); + + +(function($) { + + $.OaAnnotation = function(options) { + + jQuery.extend(this, { + text: null, + tags: null, + bounds: null, // the "frame" or "cnotext" bounds, in canvas coordinates + regionFragment: null, + id: null, // the oa (canvas) @id under which to save it, preferably a uri. + oaAnnotation: null + }, options); + + this.init(); + }; + + $.OaAnnotation.prototype = { + + init: function() { + this.oaAnnotation = {}; // stub text of valid oa annotation (as + // it would appear in an oa:annotationList) + // to go here. Properties will be queried and + // twiddled by the get/set methods for each + // property below (as the annotation is + // passed through the annotation creation process). + }, + + chars: function(chars) { + // getter and setter for text of annotation. + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + if (!arguments.length) return _this.oa.resource.chars; // not sure if this is the right "path"? + _this.oa.resource.chars = chars; + return this; // allow chaining? + }, + + tags: function(tags) { + if (!arguments.length) return _this.oa.resource.chars; // not sure if this is the right "path"? + _this.oa.resource.chars = chars; + return this; // allow chaining? + // getter and setter for tag field (only the part that can be changed by user). + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + }, + + regionFragment: function() { + if (!arguments.length) return _this.oa.on; // not sure if this is the right "path"? + _this.oa.on = chars; // not exactly, parse the "on" field to add the new context after hash. + return this; // allow chaining? + // getter and setter for tag field (only the part that can be changed by user). + // If arguments are present, the property + // is set to the given value. If there are no + // arguments given, then + } + }; +}(Mirador)); + +(function($) { + + $.OpenSeadragon = function(options) { + + var osd = OpenSeadragon( + + jQuery.extend({ + preserveViewport: true, + visibilityRatio: 1, + minZoomLevel: 0, + defaultZoomLevel: 0, + blendTime: 0.1, + alwaysBlend: false, + prefixUrl: 'images/openseadragon/', + showNavigationControl: false + }, options) + + ); + + return osd; + + }; + +}(Mirador)); + +(function($) { + + $.SaveController = function(config) { + + jQuery.extend(true, this, { + currentConfig: null, + originalConfig: null, // Don't know if we really need this. + shareEndpoint: null, // the place where POST requests for new saved sessions will go + historySize: null, // wishful thinking for later. + sessionID: null + }); + + this.init(jQuery.extend(false, $.DEFAULT_SETTINGS, config)); + + }; + + $.SaveController.prototype = { + + init: function(config) { + var _this = this; + + // Don't want to save session, therefore don't set up save controller + if (config.saveSession === false) { + this.currentConfig = config; + return false; + } + + saveModule = config.jsonStorageEndpoint.module, + saveOptions = config.jsonStorageEndpoint.options; + _this.storageModule = new $[saveModule](saveOptions); + + var sessionID = window.location.hash.substring(1); // will return empty string if none exists, causing the or statement below to evaluate to false, generating a new sesssionID. + + if (sessionID) { + this.sessionID = sessionID; + } else { + this.sessionID = $.genUUID(); // might want a cleaner thing for the url. + } + + if (localStorage.getItem(this.sessionID)) { + this.currentConfig = JSON.parse(localStorage.getItem(sessionID)); + } else { + var paramURL = window.location.search.substring(1); + if (paramURL) { + //get json from JSON storage and set currentConfig to it + var params = paramURL.split('='); + var jsonblob = params[1]; + this.currentConfig = this.storageModule.readSync(jsonblob); + } else { + this.currentConfig = config; + } + } + //remove empty hashes from config + this.currentConfig.windowObjects = jQuery.map(this.currentConfig.windowObjects, function(value, index) { + if (Object.keys(value).length === 0) return null; + return value; + }); + + //add UUIDs to parts of config that need them + if (this.currentConfig.windowObjects) { + jQuery.each(this.currentConfig.windowObjects, function(index, window) { + if (!window.id) { + window.id = $.genUUID(); + } + }); + } + // see: http://html5demos.com/history and http://diveintohtml5.info/history.html + // put history stuff here, for a great cross-browser demo, see: http://browserstate.github.io/history.js/demo/ + //http://stackoverflow.com/questions/17801614/popstate-passing-popped-state-to-event-handler + + //also remove ?json bit so it's a clean URL + var cleanURL = window.location.href.replace(window.location.search, ""); + if (window.location.hash) { + history.replaceState(this.currentConfig, "Mirador Session", cleanURL); + } else { + history.replaceState(this.currentConfig, "Mirador Session", cleanURL+"#"+this.sessionID); + } + + this.bindEvents(); + + }, + + set: function(prop, value, options) { + // when a property of the config is updated, + // save it to localStore. + if (options) { + this[options.parent][prop] = value; + } else { + this[prop] = value; + } + this.save(); + jQuery.publish("saveControllerConfigUpdated"); + }, + + bindEvents: function() { + var _this = this; + // listen to existing events and use the + // available data to update the appropriate + // field in the stored config. + + jQuery.subscribe('windowUpdated', function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + jQuery.extend(windowObjects[index], options); + } + }); + } else { + windowObjects = [options]; + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe("imageBoundsUpdated", function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + if (!windowObjects[index].windowOptions) { + windowObjects[index].windowOptions = {}; + } + windowObjects[index].windowOptions.osdBounds = options.osdBounds; + } + }); + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('windowSlotAddressUpdated', function(event, options) { + var windowObjects = _this.currentConfig.windowObjects; + if (windowObjects && windowObjects.length > 0) { + jQuery.each(windowObjects, function(index, window){ + if (window.id === options.id) { + jQuery.extend(windowObjects[index], options); + } + }); + } else { + windowObjects = [options]; + } + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('manifestQueued', function(event, manifestObject, repository) { + var data = _this.currentConfig.data, + objectInConfig = false, + url = manifestObject.uri; + + jQuery.each(data, function(index, manifestObject){ + if (manifestObject.manifestUri === url) { + objectInConfig = true; + } + }); + if (!objectInConfig) { + data.push({"manifestUri":url, "location":repository}); + _this.set("data", data, {parent: "currentConfig"}); + } + }); + + jQuery.subscribe("layoutChanged", function(event, layoutDescription) { + // string parents to prevent invalid circular representation. + var serialisedLayout = JSON.stringify(layoutDescription, function(key, value) { + if (key === 'parent') return undefined; + return value; + }); + _this.set('layout', serialisedLayout, {parent: "currentConfig"} ); + }); + + jQuery.subscribe("windowSlotAdded", function(event, options) { + var windowObjects = _this.currentConfig.windowObjects, + inArray = jQuery.grep(windowObjects, function(windowObj) { + return windowObj.id === options.id; + }); + if (inArray.length === 0) { + windowObjects.push({ + 'id' : options.id, + 'slotAddress': options.slotAddress + }); + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + } + }); + + jQuery.subscribe("windowsRemoved", function(event) { + _this.set("windowObjects", [], {parent: "currentConfig"} ); + }); + + jQuery.subscribe("windowRemoved", function(event, windowID) { + var windowObjects = jQuery.grep(_this.currentConfig.windowObjects, function(window, index) { + return window.id !== windowID; + }); + _this.set("windowObjects", windowObjects, {parent: "currentConfig"} ); + }); + + jQuery.subscribe('etc...', function(junk) { + // handle adding the property in the appropriate place + // in this.currentConfig by passing to the _this.set(), + // which "saves" to localstore as a side effect. + + }); + + // We could have simply listened to the 'set' event that + // would have been emitted by objects when their models were + // updated and sent the results to a parser function that + // would extract the calling object's properties in the config + // and updated them if they were different, but we can't + // currently do that the way the app is written, since we + // didn't actually follow that patttern almost anywhere. + // + // jQuery.subscribe('set', function(junk) { + // // 1.) send the junk to a parser function + // // 2.) use this.set(parsedJunk) to update + // // this.currentConfig, with the side effect of + // // saving to localStorage. + // + // }); + + // you may need to bind another event here that responds to the + // user navigating history, for the purpose of popping the + // history entry back off. + + }, + + save: function() { + var _this = this; + + // the hash must be stringified because + // localStorage is a key:value store that + // only accepts strings. + + localStorage.setItem(_this.sessionID, JSON.stringify(_this.currentConfig)); + } + + }; + +}(Mirador)); + +(function($) { + + $.trimString = function(str) { + return str.replace(/^\s+|\s+$/g, ''); + }; + + /* -------------------------------------------------------------------------- + Methods related to manifest data + -------------------------------------------------------------------------- */ + + $.getImageIndexById = function(imagesList, id) { + var imgIndex = 0; + + jQuery.each(imagesList, function(index, img) { + if ($.trimString(img['@id']) === $.trimString(id)) { + imgIndex = index; + } + }); + + return imgIndex; + }; + + $.getThumbnailForCanvas = function(canvas, width) { + var version = "1.1", + service, + thumbnailUrl; + + // Ensure width is an integer... + width = parseInt(width, 10); + + // Respecting the Model... + if (canvas.hasOwnProperty('thumbnail')) { + // use the thumbnail image, prefer via a service + if (typeof(canvas.thumbnail) == 'string') { + thumbnailUrl = canvas.thumbnail; + } else if (canvas.thumbnail.hasOwnProperty('service')) { + // Get the IIIF Image API via the @context + service = canvas.thumbnail.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + console.log('version'); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } else { + thumbnailUrl = canvas.thumbnail['@id']; + } + } else { + // No thumbnail, use main image + var resource = canvas.images[0].resource; + service = resource['default'] ? resource['default'].service : resource.service; + if (service.hasOwnProperty('@context')) { + version = $.Iiif.getVersionFromContext(service['@context']); + } + thumbnailUrl = $.Iiif.makeUriWithWidth(service['@id'], width, version); + } + return thumbnailUrl; + }; + + $.getImagesListByManifest = function(manifest) { + return manifest.sequences[0].canvases; + }; + + $.getCollectionTitle = function(metadata) { + return metadata.details.label || ''; + }; + + /* + miscellaneous utilities + */ + + $.getQueryParams = function(url) { + var assoc = {}; + var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); }; + var queryString = url.split('?')[1]; + var keyValues = queryString.split('&'); + + for(var i in keyValues) { + var key = keyValues[i].split('='); + if (key.length > 1) { + assoc[decode(key[0])] = decode(key[1]); + } + } + + return assoc; + }; + + $.genUUID = function() { + var idNum = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + + return idNum; + }; + + jQuery.fn.slideFadeToggle = function(speed, easing, callback) { + return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); + }; + + $.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + + if (typeof options !== 'undefined') { + options = {}; + } + + var later = function() { + previous = options.leading === false ? 0 : new Date(); + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date(); + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + $.debounce = function(func, wait, immediate) { + var timeout, args, context, timestamp, result; + return function() { + context = this; + args = arguments; + timestamp = new Date(); + var later = function() { + var last = (new Date()) - timestamp; + if (last < wait) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + } + }; + var callNow = immediate && !timeout; + if (!timeout) { + timeout = setTimeout(later, wait); + } + if (callNow) result = func.apply(context, args); + return result; + }; + }; + + $.parseRegion = function(url) { + url = new URI(url); + var regionString = url.hash(); + regionArray = regionString.split('=')[1].split(','); + return regionArray; + }; + + $.getOsdFrame = function(region, currentImg) { + var imgWidth = currentImg.width, + imgHeight = currentImg.height, + canvasWidth = currentImg.canvasWidth, + canvasHeight = currentImg.canvasHeight, + widthNormaliser = imgWidth/canvasWidth, + heightNormaliser = imgHeight/canvasHeight, + rectX = (region[0]*widthNormaliser)/imgWidth, + rectY = (region[1]*heightNormaliser)/imgWidth, + rectW = (region[2]*widthNormaliser)/imgWidth, + rectH = (region[3]*heightNormaliser)/imgWidth; + + var osdFrame = new OpenSeadragon.Rect(rectX,rectY,rectW,rectH); + + return osdFrame; + }; + + // http://upshots.org/javascript/jquery-test-if-element-is-in-viewport-visible-on-screen + $.isOnScreen = function(elem, outsideViewportFactor) { + var factor = 1; + if (outsideViewportFactor) { + factor = outsideViewportFactor; + } + var win = jQuery(window); + var viewport = { + top : (win.scrollTop() * factor), + left : (win.scrollLeft() * factor) + }; + viewport.bottom = (viewport.top + win.outerHeight()) * factor; + viewport.right = (viewport.left + win.outerWidth()) * factor; + + var el = jQuery(elem); + var bounds = el.offset(); + bounds.bottom = bounds.top + el.height(); + bounds.right = bounds.left + el.width(); + + return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); + }; + + $.getRangeIDByCanvasID = function(structures, canvasID /*, [given parent range] (for multiple ranges, later) */) { + var ranges = jQuery.grep(structures, function(range) { return jQuery.inArray(canvasID, range.canvases) > -1; }), + rangeIDs = jQuery.map(ranges, function(range) { return range['@id']; }); + + return rangeIDs; + }; + + $.layoutDescriptionFromGridString = function (gridString) { + var columns = parseInt(gridString.substring(gridString.indexOf("x") + 1, gridString.length),10), + rowsPerColumn = parseInt(gridString.substring(0, gridString.indexOf("x")),10), + layoutDescription = { + type:'row' + }; + + if (gridString === "1x1") return layoutDescription; + + layoutDescription.children = []; + + // Javascript does not have range expansions quite yet, + // long live the humble for loop. + // Use a closure to contain the column and row variables. + for (var i = 0, c = columns; i < c; i++) { + var column = { type: 'column'}; + + if (rowsPerColumn > 1) { + column.children = []; + for (var j = 0, r = rowsPerColumn; j < r; j++) { + column.children.push({ + type: 'row' + }); + } + } + + layoutDescription.children.push(column); + } + + return layoutDescription; + }; + + $.generateRange = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = step || 1; + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + }; + + // Configurable Promises + $.createImagePromise = function(imageUrl) { + var img = new Image(), + dfd = jQuery.Deferred(); + + img.onload = function() { + dfd.resolve(img.src); + }; + + img.onerror = function() { + dfd.reject(img.src); + }; + + dfd.fail(function() { + console.log('image failed to load: ' + img.src); + }); + + img.src = imageUrl; + return dfd.promise(); + }; + +}(Mirador)); diff --git a/vendor/assets/javascripts/openseadragon-viewerinputhook.js b/vendor/assets/javascripts/openseadragon-viewerinputhook.js new file mode 100644 index 0000000..86527fd --- /dev/null +++ b/vendor/assets/javascripts/openseadragon-viewerinputhook.js @@ -0,0 +1,139 @@ +//! OpenSeadragonViewerInputHook 1.1.0 +//! Build date: 2014-01-13 +//! Git commit: v1.0.0-13-g7e47873 +//! https://github.com/msalsbery/OpenSeadragonViewerInputHook +/* + * Copyright (c) 2013-2014 Mark Salsbery + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * @file + * @version OpenSeadragonViewerInputHook 1.1.0 + * @author Mark Salsbery + * + */ + +/** + * @module openseadragon-viewerinputhook + * @version OpenSeadragonViewerInputHook 1.1.0 + * + */ + + +(function(OSD, $, undefined) { + + if (!OSD.version || OSD.version.major < 1) { + throw new Error('OpenSeadragonViewerInputHook requires OpenSeadragon version 1.0.0+'); + } + + /** + * Creates a new ViewerInputHook attached to the viewer. + * + * @method addViewerInputHook + * @memberof external:"OpenSeadragon.Viewer"# + * @param {Object} options + * @param {Object[]} [options.hooks] + * @returns {OpenSeadragonImaging.ViewerInputHook} + * + **/ + OSD.Viewer.prototype.addViewerInputHook = function(options) { + options = options || {}; + options.viewer = this; + return new $.ViewerInputHook(options); + }; + + /** + * Creates a new ViewerInputHook attached (optionally) to the viewer instance passed in the options parameter. + * + * @class ViewerInputHook + * @classdesc Provides hooks into the OpenSeadragon viewer event pipeline. + * @memberof OpenSeadragonImaging + * @param {Object} options + * @param {external:"OpenSeadragon.Viewer"} [options.viewer] - Reference to OpenSeadragon viewer to attach to. + * @param {Object[]} options.hooks + * + **/ + $.ViewerInputHook = function(options) { + + var curHook, curTracker; + + options = options || {}; + options.hooks = options.hooks || []; + + this.viewerTrackers = {}; + + if (options.viewer) { + this.viewerTrackers.viewer = options.viewer.innerTracker; + this.viewerTrackers.viewer_outer = options.viewer.outerTracker; + } + + for (curHook = 0; curHook < options.hooks.length; curHook++) { + if (typeof options.hooks[curHook].tracker === 'string') { + if (!options.viewer) { + throw new Error('A viewer must be specified.'); + } + curTracker = this.viewerTrackers[options.hooks[curHook].tracker]; + if (curTracker === undefined) { + throw new Error('Unknown tracker specified: ' + options.hooks[curHook].tracker); + } + } + else { + curTracker = options.hooks[curHook].tracker; + } + /*jshint loopfunc:true*/ + (function (_this, tracker, handler, hookHandler) { + var origHandler = tracker[handler]; + tracker[handler] = function (event) { + return _this.callHandlers(hookHandler, origHandler, event); + }; + }(this, curTracker, options.hooks[curHook].handler, options.hooks[curHook].hookHandler)); + /*jshint loopfunc:false*/ + } + }; + + + /** + * ViewerInputHook version. + * @member {Object} OpenSeadragonImaging.ViewerInputHook.version + * @property {String} versionStr - The version number as a string ('major.minor.revision'). + * @property {Number} major - The major version number. + * @property {Number} minor - The minor version number. + * @property {Number} revision - The revision number. + */ + /* jshint ignore:start */ + $.ViewerInputHook.version = { + versionStr: '1.1.0', + major: 1, + minor: 1, + revision: 0 + }; + /* jshint ignore:end */ + + + $.ViewerInputHook.prototype.callHandlers = function (hookHandler, origHandler, event) { + var ret = hookHandler(event); + if (origHandler && !event.stopHandlers) { + ret = origHandler(event); + } + return event.stopBubbling ? false : ret; + }; + +}(OpenSeadragon, window.OpenSeadragonImaging = window.OpenSeadragonImaging || {})); diff --git a/vendor/assets/javascripts/scrollspy.js b/vendor/assets/javascripts/scrollspy.js new file mode 100644 index 0000000..d819462 --- /dev/null +++ b/vendor/assets/javascripts/scrollspy.js @@ -0,0 +1,172 @@ +/* ======================================================================== + * Bootstrap: scrollspy.js v3.3.6 + * http://getbootstrap.com/javascript/#scrollspy + * ======================================================================== + * Copyright 2011-2016 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // SCROLLSPY CLASS DEFINITION + // ========================== + + function ScrollSpy(element, options) { + this.$body = $(document.body) + this.$scrollElement = $(element).is(document.body) ? $(window) : $(element) + this.options = $.extend({}, ScrollSpy.DEFAULTS, options) + this.selector = (this.options.target || '') + ' .nav li > a' + this.offsets = [] + this.targets = [] + this.activeTarget = null + this.scrollHeight = 0 + + this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this)) + this.refresh() + this.process() + } + + ScrollSpy.VERSION = '3.3.6' + + ScrollSpy.DEFAULTS = { + offset: 10 + } + + ScrollSpy.prototype.getScrollHeight = function () { + return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight) + } + + ScrollSpy.prototype.refresh = function () { + var that = this + var offsetMethod = 'offset' + var offsetBase = 0 + + this.offsets = [] + this.targets = [] + this.scrollHeight = this.getScrollHeight() + + if (!$.isWindow(this.$scrollElement[0])) { + offsetMethod = 'position' + offsetBase = this.$scrollElement.scrollTop() + } + + this.$body + .find(this.selector) + .map(function () { + var $el = $(this) + var href = $el.data('target') || $el.attr('href') + var $href = /^#./.test(href) && $(href) + + return ($href + && $href.length + && $href.is(':visible') + && [[$href[offsetMethod]().top + offsetBase, href]]) || null + }) + .sort(function (a, b) { return a[0] - b[0] }) + .each(function () { + that.offsets.push(this[0]) + that.targets.push(this[1]) + }) + } + + ScrollSpy.prototype.process = function () { + var scrollTop = this.$scrollElement.scrollTop() + this.options.offset + var scrollHeight = this.getScrollHeight() + var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height() + var offsets = this.offsets + var targets = this.targets + var activeTarget = this.activeTarget + var i + + if (this.scrollHeight != scrollHeight) { + this.refresh() + } + + if (scrollTop >= maxScroll) { + return activeTarget != (i = targets[targets.length - 1]) && this.activate(i) + } + + if (activeTarget && scrollTop < offsets[0]) { + this.activeTarget = null + return this.clear() + } + + for (i = offsets.length; i--;) { + activeTarget != targets[i] + && scrollTop >= offsets[i] + && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1]) + && this.activate(targets[i]) + } + } + + ScrollSpy.prototype.activate = function (target) { + this.activeTarget = target + + this.clear() + + var selector = this.selector + + '[data-target="' + target + '"],' + + this.selector + '[href="' + target + '"]' + + var active = $(selector) + .parents('li') + .addClass('active') + + if (active.parent('.dropdown-menu').length) { + active = active + .closest('li.dropdown') + .addClass('active') + } + + active.trigger('activate.bs.scrollspy') + } + + ScrollSpy.prototype.clear = function () { + $(this.selector) + .parentsUntil(this.options.target, '.active') + .removeClass('active') + } + + + // SCROLLSPY PLUGIN DEFINITION + // =========================== + + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.scrollspy') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + var old = $.fn.scrollspy + + $.fn.scrollspy = Plugin + $.fn.scrollspy.Constructor = ScrollSpy + + + // SCROLLSPY NO CONFLICT + // ===================== + + $.fn.scrollspy.noConflict = function () { + $.fn.scrollspy = old + return this + } + + + // SCROLLSPY DATA-API + // ================== + + $(window).on('load.bs.scrollspy.data-api', function () { + $('[data-spy="scroll"]').each(function () { + var $spy = $(this) + Plugin.call($spy, $spy.data()) + }) + }) + +}(jQuery); diff --git a/vendor/assets/stylesheets/jquery-tablesorter.css.scss b/vendor/assets/stylesheets/jquery-tablesorter.css.scss new file mode 100644 index 0000000..26d8cd4 --- /dev/null +++ b/vendor/assets/stylesheets/jquery-tablesorter.css.scss @@ -0,0 +1,47 @@ +/* tables */ +table.tablesorter { + font-family:arial; + background-color: #CDCDCD; + /* margin:10px -10pt 15px; */ + margin:10px -10px; /* AR */ + /* font-size: 8pt; */ /* AR */ + width: 100%; + text-align: left; +} +table.tablesorter thead tr th, table.tablesorter tfoot tr th { + background-color: #e6EEEE; + border: 1px solid #FFF; + font-size: 8pt; + padding: 4px; + padding-right: 20px; +} +table.tablesorter thead tr .header { + background-image: asset_url('bg.gif'); + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter tbody td { + color: #3D3D3D; + padding: 4px; + background-color: #FFF; + vertical-align: top; +} +table.tablesorter tbody tr.odd td { + background-color:#F0F0F6; +} + +table.tablesorter tbody tr:nth-child(odd) td { + background-color:#F0F0F6; +} + +table.tablesorter thead tr .headerSortUp { + background-image: asset_url('asc.gif'); +} +table.tablesorter thead tr .headerSortDown { + background-image: asset_url('desc.gif'); +} +table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { +background-color: #8dbdd8; +} + diff --git a/vendor/assets/stylesheets/mirador-combined.css b/vendor/assets/stylesheets/mirador-combined.css new file mode 100644 index 0000000..ab26866 --- /dev/null +++ b/vendor/assets/stylesheets/mirador-combined.css @@ -0,0 +1,4057 @@ +/*! normalize.css v2.1.2 | MIT License | git.io/normalize */ + +/* ========================================================================== + HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined in IE 8/9. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +nav, +section, +summary { + display: block; +} + +/** + * Correct `inline-block` display not defined in IE 8/9. + */ + +audio, +canvas, +video { + display: inline-block; +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +[hidden] { + display: none; +} + +/* ========================================================================== + Base + ========================================================================== */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* ========================================================================== + Links + ========================================================================== */ + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* ========================================================================== + Typography + ========================================================================== */ + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari 5, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9, Safari 5, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari 5 and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; + border:0; + border-bottom:1px solid rgba(0,0,0,0.4); +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Correct font family set oddly in Safari 5 and Chrome. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, serif; + font-size: 1em; +} + +/** + * Improve readability of pre-formatted text in all browsers. + */ + +pre { + white-space: pre-wrap; +} + +/** + * Set consistent quote types. + */ + +q { + quotes: "\201C" "\201D" "\2018" "\2019"; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ========================================================================== + Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9. + */ + +img { + border: 0; +} + +/** + * Correct overflow displayed oddly in IE 9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* ========================================================================== + Figures + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari 5. + */ + +figure { + margin: 0; +} + +/* ========================================================================== + Forms + ========================================================================== */ + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * 1. Correct font family not being inherited in all browsers. + * 2. Correct font size not being inherited in all browsers. + * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. + */ + +button, +input, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +button, +input { + line-height: normal; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. + * Correct `select` style inheritance in Firefox 4+ and Opera. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * 1. Address box sizing set to `content-box` in IE 8/9. + * 2. Remove excess padding in IE 8/9. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari 5 and Chrome + * on OS X. + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * 1. Remove default vertical scrollbar in IE 8/9. + * 2. Improve readability and alignment in all browsers. + */ + +textarea { + overflow: auto; /* 1 */ + vertical-align: top; /* 2 */ +} + +/* ========================================================================== + Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + + +/*! + * Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */ +/* FONT PATH + * -------------------------- */ +@font-face { + font-family: 'FontAwesome'; + src: url('/assets/fontawesome-webfont.eot?v=4.1.0'); + src: url('/assets/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('/assets/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('/assets/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('/assets/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg'); + font-weight: normal; + font-style: normal; +} +.fa { + display: inline-block; + font-family: FontAwesome; + font-style: normal; + font-weight: normal; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +/* makes the font 33% larger relative to the icon container */ +.fa-lg { + font-size: 1.33333333em; + line-height: 0.75em; + vertical-align: -15%; +} +.fa-2x { + font-size: 2em; +} +.fa-3x { + font-size: 3em; +} +.fa-4x { + font-size: 4em; +} +.fa-5x { + font-size: 5em; +} +.fa-fw { + width: 1.28571429em; + text-align: center; +} +.fa-ul { + padding-left: 0; + margin-left: 2.14285714em; + list-style-type: none; +} +.fa-ul > li { + position: relative; +} +.fa-li { + position: absolute; + left: -2.14285714em; + width: 2.14285714em; + top: 0.14285714em; + text-align: center; +} +.fa-li.fa-lg { + left: -1.85714286em; +} +.fa-border { + padding: .2em .25em .15em; + border: solid 0.08em #eeeeee; + border-radius: .1em; +} +.pull-right { + float: right; +} +.pull-left { + float: left; +} +.fa.pull-left { + margin-right: .3em; +} +.fa.pull-right { + margin-left: .3em; +} +.fa-spin { + -webkit-animation: spin 2s infinite linear; + -moz-animation: spin 2s infinite linear; + -o-animation: spin 2s infinite linear; + animation: spin 2s infinite linear; +} +@-moz-keyframes spin { + 0% { + -moz-transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + } +} +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + } +} +@-o-keyframes spin { + 0% { + -o-transform: rotate(0deg); + } + 100% { + -o-transform: rotate(359deg); + } +} +@keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +.fa-rotate-90 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + transform: rotate(90deg); +} +.fa-rotate-180 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -ms-transform: rotate(180deg); + -o-transform: rotate(180deg); + transform: rotate(180deg); +} +.fa-rotate-270 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); + -webkit-transform: rotate(270deg); + -moz-transform: rotate(270deg); + -ms-transform: rotate(270deg); + -o-transform: rotate(270deg); + transform: rotate(270deg); +} +.fa-flip-horizontal { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1); + -webkit-transform: scale(-1, 1); + -moz-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + -o-transform: scale(-1, 1); + transform: scale(-1, 1); +} +.fa-flip-vertical { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1); + -webkit-transform: scale(1, -1); + -moz-transform: scale(1, -1); + -ms-transform: scale(1, -1); + -o-transform: scale(1, -1); + transform: scale(1, -1); +} +.fa-stack { + position: relative; + display: inline-block; + width: 2em; + height: 2em; + line-height: 2em; + vertical-align: middle; +} +.fa-stack-1x, +.fa-stack-2x { + position: absolute; + left: 0; + width: 100%; + text-align: center; +} +.fa-stack-1x { + line-height: inherit; +} +.fa-stack-2x { + font-size: 2em; +} +.fa-inverse { + color: #ffffff; +} +/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen + readers do not read off random characters that represent icons */ +.fa-glass:before { + content: "\f000"; +} +.fa-music:before { + content: "\f001"; +} +.fa-search:before { + content: "\f002"; +} +.fa-envelope-o:before { + content: "\f003"; +} +.fa-heart:before { + content: "\f004"; +} +.fa-star:before { + content: "\f005"; +} +.fa-star-o:before { + content: "\f006"; +} +.fa-user:before { + content: "\f007"; +} +.fa-film:before { + content: "\f008"; +} +.fa-th-large:before { + content: "\f009"; +} +.fa-th:before { + content: "\f00a"; +} +.fa-th-list:before { + content: "\f00b"; +} +.fa-check:before { + content: "\f00c"; +} +.fa-times:before { + content: "\f00d"; +} +.fa-search-plus:before { + content: "\f00e"; +} +.fa-search-minus:before { + content: "\f010"; +} +.fa-power-off:before { + content: "\f011"; +} +.fa-signal:before { + content: "\f012"; +} +.fa-gear:before, +.fa-cog:before { + content: "\f013"; +} +.fa-trash-o:before { + content: "\f014"; +} +.fa-home:before { + content: "\f015"; +} +.fa-file-o:before { + content: "\f016"; +} +.fa-clock-o:before { + content: "\f017"; +} +.fa-road:before { + content: "\f018"; +} +.fa-download:before { + content: "\f019"; +} +.fa-arrow-circle-o-down:before { + content: "\f01a"; +} +.fa-arrow-circle-o-up:before { + content: "\f01b"; +} +.fa-inbox:before { + content: "\f01c"; +} +.fa-play-circle-o:before { + content: "\f01d"; +} +.fa-rotate-right:before, +.fa-repeat:before { + content: "\f01e"; +} +.fa-refresh:before { + content: "\f021"; +} +.fa-list-alt:before { + content: "\f022"; +} +.fa-lock:before { + content: "\f023"; +} +.fa-flag:before { + content: "\f024"; +} +.fa-headphones:before { + content: "\f025"; +} +.fa-volume-off:before { + content: "\f026"; +} +.fa-volume-down:before { + content: "\f027"; +} +.fa-volume-up:before { + content: "\f028"; +} +.fa-qrcode:before { + content: "\f029"; +} +.fa-barcode:before { + content: "\f02a"; +} +.fa-tag:before { + content: "\f02b"; +} +.fa-tags:before { + content: "\f02c"; +} +.fa-book:before { + content: "\f02d"; +} +.fa-bookmark:before { + content: "\f02e"; +} +.fa-print:before { + content: "\f02f"; +} +.fa-camera:before { + content: "\f030"; +} +.fa-font:before { + content: "\f031"; +} +.fa-bold:before { + content: "\f032"; +} +.fa-italic:before { + content: "\f033"; +} +.fa-text-height:before { + content: "\f034"; +} +.fa-text-width:before { + content: "\f035"; +} +.fa-align-left:before { + content: "\f036"; +} +.fa-align-center:before { + content: "\f037"; +} +.fa-align-right:before { + content: "\f038"; +} +.fa-align-justify:before { + content: "\f039"; +} +.fa-list:before { + content: "\f03a"; +} +.fa-dedent:before, +.fa-outdent:before { + content: "\f03b"; +} +.fa-indent:before { + content: "\f03c"; +} +.fa-video-camera:before { + content: "\f03d"; +} +.fa-photo:before, +.fa-image:before, +.fa-picture-o:before { + content: "\f03e"; +} +.fa-pencil:before { + content: "\f040"; +} +.fa-map-marker:before { + content: "\f041"; +} +.fa-adjust:before { + content: "\f042"; +} +.fa-tint:before { + content: "\f043"; +} +.fa-edit:before, +.fa-pencil-square-o:before { + content: "\f044"; +} +.fa-share-square-o:before { + content: "\f045"; +} +.fa-check-square-o:before { + content: "\f046"; +} +.fa-arrows:before { + content: "\f047"; +} +.fa-step-backward:before { + content: "\f048"; +} +.fa-fast-backward:before { + content: "\f049"; +} +.fa-backward:before { + content: "\f04a"; +} +.fa-play:before { + content: "\f04b"; +} +.fa-pause:before { + content: "\f04c"; +} +.fa-stop:before { + content: "\f04d"; +} +.fa-forward:before { + content: "\f04e"; +} +.fa-fast-forward:before { + content: "\f050"; +} +.fa-step-forward:before { + content: "\f051"; +} +.fa-eject:before { + content: "\f052"; +} +.fa-chevron-left:before { + content: "\f053"; +} +.fa-chevron-right:before { + content: "\f054"; +} +.fa-plus-circle:before { + content: "\f055"; +} +.fa-minus-circle:before { + content: "\f056"; +} +.fa-times-circle:before { + content: "\f057"; +} +.fa-check-circle:before { + content: "\f058"; +} +.fa-question-circle:before { + content: "\f059"; +} +.fa-info-circle:before { + content: "\f05a"; +} +.fa-crosshairs:before { + content: "\f05b"; +} +.fa-times-circle-o:before { + content: "\f05c"; +} +.fa-check-circle-o:before { + content: "\f05d"; +} +.fa-ban:before { + content: "\f05e"; +} +.fa-arrow-left:before { + content: "\f060"; +} +.fa-arrow-right:before { + content: "\f061"; +} +.fa-arrow-up:before { + content: "\f062"; +} +.fa-arrow-down:before { + content: "\f063"; +} +.fa-mail-forward:before, +.fa-share:before { + content: "\f064"; +} +.fa-expand:before { + content: "\f065"; +} +.fa-compress:before { + content: "\f066"; +} +.fa-plus:before { + content: "\f067"; +} +.fa-minus:before { + content: "\f068"; +} +.fa-asterisk:before { + content: "\f069"; +} +.fa-exclamation-circle:before { + content: "\f06a"; +} +.fa-gift:before { + content: "\f06b"; +} +.fa-leaf:before { + content: "\f06c"; +} +.fa-fire:before { + content: "\f06d"; +} +.fa-eye:before { + content: "\f06e"; +} +.fa-eye-slash:before { + content: "\f070"; +} +.fa-warning:before, +.fa-exclamation-triangle:before { + content: "\f071"; +} +.fa-plane:before { + content: "\f072"; +} +.fa-calendar:before { + content: "\f073"; +} +.fa-random:before { + content: "\f074"; +} +.fa-comment:before { + content: "\f075"; +} +.fa-magnet:before { + content: "\f076"; +} +.fa-chevron-up:before { + content: "\f077"; +} +.fa-chevron-down:before { + content: "\f078"; +} +.fa-retweet:before { + content: "\f079"; +} +.fa-shopping-cart:before { + content: "\f07a"; +} +.fa-folder:before { + content: "\f07b"; +} +.fa-folder-open:before { + content: "\f07c"; +} +.fa-arrows-v:before { + content: "\f07d"; +} +.fa-arrows-h:before { + content: "\f07e"; +} +.fa-bar-chart-o:before { + content: "\f080"; +} +.fa-twitter-square:before { + content: "\f081"; +} +.fa-facebook-square:before { + content: "\f082"; +} +.fa-camera-retro:before { + content: "\f083"; +} +.fa-key:before { + content: "\f084"; +} +.fa-gears:before, +.fa-cogs:before { + content: "\f085"; +} +.fa-comments:before { + content: "\f086"; +} +.fa-thumbs-o-up:before { + content: "\f087"; +} +.fa-thumbs-o-down:before { + content: "\f088"; +} +.fa-star-half:before { + content: "\f089"; +} +.fa-heart-o:before { + content: "\f08a"; +} +.fa-sign-out:before { + content: "\f08b"; +} +.fa-linkedin-square:before { + content: "\f08c"; +} +.fa-thumb-tack:before { + content: "\f08d"; +} +.fa-external-link:before { + content: "\f08e"; +} +.fa-sign-in:before { + content: "\f090"; +} +.fa-trophy:before { + content: "\f091"; +} +.fa-github-square:before { + content: "\f092"; +} +.fa-upload:before { + content: "\f093"; +} +.fa-lemon-o:before { + content: "\f094"; +} +.fa-phone:before { + content: "\f095"; +} +.fa-square-o:before { + content: "\f096"; +} +.fa-bookmark-o:before { + content: "\f097"; +} +.fa-phone-square:before { + content: "\f098"; +} +.fa-twitter:before { + content: "\f099"; +} +.fa-facebook:before { + content: "\f09a"; +} +.fa-github:before { + content: "\f09b"; +} +.fa-unlock:before { + content: "\f09c"; +} +.fa-credit-card:before { + content: "\f09d"; +} +.fa-rss:before { + content: "\f09e"; +} +.fa-hdd-o:before { + content: "\f0a0"; +} +.fa-bullhorn:before { + content: "\f0a1"; +} +.fa-bell:before { + content: "\f0f3"; +} +.fa-certificate:before { + content: "\f0a3"; +} +.fa-hand-o-right:before { + content: "\f0a4"; +} +.fa-hand-o-left:before { + content: "\f0a5"; +} +.fa-hand-o-up:before { + content: "\f0a6"; +} +.fa-hand-o-down:before { + content: "\f0a7"; +} +.fa-arrow-circle-left:before { + content: "\f0a8"; +} +.fa-arrow-circle-right:before { + content: "\f0a9"; +} +.fa-arrow-circle-up:before { + content: "\f0aa"; +} +.fa-arrow-circle-down:before { + content: "\f0ab"; +} +.fa-globe:before { + content: "\f0ac"; +} +.fa-wrench:before { + content: "\f0ad"; +} +.fa-tasks:before { + content: "\f0ae"; +} +.fa-filter:before { + content: "\f0b0"; +} +.fa-briefcase:before { + content: "\f0b1"; +} +.fa-arrows-alt:before { + content: "\f0b2"; +} +.fa-group:before, +.fa-users:before { + content: "\f0c0"; +} +.fa-chain:before, +.fa-link:before { + content: "\f0c1"; +} +.fa-cloud:before { + content: "\f0c2"; +} +.fa-flask:before { + content: "\f0c3"; +} +.fa-cut:before, +.fa-scissors:before { + content: "\f0c4"; +} +.fa-copy:before, +.fa-files-o:before { + content: "\f0c5"; +} +.fa-paperclip:before { + content: "\f0c6"; +} +.fa-save:before, +.fa-floppy-o:before { + content: "\f0c7"; +} +.fa-square:before { + content: "\f0c8"; +} +.fa-navicon:before, +.fa-reorder:before, +.fa-bars:before { + content: "\f0c9"; +} +.fa-list-ul:before { + content: "\f0ca"; +} +.fa-list-ol:before { + content: "\f0cb"; +} +.fa-strikethrough:before { + content: "\f0cc"; +} +.fa-underline:before { + content: "\f0cd"; +} +.fa-table:before { + content: "\f0ce"; +} +.fa-magic:before { + content: "\f0d0"; +} +.fa-truck:before { + content: "\f0d1"; +} +.fa-pinterest:before { + content: "\f0d2"; +} +.fa-pinterest-square:before { + content: "\f0d3"; +} +.fa-google-plus-square:before { + content: "\f0d4"; +} +.fa-google-plus:before { + content: "\f0d5"; +} +.fa-money:before { + content: "\f0d6"; +} +.fa-caret-down:before { + content: "\f0d7"; +} +.fa-caret-up:before { + content: "\f0d8"; +} +.fa-caret-left:before { + content: "\f0d9"; +} +.fa-caret-right:before { + content: "\f0da"; +} +.fa-columns:before { + content: "\f0db"; +} +.fa-unsorted:before, +.fa-sort:before { + content: "\f0dc"; +} +.fa-sort-down:before, +.fa-sort-desc:before { + content: "\f0dd"; +} +.fa-sort-up:before, +.fa-sort-asc:before { + content: "\f0de"; +} +.fa-envelope:before { + content: "\f0e0"; +} +.fa-linkedin:before { + content: "\f0e1"; +} +.fa-rotate-left:before, +.fa-undo:before { + content: "\f0e2"; +} +.fa-legal:before, +.fa-gavel:before { + content: "\f0e3"; +} +.fa-dashboard:before, +.fa-tachometer:before { + content: "\f0e4"; +} +.fa-comment-o:before { + content: "\f0e5"; +} +.fa-comments-o:before { + content: "\f0e6"; +} +.fa-flash:before, +.fa-bolt:before { + content: "\f0e7"; +} +.fa-sitemap:before { + content: "\f0e8"; +} +.fa-umbrella:before { + content: "\f0e9"; +} +.fa-paste:before, +.fa-clipboard:before { + content: "\f0ea"; +} +.fa-lightbulb-o:before { + content: "\f0eb"; +} +.fa-exchange:before { + content: "\f0ec"; +} +.fa-cloud-download:before { + content: "\f0ed"; +} +.fa-cloud-upload:before { + content: "\f0ee"; +} +.fa-user-md:before { + content: "\f0f0"; +} +.fa-stethoscope:before { + content: "\f0f1"; +} +.fa-suitcase:before { + content: "\f0f2"; +} +.fa-bell-o:before { + content: "\f0a2"; +} +.fa-coffee:before { + content: "\f0f4"; +} +.fa-cutlery:before { + content: "\f0f5"; +} +.fa-file-text-o:before { + content: "\f0f6"; +} +.fa-building-o:before { + content: "\f0f7"; +} +.fa-hospital-o:before { + content: "\f0f8"; +} +.fa-ambulance:before { + content: "\f0f9"; +} +.fa-medkit:before { + content: "\f0fa"; +} +.fa-fighter-jet:before { + content: "\f0fb"; +} +.fa-beer:before { + content: "\f0fc"; +} +.fa-h-square:before { + content: "\f0fd"; +} +.fa-plus-square:before { + content: "\f0fe"; +} +.fa-angle-double-left:before { + content: "\f100"; +} +.fa-angle-double-right:before { + content: "\f101"; +} +.fa-angle-double-up:before { + content: "\f102"; +} +.fa-angle-double-down:before { + content: "\f103"; +} +.fa-angle-left:before { + content: "\f104"; +} +.fa-angle-right:before { + content: "\f105"; +} +.fa-angle-up:before { + content: "\f106"; +} +.fa-angle-down:before { + content: "\f107"; +} +.fa-desktop:before { + content: "\f108"; +} +.fa-laptop:before { + content: "\f109"; +} +.fa-tablet:before { + content: "\f10a"; +} +.fa-mobile-phone:before, +.fa-mobile:before { + content: "\f10b"; +} +.fa-circle-o:before { + content: "\f10c"; +} +.fa-quote-left:before { + content: "\f10d"; +} +.fa-quote-right:before { + content: "\f10e"; +} +.fa-spinner:before { + content: "\f110"; +} +.fa-circle:before { + content: "\f111"; +} +.fa-mail-reply:before, +.fa-reply:before { + content: "\f112"; +} +.fa-github-alt:before { + content: "\f113"; +} +.fa-folder-o:before { + content: "\f114"; +} +.fa-folder-open-o:before { + content: "\f115"; +} +.fa-smile-o:before { + content: "\f118"; +} +.fa-frown-o:before { + content: "\f119"; +} +.fa-meh-o:before { + content: "\f11a"; +} +.fa-gamepad:before { + content: "\f11b"; +} +.fa-keyboard-o:before { + content: "\f11c"; +} +.fa-flag-o:before { + content: "\f11d"; +} +.fa-flag-checkered:before { + content: "\f11e"; +} +.fa-terminal:before { + content: "\f120"; +} +.fa-code:before { + content: "\f121"; +} +.fa-mail-reply-all:before, +.fa-reply-all:before { + content: "\f122"; +} +.fa-star-half-empty:before, +.fa-star-half-full:before, +.fa-star-half-o:before { + content: "\f123"; +} +.fa-location-arrow:before { + content: "\f124"; +} +.fa-crop:before { + content: "\f125"; +} +.fa-code-fork:before { + content: "\f126"; +} +.fa-unlink:before, +.fa-chain-broken:before { + content: "\f127"; +} +.fa-question:before { + content: "\f128"; +} +.fa-info:before { + content: "\f129"; +} +.fa-exclamation:before { + content: "\f12a"; +} +.fa-superscript:before { + content: "\f12b"; +} +.fa-subscript:before { + content: "\f12c"; +} +.fa-eraser:before { + content: "\f12d"; +} +.fa-puzzle-piece:before { + content: "\f12e"; +} +.fa-microphone:before { + content: "\f130"; +} +.fa-microphone-slash:before { + content: "\f131"; +} +.fa-shield:before { + content: "\f132"; +} +.fa-calendar-o:before { + content: "\f133"; +} +.fa-fire-extinguisher:before { + content: "\f134"; +} +.fa-rocket:before { + content: "\f135"; +} +.fa-maxcdn:before { + content: "\f136"; +} +.fa-chevron-circle-left:before { + content: "\f137"; +} +.fa-chevron-circle-right:before { + content: "\f138"; +} +.fa-chevron-circle-up:before { + content: "\f139"; +} +.fa-chevron-circle-down:before { + content: "\f13a"; +} +.fa-html5:before { + content: "\f13b"; +} +.fa-css3:before { + content: "\f13c"; +} +.fa-anchor:before { + content: "\f13d"; +} +.fa-unlock-alt:before { + content: "\f13e"; +} +.fa-bullseye:before { + content: "\f140"; +} +.fa-ellipsis-h:before { + content: "\f141"; +} +.fa-ellipsis-v:before { + content: "\f142"; +} +.fa-rss-square:before { + content: "\f143"; +} +.fa-play-circle:before { + content: "\f144"; +} +.fa-ticket:before { + content: "\f145"; +} +.fa-minus-square:before { + content: "\f146"; +} +.fa-minus-square-o:before { + content: "\f147"; +} +.fa-level-up:before { + content: "\f148"; +} +.fa-level-down:before { + content: "\f149"; +} +.fa-check-square:before { + content: "\f14a"; +} +.fa-pencil-square:before { + content: "\f14b"; +} +.fa-external-link-square:before { + content: "\f14c"; +} +.fa-share-square:before { + content: "\f14d"; +} +.fa-compass:before { + content: "\f14e"; +} +.fa-toggle-down:before, +.fa-caret-square-o-down:before { + content: "\f150"; +} +.fa-toggle-up:before, +.fa-caret-square-o-up:before { + content: "\f151"; +} +.fa-toggle-right:before, +.fa-caret-square-o-right:before { + content: "\f152"; +} +.fa-euro:before, +.fa-eur:before { + content: "\f153"; +} +.fa-gbp:before { + content: "\f154"; +} +.fa-dollar:before, +.fa-usd:before { + content: "\f155"; +} +.fa-rupee:before, +.fa-inr:before { + content: "\f156"; +} +.fa-cny:before, +.fa-rmb:before, +.fa-yen:before, +.fa-jpy:before { + content: "\f157"; +} +.fa-ruble:before, +.fa-rouble:before, +.fa-rub:before { + content: "\f158"; +} +.fa-won:before, +.fa-krw:before { + content: "\f159"; +} +.fa-bitcoin:before, +.fa-btc:before { + content: "\f15a"; +} +.fa-file:before { + content: "\f15b"; +} +.fa-file-text:before { + content: "\f15c"; +} +.fa-sort-alpha-asc:before { + content: "\f15d"; +} +.fa-sort-alpha-desc:before { + content: "\f15e"; +} +.fa-sort-amount-asc:before { + content: "\f160"; +} +.fa-sort-amount-desc:before { + content: "\f161"; +} +.fa-sort-numeric-asc:before { + content: "\f162"; +} +.fa-sort-numeric-desc:before { + content: "\f163"; +} +.fa-thumbs-up:before { + content: "\f164"; +} +.fa-thumbs-down:before { + content: "\f165"; +} +.fa-youtube-square:before { + content: "\f166"; +} +.fa-youtube:before { + content: "\f167"; +} +.fa-xing:before { + content: "\f168"; +} +.fa-xing-square:before { + content: "\f169"; +} +.fa-youtube-play:before { + content: "\f16a"; +} +.fa-dropbox:before { + content: "\f16b"; +} +.fa-stack-overflow:before { + content: "\f16c"; +} +.fa-instagram:before { + content: "\f16d"; +} +.fa-flickr:before { + content: "\f16e"; +} +.fa-adn:before { + content: "\f170"; +} +.fa-bitbucket:before { + content: "\f171"; +} +.fa-bitbucket-square:before { + content: "\f172"; +} +.fa-tumblr:before { + content: "\f173"; +} +.fa-tumblr-square:before { + content: "\f174"; +} +.fa-long-arrow-down:before { + content: "\f175"; +} +.fa-long-arrow-up:before { + content: "\f176"; +} +.fa-long-arrow-left:before { + content: "\f177"; +} +.fa-long-arrow-right:before { + content: "\f178"; +} +.fa-apple:before { + content: "\f179"; +} +.fa-windows:before { + content: "\f17a"; +} +.fa-android:before { + content: "\f17b"; +} +.fa-linux:before { + content: "\f17c"; +} +.fa-dribbble:before { + content: "\f17d"; +} +.fa-skype:before { + content: "\f17e"; +} +.fa-foursquare:before { + content: "\f180"; +} +.fa-trello:before { + content: "\f181"; +} +.fa-female:before { + content: "\f182"; +} +.fa-male:before { + content: "\f183"; +} +.fa-gittip:before { + content: "\f184"; +} +.fa-sun-o:before { + content: "\f185"; +} +.fa-moon-o:before { + content: "\f186"; +} +.fa-archive:before { + content: "\f187"; +} +.fa-bug:before { + content: "\f188"; +} +.fa-vk:before { + content: "\f189"; +} +.fa-weibo:before { + content: "\f18a"; +} +.fa-renren:before { + content: "\f18b"; +} +.fa-pagelines:before { + content: "\f18c"; +} +.fa-stack-exchange:before { + content: "\f18d"; +} +.fa-arrow-circle-o-right:before { + content: "\f18e"; +} +.fa-arrow-circle-o-left:before { + content: "\f190"; +} +.fa-toggle-left:before, +.fa-caret-square-o-left:before { + content: "\f191"; +} +.fa-dot-circle-o:before { + content: "\f192"; +} +.fa-wheelchair:before { + content: "\f193"; +} +.fa-vimeo-square:before { + content: "\f194"; +} +.fa-turkish-lira:before, +.fa-try:before { + content: "\f195"; +} +.fa-plus-square-o:before { + content: "\f196"; +} +.fa-space-shuttle:before { + content: "\f197"; +} +.fa-slack:before { + content: "\f198"; +} +.fa-envelope-square:before { + content: "\f199"; +} +.fa-wordpress:before { + content: "\f19a"; +} +.fa-openid:before { + content: "\f19b"; +} +.fa-institution:before, +.fa-bank:before, +.fa-university:before { + content: "\f19c"; +} +.fa-mortar-board:before, +.fa-graduation-cap:before { + content: "\f19d"; +} +.fa-yahoo:before { + content: "\f19e"; +} +.fa-google:before { + content: "\f1a0"; +} +.fa-reddit:before { + content: "\f1a1"; +} +.fa-reddit-square:before { + content: "\f1a2"; +} +.fa-stumbleupon-circle:before { + content: "\f1a3"; +} +.fa-stumbleupon:before { + content: "\f1a4"; +} +.fa-delicious:before { + content: "\f1a5"; +} +.fa-digg:before { + content: "\f1a6"; +} +.fa-pied-piper-square:before, +.fa-pied-piper:before { + content: "\f1a7"; +} +.fa-pied-piper-alt:before { + content: "\f1a8"; +} +.fa-drupal:before { + content: "\f1a9"; +} +.fa-joomla:before { + content: "\f1aa"; +} +.fa-language:before { + content: "\f1ab"; +} +.fa-fax:before { + content: "\f1ac"; +} +.fa-building:before { + content: "\f1ad"; +} +.fa-child:before { + content: "\f1ae"; +} +.fa-paw:before { + content: "\f1b0"; +} +.fa-spoon:before { + content: "\f1b1"; +} +.fa-cube:before { + content: "\f1b2"; +} +.fa-cubes:before { + content: "\f1b3"; +} +.fa-behance:before { + content: "\f1b4"; +} +.fa-behance-square:before { + content: "\f1b5"; +} +.fa-steam:before { + content: "\f1b6"; +} +.fa-steam-square:before { + content: "\f1b7"; +} +.fa-recycle:before { + content: "\f1b8"; +} +.fa-automobile:before, +.fa-car:before { + content: "\f1b9"; +} +.fa-cab:before, +.fa-taxi:before { + content: "\f1ba"; +} +.fa-tree:before { + content: "\f1bb"; +} +.fa-spotify:before { + content: "\f1bc"; +} +.fa-deviantart:before { + content: "\f1bd"; +} +.fa-soundcloud:before { + content: "\f1be"; +} +.fa-database:before { + content: "\f1c0"; +} +.fa-file-pdf-o:before { + content: "\f1c1"; +} +.fa-file-word-o:before { + content: "\f1c2"; +} +.fa-file-excel-o:before { + content: "\f1c3"; +} +.fa-file-powerpoint-o:before { + content: "\f1c4"; +} +.fa-file-photo-o:before, +.fa-file-picture-o:before, +.fa-file-image-o:before { + content: "\f1c5"; +} +.fa-file-zip-o:before, +.fa-file-archive-o:before { + content: "\f1c6"; +} +.fa-file-sound-o:before, +.fa-file-audio-o:before { + content: "\f1c7"; +} +.fa-file-movie-o:before, +.fa-file-video-o:before { + content: "\f1c8"; +} +.fa-file-code-o:before { + content: "\f1c9"; +} +.fa-vine:before { + content: "\f1ca"; +} +.fa-codepen:before { + content: "\f1cb"; +} +.fa-jsfiddle:before { + content: "\f1cc"; +} +.fa-life-bouy:before, +.fa-life-saver:before, +.fa-support:before, +.fa-life-ring:before { + content: "\f1cd"; +} +.fa-circle-o-notch:before { + content: "\f1ce"; +} +.fa-ra:before, +.fa-rebel:before { + content: "\f1d0"; +} +.fa-ge:before, +.fa-empire:before { + content: "\f1d1"; +} +.fa-git-square:before { + content: "\f1d2"; +} +.fa-git:before { + content: "\f1d3"; +} +.fa-hacker-news:before { + content: "\f1d4"; +} +.fa-tencent-weibo:before { + content: "\f1d5"; +} +.fa-qq:before { + content: "\f1d6"; +} +.fa-wechat:before, +.fa-weixin:before { + content: "\f1d7"; +} +.fa-send:before, +.fa-paper-plane:before { + content: "\f1d8"; +} +.fa-send-o:before, +.fa-paper-plane-o:before { + content: "\f1d9"; +} +.fa-history:before { + content: "\f1da"; +} +.fa-circle-thin:before { + content: "\f1db"; +} +.fa-header:before { + content: "\f1dc"; +} +.fa-paragraph:before { + content: "\f1dd"; +} +.fa-sliders:before { + content: "\f1de"; +} +.fa-share-alt:before { + content: "\f1e0"; +} +.fa-share-alt-square:before { + content: "\f1e1"; +} +.fa-bomb:before { + content: "\f1e2"; +} + +/*! jQuery UI - v1.10.3 - 2013-06-06 +* http://jqueryui.com +* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.button.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.slider.css +* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=2px&bgColorHeader=%23ffffff&bgTextureHeader=gloss_wave&bgImgOpacityHeader=75&borderColorHeader=%23ffffff&fcHeader=%23ffffff&iconColorHeader=%23E65C2E&bgColorContent=%23ffffff&bgTextureContent=highlight_soft&bgImgOpacityContent=75&borderColorContent=%23aaaaaa&fcContent=%23222222&iconColorContent=%23222222&bgColorDefault=%23e6e6e6&bgTextureDefault=glass&bgImgOpacityDefault=75&borderColorDefault=%23d3d3d3&fcDefault=%23555555&iconColorDefault=%23888888&bgColorHover=%23dadada&bgTextureHover=glass&bgImgOpacityHover=75&borderColorHover=%23999999&fcHover=%23212121&iconColorHover=%23454545&bgColorActive=%23dadada&bgTextureActive=glass&bgImgOpacityActive=75&borderColorActive=%23999999&fcActive=%23212121&iconColorActive=%23454545&bgColorHighlight=%23fbf9ee&bgTextureHighlight=highlight_soft&bgImgOpacityHighlight=55&borderColorHighlight=%23fcefa1&fcHighlight=%23363636&iconColorHighlight=%23228ef1&bgColorError=%23b81900&bgTextureError=diagonals_thick&bgImgOpacityError=18&borderColorError=%23cd0a0a&fcError=%23ffffff&iconColorError=%23ffd27a&bgColorOverlay=%23aaaaaa&bgTextureOverlay=diagonals_thick&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=%23aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=5&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-button{display:inline-block;position:relative;padding:0;line-height:normal;margin-right:.1em;cursor:pointer;vertical-align:middle;text-align:center;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:normal}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}input.ui-button::-moz-focus-inner,button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:absolute;top:0;left:0;padding:.2em;outline:0}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 0;white-space:nowrap;width:90%;overflow:hidden;text-overflow:ellipsis}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:21px;margin:-10px 0 0 0;padding:1px;height:20px}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0;background-image:none;margin-top:.5em;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:0}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;width:100%;list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;min-height:0;font-weight:400}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:400;margin:-1px}.ui-menu .ui-state-disabled{font-weight:400;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider.ui-state-disabled .ui-slider-handle,.ui-slider.ui-state-disabled .ui-slider-range{filter:inherit}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #aaa;background:#fff url(images/ui-bg_highlight-soft_75_ffffff_1x100.png) 50% top repeat-x;color:#222}.ui-widget-content a{color:#222}.ui-widget-header{border:1px solid #fff;background:#fff url(images/ui-bg_gloss-wave_75_ffffff_500x100.png) 50% 50% repeat-x;color:#fff;font-weight:bold}.ui-widget-header a{color:#fff}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#555}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #999;background:#dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited{color:#212121;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #999;background:#dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url(images/ui-bg_highlight-soft_55_fbf9ee_1x100.png) 50% top repeat-x;color:#363636}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat;color:#fff}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#fff}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#fff}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}.ui-widget-header .ui-icon{background-image:url(images/ui-icons_E65C2E_256x240.png)}.ui-state-default .ui-icon{background-image:url(images/ui-icons_888888_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-active .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(images/ui-icons_228ef1_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(images/ui-icons_ffd27a_256x240.png)}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:2px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:2px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:2px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:2px}.ui-widget-overlay{background:#aaa url(images/ui-bg_diagonals-thick_0_aaaaaa_40x40.png) 50% 50% repeat;opacity:.3;filter:Alpha(Opacity=30)}.ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url(images/ui-bg_flat_5_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);border-radius:8px} +/* + * Default Layout Theme + * + * Created for jquery.layout + * + * Copyright (c) 2010 + * Fabrizio Balliano (http://www.fabrizioballiano.net) + * Kevin Dalman (http://allpro.net) + * + * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) + * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. + * + * Last Updated: 2010-02-10 + * NOTE: For best code readability, view this with a fixed-space font and tabs equal to 4-chars + */ + +/* + * DEFAULT FONT + * Just to make demo-pages look better - not actually relevant to Layout! + */ +body { + font-family: Geneva, Arial, Helvetica, sans-serif; + font-size: 100%; + *font-size: 80%; +} + +/* + * PANES & CONTENT-DIVs + */ +.ui-layout-pane { /* all 'panes' */ + background: #FFF; + border: 1px solid #BBB; + padding: 10px; + overflow: auto; + /* DO NOT add scrolling (or padding) to 'panes' that have a content-div, + otherwise you may get double-scrollbars - on the pane AND on the content-div + - use ui-layout-wrapper class if pane has a content-div + - use ui-layout-container if pane has an inner-layout + */ + } + /* (scrolling) content-div inside pane allows for fixed header(s) and/or footer(s) */ + .ui-layout-content { + padding: 10px; + position: relative; /* contain floated or positioned elements */ + overflow: auto; /* add scrolling to content-div */ + } + +/* + * UTILITY CLASSES + * Must come AFTER pane-class above so will override + * These classes are NOT auto-generated and are NOT used by Layout + */ +.layout-child-container, +.layout-content-container { + padding: 0; + overflow: hidden; +} +.layout-child-container { + border: 0; /* remove border because inner-layout-panes probably have borders */ +} +.layout-scroll { + overflow: auto; +} +.layout-hide { + display: none; +} + +/* + * RESIZER-BARS + */ +.ui-layout-resizer { /* all 'resizer-bars' */ + background: #DDD; + border: 1px solid #BBB; + border-width: 0; + } + .ui-layout-resizer-drag { /* REAL resizer while resize in progress */ + } + .ui-layout-resizer-hover { /* affects both open and closed states */ + } + /* NOTE: It looks best when 'hover' and 'dragging' are set to the same color, + otherwise color shifts while dragging when bar can't keep up with mouse */ + .ui-layout-resizer-open-hover , /* hover-color to 'resize' */ + .ui-layout-resizer-dragging { /* resizer beging 'dragging' */ + background: #C4E1A4; + } + .ui-layout-resizer-dragging { /* CLONED resizer being dragged */ + border: 1px solid #BBB; + } + .ui-layout-resizer-north-dragging, + .ui-layout-resizer-south-dragging { + border-width: 1px 0; + } + .ui-layout-resizer-west-dragging, + .ui-layout-resizer-east-dragging { + border-width: 0 1px; + } + /* NOTE: Add a 'dragging-limit' color to provide visual feedback when resizer hits min/max size limits */ + .ui-layout-resizer-dragging-limit { /* CLONED resizer at min or max size-limit */ + background: #E1A4A4; /* red */ + } + + .ui-layout-resizer-closed-hover { /* hover-color to 'slide open' */ + background: #EBD5AA; + } + .ui-layout-resizer-sliding { /* resizer when pane is 'slid open' */ + opacity: .10; /* show only a slight shadow */ + filter: alpha(opacity=10); + } + .ui-layout-resizer-sliding-hover { /* sliding resizer - hover */ + opacity: 1.00; /* on-hover, show the resizer-bar normally */ + filter: alpha(opacity=100); + } + /* sliding resizer - add 'outside-border' to resizer on-hover + * this sample illustrates how to target specific panes and states */ + .ui-layout-resizer-north-sliding-hover { border-bottom-width: 1px; } + .ui-layout-resizer-south-sliding-hover { border-top-width: 1px; } + .ui-layout-resizer-west-sliding-hover { border-right-width: 1px; } + .ui-layout-resizer-east-sliding-hover { border-left-width: 1px; } + +/* + * TOGGLER-BUTTONS + */ +.ui-layout-toggler { + border: 1px solid #BBB; /* match pane-border */ + background-color: #BBB; + } + .ui-layout-resizer-hover .ui-layout-toggler { + opacity: .60; + filter: alpha(opacity=60); + } + .ui-layout-toggler-hover , /* need when NOT resizable */ + .ui-layout-resizer-hover .ui-layout-toggler-hover { /* need specificity when IS resizable */ + background-color: #FC6; + opacity: 1.00; + filter: alpha(opacity=100); + } + .ui-layout-toggler-north , + .ui-layout-toggler-south { + border-width: 0 1px; /* left/right borders */ + } + .ui-layout-toggler-west , + .ui-layout-toggler-east { + border-width: 1px 0; /* top/bottom borders */ + } + /* hide the toggler-button when the pane is 'slid open' */ + .ui-layout-resizer-sliding .ui-layout-toggler { + display: none; + } + /* + * style the text we put INSIDE the togglers + */ + .ui-layout-toggler .content { + color: #666; + font-size: 12px; + font-weight: bold; + width: 100%; + padding-bottom: 0.35ex; /* to 'vertically center' text inside text-span */ + } + +/* + * PANE-MASKS + * these styles are hard-coded on mask elems, but are also + * included here as !important to ensure will overrides any generic styles + */ +.ui-layout-mask { + border: none !important; + padding: 0 !important; + margin: 0 !important; + overflow: hidden !important; + position: absolute !important; + opacity: 0 !important; + filter: Alpha(Opacity="0") !important; +} +.ui-layout-mask-inside-pane { /* masks always inside pane EXCEPT when pane is an iframe */ + top: 0 !important; + left: 0 !important; + width: 100% !important; + height: 100% !important; +} +div.ui-layout-mask {} /* standard mask for iframes */ +iframe.ui-layout-mask {} /* extra mask for objects/applets */ + +/* + * Default printing styles + */ +@media print { + /* + * Unless you want to print the layout as it appears onscreen, + * these html/body styles are needed to allow the content to 'flow' + */ + html { + height: auto !important; + overflow: visible !important; + } + body.ui-layout-container { + position: static !important; + top: auto !important; + bottom: auto !important; + left: auto !important; + right: auto !important; + /* only IE6 has container width & height set by Layout */ + _width: auto !important; + _height: auto !important; + } + .ui-layout-resizer, .ui-layout-toggler { + display: none !important; + } + /* + * Default pane print styles disables positioning, borders and backgrounds. + * You can modify these styles however it suit your needs. + */ + .ui-layout-pane { + border: none !important; + background: transparent !important; + position: relative !important; + top: auto !important; + bottom: auto !important; + left: auto !important; + right: auto !important; + width: auto !important; + height: auto !important; + overflow: visible !important; + } +} +/* qTip2 v2.2.1 | Plugins: tips modal viewport svg imagemap ie6 | Styles: core basic css3 | qtip2.com | Licensed MIT | Sat Sep 06 2014 23:12:07 */ + +.qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.qtip-content{position:relative;padding:5px 9px;overflow:hidden;text-align:left;word-wrap:break-word}.qtip-titlebar{position:relative;padding:5px 35px 5px 10px;overflow:hidden;border-width:0 0 1px;font-weight:700}.qtip-titlebar+.qtip-content{border-top-width:0!important}.qtip-close{position:absolute;right:-9px;top:-9px;z-index:11;cursor:pointer;outline:0;border:1px solid transparent}.qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}* html .qtip-titlebar .qtip-close{top:16px}.qtip-icon .ui-icon,.qtip-titlebar .ui-icon{display:block;text-indent:-1000em;direction:ltr}.qtip-icon,.qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:400 bold 10px/13px Tahoma,sans-serif;color:inherit;background:-100em -100em no-repeat}.qtip-default{border:1px solid #F1D031;background-color:#FFFFA3;color:#555}.qtip-default .qtip-titlebar{background-color:#FFEF93}.qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111}.qtip-light{background-color:#fff;border-color:#E2E2E2;color:#454545}.qtip-light .qtip-titlebar{background-color:#f1f1f1}.qtip-dark{background-color:#505050;border-color:#303030;color:#f3f3f3}.qtip-dark .qtip-titlebar{background-color:#404040}.qtip-dark .qtip-icon{border-color:#444}.qtip-dark .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-cream{background-color:#FBF7AA;border-color:#F9E98E;color:#A27D35}.qtip-cream .qtip-titlebar{background-color:#F0DE7D}.qtip-cream .qtip-close .qtip-icon{background-position:-82px 0}.qtip-red{background-color:#F78B83;border-color:#D95252;color:#912323}.qtip-red .qtip-titlebar{background-color:#F06D65}.qtip-red .qtip-close .qtip-icon{background-position:-102px 0}.qtip-red .qtip-icon,.qtip-red .qtip-titlebar .ui-state-hover{border-color:#D95252}.qtip-green{background-color:#CAED9E;border-color:#90D93F;color:#3F6219}.qtip-green .qtip-titlebar{background-color:#B0DE78}.qtip-green .qtip-close .qtip-icon{background-position:-42px 0}.qtip-blue{background-color:#E5F6FE;border-color:#ADD9ED;color:#5E99BD}.qtip-blue .qtip-titlebar{background-color:#D0E9F5}.qtip-blue .qtip-close .qtip-icon{background-position:-2px 0}.qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,.15)}.qtip-bootstrap,.qtip-rounded,.qtip-tipsy{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border:0 solid transparent;background:#4A4A4A;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4A4A4A),color-stop(100%,#000));background-image:-webkit-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-moz-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-ms-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-o-linear-gradient(top,#4A4A4A 0,#000 100%)}.qtip-youtube .qtip-titlebar{background-color:transparent}.qtip-youtube .qtip-content{padding:.75em;font:12px arial,sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#4a4a4a,EndColorStr=#000000);"}.qtip-youtube .qtip-icon{border-color:#222}.qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-jtools{background:#232323;background:rgba(0,0,0,.7);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-linear-gradient(top,#717171,#232323);background-image:-ms-linear-gradient(top,#717171,#232323);background-image:-o-linear-gradient(top,#717171,#232323);border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.qtip-jtools .qtip-titlebar{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A)"}.qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323)"}.qtip-jtools .qtip-content,.qtip-jtools .qtip-titlebar{background:0 0;color:#fff;border:0 dashed transparent}.qtip-jtools .qtip-icon{border-color:#555}.qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,.4);box-shadow:4px 4px 5px rgba(0,0,0,.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.qtip-cluetip .qtip-icon{border-color:#808064}.qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.qtip-tipsy{background:#000;background:rgba(0,0,0,.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.qtip-tipsy .qtip-content{padding:6px 10px}.qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));background-image:-webkit-linear-gradient(top,#3A79B8,#2E629D);background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-ms-linear-gradient(top,#3A79B8,#2E629D);background-image:-o-linear-gradient(top,#3A79B8,#2E629D);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D)"}.qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.qtip-bootstrap .qtip-content{padding:9px 14px}.qtip-bootstrap .qtip-icon{background:0 0}.qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.qtip:not(.ie9haxors) div.qtip-content,.qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}.qtip .qtip-tip,x:-o-prefocus{visibility:hidden}.qtip .qtip-tip,.qtip .qtip-tip .qtip-vml,.qtip .qtip-tip canvas{position:absolute;color:#123456;background:0 0;border:0 dashed transparent}.qtip .qtip-tip canvas{top:0;left:0}.qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}#qtip-overlay{position:fixed;left:0;top:0;width:100%;height:100%}#qtip-overlay.blurs{cursor:pointer}#qtip-overlay div{position:absolute;left:0;top:0;width:100%;height:100%;background-color:#000;opacity:.7;filter:alpha(opacity=70);-ms-filter:"alpha(Opacity=70)"}.qtipmodal-ie6fix{position:absolute!important} +body { + padding: 0; + margin: 0; + overflow: hidden; +} +a { + color: inherit; /* blue colors for links too */ + text-decoration: inherit; /* no underline */ +} + +/* jquery-ui-dialog theming/customisation (overrides to reset neutral defaults) +---------------------------------------------------------------------------- + */ + .ui-dialog-titlebar { + display:none; +} +.ui-dialog { + overflow:hidden; + padding:0; +} +.slot.ui-dialog-content { + margin:0; +} + +/* Full screen +---------------------------------------------------------------------------- */ +:-webkit-full-screen { + height: 100%; + left: 0; + margin: 0; + top: 0; + width: 100%; +} + +:-moz-full-screen { + height: 100%; + left: 0; + margin: 0; + top: 0; + width: 100%; +} + +:-ms-fullscreen { + height: 100%; + left: 0; + margin: 0; + top: 0; + width: 100%; +} + +:fullscreen { + height: 100%; + left: 0; + margin: 0; + top: 0; + width: 100%; +} + +/*---------------------------------------------------------------------------- +/* Mirador styles +---------------------------------------------------------------------------- + */ + + .mirador-viewer, .mirador-main-menu-bar, .mirador-status-bar { + font-family: 'Open Sans', 'Lucida Grande', Verdana, Arial,sans-serif; +} + +.mirador-viewer { + position:absolute; + top:33px; + bottom:0; + left:0; + right:0; + overflow:hidden; + box-sizing: border-box; + -moz-border-sizing: border-box; + margin: 0; + padding: 0; + border: 0; +} + +/* media-queries ++---------------------------------------------------------------------------- */ + +@media screen and (max-width: 768px) { + #load-controls form { + float: none; + } + + #url-load-form { + margin-bottom: 5px; + } +} + + +/* main menu +---------------------------------------------------------------------------- */ + + .mirador-main-menu-bar { + background-color: #000; + border-bottom: 1px solid #555; + color: #fff; + height: 33px; + width: 100%; + /*padding: 4px;*/ + font-size: 14px; + top: 0; +} + +.mirador-main-menu { + float: right; + list-style: none; + margin: 0; + padding: 8px 12px 0 0; + text-align: right; +} + +.mirador-main-menu.user-buttons { + padding-right: 0; +} +.mirador-main-menu.user-logo { + padding-right: 0; + padding-left: 0; + float: left; +} + +.mirador-main-menu li { + cursor: pointer; + float: left; + padding: 0 15px; +} + +.mirador-main-menu a, +.mirador-main-menu a:active, +.mirador-main-menu a:visited { + color: #fff; + font-weight: normal; + text-decoration: none; +} + +.mirador-main-menu a:focus { + border-bottom: 2px solid deepskyblue; + outline: none; +} + +.mirador-main-menu .icon-bookmark-workspace, +.mirador-main-menu .icon-load-window, +.mirador-main-menu .icon-window-options, +.mirador-main-menu .icon-clear-local-storage { + background-image: url('../images/mirador-icons.png'); + background-repeat: none; + cursor: pointer; + display: inline-block; + height: 20px; + margin: 0 2px -7px 0; + width: 20px; +} + +.mirador-main-menu .icon-bookmark-workspace { background-position: -221px -41px; } +.mirador-main-menu .icon-load-window { background-position: -241px -41px; } +.mirador-main-menu .icon-window-options { background-position: -261px -41px; } +.mirador-main-menu .icon-clear-local-storage { background-position: -60px -80px; } + +.mirador-main-menu-bar .window-options-menu { + position: relative; + border-radius: 0; + display: none; + /*z-index: 10000;*/ +} +/* status bar +---------------------------------------------------------------------------- */ + .mirador-status-bar { + background-color: #ccc; + border-top: 1px solid #000; + bottom: 0; + color: #000; + position: fixed; +} + +.mirador-status-bar-msg-left, .mirador-status-bar-msg-right { + color: #666; + float: left; + overflow: hidden; + padding: 4px 10px; + text-align: left; + text-overflow: ellipsis; + white-space: nowrap; + width: 40%; +} + +.mirador-status-bar-msg-right { + float: right; + text-align: right; +} + +/* main menu window options +---------------------------------------------------------------------------- */ +.mirador-window-options-menu { + list-style: none; + margin: 0; + padding: 10px 5px; +} + +.mirador-window-options-menu li { + cursor: pointer; + padding: 3px 5px; +} + +.window-manifest-title { + text-overflow: ellipsis; + max-width: 80%; + overflow: hidden; + white-space: nowrap; + padding-left: 10px; + margin: 8px 0px 8px 0px; + font-weight: bold; + font-size: 16px; +} + +.window-manifest-navigation { + float: right; + width: 24%; + text-align: right; + padding-right: 10px; + font-size: 16px; +} + + +/* main menu select menu +---------------------------------------------------------------------------- */ +#workspace-select-menu, #workspaceContainer { + position: absolute; + height: 100%; + width: 100%; + background-color: rgba(255,255,255,0.94); + display: none; + overflow: hidden; + z-index: 5; +} +#manifest-select-menu { + position: absolute; + margin: 6px; + display: block; + left: 0; + right: 0; + bottom: 0; + top: 0; + display: none; + overflow: hidden; + z-index: 101; + background-color: #fff; + box-shadow: 0 0 6px #333; +} +#bookmark-panel { + position: absolute; + height: 20%; + width: 30%; + background-color: rgba(255,255,255,0.94); + display: none; + overflow: hidden; + z-index: 5; + right: 0; + top: 0; + padding: 10px; +} +#bookmark-panel span { + width: 100%; + padding-left: 2%; +} +#bookmark-panel input { + width: 80%; + margin-right: 3px; +} +#bookmark-panel h3 { + text-align: center; +} +/* .container { + position: relative; + width: 100%; + height:100%; + padding: 10px 4px 10px 10px; + box-sizing: border-box; + overflow: hidden; + margin:0 auto; +} */ +.items-listing { + margin: 0; + padding-left: 0; + box-sizing: border-box; +} +.items-listing li { + list-style-type: none; + overflow: hidden; + border-bottom: 1px solid #d3d3d3; + padding-top: 10px; + padding-bottom: 10px; + position: relative; + padding-left: 5px; + transition: background-color 0.3s ease-out; +} +.items-listing li:hover { + background-color: #ddd; + cursor: pointer; +} +.manifest-load-status-indicator { + width:100%; + padding: 10px; + box-sizing: border-box; + overflow: hidden; + background: rgba(255,255,255,0.94); + position: absolute; +} +.request-status-bar { + background: deepSkyblue; + width:10px; + height:50px; + display: inline-block; + margin-left: 5px; + vertical-align:bottom; + transition: all 0.1s ease-out; +} +.request-status-bar.pending { + background: gray; + transition: all 0.1s ease-out; +} +.loading-status { + display:block; +} +.request-status-bar:nth-child(2) { + margin-left: 0; +} +.repository-label { + border-top: 1px solid rgba(0,0,0,0.7); + padding-top:3px; + position:absolute; + bottom:0; + width:100%; +} +.select-metadata { + width: 45%; + max-width: 450px; + min-width: 300px; + position: relative; + /*width:200px; + text-overflow: ellipsis; + white-space: nowrap; + overflow:hidden; + position: relative;*/ +} +.repo-image { + position:relative; + width: 80px; + height: 80px; + overflow: hidden; + opacity: 0.5; +} +.repo-image img { + position:absolute; + width: 100%; + top: 0; +} +.items-listing h4, .items-listing h3 { + margin: 0; + font-weight: normal; + color:rgba(0,0,0,0.7); +} +.items-listing h3 { + color:rgba(0,0,0,0.8); + margin-top:2px; + font-size: 1em; +} +.manifest-title h3 { + line-height: 1.2em; + height: 3.6em; + position: relative; + overflow: hidden; +} +.manifest-title h3:after { + content: ""; + text-align: right; + position: absolute; + bottom: 0; + right: 0; + width: 20%; + height: 1.2em; + /*background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);*/ +} +.item-info { + position: absolute; + bottom: 0; + display: table; + width: 100%; +} +.item-info-row { + display: table-row; +} +.repo-label, .canvas-count { + display: table-cell; + white-space: nowrap; + font-size: .85em; + vertical-align: bottom; + color: gray; +} +.canvas-count { + text-align: right; +} +.repo-image, .select-metadata, .preview-images { + float:left; + margin-right:15px; + height: 80px; +} +.preview-images { + margin-right:0; +} + +.preview-image { + background-color: gray; + box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.7); + float:left; + margin-right:15px; + min-height: 25px; + min-width: 25px; + /*transition: all 0.1s ease-out; ?*/ +} + +.preview-image:hover { + box-shadow: 0px 0px 5px rgba(0, 191, 255, 1); + transform: scale(1.1); + transition: all 0.6 ease-out; +} + +.thumbnail-image { + background-color: gray; + box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.6); + float:left; + margin-right:15px; + /*height: 80px;*/ + /* background-image: url(../images/loading.gif); */ + /* background-position: center; */ + /* background-repeat: no-repeat; */ +} + +img.thumbnail-image.highlight { + border: 2px solid deepskyblue; +} + +li.highlight { + margin-bottom: 11px !important; + padding-left: 8px !important; + padding-right: 8px !important; +} +.remaining { + line-height:80px; + opacity: 0.5; + text-align: center; + box-sizing: border-box; + vertical-align: middle; + width: 20px; +} +#load-controls { + margin-top: 20px; +} +#load-controls:after { + content: ""; + display: table; + clear: both; +} +#load-controls input { + height:25px; + border:1px solid #d3d3d3; + color: gray; + background:none; + border-radius: 2px; + transition: border-color 0.3s ease-out; +} +#manifest-select-menu .remove-object-option { + cursor: pointer; + display: inline-block; + font-size: .9em; + font-weight: bold; + transition: color 0.2s ease-out; +} +#manifest-select-menu .remove-object-option:hover { + color: rgb( 146, 145, 145 ); +} +#manifest-search-form { + float:left; +} +#manifest-search-form label { + margin-right: 6px; +} +#url-load-form { + float: right; +} +#url-load-form input[type="text"] { + width: 250px; + margin: 0 5px; +} +#load-controls input[type="submit"]{ + height: 29px; +} +#manifest-search i { + position:absolute; + left:0; + color:black; +} +#manifest-search-form input:focus, #url-load-form input:focus, +#manifest-search-form input:focus, +#url-load-form input:focus, +#url-load-form input[type="submit"]:hover{ + outline:none; + border-color:deepskyblue; +} +#manifest-search i { + width:25px; + height:25px; + color:red; + border: 1 px solid red; +} + +.select-results { + height:100%; + overflow-y: scroll; + margin-top: 10px; + border-top: 1px solid gray; +} + +/* main-menu workspaces-panel */ +#workspace-select-menu { + background-color: #333; + text-align:center; + padding:20%; + padding-top:0; + box-sizing:border-box; +} +#workspace-select-menu h1 { + color: lightgray; + padding-bottom: 3%; + font-weight: normal; +} +#workspace-select-menu h3, #workspace-select-menu h2 { + color:lightGray; +} +.select-grid { + width:60%; + min-width:300px; + position:relative; + margin:auto; +} +.grid-row { + content: ""; + display: table; + clear: both; + margin: 0 auto; +} +.grid-item { + height: 50px; + width: 50px; + float: left; + padding: 4px; + display: block; +} +.grid-item .grid-icon { + background:gray; + height: 50px; + width: 50px; + border-radius: 7px; + display: block; + transition: all 0.2s ease-out; + margin:auto; +} +.grid-item.hovered .grid-icon { + background:deepSkyBlue; + box-shadow: 0 0 10px black; + transform: scale(1.1) translateY(-10px) translateX(-5px); + transition: all 0.2s ease-out; +} +.grid-text { + display:none; +} + +/* Workspace scaffolding */ +.workspace-container { + position: absolute; + left:0; + right:0; + top:0; + bottom:0; + overflow: hidden; + box-sizing: border-box; + margin: 3px; +} + +/* invisible layout slot styling */ +.layout-slot { + position: absolute; + margin: 0; + padding: 0; + box-sizing: border-box; +} + +/* Slot Scaffolding */ + +.slot { + width:100%; + height:100%; + box-shadow: inset 0 0 35px black; + overflow: hidden; + box-sizing:border-box; +} +.slot .remove-slot-option { + position: absolute; + margin:10px; + color:gray; + cursor: pointer; +} +.slot .remove-slot-option:hover { + float:left; + margin:10px; + color:lightGray; +} +.slot h1 { + color: gray; + text-align: center; + font-weight: normal; +} +.slot:hover h1 { + color: lightgray; +} +.plus { + font-size: 170px; + font-weight: bold; + margin-bottom: 20px; +} +.slotIconContainer { + position:absolute; + top:50%; + margin-top:-260px; + width:100%; + overflow:hidden; + pointer-events: none; +} +.slot:hover, .slot.focused, .slot.draggedOver { + box-shadow: inset 0 0 35px rgba(94, 219, 255, 1); +} +.slot.draggedOver .dropMeMessage, .slot.draggedOver .dropIcon { + display:block; +} +.dropMeMessage, .dropIcon { + display:none; +} +.slot.draggedOver .addItemText, .slot.draggedOver .plus span { + display:none; +} +.addItemLink { + display:block; + position:absolute; + top:0; + bottom:0; + right:0; + left:0; + cursor: pointer; +} +.dropMask { + position:absolute; + top:0; + bottom:0; + right:0; + left:0; + display:none; +} + +/* window scaffolding */ +.window { + position:relative; + width:100%; + height:100%; + overflow: hidden; + background-color: #333; +} +.manifest-info { + overflow: auto; + background: #fafafa; +} +.manifest-info .mirador-btn { + font-size: .8em; +} +.content-container { + position: absolute; + bottom:0; + left:0; + right:0; + top:0; + margin-top:34px; + box-sizing: border-box; +} + + +.sidePanel { + position:absolute; + width:280px; + left: 0; + bottom: 0; + top:0; + background-color: #efefef; + border-right: 1px solid lightgray; + box-sizing: border-box; + overflow: hidden; + transition: all 0.3s ease; + padding: 10px; + opacity:1; + transition: all 0.2s ease-out; + transform: translateX(0); +} + +.sidePanel.minimized { + transition: all 0.2s ease-out; + transform: translateX(-280px); + opacity:0; + border:none; +} + +.tabContentArea { + position: relative; + width:280px; + height:100%; + float: left; + background-color: #efefef; + border-right: 1px solid lightgray; + box-sizing: border-box; + overflow: hidden; + transition: all 0.3s ease; +} + +.sidePanel .tabGroup { + list-style-type:none; + margin:0; + padding:0; +} + +.sidePanel .tab { + padding: 4px 6px; + border-left:0; + border-bottom: 2px solid black; + display: inline-block; + cursor: pointer; + border-radius: 3px 3px 0 0; +} + +.sidePanel .tab:not(.selected):hover { + border: 2px solid rgba(0,0,0,0.3); + border-bottom: 2px solid black; + padding:4px 4px; +} + +.sidePanel .tab.selected { + border: 2px solid black; + border-bottom:0; + border-radius: 3px 3px 0 0; + margin: 0 -2px; +} +.annotationsPanel ul { + padding:0; + margin:0; + } +.sidePanel .annotationListItem { + list-style-type: none; + border-left:0; + border-right:0; + padding:10px 10px 0 10px; +} +.sidePanel .annotationListItem:after { + content: ""; + height: 1px; + background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(147,147,147,1) 50%,rgba(0,0,0,0) 100%); + + display: block; + margin-top: 10px; + } +.sidePanel .annotationListItem.focused { + background-color: #ddd; + border-left: 3px solid lightBlue; +} + +.sidePanel .annotationListItem:hover { + background-color: #ddd; + border-left: 3px solid lightBlue; +} + +.sidePanel .annotationListItem.selected { + background-color: #ccc; + border-left: 3px solid deepskyblue; +} + +.sidePanel a:hover { + text-decoration: none; +} +.sidePanel h1, .sidePanel h2, .sidePanel h3, .sidePanel h4 { + margin:0; + padding:0; + font-weight: normal; +} +.sidePanel h1:hover, .sidePanel h2:hover, .sidePanel h3:hover, .sidePanel h4:hover { +} +/*.sidePanel h2 { + font-size: 1.5em; +} +.sidePanel h3 { + font-size: 1.25em; +} +.sidePanel h4 { + font-size: 1.0em; +} +.sidePanel h5 { + font-size: .75em; +}*/ +.toc { + margin:0; + overflow-y: scroll; + width: 280px; + padding:0; + position:absolute; + box-sizing: border-box; + left:0; + top:0px; + bottom:0; + list-style-type:none; + font-size: 75%; +} +.toc a.toc-link { + color: black; + padding: 8px; + padding-left: 8px; + display: block; +} +.toc a.toc-link:hover { + cursor: pointer; + background-color: #dddddd; + display:block; + overflow:hidden; +} +.toc ul { + margin:0; + padding:0; + box-sizing: border-box; + list-style-type:none; + width:100%; +} +.toc li { + cursor: pointer; + box-sizing: border-box; + display:block; + position:relative; + margin-left:8px; + margin-bottom: 5px; +} +.toc li.open { +} +.toc li.selected { + cursor: pointer; + overflow:hidden; + border-left: 4px solid deepSkyblue; + transition: all 0.2s ease-out; +} +.toc-link i { + color: rgba(0,0,0,0.4); + margin-right:8px; + transition: all 0.2s linear; +} +.toc-link i:hover { + color: black; +} +.toc li.has-child i.star { + display: none; +} +.toc li.leaf-item i.toc-caret { + display: none +} +.toc li.leaf-item i.star { + display: inline-block; +} +.toc li.selected>h2 .toc-link , .toc li.selected>h3 .toc-link, .toc li.selected>h4 .toc-link, .toc li.selected>h5 .toc-link { + font-weight: bold; +} +.toc li.selected>h2 .toc-link .star, .toc li.selected>h3 .toc-link .star, .toc li.selected>h4 .toc-link .star, .toc li.selected>h5 .toc-link .star .toc li.hovered>h2 .toc-link .star, .toc li.hovered>h3 .toc-link .star, .toc li.hovered>h4 .toc-link .star, .toc li.hovered>h5 .toc-link .star { + color:black; +} +.toc li.open>h2 .toc-link .toc-caret, .toc li.open>h3 .toc-link .toc-caret, .toc li.open>h4 .toc-link .toc-caret, .toc li.open>h5 .toc-link .toc-caret { + transition: all 0.2s linear; + transform: rotate(90deg); + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + /* Internet Explorer */ + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); +} +.toc li.selected-parent { + +} +.toc li.hovered { + border-left: 4px solid deepSkyblue; +} +.toc li:hover { + border-left: 4px solid #99e5ff; +} +.toc-link:hover .star { + color:black; +} +.toc li:hover>h2 a.toc-link, .toc li:hover>h3 a.toc-link, .toc li:hover>h4 a.toc-link, .toc li:hover>h5 a.toc-link, .toc li:hover>h6 a.toc-link { + font-weight: bold; +} + +/* .toc li:hover > h2 a { */ +/* font-weight: bold; */ +/* } */ +.view-container { + margin-left: 280px; + height: 100%; + position:relative; + transition:all 0s ease; +} + +.view-container.tranisition { +} + +.view-container.focus-max-width { + margin-left: 0px; +} + +.view-container.focus-side-panel-minimized { + margin-left: 0px; +} + +.overlay { + display: none; + position: absolute; + right: 0; + top: 0; + box-sizing: border-box; + background-color: rgba(255,255,255,0.9); + z-index: 4; + width: 45%; + overflow-y: scroll; + height: 80%; + word-wrap: break-word; +} +.bottomPanel { + background-color: rgba(0,0,0,0.7); + position: absolute; + bottom:0; + left:0; + right:0; + height: 130px; + z-index: 4; + overflow:hidden; + display: none; + transition:transform 0.3s ease; +} +.bottomPanel.minimized { + transform:translateY(130px); +} + +/* window views +---------------------------------------------------------------------------- */ + + .thumbnail-view, .image-view, .book-view, .scroll-view { + height: 100%; + width: 100%; + background-color: black; + display: none; + overflow-y: scroll; +} +.image-view, .book-view { + overflow: hidden; +} +.scroll-view { + overflow-y: hidden; + overflow-x: scroll; +} + +.focus-max-height { + height: 100%; +} + +.focus-bottom-panel-minimized { + height: 95%; +} + +/* panels +---------------------------------------------------------------------------- */ + + .panel-thumbnail-view { + position: absolute; + height: 100%; + width: 100%; + overflow-x: scroll; + overflow-y: hidden; +} + +.panel-thumbnail-view ul.panel-listing-thumbs { + clear: both; + list-style: none; + padding: 0; + white-space: nowrap; + margin-top: 10px; + margin-bottom: 4px; +} + +.panel-thumbnail-view ul.panel-listing-thumbs li { + box-sizing:border-box; + /*float: left;*/ + /*margin: 0 0 15px 0;*/ + padding: 0px 10px 0px 10px; + /*transition: all 0.03s ease-out;*/ + display: inline-block; +} + +.panel-thumbnail-view ul.panel-listing-thumbs li img { + background-color: gray; + min-height: 25px; + min-width: 25px; + margin: 0 auto; + display: block; + box-sizing:border-box; +} +.panel-thumbnail-view ul.panel-listing-thumbs li img:hover { + border:2px solid rgba(0,191,255,0.7); + transform: scale(1.1); + cursor: pointer; +} + +.panel-thumbnail-view ul.panel-listing-thumbs li .thumb-label { + clear: both; + color: #999; + font-size: 12px; + margin: 0 auto; + max-width: 75px; + text-align: left; + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; + text-align: center; +} + +/* openseadragon +---------------------------------------------------------------------------- */ + + .mirador-osd { + background-color: #000; + width: 100%; + height: 100%; +} + +/* Canvas HUD +----------------------- */ + .mirador-canvas-hud { + position:absolute; + left: 0; + top:0; + bottom:0; + right:0; + background: rgba(255, 0, 128, 0.5); + pointer-events: none; +} +.hud-control { + cursor: pointer; + color:white; + text-shadow: 0 0 5px black; + transition: all 0.3s ease; + opacity: 0.6; + font-size: 18px; + z-index:2; +} +.hud-container { + cursor: pointer; + color:white; + text-shadow: 0 0 5px black; + transition: all 0.3s ease; + font-size: 18px; + z-index:2; +} +.hud-control:hover { + transition: all 0.3s ease; + opacity: 1; +} +.mirador-osd-edit-mode.selected, .mirador-osd-annotations-layer.selected { + opacity: 1; + /*transition: none;*/ +} +.mirador-osd-previous { + position:absolute; + left:1%; + top:50%; + margin-top:-35px; + width: 40px; +} +.mirador-osd-next { + position:absolute; + right:1%; + top:50%; + margin-top:-35px; +} +.mirador-osd-annotations-layer { + position:absolute; + top: 10px; + left: 10px; + transition: none; +} +.mirador-osd-toggle-bottom-panel { + position: absolute; + bottom:0; + right:50%; + margin-right: -25px; +} +.mirador-osd-fullscreen { + position:absolute; + right:10px; + top:10px; + z-index: 2; +} +.mirador-pan-zoom-controls { + position: absolute; + width: 100px; + height: 65px; + bottom:0; + right:0; + margin:1%; +} +.mirador-osd-up { + position:absolute; + right:20px; + top:0; +} +.mirador-osd-right { + position:absolute; + right:0; + top:20px; +} +.mirador-osd-down { + position:absolute; + right:20px; + top:40px; +} +.mirador-osd-left { + position:absolute; + right:40px; + top:20px; +} +.mirador-osd-zoom-in { + font-size:130%; + position:absolute; + right:70px; + top:5px; +} +.mirador-osd-zoom-out { + font-size:130%; + position:absolute; + right:70px; + top:30px; +} +.mirador-osd-go-home { + position: absolute; + right:20px; + top:20px; +} +.mirador-osd-context-controls { + position: absolute; + top: 10px; + left: 10px; + transition: none; +} +.mirador-osd-context-controls a { + float:left; + margin:0 15px 0 0; + font-weight: normal; +} + +/* image view +---------------------------------------------------------------------------- */ + + .mirador-image-view-nav-toolbar { + position:relative; + float: right; + margin-right: 5px; +} + +.mirador-image-view-bg { + background-color: #000; +} + +.mirador-image-scale { + bottom:25px; + display:block; + position:absolute; + z-index:2; +} + +.axis path, .axis line { + fill: none; + shape-rendering: crispEdges; + stroke: white; + stroke-width: 2px; +} + +text { + fill: white; + text-shadow: 0px 0px 3px black; +} + +.mirador-image-dimensions { + margin-right:10px; + margin-top:7px; + position:absolute; + right:0; + top:0; +} + +.mirador-image-view-physical-dimensions { + border: none; + font-weight: bold; + height: 16px; + margin:0; + outline: none; + overflow-wrap: normal; + overflow:hidden; + padding:0; + resize: none; + vertical-align: top; + width: 40px; + text-align: center; +} + +.mirador-image-view-physical-dimensions:hover, +.mirador-image-view-physical-dimensions:focus, +.mirador-image-dimensions.noDimensionsSet .mirador-image-view-physical-dimensions { + border-bottom: 2px solid orangered; + height: 16px; + margin-bottom: -2px; + transition: all .2s ease-out; +} +.noDimensionsWarning { + display: none; + margin-right:10px; +} +.mirador-image-dimensions.noDimensionsSet .noDimensionsWarning { + color: rgba(0,0,0,0.5); + display: inline-block; +} + +.mirador-image-view-physical-dimensions:focus { + background-color: rgba(200,200,200,0.7); + box-shadow: 0 0 4px rgba(200,200,200,0.7); + -webkit-transform: scale(1.2); + -moz-transform: scale(1.2); + transform: scale(1.2); +} + +.mirador-image-dimensions .units { + cursor: context-menu; +} + +.mirador-image-dimensions .units:hover { + height:16px; + border-bottom:2px solid orangered; + margin-bottom:-2px; + transition: all .2s ease-out; +} + +.mirador-image-dimensions .unit-selector { + position:absolute; + display:none; +} + +.mirador-image-dimensions .unit-selector.active { + display:block; +} + +/* scale +----------------*/ + .mirador-image-scale.hidden { + display:none; +} + +/* annotation list +-----------------*/ + .annotationListPanel { + background-color: #f0f0f0; + width:200px; + height:100%; + position:absolute; + right:0; + top:0; + margin:0; + padding: 0; + z-index:2; + box-shadow: 0px 0px 5px rgba(0,0,0,0.3); + border-left:1px solid gray; +} +.annotationPanelHeader { + padding: 0 10px; +} +.annotationListPanel ul { + position:absolute; + bottom:0; + top:80px; + border-top:1px solid white; + list-style: none; + overflow:scroll; + overflow-x:hidden; + margin-bottom:0; + padding:0; + width:100%; +} +.annotationListPanel ul li { + font-size:80%; + margin: 0; + padding: 10px; + border-bottom:1px solid white; + box-sizing: border-box; +} +.annotationListPanel ul li:hover { + background-color:lightGray; + cursor:pointer; + border-left: 2px solid orangered; + padding-left:8px; +} +.annotationListPanel ul li.selected { + color:white; + background-color:gray; + cursor:pointer; + border-left: 3px solid orangered; + padding-left:7px; +} +.annotationListPanel ul li.hovered { + background-color:lightGray; + cursor:pointer; + border-left: 2px solid orangered; + padding-left:8px; +} +.annotationListPanel ul li p { + margin:0; +} +.annotationListPanel ul li p:hover { + margin:0; + cursor:pointer; +} +.annotationListPanel ul li a { + display:block; + position:absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; +} +.annotationListPanel .resizeGrip { + position:absolute; + left:-7px; + bottom:0; + top:0; + width:12px; + z-index:3; + background:none; + display:block; + cursor:ew-resize; +} +.annotation, .osd-select-rectangle { + border: 2px solid deepSkyBlue; + box-shadow: 0px 0px 5px white; + box-sizing: border-box; +} +.annotation.selected { + border: 3px solid orangered; + box-shadow: 0px 0px 8px rgba(0,0,0,0.7); +} +/*.annotation:hover { + border: 3px solid orangered; + opacity: 0.5; + box-shadow: 0px 0px 15px rgba(0,0,0,1); +} +.annotation.selected:hover { + border: 3px solid orangered; + opacity: 1; + box-shadow: 0px 0px 8px rgba(0,0,0,0.7); +}*/ +.annotation.hovered { + border: 3px solid orangered; + opacity: 0.5; + box-shadow: 0px 0px 15px rgba(0,0,0,1); +} +.annotationDetails { + box-sizing: border-box; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + padding:inherit; + padding-top:25px; + color: white; + overflow:hidden; + height:20%; + z-index: 2; + background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.77) 13%, rgba(0,0,0,0.77) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0)), color-stop(13%,rgba(0,0,0,0.77)), color-stop(100%,rgba(0,0,0,0.77))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.77) 13%,rgba(0,0,0,0.77) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.77) 13%,rgba(0,0,0,0.77) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.77) 13%,rgba(0,0,0,0.77) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.77) 13%,rgba(0,0,0,0.77) 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#c4000000',GradientType=0 ); /* IE6-9 */ +} + +.annotationDetailToggle { + float:right; + margin: 32px; + margin-top:0; + cursor: pointer; +} + +.osd-annotation-overlay { + display: none; +} + +.displayBottomPanelButton { + box-sizing: border-box; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + padding:inherit; + color: white; + height:75px; + z-index: 2; +} + +.annotationDetails p { + width: 80%; + font-size: 1.3em; + font-weight: bold; + display: block; + margin: 0 auto; +} + +/* image choice controls +------------------------*/ + + .mirador-image-view-choices { + list-style: none; + max-height: 350px; + overflow: auto; + padding: 0; +} + +.mirador-image-view-choices li { + margin: 0; + padding: 0; +} + +.mirador-image-view-choices li a { + padding-left: 12px; +} + +.mirador-image-view-choice { + background-repeat: no-repeat; + height: 6px; + background-position: 0px 6px; + width: 6px; +} + +.mirador-image-view-choice { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0RUQ5OEI2ODFFMkIxMUUzOUExN0IyREY1RTI1MUQ0QiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0RUQ5OEI2OTFFMkIxMUUzOUExN0IyREY1RTI1MUQ0QiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjRFRDk4QjY2MUUyQjExRTM5QTE3QjJERjVFMjUxRDRCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjRFRDk4QjY3MUUyQjExRTM5QTE3QjJERjVFMjUxRDRCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+fRx/ZQAAAHRJREFUeNpi/P//P0NnZ2cNAwNDOgMEzCwvL29h5uTkrFFSUkqOiorSMjMzm/L27ds5W7Zs4WUCqfT09NTh4eH5BsIgNkiMiQENMDIy/gdRIImZO3bsuPL161fOz58/c23fvv0qSIwRankt1PK/UMvbAAIMALeqLWb/azLQAAAAAElFTkSuQmCC); } +.mirador-image-view-choice-selected { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0RUQ5OEI2QzFFMkIxMUUzOUExN0IyREY1RTI1MUQ0QiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo0RUQ5OEI2RDFFMkIxMUUzOUExN0IyREY1RTI1MUQ0QiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjRFRDk4QjZBMUUyQjExRTM5QTE3QjJERjVFMjUxRDRCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjRFRDk4QjZCMUUyQjExRTM5QTE3QjJERjVFMjUxRDRCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+9DJqAgAAAF1JREFUeNpitLS0ZHj69GktAwNDJgMETJeWlm5mZmJiAgk2ATEvFDt+/vz5H6OcnNwzIEeSARU8Z2LADhiZ+fn5uUDa0SS6mbW0tA4BzfwP5GgC8Ucg7gJa3gIQYAChCRXFhBXUngAAAABJRU5ErkJggg==); } + + +/* scroll view +---------------------------------------------------------------------------- */ + + ul.scroll-listing-thumbs { + clear: both; + list-style: none; + padding: 0; + white-space: nowrap; +} + +ul.scroll-listing-thumbs li { + box-sizing:border-box; + margin: 0 0 15px 0; + padding: 10px 10px 10px 10px; + /*transition: all 0.05s ease-out;*/ + display: inline-block; +} + +ul.scroll-listing-thumbs li img { + background-color: #eee; + min-height: 25px; + min-width: 25px; + margin: 0 auto; + display: block; +} + +ul.scroll-listing-thumbs li .thumb-label { + clear: both; + color: #999; + font-size: 12px; + margin: 0 auto; + max-width: 200px; + text-align: left; + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; + text-align: center; +} + + +/* thumbnails view +---------------------------------------------------------------------------- */ + + .mirador-viewer ul.listing-thumbs { + clear: both; + list-style: none; + overflow: auto; + padding: 0; +} + +.mirador-viewer ul.listing-thumbs li { + box-sizing:border-box; + float: left; + margin: 0 0 15px 0; + padding: 10px 10px 10px 10px; + /*transition: all 0.05s ease-out;*/ +} + +.mirador-viewer ul.listing-thumbs li img { + background-color: #eee; + min-height: 25px; + min-width: 25px; + margin: 0 auto; + display: block; + box-sizing:border-box; + /*transition: all 0.2 ease-out;*/ +} +.mirador-viewer ul.listing-thumbs li img:hover { + border:3px solid rgba(0,191,255,0.7); + transform: scale(1.1); + cursor: pointer; + transition: all 0.2 ease-out; +} + +.mirador-viewer ul.listing-thumbs li .thumb-label { + clear: both; + color: #999; + font-size: 12px; + margin: 0 auto; + max-width: 125px; + text-align: left; + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; + text-align: center; +} + +.mirador-viewer .thumbnails-view-slider { + float: left; + margin: 10px 15px; + width: 60px; +} + +.mirador-thumbnails-view-nav-toolbar { + float: right; + margin-right: 5px; +} + +.mirador-widget-toolbar .ui-slider-horizontal { + height: .4em; +} + +.mirador-widget-toolbar .ui-slider-handle { + top: -0.5em; +} + +/* metadata view +---------------------------------------------------------------------------- */ + + .mirador-viewer .sub-title { + border-bottom: 1px dotted #ccc; + color: #666; + font-weight: bold; + margin: 10px 20px 0 20px; + padding: 0 5px 5px 0; +} + +.mirador-viewer .metadata-listing { + display: table; + table-layout: fixed; + width: 100%; + margin: 0; + padding: 0px 20px 10px 20px; + box-sizing: border-box; +} + +.mirador-viewer .metadata-item { + padding-bottom: 5px; +} + +.mirador-viewer .metadata-label, .mirador-viewer .metadata-value { + line-height: 1.5; + margin-left: 3%; +} + +.mirador-viewer .metadata-label { + text-transform: capitalize; + color: #555; + margin-left: 3%; + font-style: italic; +} + +.mirador-viewer .metadata-value { + vertical-align: bottom; +} + +.mirador-viewer .metadata-listing a:hover { + border-bottom: 1px dotted #005EBD; +} + +.mirador-metadata-view-nav-toolbar { + float: right; + margin-right: 5px; +} + +.metadata-logo { + width: 80px; + margin-left: 3%; +} + + +/* initial loader +---------------------------------------------------------------------------- */ + .mirador-loading { + background-color: #fff; + border: 1px solid #999; + padding: 20px; +} + + +/* buttons and icons +---------------------------------------------------------------------------- */ + .mirador-btn { + cursor: pointer; + display: inline-block; + height: 20px; + width: 20px; + margin-top: 9px; + /*margin-left: 3px;*/ +} + +.mirador-btn.disabled { + opacity: 0.5; +} +.disabled { + opacity: 0.5; + pointer-events: none; +} + +a.mirador-icon-annotations [class^="icon-"] { + display:block; + position:absolute; +} +.mirador-viewer a.mirador-icon-annotations { + background: none; + color: rgb( 146, 145, 145 ); + box-sizing: border-box; +} +.mirador-viewer a.mirador-icon-annotations:hover { + color: black +} + +ul.dropdown { + display: none; + width: 160px; + z-index: 3; + opacity: 0.9; + background-color: #efefef; + text-align: center; + list-style: none; + position: absolute; + padding:0; + margin-top:9px; +} + +.dropdown li { + margin:0; + cursor: pointer; + box-sizing: border-box; + background-color: #dddddd; + padding: 10px; + width:100%; + text-align:left; +} +.dropdown li:hover { + border-left: 3px solid deepskyblue; + background-color: #dddddd; + padding-left: 7px; + font-weight: bold; +} + +.image-list { + right: 0; +} + +.slot-controls { + left: 0; +} + +a.mirador-icon-image-view [class^="icon-"] { + display:block; + position:absolute; +} + +a.mirador-icon-empty-slot [class^="icon-"] { + display:block; + position:absolute; +} +div.manifest-info a.mirador-btn.mirador-icon-toc { + background-color: #efefef; + height: 100%; + margin-top: 0px; + padding-top: 9px; + height: 34px; + width: 24px; + z-index:4; +} +.mirador-viewer a.mirador-icon-image-view, .mirador-viewer a.mirador-icon-thumbs-view, .mirador-viewer a.mirador-icon-metadata-view { + background: none; + color: rgb( 146, 145, 145 ); + box-sizing: border-box; + margin-right:5px; + padding-bottom:30px; +} + +.mirador-viewer a.mirador-icon-window-menu, .mirador-viewer a.mirador-icon-toc { + float:left; + background: none; + color: rgb( 146, 145, 145 ); + box-sizing: border-box; + margin-left:5px; + padding-bottom:30px; +} + +.mirador-viewer a.mirador-icon-image-view:hover, +.mirador-viewer a.mirador-icon-thumbs-view:hover, +.mirador-viewer a.mirador-icon-metadata-view:hover, +.mirador-viewer a.mirador-icon-empty-slot:hover, +.mirador-viewer a.mirador-icon-window-menu:hover, +.mirador-viewer a.mirador-icon-toc:hover { + color: black; +} + +.mirador-viewer a.mirador-icon-image-view.selected, +.mirador-viewer a.mirador-icon-thumbs-view.selected, +.mirador-viewer a.mirador-icon-toc.selected, +.mirador-viewer a.mirador-icon-metadata-view.selected { + color: black; +} + +.mirador-viewer a.mirador-icon-copy { + background: none; + /*color: rgb( 146, 145, 145 );*/ + box-sizing: border-box; +} + +// qtip overrides. +.qtip { +} +.qtip-bootstrap { + border-radius: 2px; + padding:0; + background-color:#fafafa; +} +.qtip-bootstrap .qtip-content { + padding: 0; + clear: both; +} +.qtip-content { + min-width: 275px; + max-height: 200px; + overflow: auto; +} +.annotation-tooltip { + padding: 7px; +} +.annotation-display { + position:relative; + border-left:0; + border-right:0; + padding: 12px; + padding-bottom:0; + border-bottom: 1px solid gray; +} +.annotation-display:last-child { + border: none; +} +.annotation-tooltip .button-container { + text-align: right; +} +.annotation-tooltip .save, .annotation-tooltip .cancel { + margin-left: 12px; + /* padding: 5px 7px; */ + /* border-radius: 2px; */ + /* text-decoration: underline; */ + /* color: white; */ + /* background-color: black; */ + font-size: 12px; + text-decoration: underline; +} +.annotation-tooltip .save:hover, .annotation-tooltip .cancel:hover { + /* padding: 5px 7px; */ + /* border-radius: 2px; */ + /* text-decoration: underline; */ + font-weight:bold; + /* color: white; */ + /* background-color: black; */ +} +.text-editor, .tags-editor { + padding: 5px; + display: block; + margin: 6px 0px 6px 0px; + border: 0; + background: #efefef; + box-shadow: inset 0 0 7px gray; + resize: vertical; + border: 1px solid gray; +} +.annotation-display.annotation-tooltip .button-container { + text-align: right; +} +.annotation-display .edit, .annotation-display .delete { + font-size: 12px; + margin-left: 5px; + text-decoration: underline; +} +.text-viewer p { + margin-top: 0; +} +.text-viewer p.user { + color: gray; + font-style: italic; + font-size: 11px; +} +.tags-viewer { + margin-bottom: 12px; +} +.qtip-bootstrap .tags-viewer span.tag { + background: lightgray; + color: #222; + border-radius: 6px; + padding: 0 5px; + margin-right:5px; + margin-bottom: 5px; + text-align: center; + font-size: 12; + font-weight: bold; + border: 1px solid #aaa; + display: inline-block; +} + +.mce-edit-area iframe { + height: 75px !important; +}