`, and ``.
+@font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace;
+@font-family-base: @font-family-sans-serif;
+
+@font-size-base: 14px;
+@font-size-large: ceil((@font-size-base * 1.25)); // ~18px
+@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
+
+@font-size-h1: floor((@font-size-base * 2.6)); // ~36px
+@font-size-h2: floor((@font-size-base * 2.15)); // ~30px
+@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px
+@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px
+@font-size-h5: @font-size-base;
+@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px
+
+//== Unit-less `line-height` for use in components like buttons.
+@line-height-base: 1.428571429; // 20/14
+//== Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc.
+@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px
+
+//== By default, this inherits from the ``.
+@headings-font-family: inherit;
+@headings-font-weight: 500;
+@headings-line-height: 1.1;
+@headings-color: inherit;
+
+
+//== Iconography
+//
+//## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.
+
+//== Load fonts from this directory.
+@icon-font-path: "../fonts/";
+//== File name for all font files.
+@icon-font-name: "glyphicons-halflings-regular";
+//== Element ID within SVG icon file.
+@icon-font-svg-id: "glyphicons_halflingsregular";
+
+
+//== Components
+//
+//## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start).
+
+@padding-base-vertical: 6px;
+@padding-base-horizontal: 12px;
+
+@padding-large-vertical: 10px;
+@padding-large-horizontal: 16px;
+
+@padding-small-vertical: 5px;
+@padding-small-horizontal: 10px;
+
+@padding-xs-vertical: 1px;
+@padding-xs-horizontal: 5px;
+
+@line-height-large: 1.33;
+@line-height-small: 1.5;
+
+@border-radius-base: 4px;
+@border-radius-large: 6px;
+@border-radius-small: 3px;
+
+//== Global color for active items (e.g., navs or dropdowns).
+@component-active-color: #fff;
+//== Global background color for active items (e.g., navs or dropdowns).
+@component-active-bg: @brand-primary;
+
+//== Width of the `border` for generating carets that indicator dropdowns.
+@caret-width-base: 4px;
+//== Carets increase slightly in size for larger components.
+@caret-width-large: 5px;
+
+
+//== Tables
+//
+//## Customizes the `.table` component with basic values, each used across all table variations.
+
+//== Padding for ``s and ` `s.
+@table-cell-padding: 8px;
+//== Padding for cells in `.table-condensed`.
+@table-condensed-cell-padding: 5px;
+
+//== Default background color used for all tables.
+@table-bg: transparent;
+//== Background color used for `.table-striped`.
+@table-bg-accent: #f9f9f9;
+//== Background color used for `.table-hover`.
+@table-bg-hover: #f5f5f5;
+@table-bg-active: @table-bg-hover;
+
+//== Border color for table and cell borders.
+@table-border-color: #ddd;
+
+
+//== Buttons
+//
+//## For each of Bootstrap's buttons, define text, background and border color.
+
+@btn-font-weight: normal;
+
+@btn-default-color: #333;
+@btn-default-bg: #fff;
+@btn-default-border: #ccc;
+
+@btn-primary-color: #fff;
+@btn-primary-bg: @brand-primary;
+@btn-primary-border: darken(@btn-primary-bg, 5%);
+
+@btn-success-color: #fff;
+@btn-success-bg: @brand-success;
+@btn-success-border: darken(@btn-success-bg, 5%);
+
+@btn-info-color: #fff;
+@btn-info-bg: @brand-info;
+@btn-info-border: darken(@btn-info-bg, 5%);
+
+@btn-warning-color: #fff;
+@btn-warning-bg: @brand-warning;
+@btn-warning-border: darken(@btn-warning-bg, 5%);
+
+@btn-danger-color: #fff;
+@btn-danger-bg: @brand-danger;
+@btn-danger-border: darken(@btn-danger-bg, 5%);
+
+@btn-link-disabled-color: @gray-light;
+
+
+//== Forms
+//
+//##
+
+//== ` ` background color
+@input-bg: #fff;
+//== ` ` background color
+@input-bg-disabled: @gray-lighter;
+
+//== Text color for ` `s
+@input-color: @gray;
+//== ` ` border color
+@input-border: #ccc;
+//== ` ` border radius
+@input-border-radius: @border-radius-base;
+//== Border color for inputs on focus
+@input-border-focus: #66afe9;
+
+//== Placeholder text color
+@input-color-placeholder: @gray-light;
+
+//== Default `.form-control` height
+@input-height-base: (@line-height-computed + (@padding-base-vertical * 2) + 2);
+//== Large `.form-control` height
+@input-height-large: (ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2);
+//== Small `.form-control` height
+@input-height-small: (floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2);
+
+@legend-color: @gray-dark;
+@legend-border-color: #e5e5e5;
+
+//== Background color for textual input addons
+@input-group-addon-bg: @gray-lighter;
+//== Border color for textual input addons
+@input-group-addon-border-color: @input-border;
+
+
+//== Dropdowns
+//
+//## Dropdown menu container and contents.
+
+//== Background for the dropdown menu.
+@dropdown-bg: #fff;
+//== Dropdown menu `border-color`.
+@dropdown-border: rgba(0,0,0,.15);
+//== Dropdown menu `border-color` **for IE8**.
+@dropdown-fallback-border: #ccc;
+//== Divider color for between dropdown items.
+@dropdown-divider-bg: #e5e5e5;
+
+//== Dropdown link text color.
+@dropdown-link-color: @gray-dark;
+//== Hover color for dropdown links.
+@dropdown-link-hover-color: darken(@gray-dark, 5%);
+//== Hover background for dropdown links.
+@dropdown-link-hover-bg: #f5f5f5;
+
+//== Active dropdown menu item text color.
+@dropdown-link-active-color: @component-active-color;
+//== Active dropdown menu item background color.
+@dropdown-link-active-bg: @component-active-bg;
+
+//== Disabled dropdown menu item background color.
+@dropdown-link-disabled-color: @gray-light;
+
+//== Text color for headers within dropdown menus.
+@dropdown-header-color: @gray-light;
+
+//== Deprecated `@dropdown-caret-color` as of v3.1.0
+@dropdown-caret-color: #000;
+
+
+//-- Z-index master list
+//
+// Warning: Avoid customizing these values. They're used for a bird's eye view
+// of components dependent on the z-axis and are designed to all work together.
+//
+// Note: These variables are not generated into the Customizer.
+
+@zindex-navbar: 1000;
+@zindex-dropdown: 1000;
+@zindex-popover: 1060;
+@zindex-tooltip: 1070;
+@zindex-navbar-fixed: 1030;
+@zindex-modal-background: 1040;
+@zindex-modal: 1050;
+
+
+//== Media queries breakpoints
+//
+//## Define the breakpoints at which your layout will change, adapting to different screen sizes.
+
+// Extra small screen / phone
+//== Deprecated `@screen-xs` as of v3.0.1
+@screen-xs: 480px;
+//== Deprecated `@screen-xs-min` as of v3.2.0
+@screen-xs-min: @screen-xs;
+//== Deprecated `@screen-phone` as of v3.0.1
+@screen-phone: @screen-xs-min;
+
+// Small screen / tablet
+//== Deprecated `@screen-sm` as of v3.0.1
+@screen-sm: 768px;
+@screen-sm-min: @screen-sm;
+//== Deprecated `@screen-tablet` as of v3.0.1
+@screen-tablet: @screen-sm-min;
+
+// Medium screen / desktop
+//== Deprecated `@screen-md` as of v3.0.1
+@screen-md: 992px;
+@screen-md-min: @screen-md;
+//== Deprecated `@screen-desktop` as of v3.0.1
+@screen-desktop: @screen-md-min;
+
+// Large screen / wide desktop
+//== Deprecated `@screen-lg` as of v3.0.1
+@screen-lg: 1200px;
+@screen-lg-min: @screen-lg;
+//== Deprecated `@screen-lg-desktop` as of v3.0.1
+@screen-lg-desktop: @screen-lg-min;
+
+// So media queries don't overlap when required, provide a maximum
+@screen-xs-max: (@screen-sm-min - 1);
+@screen-sm-max: (@screen-md-min - 1);
+@screen-md-max: (@screen-lg-min - 1);
+
+
+//== Grid system
+//
+//## Define your custom responsive grid.
+
+//== Number of columns in the grid.
+@grid-columns: 12;
+//== Padding between columns. Gets divided in half for the left and right.
+@grid-gutter-width: 30px;
+// Navbar collapse
+//== Point at which the navbar becomes uncollapsed.
+@grid-float-breakpoint: @screen-sm-min;
+//== Point at which the navbar begins collapsing.
+@grid-float-breakpoint-max: (@grid-float-breakpoint - 1);
+
+
+//== Container sizes
+//
+//## Define the maximum width of `.container` for different screen sizes.
+
+// Small screen / tablet
+@container-tablet: ((720px + @grid-gutter-width));
+//== For `@screen-sm-min` and up.
+@container-sm: @container-tablet;
+
+// Medium screen / desktop
+@container-desktop: ((940px + @grid-gutter-width));
+//== For `@screen-md-min` and up.
+@container-md: @container-desktop;
+
+// Large screen / wide desktop
+@container-large-desktop: ((1140px + @grid-gutter-width));
+//== For `@screen-lg-min` and up.
+@container-lg: @container-large-desktop;
+
+
+//== Navbar
+//
+//##
+
+// Basics of a navbar
+@navbar-height: 50px;
+@navbar-margin-bottom: @line-height-computed;
+@navbar-border-radius: @border-radius-base;
+@navbar-padding-horizontal: floor((@grid-gutter-width / 2));
+@navbar-padding-vertical: ((@navbar-height - @line-height-computed) / 2);
+@navbar-collapse-max-height: 340px;
+
+@navbar-default-color: #777;
+@navbar-default-bg: #f8f8f8;
+@navbar-default-border: darken(@navbar-default-bg, 6.5%);
+
+// Navbar links
+@navbar-default-link-color: #777;
+@navbar-default-link-hover-color: #333;
+@navbar-default-link-hover-bg: transparent;
+@navbar-default-link-active-color: #555;
+@navbar-default-link-active-bg: darken(@navbar-default-bg, 6.5%);
+@navbar-default-link-disabled-color: #ccc;
+@navbar-default-link-disabled-bg: transparent;
+
+// Navbar brand label
+@navbar-default-brand-color: @navbar-default-link-color;
+@navbar-default-brand-hover-color: darken(@navbar-default-brand-color, 10%);
+@navbar-default-brand-hover-bg: transparent;
+
+// Navbar toggle
+@navbar-default-toggle-hover-bg: #ddd;
+@navbar-default-toggle-icon-bar-bg: #888;
+@navbar-default-toggle-border-color: #ddd;
+
+
+// Inverted navbar
+// Reset inverted navbar basics
+@navbar-inverse-color: @gray-light;
+@navbar-inverse-bg: #222;
+@navbar-inverse-border: darken(@navbar-inverse-bg, 10%);
+
+// Inverted navbar links
+@navbar-inverse-link-color: @gray-light;
+@navbar-inverse-link-hover-color: #fff;
+@navbar-inverse-link-hover-bg: transparent;
+@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color;
+@navbar-inverse-link-active-bg: darken(@navbar-inverse-bg, 10%);
+@navbar-inverse-link-disabled-color: #444;
+@navbar-inverse-link-disabled-bg: transparent;
+
+// Inverted navbar brand label
+@navbar-inverse-brand-color: @navbar-inverse-link-color;
+@navbar-inverse-brand-hover-color: #fff;
+@navbar-inverse-brand-hover-bg: transparent;
+
+// Inverted navbar toggle
+@navbar-inverse-toggle-hover-bg: #333;
+@navbar-inverse-toggle-icon-bar-bg: #fff;
+@navbar-inverse-toggle-border-color: #333;
+
+
+//== Navs
+//
+//##
+
+//=== Shared nav styles
+@nav-link-padding: 10px 15px;
+@nav-link-hover-bg: @gray-lighter;
+
+@nav-disabled-link-color: @gray-light;
+@nav-disabled-link-hover-color: @gray-light;
+
+@nav-open-link-hover-color: #fff;
+
+//== Tabs
+@nav-tabs-border-color: #ddd;
+
+@nav-tabs-link-hover-border-color: @gray-lighter;
+
+@nav-tabs-active-link-hover-bg: @body-bg;
+@nav-tabs-active-link-hover-color: @gray;
+@nav-tabs-active-link-hover-border-color: #ddd;
+
+@nav-tabs-justified-link-border-color: #ddd;
+@nav-tabs-justified-active-link-border-color: @body-bg;
+
+//== Pills
+@nav-pills-border-radius: @border-radius-base;
+@nav-pills-active-link-hover-bg: @component-active-bg;
+@nav-pills-active-link-hover-color: @component-active-color;
+
+
+//== Pagination
+//
+//##
+
+@pagination-color: @link-color;
+@pagination-bg: #fff;
+@pagination-border: #ddd;
+
+@pagination-hover-color: @link-hover-color;
+@pagination-hover-bg: @gray-lighter;
+@pagination-hover-border: #ddd;
+
+@pagination-active-color: #fff;
+@pagination-active-bg: @brand-primary;
+@pagination-active-border: @brand-primary;
+
+@pagination-disabled-color: @gray-light;
+@pagination-disabled-bg: #fff;
+@pagination-disabled-border: #ddd;
+
+
+//== Pager
+//
+//##
+
+@pager-bg: @pagination-bg;
+@pager-border: @pagination-border;
+@pager-border-radius: 15px;
+
+@pager-hover-bg: @pagination-hover-bg;
+
+@pager-active-bg: @pagination-active-bg;
+@pager-active-color: @pagination-active-color;
+
+@pager-disabled-color: @pagination-disabled-color;
+
+
+//== Jumbotron
+//
+//##
+
+@jumbotron-padding: 30px;
+@jumbotron-color: inherit;
+@jumbotron-bg: @gray-lighter;
+@jumbotron-heading-color: inherit;
+@jumbotron-font-size: ceil((@font-size-base * 1.5));
+
+
+//== Form states and alerts
+//
+//## Define colors for form feedback states and, by default, alerts.
+
+@state-success-text: #3c763d;
+@state-success-bg: #dff0d8;
+@state-success-border: darken(spin(@state-success-bg, -10), 5%);
+
+@state-info-text: #31708f;
+@state-info-bg: #d9edf7;
+@state-info-border: darken(spin(@state-info-bg, -10), 7%);
+
+@state-warning-text: #8a6d3b;
+@state-warning-bg: #fcf8e3;
+@state-warning-border: darken(spin(@state-warning-bg, -10), 5%);
+
+@state-danger-text: #a94442;
+@state-danger-bg: #f2dede;
+@state-danger-border: darken(spin(@state-danger-bg, -10), 5%);
+
+
+//== Tooltips
+//
+//##
+
+//== Tooltip max width
+@tooltip-max-width: 200px;
+//== Tooltip text color
+@tooltip-color: #fff;
+//== Tooltip background color
+@tooltip-bg: #000;
+@tooltip-opacity: .9;
+
+//== Tooltip arrow width
+@tooltip-arrow-width: 5px;
+//== Tooltip arrow color
+@tooltip-arrow-color: @tooltip-bg;
+
+
+//== Popovers
+//
+//##
+
+//== Popover body background color
+@popover-bg: #fff;
+//== Popover maximum width
+@popover-max-width: 276px;
+//== Popover border color
+@popover-border-color: rgba(0,0,0,.2);
+//== Popover fallback border color
+@popover-fallback-border-color: #ccc;
+
+//== Popover title background color
+@popover-title-bg: darken(@popover-bg, 3%);
+
+//== Popover arrow width
+@popover-arrow-width: 10px;
+//== Popover arrow color
+@popover-arrow-color: #fff;
+
+//== Popover outer arrow width
+@popover-arrow-outer-width: (@popover-arrow-width + 1);
+//== Popover outer arrow color
+@popover-arrow-outer-color: fadein(@popover-border-color, 5%);
+//== Popover outer arrow fallback color
+@popover-arrow-outer-fallback-color: darken(@popover-fallback-border-color, 20%);
+
+
+//== Labels
+//
+//##
+
+//== Default label background color
+@label-default-bg: @gray-light;
+//== Primary label background color
+@label-primary-bg: @brand-primary;
+//== Success label background color
+@label-success-bg: @brand-success;
+//== Info label background color
+@label-info-bg: @brand-info;
+//== Warning label background color
+@label-warning-bg: @brand-warning;
+//== Danger label background color
+@label-danger-bg: @brand-danger;
+
+//== Default label text color
+@label-color: #fff;
+//== Default text color of a linked label
+@label-link-hover-color: #fff;
+
+
+//== Modals
+//
+//##
+
+//== Padding applied to the modal body
+@modal-inner-padding: 15px;
+
+//== Padding applied to the modal title
+@modal-title-padding: 15px;
+//== Modal title line-height
+@modal-title-line-height: @line-height-base;
+
+//== Background color of modal content area
+@modal-content-bg: #fff;
+//== Modal content border color
+@modal-content-border-color: rgba(0,0,0,.2);
+//== Modal content border color **for IE8**
+@modal-content-fallback-border-color: #999;
+
+//== Modal backdrop background color
+@modal-backdrop-bg: #000;
+//== Modal backdrop opacity
+@modal-backdrop-opacity: .5;
+//== Modal header border color
+@modal-header-border-color: #e5e5e5;
+//== Modal footer border color
+@modal-footer-border-color: @modal-header-border-color;
+
+@modal-lg: 900px;
+@modal-md: 600px;
+@modal-sm: 300px;
+
+
+//== Alerts
+//
+//## Define alert colors, border radius, and padding.
+
+@alert-padding: 15px;
+@alert-border-radius: @border-radius-base;
+@alert-link-font-weight: bold;
+
+@alert-success-bg: @state-success-bg;
+@alert-success-text: @state-success-text;
+@alert-success-border: @state-success-border;
+
+@alert-info-bg: @state-info-bg;
+@alert-info-text: @state-info-text;
+@alert-info-border: @state-info-border;
+
+@alert-warning-bg: @state-warning-bg;
+@alert-warning-text: @state-warning-text;
+@alert-warning-border: @state-warning-border;
+
+@alert-danger-bg: @state-danger-bg;
+@alert-danger-text: @state-danger-text;
+@alert-danger-border: @state-danger-border;
+
+
+//== Progress bars
+//
+//##
+
+//== Background color of the whole progress component
+@progress-bg: #f5f5f5;
+//== Progress bar text color
+@progress-bar-color: #fff;
+
+//== Default progress bar color
+@progress-bar-bg: @brand-primary;
+//== Success progress bar color
+@progress-bar-success-bg: @brand-success;
+//== Warning progress bar color
+@progress-bar-warning-bg: @brand-warning;
+//== Danger progress bar color
+@progress-bar-danger-bg: @brand-danger;
+//== Info progress bar color
+@progress-bar-info-bg: @brand-info;
+
+
+//== List group
+//
+//##
+
+//== Background color on `.list-group-item`
+@list-group-bg: #fff;
+//== `.list-group-item` border color
+@list-group-border: #ddd;
+//== List group border radius
+@list-group-border-radius: @border-radius-base;
+
+//== Background color of single list items on hover
+@list-group-hover-bg: #f5f5f5;
+//== Text color of active list items
+@list-group-active-color: @component-active-color;
+//== Background color of active list items
+@list-group-active-bg: @component-active-bg;
+//== Border color of active list elements
+@list-group-active-border: @list-group-active-bg;
+//== Text color for content within active list items
+@list-group-active-text-color: lighten(@list-group-active-bg, 40%);
+
+//== Text color of disabled list items
+@list-group-disabled-color: @gray-light;
+//== Background color of disabled list items
+@list-group-disabled-bg: @gray-lighter;
+//== Text color for content within disabled list items
+@list-group-disabled-text-color: @list-group-disabled-color;
+
+@list-group-link-color: #555;
+@list-group-link-hover-color: @list-group-link-color;
+@list-group-link-heading-color: #333;
+
+
+//== Panels
+//
+//##
+
+@panel-bg: #fff;
+@panel-body-padding: 15px;
+@panel-heading-padding: 10px 15px;
+@panel-footer-padding: @panel-heading-padding;
+@panel-border-radius: @border-radius-base;
+
+//== Border color for elements within panels
+@panel-inner-border: #ddd;
+@panel-footer-bg: #f5f5f5;
+
+@panel-default-text: @gray-dark;
+@panel-default-border: #ddd;
+@panel-default-heading-bg: #f5f5f5;
+
+@panel-primary-text: #fff;
+@panel-primary-border: @brand-primary;
+@panel-primary-heading-bg: @brand-primary;
+
+@panel-success-text: @state-success-text;
+@panel-success-border: @state-success-border;
+@panel-success-heading-bg: @state-success-bg;
+
+@panel-info-text: @state-info-text;
+@panel-info-border: @state-info-border;
+@panel-info-heading-bg: @state-info-bg;
+
+@panel-warning-text: @state-warning-text;
+@panel-warning-border: @state-warning-border;
+@panel-warning-heading-bg: @state-warning-bg;
+
+@panel-danger-text: @state-danger-text;
+@panel-danger-border: @state-danger-border;
+@panel-danger-heading-bg: @state-danger-bg;
+
+
+//== Thumbnails
+//
+//##
+
+//== Padding around the thumbnail image
+@thumbnail-padding: 4px;
+//== Thumbnail background color
+@thumbnail-bg: @body-bg;
+//== Thumbnail border color
+@thumbnail-border: #ddd;
+//== Thumbnail border radius
+@thumbnail-border-radius: @border-radius-base;
+
+//== Custom text color for thumbnail captions
+@thumbnail-caption-color: @text-color;
+//== Padding around the thumbnail caption
+@thumbnail-caption-padding: 9px;
+
+
+//== Wells
+//
+//##
+
+@well-bg: #f5f5f5;
+@well-border: darken(@well-bg, 7%);
+
+
+//== Badges
+//
+//##
+
+@badge-color: #fff;
+//== Linked badge text color on hover
+@badge-link-hover-color: #fff;
+@badge-bg: @gray-light;
+
+//== Badge text color in active nav link
+@badge-active-color: @link-color;
+//== Badge background color in active nav link
+@badge-active-bg: #fff;
+
+@badge-font-weight: bold;
+@badge-line-height: 1;
+@badge-border-radius: 10px;
+
+
+//== Breadcrumbs
+//
+//##
+
+@breadcrumb-padding-vertical: 8px;
+@breadcrumb-padding-horizontal: 15px;
+//== Breadcrumb background color
+@breadcrumb-bg: #f5f5f5;
+//== Breadcrumb text color
+@breadcrumb-color: #ccc;
+//== Text color of current page in the breadcrumb
+@breadcrumb-active-color: @gray-light;
+//== Textual separator for between breadcrumb elements
+@breadcrumb-separator: "/";
+
+
+//== Carousel
+//
+//##
+
+@carousel-text-shadow: 0 1px 2px rgba(0,0,0,.6);
+
+@carousel-control-color: #fff;
+@carousel-control-width: 15%;
+@carousel-control-opacity: .5;
+@carousel-control-font-size: 20px;
+
+@carousel-indicator-active-bg: #fff;
+@carousel-indicator-border-color: #fff;
+
+@carousel-caption-color: #fff;
+
+
+//== Close
+//
+//##
+
+@close-font-weight: bold;
+@close-color: #000;
+@close-text-shadow: 0 1px 0 #fff;
+
+
+//== Code
+//
+//##
+
+@code-color: #c7254e;
+@code-bg: #f9f2f4;
+
+@kbd-color: #fff;
+@kbd-bg: #333;
+
+@pre-bg: #f5f5f5;
+@pre-color: @gray-dark;
+@pre-border-color: #ccc;
+@pre-scrollable-max-height: 340px;
+
+
+//== Type
+//
+//##
+
+//== Horizontal offset for forms and lists.
+@component-offset-horizontal: 180px;
+//== Text muted color
+@text-muted: @gray-light;
+//== Abbreviations and acronyms border color
+@abbr-border-color: @gray-light;
+//== Headings small color
+@headings-small-color: @gray-light;
+//== Blockquote small color
+@blockquote-small-color: @gray-light;
+//== Blockquote font size
+@blockquote-font-size: (@font-size-base * 1.25);
+//== Blockquote border color
+@blockquote-border-color: @gray-lighter;
+//== Page header border color
+@page-header-border-color: @gray-lighter;
+//== Width of horizontal description list titles
+@dl-horizontal-offset: @component-offset-horizontal;
+//== Horizontal line color.
+@hr-border: @gray-lighter;
+
+
diff --git a/CkEditorSample/Content/bootstrap/wells.less b/CkEditorSample/Content/bootstrap/wells.less
new file mode 100644
index 0000000..15d072b
--- /dev/null
+++ b/CkEditorSample/Content/bootstrap/wells.less
@@ -0,0 +1,29 @@
+//
+// Wells
+// --------------------------------------------------
+
+
+// Base class
+.well {
+ min-height: 20px;
+ padding: 19px;
+ margin-bottom: 20px;
+ background-color: @well-bg;
+ border: 1px solid @well-border;
+ border-radius: @border-radius-base;
+ .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
+ blockquote {
+ border-color: #ddd;
+ border-color: rgba(0,0,0,.15);
+ }
+}
+
+// Sizes
+.well-lg {
+ padding: 24px;
+ border-radius: @border-radius-large;
+}
+.well-sm {
+ padding: 9px;
+ border-radius: @border-radius-small;
+}
diff --git a/CkEditorSample/Content/font-awesome.css b/CkEditorSample/Content/font-awesome.css
new file mode 100644
index 0000000..4040b3c
--- /dev/null
+++ b/CkEditorSample/Content/font-awesome.css
@@ -0,0 +1,1672 @@
+/*!
+ * Font Awesome 4.2.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('../fonts/fontawesome-webfont.eot?v=4.2.0');
+ src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');
+ font-weight: normal;
+ font-style: normal;
+}
+.fa {
+ display: inline-block;
+ font: normal normal normal 14px/1 FontAwesome;
+ font-size: inherit;
+ text-rendering: auto;
+ -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: fa-spin 2s infinite linear;
+ animation: fa-spin 2s infinite linear;
+}
+@-webkit-keyframes fa-spin {
+ 0% {
+ -webkit-transform: rotate(0deg);
+ transform: rotate(0deg);
+ }
+ 100% {
+ -webkit-transform: rotate(359deg);
+ transform: rotate(359deg);
+ }
+}
+@keyframes fa-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);
+ -ms-transform: rotate(90deg);
+ transform: rotate(90deg);
+}
+.fa-rotate-180 {
+ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
+ -webkit-transform: rotate(180deg);
+ -ms-transform: rotate(180deg);
+ transform: rotate(180deg);
+}
+.fa-rotate-270 {
+ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
+ -webkit-transform: rotate(270deg);
+ -ms-transform: rotate(270deg);
+ transform: rotate(270deg);
+}
+.fa-flip-horizontal {
+ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);
+ -webkit-transform: scale(-1, 1);
+ -ms-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);
+ -ms-transform: scale(1, -1);
+ transform: scale(1, -1);
+}
+:root .fa-rotate-90,
+:root .fa-rotate-180,
+:root .fa-rotate-270,
+:root .fa-flip-horizontal,
+:root .fa-flip-vertical {
+ filter: none;
+}
+.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-remove:before,
+.fa-close:before,
+.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,
+.fa-bar-chart: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: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-buoy: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";
+}
+.fa-soccer-ball-o:before,
+.fa-futbol-o:before {
+ content: "\f1e3";
+}
+.fa-tty:before {
+ content: "\f1e4";
+}
+.fa-binoculars:before {
+ content: "\f1e5";
+}
+.fa-plug:before {
+ content: "\f1e6";
+}
+.fa-slideshare:before {
+ content: "\f1e7";
+}
+.fa-twitch:before {
+ content: "\f1e8";
+}
+.fa-yelp:before {
+ content: "\f1e9";
+}
+.fa-newspaper-o:before {
+ content: "\f1ea";
+}
+.fa-wifi:before {
+ content: "\f1eb";
+}
+.fa-calculator:before {
+ content: "\f1ec";
+}
+.fa-paypal:before {
+ content: "\f1ed";
+}
+.fa-google-wallet:before {
+ content: "\f1ee";
+}
+.fa-cc-visa:before {
+ content: "\f1f0";
+}
+.fa-cc-mastercard:before {
+ content: "\f1f1";
+}
+.fa-cc-discover:before {
+ content: "\f1f2";
+}
+.fa-cc-amex:before {
+ content: "\f1f3";
+}
+.fa-cc-paypal:before {
+ content: "\f1f4";
+}
+.fa-cc-stripe:before {
+ content: "\f1f5";
+}
+.fa-bell-slash:before {
+ content: "\f1f6";
+}
+.fa-bell-slash-o:before {
+ content: "\f1f7";
+}
+.fa-trash:before {
+ content: "\f1f8";
+}
+.fa-copyright:before {
+ content: "\f1f9";
+}
+.fa-at:before {
+ content: "\f1fa";
+}
+.fa-eyedropper:before {
+ content: "\f1fb";
+}
+.fa-paint-brush:before {
+ content: "\f1fc";
+}
+.fa-birthday-cake:before {
+ content: "\f1fd";
+}
+.fa-area-chart:before {
+ content: "\f1fe";
+}
+.fa-pie-chart:before {
+ content: "\f200";
+}
+.fa-line-chart:before {
+ content: "\f201";
+}
+.fa-lastfm:before {
+ content: "\f202";
+}
+.fa-lastfm-square:before {
+ content: "\f203";
+}
+.fa-toggle-off:before {
+ content: "\f204";
+}
+.fa-toggle-on:before {
+ content: "\f205";
+}
+.fa-bicycle:before {
+ content: "\f206";
+}
+.fa-bus:before {
+ content: "\f207";
+}
+.fa-ioxhost:before {
+ content: "\f208";
+}
+.fa-angellist:before {
+ content: "\f209";
+}
+.fa-cc:before {
+ content: "\f20a";
+}
+.fa-shekel:before,
+.fa-sheqel:before,
+.fa-ils:before {
+ content: "\f20b";
+}
+.fa-meanpath:before {
+ content: "\f20c";
+}
diff --git a/CkEditorSample/Content/font-awesome.min.css b/CkEditorSample/Content/font-awesome.min.css
new file mode 100644
index 0000000..ec53d4d
--- /dev/null
+++ b/CkEditorSample/Content/font-awesome.min.css
@@ -0,0 +1,4 @@
+/*!
+ * Font Awesome 4.2.0 by @davegandy - http://fontawesome.io - @fontawesome
+ * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
+ */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.2.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.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:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;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:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-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);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-ms-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);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.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:#fff}.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-remove:before,.fa-close:before,.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,.fa-bar-chart: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: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-buoy: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"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}
\ No newline at end of file
diff --git a/CkEditorSample/Content/fonts/glyphicons-halflings-regular.eot b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.eot
new file mode 100644
index 0000000..4a4ca86
Binary files /dev/null and b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.eot differ
diff --git a/CkEditorSample/Content/fonts/glyphicons-halflings-regular.svg b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.svg
new file mode 100644
index 0000000..e3e2dc7
--- /dev/null
+++ b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.svg
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CkEditorSample/Content/fonts/glyphicons-halflings-regular.ttf b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.ttf
new file mode 100644
index 0000000..67fa00b
Binary files /dev/null and b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.ttf differ
diff --git a/CkEditorSample/Content/fonts/glyphicons-halflings-regular.woff b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.woff
new file mode 100644
index 0000000..8c54182
Binary files /dev/null and b/CkEditorSample/Content/fonts/glyphicons-halflings-regular.woff differ
diff --git a/CkEditorSample/Content/fonts/stylesheet.css b/CkEditorSample/Content/fonts/stylesheet.css
new file mode 100644
index 0000000..8738783
--- /dev/null
+++ b/CkEditorSample/Content/fonts/stylesheet.css
@@ -0,0 +1,8 @@
+/* @font-face kit by Fonts2u (http://www.fonts2u.com) */
+@font-face
+{
+ font-family: "WeblySleek UI Light";
+ src: url("weblysleekuil.eot?") format("eot"),url("weblysleekuil.woff") format("woff"),url("weblysleekuil.ttf") format("truetype"),url("weblysleekuil.svg#WeblySleekUILight") format("svg");
+ font-weight: normal;
+ font-style: normal;
+}
diff --git a/CkEditorSample/Content/metro-bootstrap/alerts.less b/CkEditorSample/Content/metro-bootstrap/alerts.less
new file mode 100644
index 0000000..1be7ec0
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/alerts.less
@@ -0,0 +1,35 @@
+//
+// Alerts
+// --------------------------------------------------
+
+
+// Base styles
+// -------------------------
+
+.alert {
+ border: none;
+ color: white;
+ .alert-link {
+ color: white;
+ font-weight: bold;
+ font-variant: small-caps;
+ }
+}
+
+
+// Alternate styles
+//
+// Generate contextual modifier classes for colorizing the alert.
+
+.alert-success {
+ background-color: @btn-success-bg;
+}
+.alert-info {
+ background-color: @btn-primary-bg;
+}
+.alert-warning {
+ background-color: @btn-warning-bg;
+}
+.alert-danger {
+ background-color: @btn-danger-bg;
+}
diff --git a/CkEditorSample/Content/metro-bootstrap/checkbox.less b/CkEditorSample/Content/metro-bootstrap/checkbox.less
new file mode 100644
index 0000000..2c7f043
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/checkbox.less
@@ -0,0 +1,49 @@
+// Checkboxes
+.checkbox {
+ display: inline-block;
+ margin-right: 10px;
+ margin-bottom: 10px;
+ cursor: pointer;
+
+ & > input[type=checkbox] {
+ position: absolute;
+ opacity: 0;
+ }
+ & > span {}
+
+ .checkbox-label {
+ padding-left: 28px;
+ position: relative;
+ }
+
+ .checkbox-label:before {
+ position: absolute;
+ display: block;
+ height: 24px;
+ width: 24px;
+ content: "";
+ text-indent: -9999px;
+ border: 2px #d9d9d9 solid;
+ z-index: 1;
+ opacity: 1;
+ top: 0;
+ left: 0;
+ }
+
+ input[type="checkbox"]:checked ~ .checkbox-label:after {
+ position: absolute;
+ display: block;
+ content: "\f00c";
+ font-size: 10pt;
+ height: 14px;
+ width: 14px;
+ line-height: 14px;
+ z-index: 2;
+ top: 50%;
+ margin-top: -6px;
+ left: 0;
+ margin-left: 4px;
+ font-family: FontAwesome;
+ }
+
+ }
diff --git a/CkEditorSample/Content/metro-bootstrap/custom.less b/CkEditorSample/Content/metro-bootstrap/custom.less
new file mode 100644
index 0000000..b0d839a
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/custom.less
@@ -0,0 +1,63 @@
+@import url('../bootstrap/variables.less');
+@import url('variables.less');
+
+img.right
+{
+ border: 1px solid #ccc;
+ float: right;
+ margin-left: 15px;
+ padding: 5px;
+}
+
+img.left
+{
+ border: 1px solid #ccc;
+ float: left;
+ margin-right: 15px;
+ padding: 5px;
+}
+
+.navbar-brand
+{
+ padding: 8px 15px;
+
+ img
+ {
+ margin-top: -4px;
+ }
+}
+
+.jumbotron
+{
+ h1, .h1, h2, .h2
+ {
+ margin-top: 0;
+ }
+
+ h2, .h2
+ {
+ font-size: @font-size-base * 3.5;
+ color: @jumbotron-heading-color;
+ }
+}
+
+pre.prettyprint
+{
+ -mo-word-break: normal;
+ -mo-word-wrap: normal;
+ word-break: normal;
+ word-wrap: normal;
+}
+
+small, .small
+{
+ font-size: 80%;
+}
+
+.navbar
+{
+ ul li a i
+ {
+ margin-right: 5px;
+ }
+}
diff --git a/CkEditorSample/Content/metro-bootstrap/labels.less b/CkEditorSample/Content/metro-bootstrap/labels.less
new file mode 100644
index 0000000..9d01ad0
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/labels.less
@@ -0,0 +1,34 @@
+//
+// Labels
+// --------------------------------------------------
+
+.label {
+ border-radius: 0px;
+}
+
+// Colors
+// Contextual variations (linked labels get darker on :hover)
+
+.label-default {
+ border-radius: 0px;
+}
+
+.label-primary {
+ border-radius: 0px;
+}
+
+.label-success {
+ border-radius: 0px;
+}
+
+.label-info {
+ border-radius: 0px;
+}
+
+.label-warning {
+ border-radius: 0px;
+}
+
+.label-danger {
+ border-radius: 0px;
+}
diff --git a/CkEditorSample/Content/metro-bootstrap/metro-bootstrap.less b/CkEditorSample/Content/metro-bootstrap/metro-bootstrap.less
new file mode 100644
index 0000000..6859731
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/metro-bootstrap.less
@@ -0,0 +1,85 @@
+/*!
+ * metro-bootstrap v3.2.0.0
+ *
+ * from talkslab based on twitter bootstrap.
+ */
+@font-face
+{
+ font-family: "WeblySleek UI Light";
+ src: url("/fonts/weblysleekuil.eot?") format("eot"),
+ url("/fonts/weblysleekuil.woff") format("woff"),
+ url("/fonts/weblysleekuil.ttf") format("truetype"),
+ url("/fonts/weblysleekuil.svg#WeblySleekUILight") format("svg");
+ font-weight: normal;
+ font-style: normal;
+}
+
+
+// Core variables and mixins
+@import "../bootstrap/variables.less";
+@import "variables.less";
+@import "../bootstrap/mixins.less";
+
+// Reset
+@import "../bootstrap/normalize.less";
+@import "../bootstrap/print.less";
+
+// Core CSS
+@import "../bootstrap/scaffolding.less";
+@import "../bootstrap/type.less";
+@import "../bootstrap/code.less";
+@import "../bootstrap/grid.less";
+@import "../bootstrap/tables.less";
+@import "../bootstrap/forms.less";
+@import "../bootstrap/buttons.less";
+
+// Components
+@import "../bootstrap/component-animations.less";
+@import "../bootstrap/glyphicons.less";
+@import "../bootstrap/dropdowns.less";
+@import "../bootstrap/button-groups.less";
+@import "../bootstrap/input-groups.less";
+@import "../bootstrap/navs.less";
+@import "../bootstrap/navbar.less";
+@import "../bootstrap/breadcrumbs.less";
+@import "../bootstrap/pagination.less";
+@import "../bootstrap/pager.less";
+@import "../bootstrap/labels.less";
+@import "../bootstrap/badges.less";
+@import "../bootstrap/jumbotron.less";
+@import "../bootstrap/thumbnails.less";
+@import "../bootstrap/alerts.less";
+@import "../bootstrap/progress-bars.less";
+@import "../bootstrap/media.less";
+@import "../bootstrap/list-group.less";
+@import "../bootstrap/panels.less";
+@import "../bootstrap/wells.less";
+@import "../bootstrap/close.less";
+
+// Components w/ JavaScript
+@import "../bootstrap/modals.less";
+@import "../bootstrap/tooltip.less";
+@import "../bootstrap/popovers.less";
+@import "../bootstrap/carousel.less";
+
+// Utility classes
+@import "../bootstrap/utilities.less";
+@import "../bootstrap/responsive-utilities.less";
+
+
+
+
+
+/*
+ * metro-bootstrap files
+ */
+
+
+@import "tiles.less";
+@import "alerts.less";
+@import "checkbox.less";
+@import "radio.less";
+@import "labels.less";
+@import "modals.less";
+@import "navbar-side.less";
+@import 'custom.less';
\ No newline at end of file
diff --git a/CkEditorSample/Content/metro-bootstrap/modals.less b/CkEditorSample/Content/metro-bootstrap/modals.less
new file mode 100644
index 0000000..ec9e2bd
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/modals.less
@@ -0,0 +1,9 @@
+//
+// Modals
+// --------------------------------------------------
+
+// Shell div to position the modal with bottom padding
+.modal-dialog {
+ margin-left: auto;
+ margin-right: auto;
+}
diff --git a/CkEditorSample/Content/metro-bootstrap/navbar-side.less b/CkEditorSample/Content/metro-bootstrap/navbar-side.less
new file mode 100644
index 0000000..dbb63e6
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/navbar-side.less
@@ -0,0 +1,93 @@
+@media (min-width: @grid-float-breakpoint) {
+
+.navbar-side
+{
+ width: 225px;
+ margin-left: -225px;
+ left: 225px;
+ position: fixed;
+ height: 100%;
+ z-index: 1000;
+
+}
+
+.navbar-side .navbar-header
+{
+ float:none;
+ padding-top:15px;
+}
+
+.navbar-side .navbar-nav
+{
+ float:none;
+}
+
+.navbar-side .navbar-collapse
+{
+ padding-right: 0;
+ padding-left:0;
+ padding-top: 30px;
+ margin-bottom: 50px;
+}
+
+.navbar-side .navbar-nav > li
+{
+ float:none;
+}
+
+.navbar-side .navbar-nav > li > a
+{
+ display:inline-block;
+ width: 100%;
+ padding-left: 25px;
+
+}
+
+.navbar-side .navbar-nav > li > a:hover
+{
+ background: fade(@navbar-inverse-link-hover-bg, 50%) ;
+}
+
+.navbar-side.navbar-side-closed
+{
+ width: 85px;
+ margin-left: -85px;
+ left: 85px;
+}
+
+.navbar-side.navbar-side-closed .navbar-nav .fa
+{
+ font-size: 2em;
+}
+
+.navbar-side.navbar-side-closed .navbar-nav span
+{
+ font-size: 12px;
+}
+.navbar-side.navbar-side-closed .navbar-nav > li > a
+{
+ padding-left:0px;
+ padding-right:0px;
+ text-align:center;
+}
+
+.navbar-side.navbar-side-closed .navbar-nav > li > a > span
+{
+ display: list-item;
+}
+
+}
+
+.navbar-side-options
+{
+ padding-left:0px;
+ padding-right:0px;
+ padding-top: 40px;
+ width: 100%;
+ text-align: center;
+
+ @media (max-width: @grid-float-breakpoint) {
+ display:none;
+ }
+
+}
\ No newline at end of file
diff --git a/CkEditorSample/Content/metro-bootstrap/radio.less b/CkEditorSample/Content/metro-bootstrap/radio.less
new file mode 100644
index 0000000..b19d6ee
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/radio.less
@@ -0,0 +1,51 @@
+// Radio
+.radio {
+ display: inline-block;
+ margin-right: 10px;
+ margin-bottom: 10px;
+ cursor: pointer;
+
+ & > input[type=radio] {
+ position: absolute;
+ opacity: 0;
+ }
+ & > span {}
+
+ .radio-label {
+ padding-left: 28px;
+ position: relative;
+ }
+
+ .radio-label:before {
+ position: absolute;
+ display: block;
+ height: 24px;
+ width: 24px;
+ content: "";
+ text-indent: -9999px;
+ border: 2px #d9d9d9 solid;
+ z-index: 1;
+ opacity: 1;
+ top: 0;
+ left: 0;
+ border-radius: 100%;
+ }
+
+ input[type="radio"]:checked ~ .radio-label:after {
+ position: absolute;
+ display: block;
+ content: "";
+ color: #1a1a1a;
+ z-index: 2;
+ font-size: 16px;
+ font-weight: bold;
+ left: 10px;
+ margin-left: -3px;
+ top: 60%;
+ margin-top: -4px;
+ background-color: #1a1a1a;
+ width: 10px;
+ height: 10px;
+ border-radius: 100%;
+ }
+ }
diff --git a/CkEditorSample/Content/metro-bootstrap/tiles.less b/CkEditorSample/Content/metro-bootstrap/tiles.less
new file mode 100644
index 0000000..f642995
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/tiles.less
@@ -0,0 +1,256 @@
+.tile
+{
+ display:block;
+ cursor: pointer;
+ -webkit-perspective: 0;
+ -webkit-transform-style: preserve-3d;
+ -webkit-transition: -webkit-transform 0.2s;
+ float: left;
+ min-width: 75px;
+ min-height: 75px;
+ text-align:center;
+ opacity:0.75;
+ background-color: @tile-bg;
+ z-index: 1;
+ border: @tile-border @tile-border-bg solid;
+ color: @tile-text-color;
+
+ h1, h2, h3, h4, h5, h6 {
+ color: @tile-text-color;
+ -webkit-user-select: none;
+ }
+ h2 { margin-top: -20px; margin-left:0px; }
+ h3, h4 { margin-top: -15px; }
+
+ h1.tile-text, h2.tile-text, h3.tile-text, h4.tile-text { margin-top: 20px; }
+
+ h1
+ {
+ font-size: @tile-font-size-h1;
+ }
+ h2
+ {
+ font-size: @tile-font-size-h2;
+ }
+ h3
+ {
+ font-size: @tile-font-size-h3;
+ }
+ h4
+ {
+ font-size: @tile-font-size-h4;
+ }
+
+ a:hover { text-decoration: none; }
+
+}
+
+.tile img
+{
+ border :0;
+}
+.tile:hover
+{
+ opacity:1;
+}
+
+.tile .tile-label {
+ position: absolute;
+ bottom: 10px;
+ left: 20px;
+ font-size: 14px;
+ color: @tile-text-color;
+}
+
+.tile .tile-content .tile-icon-large {
+ margin-left: 0px;
+ vertical-align: middle !important;
+ text-align: center;
+}
+
+.tile .tile-content
+{
+ padding-top: 20px;
+ line-height: normal;
+ position: relative;
+ width: 100%;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+
+.tile.tile-blue
+{
+ background-color: @blue;
+}
+.tile.tile-green
+{
+ background-color: @green;
+}
+.tile.tile-red
+{
+ background-color: @red;
+}
+.tile.tile-yellow
+{
+ background-color: @yellow;
+}
+.tile.tile-orange
+{
+ background-color: @orange;
+}
+.tile.tile-pink
+{
+ background-color: @pink;
+}
+.tile.tile-purple
+{
+ background-color: @purple;
+}
+.tile.tile-lime
+{
+ background-color: @lime;
+}
+.tile.tile-magenta
+{
+ background-color: @magenta;
+}
+.tile.tile-teal
+{
+ background-color: @teal;
+}
+.tile.tile-turquoise
+{
+ background-color: @turquoise;
+}
+.tile.tile-green-sea
+{
+ background-color: @green-sea;
+}
+.tile.tile-emerald
+{
+ background-color: @emerald;
+}
+.tile.tile-nephritis
+{
+ background-color: @nephritis;
+}
+.tile.tile-peter-river
+{
+ background-color: @peter-river;
+}
+.tile.tile-belize-hole
+{
+ background-color: @belize-hole;
+}
+.tile.tile-amethyst
+{
+ background-color: @amethyst;
+}
+.tile.tile-wisteria
+{
+ background-color: @wisteria;
+}
+.tile.tile-wet-asphalt
+{
+ background-color: @wet-asphalt;
+}
+.tile.tile-midnight-blue
+{
+ background-color: @midnight-blue;
+}
+.tile.tile-sun-flower
+{
+ background-color: @sun-flower;
+}
+.tile.tile-carrot
+{
+ background-color: @carrot;
+}
+.tile.tile-pumpkin
+{
+ background-color: @pumpkin;
+}
+.tile.tile-alizarin
+{
+ background-color: @alizarin;
+}
+.tile.tile-pomegranate
+{
+ background-color: @pomegranate;
+}
+.tile.tile-clouds
+{
+ background-color: @clouds;
+ color: @tile-light-text-color;
+ h1, h2, h3, h4, h5, h6 {
+ color: @tile-light-text-color;
+ }
+}
+
+.tile.tile-clouds .tile-label {
+ color: @tile-light-text-color;
+}
+
+.tile.tile-silver
+{
+ background-color: @silver;
+}
+.tile.tile-concrete
+{
+ background-color: @concrete;
+}
+.tile.tile-asbestos
+{
+ background-color: @asbestos;
+}
+
+.tile.tile-info
+{
+ background-color: @tile-info-bg;
+}
+.tile.tile-danger
+{
+ background-color: @tile-danger-bg;
+}
+.tile.tile-warning
+{
+ background-color: @tile-warning-bg;
+}
+.tile.tile-success
+{
+ background-color: @tile-success-bg;
+}
+
+
+a.fa-links
+{
+color:#ffffff;
+}
+a.fa-links:hover,a.fa-links:focus
+{
+color:#ffffff;
+}
+
+
+
+.tile.tile-small
+{
+ height: 70px;
+ width: 70px;
+}
+.tile.tile-medium
+{
+ height: 150px;
+ width: 150px;
+}
+.tile.tile-wide, .tile.tile-double
+{
+ height: 150px;
+ width: 310px;
+}
+.tile.tile-large
+{
+ height: 310px;
+ width: 310px;
+}
\ No newline at end of file
diff --git a/CkEditorSample/Content/metro-bootstrap/variables.less b/CkEditorSample/Content/metro-bootstrap/variables.less
new file mode 100644
index 0000000..334dc7c
--- /dev/null
+++ b/CkEditorSample/Content/metro-bootstrap/variables.less
@@ -0,0 +1,157 @@
+@import url('../bootstrap/variables.less');
+// Accent colors
+// -------------------------
+@blue: #2E8BCC;
+@green: #339933;
+@red: #E51400;
+@yellow: #ffc40d;
+@pink: #E671B8;
+@purple: #7B4F9D;
+@lime: #8CBF26;
+@magenta: #FF0097;
+@teal: #00ABA9;
+@white: #FFFFFF;
+
+// Flat colors
+// Reference: http://flatuicolors.com/
+// -------------------------
+@turquoise: #1abc9c;
+@green-sea: #16a085;
+@emerald: #2ecc71;
+@nephritis: #27ae60;
+@peter-river: #3498db;
+@belize-hole: #2980b9;
+@amethyst: #9b59b6;
+@wisteria: #8e44ad;
+@wet-asphalt: #34495e;
+@midnight-blue: #2c3e50;
+@sun-flower: #f1c40f;
+@orange: #f39c12;
+@carrot: #e67e22;
+@pumpkin: #d35400;
+@alizarin: #e74c3c;
+@pomegranate: #c0392b;
+@clouds: #ecf0f1;
+@silver: #bdc3c7;
+@concrete: #95a5a6;
+@asbestos: #7f8c8d;
+
+
+@brand-success: @emerald;
+@brand-info: @peter-river;
+@brand-warning: @sun-flower;
+@brand-danger: @alizarin;
+
+
+// Typography
+// -------------------------
+
+@font-family-sans-serif: "WeblySleek UI Light","Segoe UI", "Segoe WP", "Helvetica Neue", sans-serif;
+@font-family-serif: Georgia, "Times New Roman", Times, serif;
+@font-family-monospace: Monaco, Menlo, Consolas, "Courier New", monospace;
+@font-family-base: @font-family-sans-serif;
+
+@headings-font-family: "WeblySleek UI Light", "Helvetica Neue", "Segoe UI", "Segoe WP", sans-serif;
+@headings-font-weight: 100;
+@font-size-base: 16px;
+
+
+
+// Components
+// -------------------------
+
+@border-radius-base: 0px;
+@border-radius-large: 0px;
+@border-radius-small: 0px;
+
+
+// Navbar
+// -------------------------
+
+// Basics of a navbar
+@navbar-default-bg: @blue;
+@navbar-default-border: @blue;
+
+
+// Navbar links
+@navbar-default-link-color: @white;
+@navbar-default-link-hover-color: @white;
+@navbar-default-link-hover-bg: darken(@navbar-default-bg, 6.5%);
+@navbar-default-link-active-color: @white;
+@navbar-default-link-active-bg: darken(@navbar-default-bg, 6.5%);
+@navbar-default-link-disabled-color: #ccc;
+@navbar-default-link-disabled-bg: transparent;
+
+
+// Inverted navbar
+//
+// Reset inverted navbar basics
+@navbar-inverse-color: @gray-light;
+@navbar-inverse-bg: #222;
+@navbar-inverse-border: @navbar-inverse-bg;
+
+// Inverted navbar links
+@navbar-inverse-link-color: @white;
+@navbar-inverse-link-hover-color: @white;
+@navbar-inverse-link-hover-bg: @gray;
+@navbar-inverse-link-active-color: @navbar-inverse-link-hover-color;
+@navbar-inverse-link-active-bg: @peter-river;
+@navbar-inverse-link-disabled-color: #444;
+@navbar-inverse-link-disabled-bg: transparent;
+
+
+// Tiles
+// -----------------------
+@tile-border: 4px;
+@tile-border-bg: @white;
+@tile-bg: @blue;
+@tile-text-color: @white;
+@tile-light-text-color: @wet-asphalt;
+
+@tile-success-bg: @state-success-bg;
+@tile-info-bg: @state-info-bg;
+@tile-warning-bg: @state-warning-bg;
+@tile-danger-bg: @state-danger-bg;
+
+
+@tile-font-size-h1: @font-size-h1;
+@tile-font-size-h2: @font-size-h2;
+@tile-font-size-h3: @font-size-h3;
+@tile-font-size-h4: @font-size-h4;
+
+
+// Pager
+// -------------------------
+
+@pager-border-radius: 0px;
+@pager-disabled-color: @gray-light;
+
+
+// Badges
+// -------------------------
+@badge-border-radius: 0px;
+
+//== Form states and alerts
+//
+//## Define colors for form feedback states and, by default, alerts.
+
+@state-success-bg: @brand-success;
+@state-success-border: darken(spin(@state-success-bg, -10), 5%);
+
+@state-info-bg: @brand-info;
+@state-info-border: darken(spin(@state-info-bg, -10), 7%);
+
+@state-warning-bg: @brand-warning;
+@state-warning-border: darken(spin(@state-warning-bg, -10), 5%);
+
+@state-danger-bg: @brand-danger;
+@state-danger-border: darken(spin(@state-danger-bg, -10), 5%);
+
+//== Jumbotron
+//
+//##
+
+@jumbotron-padding: 30px;
+@jumbotron-color: #eee;
+@jumbotron-bg: @gray-dark;
+@jumbotron-heading-color: @orange;
diff --git a/CkEditorSample/Default.aspx b/CkEditorSample/Default.aspx
new file mode 100644
index 0000000..a5269e0
--- /dev/null
+++ b/CkEditorSample/Default.aspx
@@ -0,0 +1,130 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
+
+
+
+
+
+
+ CKEDITOR sample
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CkEditorSample/Default.aspx.cs b/CkEditorSample/Default.aspx.cs
new file mode 100644
index 0000000..72b8fa5
--- /dev/null
+++ b/CkEditorSample/Default.aspx.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+public partial class _Default : System.Web.UI.Page
+{
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ Response.Redirect("Home.aspx");
+ }
+}
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/FileBrowser.aspx b/CkEditorSample/FileBrowser/FileBrowser.aspx
new file mode 100644
index 0000000..b44f8d8
--- /dev/null
+++ b/CkEditorSample/FileBrowser/FileBrowser.aspx
@@ -0,0 +1,288 @@
+<%@ Page Language="C#" AutoEventWireup="true" Inherits="MB.FileBrowser.FileBrowser" Codebehind="FileBrowser.aspx.cs" %>
+
+<%@ Register Assembly="IZ.WebFileManager" Namespace="IZ.WebFileManager" TagPrefix="iz" %>
+
+
+
+
+
+ File Browser
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Click to upload
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CkEditorSample/FileBrowser/FileBrowser.aspx.cs b/CkEditorSample/FileBrowser/FileBrowser.aspx.cs
new file mode 100644
index 0000000..d2cfcc6
--- /dev/null
+++ b/CkEditorSample/FileBrowser/FileBrowser.aspx.cs
@@ -0,0 +1,294 @@
+using System;
+using System.IO;
+using IZ.WebFileManager;
+using System.Security.AccessControl;
+using System.Web;
+using System.Web.UI.WebControls;
+using System.Globalization;
+using MB.FileBrowser;
+
+namespace MB.FileBrowser
+{
+ public partial class FileBrowser : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
+ {
+ protected AjaxJsonResponse ajaxResponse = new AjaxJsonResponse();
+ public string Opener;
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+
+ if (Request.Url.Host.IndexOf("localhost") > -1)
+ FileManager1.DefaultAccessMode = AccessMode.Write;
+
+
+ CultureInfo culture;
+ try
+ {
+ culture = new CultureInfo(Request["langCode"]);
+ }
+ catch (Exception)
+ {
+ culture = CultureInfo.CurrentCulture;
+ }
+ FileManager1.ShowAddressBar = false;
+ FileManager1.AllowUpload = false;
+
+ String cbReference =
+ Page.ClientScript.GetCallbackEventReference(this,
+ "arg", "ReceiveServerData", "context");
+ String callbackScript;
+ callbackScript = "function CallServer(arg, context)" +
+ "{ " + cbReference + ";}";
+ Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
+ "CallServer", callbackScript, true);
+
+ if (!IsPostBack)
+ {
+ /**
+ * -------- Parameters --------------
+ * CKEDITOR automatically call FileManager service adding two custom parameters
+ * CKEditorFuncNum e type.
+ * First parameter allows you to pass choosen file url back to CKEDITOR
+ * through callback function
+ * Type paramete is used to restrict the file search to a
+ * specific folder
+ *
+ * Tiny MCE 4 use the type parameter and field parameter wich is
+ * the id of the field whose value must be set.
+ *
+ *
+ * Other recognized parameters
+ * caller:
+ * allowed values: ckeditor, tinymce, parent, top
+ * default: caller id defaulted to ckeditor if the CKEditor parameter is specified otherwise to parent
+ * Idicates the object to wich the callback must be return
+ *
+ * fn:
+ * allowed values: any string
+ * default: null
+ * Function name to be called.
+ *
+ * langCode:
+ * allowed value: a standard language code
+ * default: current language
+ * CKEdito pass this paramenter automatically
+ *
+ */
+
+ int fnumber = 0;
+ string caller, fn;
+
+ // the caller is CKEditor
+ if (!string.IsNullOrEmpty(Request["CKEditor"]))
+ {
+ caller = "ckeditor";
+ }
+ else
+ caller = (String.IsNullOrEmpty(Request["caller"]) ? "parent" : Request["caller"]);
+
+ HF_Opener.Value = caller;
+
+ fn = Request["fn"];
+
+ if (!String.IsNullOrEmpty(fn))
+ HF_CallBack.Value = fn;
+
+ if (int.TryParse(Request["CKEditorFuncNum"], out fnumber))
+ HF_CKEditorFunctionNumber.Value = fnumber.ToString();
+
+ if (!String.IsNullOrEmpty(Request["field"]))
+ HF_Field.Value = Request["field"];
+
+ string type = "";
+ string mainRoot = "~/userfiles";
+
+ if (FileManager1.Culture == null)
+ FileManager1.Culture = culture;
+
+ HF_CurrentCulture.Value = FileManager1.Culture.Name;
+
+ FileManager1.CustomToolbarButtons[0].Text = FileManager1.Controller.GetResourceString("View_file", "View File");
+ Upload_button.InnerText = FileManager1.Controller.GetResourceString("Upload_file_click", "Click here to download a file");
+ DND_message.InnerText = FileManager1.Controller.GetResourceString("Upload_dnd", "Or drag 'nd drop one or more files on the above area");
+
+ if (!String.IsNullOrEmpty(FileManager1.MainDirectory))
+ mainRoot = FileManager1.MainDirectory;
+ //mainRoot = ResolveClientUrl(mainRoot);
+ if (!Directory.Exists(Server.MapPath(ResolveClientUrl(mainRoot))))
+ throw new Exception("User directory with write privileges is needed.");
+
+ DirectoryInfo mainRootInfo = new DirectoryInfo(Server.MapPath(ResolveClientUrl(mainRoot)));
+
+ mainRootInfo.CreateSubdirectory("images");
+ mainRootInfo.CreateSubdirectory("files");
+ mainRootInfo.CreateSubdirectory("flash");
+ mainRootInfo.CreateSubdirectory("media");
+
+ if (!String.IsNullOrEmpty(Request["type"]))
+ {
+ type = Request["type"];
+ }
+
+ RootDirectory images, flash, files, media;
+ // Display text of root folders are localized using WebFileBrowser resources files
+ // in "/App_GlobalResources/WebFileManager" and GetResoueceString method
+ // of FileManager.Controller class
+ switch (type)
+ {
+ case "images":
+ case "image":
+ FileManager1.RootDirectories.Clear();
+ images = new RootDirectory();
+ images.ShowRootIndex = false;
+ images.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "images";
+ images.Text = FileManager1.Controller.GetResourceString("Root_Image", "Images");
+ images.LargeImageUrl = "~/FileBrowser/img/32/camera.png";
+ images.SmallImageUrl = "~/FileBrowser/img/16/camera.png";
+ FileManager1.RootDirectories.Add(images);
+ break;
+ case "flash":
+ FileManager1.RootDirectories.Clear();
+ flash = new RootDirectory();
+ flash.ShowRootIndex = false;
+ flash.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "flash";
+ flash.LargeImageUrl = "~/FileBrowser/img/32/folder-flash.png";
+ flash.SmallImageUrl = "~/FileBrowser/img/16/folder-flash.png";
+ flash.Text = FileManager1.Controller.GetResourceString("Root_Flash", "Flash Movies");
+ FileManager1.RootDirectories.Add(flash);
+ break;
+ case "files":
+ FileManager1.RootDirectories.Clear();
+ files = new RootDirectory();
+ files.ShowRootIndex = false;
+ files.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "files";
+ files.LargeImageUrl = "~/FileBrowser/img/32/folder-document-alt.png";
+ files.SmallImageUrl = "~/FileBrowser/img/16/folder-document-alt.png";
+ files.Text = FileManager1.Controller.GetResourceString("Root_File", "Files");
+ FileManager1.RootDirectories.Add(files);
+ break;
+ case "media":
+ FileManager1.RootDirectories.Clear();
+ media = new RootDirectory();
+ media.ShowRootIndex = false;
+ media.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "media";
+ media.LargeImageUrl = "~/FileBrowser/img/32/folder-video-alt.png";
+ media.SmallImageUrl = "~/FileBrowser/img/16/folder-video-alt.png";
+ media.Text = FileManager1.Controller.GetResourceString("Root_Media", "Media");
+ FileManager1.RootDirectories.Add(media);
+ break;
+ default:
+ FileManager1.RootDirectories.Clear();
+ files = new RootDirectory();
+ files.ShowRootIndex = false;
+ files.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "files";
+ files.LargeImageUrl = "~/FileBrowser/img/32/folder-document-alt.png";
+ files.SmallImageUrl = "~/FileBrowser/img/16/folder-document-alt.png";
+ // Display text of root folders are localized using WebFileBrowser resources files
+ // in "/App_GlobalResources/WebFileManager" and GetResoueceString method
+ // of FileManager.Controller class
+ files.Text = FileManager1.Controller.GetResourceString("Root_File", "Files");
+ FileManager1.RootDirectories.Add(files);
+
+ flash = new RootDirectory();
+ flash.ShowRootIndex = false;
+ flash.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "flash";
+ flash.LargeImageUrl = "~/FileBrowser/img/32/folder-flash.png";
+ flash.SmallImageUrl = "~/FileBrowser/img/16/folder-flash.png";
+ flash.Text = FileManager1.Controller.GetResourceString("Root_Flash", "Flash Movies");
+ FileManager1.RootDirectories.Add(flash);
+
+ images = new RootDirectory();
+ images.ShowRootIndex = false;
+ images.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "images";
+ images.Text = FileManager1.Controller.GetResourceString("Root_Image", "Images");
+ images.LargeImageUrl = "~/FileBrowser/img/32/camera.png";
+ images.SmallImageUrl = "~/FileBrowser/img/16/camera.png";
+ FileManager1.RootDirectories.Add(images);
+
+ media = new RootDirectory();
+ media.ShowRootIndex = false;
+ media.DirectoryPath = VirtualPathUtility.AppendTrailingSlash(mainRoot) + "media";
+ media.LargeImageUrl = "~/FileBrowser/img/32/folder-video-alt.png";
+ media.SmallImageUrl = "~/FileBrowser/img/16/folder-video-alt.png";
+ media.Text = FileManager1.Controller.GetResourceString("Root_Media", "Media");
+ FileManager1.RootDirectories.Add(media);
+
+ break;
+ }
+ }
+
+ AccessMode fbAccessMode;
+ if (MagicSession.Current.FileBrowserAccessMode == AccessMode.Default)
+ fbAccessMode = FileManager1.DefaultAccessMode;
+ else
+ fbAccessMode = MagicSession.Current.FileBrowserAccessMode;
+
+ Literal content;
+
+ switch (fbAccessMode)
+ {
+ case AccessMode.Delete:
+ FileManager1.Visible = true;
+ Panel_upload.Visible = true;
+ Panel_deny.Visible = false;
+ FileManager1.ReadOnly = false;
+ FileManager1.AllowDelete = true;
+ FileManager1.AllowOverwrite = true;
+ break;
+ case AccessMode.DenyAll:
+ FileManager1.Visible = false;
+ Panel_upload.Visible = false;
+ Panel_deny.Visible = true;
+ content = new Literal();
+ content.Text = "" + FileManager1.Controller.GetResourceString("Upload_Error_3", "User does not have sufficient privileges.") + " ";
+ Panel_deny.Controls.Add(content);
+ break;
+ case AccessMode.ReadOnly:
+ case AccessMode.Default:
+ FileManager1.Visible = true;
+ Panel_upload.Visible = true;
+ Panel_deny.Visible = false;
+ FileManager1.ReadOnly = true;
+ break;
+ case AccessMode.Write:
+ FileManager1.Visible = true;
+ Panel_upload.Visible = true;
+ Panel_deny.Visible = false;
+ FileManager1.ReadOnly = false;
+ FileManager1.AllowDelete = false;
+ FileManager1.AllowOverwrite = false;
+ break;
+ default:
+ break;
+ }
+
+
+ }
+ public void RaiseCallbackEvent(String eventArgument)
+ {
+ string[] cmds = eventArgument.Split(new char[] { ',' });
+ ajaxResponse.command = cmds[0].ToLower();
+ switch (cmds[0].ToLower())
+ {
+ case "showfile":
+ if (FileManager1.CurrentDirectory != null)
+ ajaxResponse.data = VirtualPathUtility.AppendTrailingSlash(FileManager1.CurrentDirectory.VirtualPath) + cmds[1];
+ break;
+ case "upload":
+ if (FileManager1.CurrentDirectory != null)
+ ajaxResponse.data = VirtualPathUtility.AppendTrailingSlash(FileManager1.CurrentDirectory.VirtualPath);
+ break;
+ default:
+ break;
+ }
+
+ }
+ public String GetCallbackResult()
+ {
+ System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
+ return serializer.Serialize(ajaxResponse);
+
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/IZWebFileManagerThumbnailHandler.ashx b/CkEditorSample/FileBrowser/IZWebFileManagerThumbnailHandler.ashx
new file mode 100644
index 0000000..c2f9921
--- /dev/null
+++ b/CkEditorSample/FileBrowser/IZWebFileManagerThumbnailHandler.ashx
@@ -0,0 +1 @@
+<%@ WebHandler Language="C#" Class="IZ.WebFileManager.ThumbnailHandler, IZ.WebFileManager" %>
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/MyUpload.ashx b/CkEditorSample/FileBrowser/MyUpload.ashx
new file mode 100644
index 0000000..042b5a9
--- /dev/null
+++ b/CkEditorSample/FileBrowser/MyUpload.ashx
@@ -0,0 +1,104 @@
+<%@ WebHandler Language="C#" Class="MB.FileBrowser.MyUpload" %>
+
+using System;
+using System.Web;
+using System.Linq;
+using System.IO;
+using IZ.WebFileManager;
+
+namespace MB.FileBrowser
+{
+ public class MyUpload : IHttpHandler, System.Web.SessionState.IRequiresSessionState
+ {
+ const int MaxAllowedSize = 50; //Megabyte
+ public void ProcessRequest(HttpContext context)
+ {
+ string filename, imagepath, cultureName;
+ AjaxJsonResponse response = new AjaxJsonResponse();
+ try
+ {
+ filename = context.Request["qqfilename"];
+ imagepath = context.Request["dest"];
+ cultureName = context.Request["culture"];
+ System.Globalization.CultureInfo culture = (String.IsNullOrEmpty(cultureName) ?
+ System.Globalization.CultureInfo.CurrentCulture :
+ new System.Globalization.CultureInfo(cultureName));
+ string successMsg = GetResource("Upload_success", culture, "File \"{0}\" was successfully handled.");
+ response.exitcode = 0;
+ response.data = null;
+ response.success = true;
+ response.msg = String.Format(successMsg, filename);
+ string extension = System.IO.Path.GetExtension(filename).Remove(0, 1).ToLower();
+ if (context.Request.Files[0].InputStream.Length > 1024 * 1024 * MaxAllowedSize)
+ {
+ string msg = GetResource("Upload_Error_1", culture, "File exceeds maximum size allowed ({0} Mb)");
+ response.success = false;
+ response.exitcode = 1;
+ response.msg = String.Format(msg, MaxAllowedSize);
+ }
+ else if (!AllowedFilesType.GetAllowed().Contains(extension))
+ {
+ response.success = false;
+ response.exitcode = 2;
+ response.msg = GetResource("Upload_Error_2", culture, "File type not allowed or not supported.");
+ }
+ else if (!MagicSession.Current.Upload)
+ {
+ response.success = false;
+ response.exitcode = 3;
+ response.msg = GetResource("Upload_Error_3", culture, "User does not have sufficient privileges.");
+ }
+ else
+ {
+ for (int k = 0; k < context.Request.Files.Count; k++)
+ {
+ string destPath = context.Server.MapPath(VirtualPathUtility.AppendTrailingSlash(imagepath) + filename);
+ int i = 1;
+ while (File.Exists((destPath)))
+ {
+ destPath = Path.GetFileNameWithoutExtension(destPath) + "(" + i.ToString() + ")" + Path.GetExtension(destPath);
+ i++;
+ }
+ context.Request.Files[0].SaveAs(destPath);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+
+ response.success = false;
+ response.exitcode = 4;
+ response.msg = e.Message;
+ }
+
+ System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
+ string json = serializer.Serialize(response);
+
+ context.Response.ContentType = "application/json";
+ context.Response.Charset = "UTF-8";
+ context.Response.Write(json);
+ }
+
+
+ public bool IsReusable
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ private string GetResource(string key, System.Globalization.CultureInfo culture, string defaultValue)
+ {
+
+ if (HttpContext.GetGlobalResourceObject("IZWebFileManagerResource", key, culture) != null)
+ return HttpContext.GetGlobalResourceObject("IZWebFileManagerResource", key, culture).ToString();
+
+ if (HttpContext.GetGlobalResourceObject("IZWebFileManagerResource", key, System.Globalization.CultureInfo.InvariantCulture) != null)
+ return HttpContext.GetGlobalResourceObject("IZWebFileManagerResource", key, System.Globalization.CultureInfo.InvariantCulture).ToString();
+
+ return defaultValue;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/css/style.css b/CkEditorSample/FileBrowser/css/style.css
new file mode 100644
index 0000000..77e6688
--- /dev/null
+++ b/CkEditorSample/FileBrowser/css/style.css
@@ -0,0 +1,1237 @@
+@font-face {
+ font-family: "WeblySleek UI Light";
+ src: url("/fonts/weblysleekuil.eot?") format("eot"), url("/fonts/weblysleekuil.woff") format("woff"), url("/fonts/weblysleekuil.ttf") format("truetype"), url("/fonts/weblysleekuil.svg#WeblySleekUILight") format("svg");
+ font-weight: normal;
+ font-style: normal;
+}
+/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
+html {
+ font-family: sans-serif;
+ -ms-text-size-adjust: 100%;
+ -webkit-text-size-adjust: 100%;
+}
+body {
+ margin: 0;
+}
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+main,
+nav,
+section,
+summary {
+ display: block;
+}
+audio,
+canvas,
+progress,
+video {
+ display: inline-block;
+ vertical-align: baseline;
+}
+audio:not([controls]) {
+ display: none;
+ height: 0;
+}
+[hidden],
+template {
+ display: none;
+}
+a {
+ background: transparent;
+}
+a:active,
+a:hover {
+ outline: 0;
+}
+abbr[title] {
+ border-bottom: 1px dotted;
+}
+b,
+strong {
+ font-weight: bold;
+}
+dfn {
+ font-style: italic;
+}
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+mark {
+ background: #ff0;
+ color: #000;
+}
+small {
+ font-size: 80%;
+}
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+}
+sup {
+ top: -0.5em;
+}
+sub {
+ bottom: -0.25em;
+}
+img {
+ border: 0;
+}
+svg:not(:root) {
+ overflow: hidden;
+}
+figure {
+ margin: 1em 40px;
+}
+hr {
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ height: 0;
+}
+pre {
+ overflow: auto;
+}
+code,
+kbd,
+pre,
+samp {
+ font-family: monospace, monospace;
+ font-size: 1em;
+}
+button,
+input,
+optgroup,
+select,
+textarea {
+ color: inherit;
+ font: inherit;
+ margin: 0;
+}
+button {
+ overflow: visible;
+}
+button,
+select {
+ text-transform: none;
+}
+button,
+html input[type="button"],
+input[type="reset"],
+input[type="submit"] {
+ -webkit-appearance: button;
+ cursor: pointer;
+}
+button[disabled],
+html input[disabled] {
+ cursor: default;
+}
+button::-moz-focus-inner,
+input::-moz-focus-inner {
+ border: 0;
+ padding: 0;
+}
+input {
+ line-height: normal;
+}
+input[type="checkbox"],
+input[type="radio"] {
+ box-sizing: border-box;
+ padding: 0;
+}
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ height: auto;
+}
+input[type="search"] {
+ -webkit-appearance: textfield;
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ box-sizing: content-box;
+}
+input[type="search"]::-webkit-search-cancel-button,
+input[type="search"]::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+fieldset {
+ border: 1px solid #c0c0c0;
+ margin: 0 2px;
+ padding: 0.35em 0.625em 0.75em;
+}
+legend {
+ border: 0;
+ padding: 0;
+}
+textarea {
+ overflow: auto;
+}
+optgroup {
+ font-weight: bold;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+td,
+th {
+ padding: 0;
+}
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+*:before,
+*:after {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+html {
+ font-size: 10px;
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+}
+body {
+ font-family: "WeblySleek UI Light", "Segoe UI", "Segoe WP", "Helvetica Neue", sans-serif;
+ font-size: 16px;
+ line-height: 1.42857143;
+ color: #333333;
+ background-color: #ffffff;
+}
+input,
+button,
+select,
+textarea {
+ font-family: inherit;
+ font-size: inherit;
+ line-height: inherit;
+}
+a {
+ color: #428bca;
+ text-decoration: none;
+}
+a:hover,
+a:focus {
+ color: #2a6496;
+ text-decoration: underline;
+}
+a:focus {
+ outline: thin dotted;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+figure {
+ margin: 0;
+}
+img {
+ vertical-align: middle;
+}
+.img-responsive {
+ display: block;
+ width: 100% \9;
+ max-width: 100%;
+ height: auto;
+}
+.img-rounded {
+ border-radius: 0px;
+}
+.img-thumbnail {
+ padding: 4px;
+ line-height: 1.42857143;
+ background-color: #ffffff;
+ border: 1px solid #dddddd;
+ border-radius: 0px;
+ -webkit-transition: all 0.2s ease-in-out;
+ -o-transition: all 0.2s ease-in-out;
+ transition: all 0.2s ease-in-out;
+ display: inline-block;
+ width: 100% \9;
+ max-width: 100%;
+ height: auto;
+}
+.img-circle {
+ border-radius: 50%;
+}
+hr {
+ margin-top: 22px;
+ margin-bottom: 22px;
+ border: 0;
+ border-top: 1px solid #eeeeee;
+}
+.sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ margin: -1px;
+ padding: 0;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ border: 0;
+}
+.sr-only-focusable:active,
+.sr-only-focusable:focus {
+ position: static;
+ width: auto;
+ height: auto;
+ margin: 0;
+ overflow: visible;
+ clip: auto;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+.h1,
+.h2,
+.h3,
+.h4,
+.h5,
+.h6 {
+ font-family: "WeblySleek UI Light", "Helvetica Neue", "Segoe UI", "Segoe WP", sans-serif;
+ font-weight: 100;
+ line-height: 1.1;
+ color: inherit;
+}
+h1 small,
+h2 small,
+h3 small,
+h4 small,
+h5 small,
+h6 small,
+.h1 small,
+.h2 small,
+.h3 small,
+.h4 small,
+.h5 small,
+.h6 small,
+h1 .small,
+h2 .small,
+h3 .small,
+h4 .small,
+h5 .small,
+h6 .small,
+.h1 .small,
+.h2 .small,
+.h3 .small,
+.h4 .small,
+.h5 .small,
+.h6 .small {
+ font-weight: normal;
+ line-height: 1;
+ color: #777777;
+}
+h1,
+.h1,
+h2,
+.h2,
+h3,
+.h3 {
+ margin-top: 22px;
+ margin-bottom: 11px;
+}
+h1 small,
+.h1 small,
+h2 small,
+.h2 small,
+h3 small,
+.h3 small,
+h1 .small,
+.h1 .small,
+h2 .small,
+.h2 .small,
+h3 .small,
+.h3 .small {
+ font-size: 65%;
+}
+h4,
+.h4,
+h5,
+.h5,
+h6,
+.h6 {
+ margin-top: 11px;
+ margin-bottom: 11px;
+}
+h4 small,
+.h4 small,
+h5 small,
+.h5 small,
+h6 small,
+.h6 small,
+h4 .small,
+.h4 .small,
+h5 .small,
+.h5 .small,
+h6 .small,
+.h6 .small {
+ font-size: 75%;
+}
+h1,
+.h1 {
+ font-size: 41px;
+}
+h2,
+.h2 {
+ font-size: 34px;
+}
+h3,
+.h3 {
+ font-size: 28px;
+}
+h4,
+.h4 {
+ font-size: 20px;
+}
+h5,
+.h5 {
+ font-size: 16px;
+}
+h6,
+.h6 {
+ font-size: 14px;
+}
+p {
+ margin: 0 0 11px;
+}
+.lead {
+ margin-bottom: 22px;
+ font-size: 18px;
+ font-weight: 300;
+ line-height: 1.4;
+}
+@media (min-width: 768px) {
+ .lead {
+ font-size: 24px;
+ }
+}
+small,
+.small {
+ font-size: 87%;
+}
+cite {
+ font-style: normal;
+}
+mark,
+.mark {
+ background-color: #f1c40f;
+ padding: .2em;
+}
+.text-left {
+ text-align: left;
+}
+.text-right {
+ text-align: right;
+}
+.text-center {
+ text-align: center;
+}
+.text-justify {
+ text-align: justify;
+}
+.text-nowrap {
+ white-space: nowrap;
+}
+.text-lowercase {
+ text-transform: lowercase;
+}
+.text-uppercase {
+ text-transform: uppercase;
+}
+.text-capitalize {
+ text-transform: capitalize;
+}
+.text-muted {
+ color: #777777;
+}
+.text-primary {
+ color: #428bca;
+}
+a.text-primary:hover {
+ color: #3071a9;
+}
+.text-success {
+ color: #3c763d;
+}
+a.text-success:hover {
+ color: #2b542c;
+}
+.text-info {
+ color: #31708f;
+}
+a.text-info:hover {
+ color: #245269;
+}
+.text-warning {
+ color: #8a6d3b;
+}
+a.text-warning:hover {
+ color: #66512c;
+}
+.text-danger {
+ color: #a94442;
+}
+a.text-danger:hover {
+ color: #843534;
+}
+.bg-primary {
+ color: #fff;
+ background-color: #428bca;
+}
+a.bg-primary:hover {
+ background-color: #3071a9;
+}
+.bg-success {
+ background-color: #2ecc71;
+}
+a.bg-success:hover {
+ background-color: #25a25a;
+}
+.bg-info {
+ background-color: #3498db;
+}
+a.bg-info:hover {
+ background-color: #217dbb;
+}
+.bg-warning {
+ background-color: #f1c40f;
+}
+a.bg-warning:hover {
+ background-color: #c29d0b;
+}
+.bg-danger {
+ background-color: #e74c3c;
+}
+a.bg-danger:hover {
+ background-color: #d62c1a;
+}
+.page-header {
+ padding-bottom: 10px;
+ margin: 44px 0 22px;
+ border-bottom: 1px solid #eeeeee;
+}
+ul,
+ol {
+ margin-top: 0;
+ margin-bottom: 11px;
+}
+ul ul,
+ol ul,
+ul ol,
+ol ol {
+ margin-bottom: 0;
+}
+.list-unstyled {
+ padding-left: 0;
+ list-style: none;
+}
+.list-inline {
+ padding-left: 0;
+ list-style: none;
+ margin-left: -5px;
+}
+.list-inline > li {
+ display: inline-block;
+ padding-left: 5px;
+ padding-right: 5px;
+}
+dl {
+ margin-top: 0;
+ margin-bottom: 22px;
+}
+dt,
+dd {
+ line-height: 1.42857143;
+}
+dt {
+ font-weight: bold;
+}
+dd {
+ margin-left: 0;
+}
+@media (min-width: 768px) {
+ .dl-horizontal dt {
+ float: left;
+ width: 160px;
+ clear: left;
+ text-align: right;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .dl-horizontal dd {
+ margin-left: 180px;
+ }
+}
+abbr[title],
+abbr[data-original-title] {
+ cursor: help;
+ border-bottom: 1px dotted #777777;
+}
+.initialism {
+ font-size: 90%;
+ text-transform: uppercase;
+}
+blockquote {
+ padding: 11px 22px;
+ margin: 0 0 22px;
+ font-size: 20px;
+ border-left: 5px solid #eeeeee;
+}
+blockquote p:last-child,
+blockquote ul:last-child,
+blockquote ol:last-child {
+ margin-bottom: 0;
+}
+blockquote footer,
+blockquote small,
+blockquote .small {
+ display: block;
+ font-size: 80%;
+ line-height: 1.42857143;
+ color: #777777;
+}
+blockquote footer:before,
+blockquote small:before,
+blockquote .small:before {
+ content: '\2014 \00A0';
+}
+.blockquote-reverse,
+blockquote.pull-right {
+ padding-right: 15px;
+ padding-left: 0;
+ border-right: 5px solid #eeeeee;
+ border-left: 0;
+ text-align: right;
+}
+.blockquote-reverse footer:before,
+blockquote.pull-right footer:before,
+.blockquote-reverse small:before,
+blockquote.pull-right small:before,
+.blockquote-reverse .small:before,
+blockquote.pull-right .small:before {
+ content: '';
+}
+.blockquote-reverse footer:after,
+blockquote.pull-right footer:after,
+.blockquote-reverse small:after,
+blockquote.pull-right small:after,
+.blockquote-reverse .small:after,
+blockquote.pull-right .small:after {
+ content: '\00A0 \2014';
+}
+blockquote:before,
+blockquote:after {
+ content: "";
+}
+address {
+ margin-bottom: 22px;
+ font-style: normal;
+ line-height: 1.42857143;
+}
+.btn {
+ display: inline-block;
+ margin-bottom: 0;
+ font-weight: normal;
+ text-align: center;
+ vertical-align: middle;
+ cursor: pointer;
+ background-image: none;
+ border: 1px solid transparent;
+ white-space: nowrap;
+ padding: 6px 12px;
+ font-size: 16px;
+ line-height: 1.42857143;
+ border-radius: 0px;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+.btn:focus,
+.btn:active:focus,
+.btn.active:focus {
+ outline: thin dotted;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+.btn:hover,
+.btn:focus {
+ color: #333333;
+ text-decoration: none;
+}
+.btn:active,
+.btn.active {
+ outline: 0;
+ background-image: none;
+ -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+ box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
+}
+.btn.disabled,
+.btn[disabled],
+fieldset[disabled] .btn {
+ cursor: not-allowed;
+ pointer-events: none;
+ opacity: 0.65;
+ filter: alpha(opacity=65);
+ -webkit-box-shadow: none;
+ box-shadow: none;
+}
+.btn-default {
+ color: #333333;
+ background-color: #ffffff;
+ border-color: #cccccc;
+}
+.btn-default:hover,
+.btn-default:focus,
+.btn-default:active,
+.btn-default.active,
+.open > .dropdown-toggle.btn-default {
+ color: #333333;
+ background-color: #e6e6e6;
+ border-color: #adadad;
+}
+.btn-default:active,
+.btn-default.active,
+.open > .dropdown-toggle.btn-default {
+ background-image: none;
+}
+.btn-default.disabled,
+.btn-default[disabled],
+fieldset[disabled] .btn-default,
+.btn-default.disabled:hover,
+.btn-default[disabled]:hover,
+fieldset[disabled] .btn-default:hover,
+.btn-default.disabled:focus,
+.btn-default[disabled]:focus,
+fieldset[disabled] .btn-default:focus,
+.btn-default.disabled:active,
+.btn-default[disabled]:active,
+fieldset[disabled] .btn-default:active,
+.btn-default.disabled.active,
+.btn-default[disabled].active,
+fieldset[disabled] .btn-default.active {
+ background-color: #ffffff;
+ border-color: #cccccc;
+}
+.btn-default .badge {
+ color: #ffffff;
+ background-color: #333333;
+}
+.btn-primary {
+ color: #ffffff;
+ background-color: #428bca;
+ border-color: #357ebd;
+}
+.btn-primary:hover,
+.btn-primary:focus,
+.btn-primary:active,
+.btn-primary.active,
+.open > .dropdown-toggle.btn-primary {
+ color: #ffffff;
+ background-color: #3071a9;
+ border-color: #285e8e;
+}
+.btn-primary:active,
+.btn-primary.active,
+.open > .dropdown-toggle.btn-primary {
+ background-image: none;
+}
+.btn-primary.disabled,
+.btn-primary[disabled],
+fieldset[disabled] .btn-primary,
+.btn-primary.disabled:hover,
+.btn-primary[disabled]:hover,
+fieldset[disabled] .btn-primary:hover,
+.btn-primary.disabled:focus,
+.btn-primary[disabled]:focus,
+fieldset[disabled] .btn-primary:focus,
+.btn-primary.disabled:active,
+.btn-primary[disabled]:active,
+fieldset[disabled] .btn-primary:active,
+.btn-primary.disabled.active,
+.btn-primary[disabled].active,
+fieldset[disabled] .btn-primary.active {
+ background-color: #428bca;
+ border-color: #357ebd;
+}
+.btn-primary .badge {
+ color: #428bca;
+ background-color: #ffffff;
+}
+.btn-success {
+ color: #ffffff;
+ background-color: #2ecc71;
+ border-color: #29b765;
+}
+.btn-success:hover,
+.btn-success:focus,
+.btn-success:active,
+.btn-success.active,
+.open > .dropdown-toggle.btn-success {
+ color: #ffffff;
+ background-color: #25a25a;
+ border-color: #1e854a;
+}
+.btn-success:active,
+.btn-success.active,
+.open > .dropdown-toggle.btn-success {
+ background-image: none;
+}
+.btn-success.disabled,
+.btn-success[disabled],
+fieldset[disabled] .btn-success,
+.btn-success.disabled:hover,
+.btn-success[disabled]:hover,
+fieldset[disabled] .btn-success:hover,
+.btn-success.disabled:focus,
+.btn-success[disabled]:focus,
+fieldset[disabled] .btn-success:focus,
+.btn-success.disabled:active,
+.btn-success[disabled]:active,
+fieldset[disabled] .btn-success:active,
+.btn-success.disabled.active,
+.btn-success[disabled].active,
+fieldset[disabled] .btn-success.active {
+ background-color: #2ecc71;
+ border-color: #29b765;
+}
+.btn-success .badge {
+ color: #2ecc71;
+ background-color: #ffffff;
+}
+.btn-info {
+ color: #ffffff;
+ background-color: #3498db;
+ border-color: #258cd1;
+}
+.btn-info:hover,
+.btn-info:focus,
+.btn-info:active,
+.btn-info.active,
+.open > .dropdown-toggle.btn-info {
+ color: #ffffff;
+ background-color: #217dbb;
+ border-color: #1c699d;
+}
+.btn-info:active,
+.btn-info.active,
+.open > .dropdown-toggle.btn-info {
+ background-image: none;
+}
+.btn-info.disabled,
+.btn-info[disabled],
+fieldset[disabled] .btn-info,
+.btn-info.disabled:hover,
+.btn-info[disabled]:hover,
+fieldset[disabled] .btn-info:hover,
+.btn-info.disabled:focus,
+.btn-info[disabled]:focus,
+fieldset[disabled] .btn-info:focus,
+.btn-info.disabled:active,
+.btn-info[disabled]:active,
+fieldset[disabled] .btn-info:active,
+.btn-info.disabled.active,
+.btn-info[disabled].active,
+fieldset[disabled] .btn-info.active {
+ background-color: #3498db;
+ border-color: #258cd1;
+}
+.btn-info .badge {
+ color: #3498db;
+ background-color: #ffffff;
+}
+.btn-warning {
+ color: #ffffff;
+ background-color: #f1c40f;
+ border-color: #dab10d;
+}
+.btn-warning:hover,
+.btn-warning:focus,
+.btn-warning:active,
+.btn-warning.active,
+.open > .dropdown-toggle.btn-warning {
+ color: #ffffff;
+ background-color: #c29d0b;
+ border-color: #a08209;
+}
+.btn-warning:active,
+.btn-warning.active,
+.open > .dropdown-toggle.btn-warning {
+ background-image: none;
+}
+.btn-warning.disabled,
+.btn-warning[disabled],
+fieldset[disabled] .btn-warning,
+.btn-warning.disabled:hover,
+.btn-warning[disabled]:hover,
+fieldset[disabled] .btn-warning:hover,
+.btn-warning.disabled:focus,
+.btn-warning[disabled]:focus,
+fieldset[disabled] .btn-warning:focus,
+.btn-warning.disabled:active,
+.btn-warning[disabled]:active,
+fieldset[disabled] .btn-warning:active,
+.btn-warning.disabled.active,
+.btn-warning[disabled].active,
+fieldset[disabled] .btn-warning.active {
+ background-color: #f1c40f;
+ border-color: #dab10d;
+}
+.btn-warning .badge {
+ color: #f1c40f;
+ background-color: #ffffff;
+}
+.btn-danger {
+ color: #ffffff;
+ background-color: #e74c3c;
+ border-color: #e43725;
+}
+.btn-danger:hover,
+.btn-danger:focus,
+.btn-danger:active,
+.btn-danger.active,
+.open > .dropdown-toggle.btn-danger {
+ color: #ffffff;
+ background-color: #d62c1a;
+ border-color: #b62516;
+}
+.btn-danger:active,
+.btn-danger.active,
+.open > .dropdown-toggle.btn-danger {
+ background-image: none;
+}
+.btn-danger.disabled,
+.btn-danger[disabled],
+fieldset[disabled] .btn-danger,
+.btn-danger.disabled:hover,
+.btn-danger[disabled]:hover,
+fieldset[disabled] .btn-danger:hover,
+.btn-danger.disabled:focus,
+.btn-danger[disabled]:focus,
+fieldset[disabled] .btn-danger:focus,
+.btn-danger.disabled:active,
+.btn-danger[disabled]:active,
+fieldset[disabled] .btn-danger:active,
+.btn-danger.disabled.active,
+.btn-danger[disabled].active,
+fieldset[disabled] .btn-danger.active {
+ background-color: #e74c3c;
+ border-color: #e43725;
+}
+.btn-danger .badge {
+ color: #e74c3c;
+ background-color: #ffffff;
+}
+.btn-link {
+ color: #428bca;
+ font-weight: normal;
+ cursor: pointer;
+ border-radius: 0;
+}
+.btn-link,
+.btn-link:active,
+.btn-link[disabled],
+fieldset[disabled] .btn-link {
+ background-color: transparent;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+}
+.btn-link,
+.btn-link:hover,
+.btn-link:focus,
+.btn-link:active {
+ border-color: transparent;
+}
+.btn-link:hover,
+.btn-link:focus {
+ color: #2a6496;
+ text-decoration: underline;
+ background-color: transparent;
+}
+.btn-link[disabled]:hover,
+fieldset[disabled] .btn-link:hover,
+.btn-link[disabled]:focus,
+fieldset[disabled] .btn-link:focus {
+ color: #777777;
+ text-decoration: none;
+}
+.btn-lg {
+ padding: 10px 16px;
+ font-size: 20px;
+ line-height: 1.33;
+ border-radius: 0px;
+}
+.btn-sm {
+ padding: 5px 10px;
+ font-size: 14px;
+ line-height: 1.5;
+ border-radius: 0px;
+}
+.btn-xs {
+ padding: 1px 5px;
+ font-size: 14px;
+ line-height: 1.5;
+ border-radius: 0px;
+}
+.btn-block {
+ display: block;
+ width: 100%;
+}
+.btn-block + .btn-block {
+ margin-top: 5px;
+}
+input[type="submit"].btn-block,
+input[type="reset"].btn-block,
+input[type="button"].btn-block {
+ width: 100%;
+}
+.modal-open {
+ overflow: hidden;
+}
+.modal {
+ display: none;
+ overflow: hidden;
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1050;
+ -webkit-overflow-scrolling: touch;
+ outline: 0;
+}
+.modal.fade .modal-dialog {
+ -webkit-transform: translate3d(0, -25%, 0);
+ transform: translate3d(0, -25%, 0);
+ -webkit-transition: -webkit-transform 0.3s ease-out;
+ -moz-transition: -moz-transform 0.3s ease-out;
+ -o-transition: -o-transform 0.3s ease-out;
+ transition: transform 0.3s ease-out;
+}
+.modal.in .modal-dialog {
+ -webkit-transform: translate3d(0, 0, 0);
+ transform: translate3d(0, 0, 0);
+}
+.modal-open .modal {
+ overflow-x: hidden;
+ overflow-y: auto;
+}
+.modal-dialog {
+ position: relative;
+ width: auto;
+ margin: 10px;
+}
+.modal-content {
+ position: relative;
+ background-color: #ffffff;
+ border: 1px solid #999999;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ border-radius: 0px;
+ -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+ box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+ background-clip: padding-box;
+ outline: 0;
+}
+.modal-backdrop {
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1040;
+ background-color: #000000;
+}
+.modal-backdrop.fade {
+ opacity: 0;
+ filter: alpha(opacity=0);
+}
+.modal-backdrop.in {
+ opacity: 0.5;
+ filter: alpha(opacity=50);
+}
+.modal-header {
+ padding: 15px;
+ border-bottom: 1px solid #e5e5e5;
+ min-height: 16.42857143px;
+}
+.modal-header .close {
+ margin-top: -2px;
+}
+.modal-title {
+ margin: 0;
+ line-height: 1.42857143;
+}
+.modal-body {
+ position: relative;
+ padding: 15px;
+}
+.modal-footer {
+ padding: 15px;
+ text-align: right;
+ border-top: 1px solid #e5e5e5;
+}
+.modal-footer .btn + .btn {
+ margin-left: 5px;
+ margin-bottom: 0;
+}
+.modal-footer .btn-group .btn + .btn {
+ margin-left: -1px;
+}
+.modal-footer .btn-block + .btn-block {
+ margin-left: 0;
+}
+.modal-scrollbar-measure {
+ position: absolute;
+ top: -9999px;
+ width: 50px;
+ height: 50px;
+ overflow: scroll;
+}
+@media (min-width: 768px) {
+ .modal-dialog {
+ width: 600px;
+ margin: 30px auto;
+ }
+ .modal-content {
+ -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
+ }
+ .modal-sm {
+ width: 300px;
+ }
+}
+@media (min-width: 992px) {
+ .modal-lg {
+ width: 900px;
+ }
+}
+.close {
+ float: right;
+ font-size: 24px;
+ font-weight: bold;
+ line-height: 1;
+ color: #000000;
+ text-shadow: 0 1px 0 #ffffff;
+ opacity: 0.2;
+ filter: alpha(opacity=20);
+}
+.close:hover,
+.close:focus {
+ color: #000000;
+ text-decoration: none;
+ cursor: pointer;
+ opacity: 0.5;
+ filter: alpha(opacity=50);
+}
+button.close {
+ padding: 0;
+ cursor: pointer;
+ background: transparent;
+ border: 0;
+ -webkit-appearance: none;
+}
+.alert {
+ padding: 15px;
+ margin-bottom: 22px;
+ border: 1px solid transparent;
+ border-radius: 0px;
+}
+.alert h4 {
+ margin-top: 0;
+ color: inherit;
+}
+.alert .alert-link {
+ font-weight: bold;
+}
+.alert > p,
+.alert > ul {
+ margin-bottom: 0;
+}
+.alert > p + p {
+ margin-top: 5px;
+}
+.alert-dismissable,
+.alert-dismissible {
+ padding-right: 35px;
+}
+.alert-dismissable .close,
+.alert-dismissible .close {
+ position: relative;
+ top: -2px;
+ right: -21px;
+ color: inherit;
+}
+.alert-success {
+ background-color: #2ecc71;
+ border-color: #29b74e;
+ color: #3c763d;
+}
+.alert-success hr {
+ border-top-color: #25a245;
+}
+.alert-success .alert-link {
+ color: #2b542c;
+}
+.alert-info {
+ background-color: #3498db;
+ border-color: #23a1c8;
+ color: #31708f;
+}
+.alert-info hr {
+ border-top-color: #2090b2;
+}
+.alert-info .alert-link {
+ color: #245269;
+}
+.alert-warning {
+ background-color: #f1c40f;
+ border-color: #da8f0d;
+ color: #8a6d3b;
+}
+.alert-warning hr {
+ border-top-color: #c27f0b;
+}
+.alert-warning .alert-link {
+ color: #66512c;
+}
+.alert-danger {
+ background-color: #e74c3c;
+ border-color: #e42533;
+ color: #a94442;
+}
+.alert-danger hr {
+ border-top-color: #d61a28;
+}
+.alert-danger .alert-link {
+ color: #843534;
+}
+.upload-group {
+ padding: 3px 5px;
+}
+.upload-group:before,
+.upload-group:after {
+ content: " ";
+ display: table;
+}
+.upload-group:after {
+ clear: both;
+}
+.upload-group small {
+ display: block;
+ margin-top: 3px;
+}
+.upload-group .btn {
+ display: block;
+ float: left;
+ margin-right: 5px;
+}
diff --git a/CkEditorSample/FileBrowser/css/style.min.css b/CkEditorSample/FileBrowser/css/style.min.css
new file mode 100644
index 0000000..e8ec3a3
--- /dev/null
+++ b/CkEditorSample/FileBrowser/css/style.min.css
@@ -0,0 +1 @@
+@font-face{font-family:"WeblySleek UI Light";src:url("/fonts/weblysleekuil.eot?") format("eot"),url("/fonts/weblysleekuil.woff") format("woff"),url("/fonts/weblysleekuil.ttf") format("truetype"),url("/fonts/weblysleekuil.svg#WeblySleekUILight") format("svg");font-weight:normal;font-style:normal}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"WeblySleek UI Light","Segoe UI","Segoe WP","Helvetica Neue",sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.img-responsive{display:block;width:100% \9;max-width:100%;height:auto}.img-rounded{border-radius:0}.img-thumbnail{padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:0;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;display:inline-block;width:100% \9;max-width:100%;height:auto}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"WeblySleek UI Light","Helvetica Neue","Segoe UI","Segoe WP",sans-serif;font-weight:100;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#777}h1,.h1,h2,.h2,h3,.h3{margin-top:20px;margin-bottom:10px}h1 small,.h1 small,h2 small,.h2 small,h3 small,.h3 small,h1 .small,.h1 .small,h2 .small,.h2 .small,h3 .small,.h3 .small{font-size:65%}h4,.h4,h5,.h5,h6,.h6{margin-top:10px;margin-bottom:10px}h4 small,.h4 small,h5 small,.h5 small,h6 small,.h6 small,h4 .small,.h4 .small,h5 .small,.h5 .small,h6 .small,.h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:300;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}cite{font-style:normal}mark,.mark{background-color:#f1c40f;padding:.2em}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#428bca}a.text-primary:hover{color:#3071a9}.text-success{color:#3c763d}a.text-success:hover{color:#2b542c}.text-info{color:#31708f}a.text-info:hover{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:hover{color:#66512c}.text-danger{color:#a94442}a.text-danger:hover{color:#843534}.bg-primary{color:#fff;background-color:#428bca}a.bg-primary:hover{background-color:#3071a9}.bg-success{background-color:#2ecc71}a.bg-success:hover{background-color:#25a25a}.bg-info{background-color:#3498db}a.bg-info:hover{background-color:#217dbb}.bg-warning{background-color:#f1c40f}a.bg-warning:hover{background-color:#c29d0b}.bg-danger{background-color:#e74c3c}a.bg-danger:hover{background-color:#d62c1a}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none;margin-left:-5px}.list-inline>li{display:inline-block;padding-left:5px;padding-right:5px}dl{margin-top:0;margin-bottom:20px}dt,dd{line-height:1.42857143}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;clear:left;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote p:last-child,blockquote ul:last-child,blockquote ol:last-child{margin-bottom:0}blockquote footer,blockquote small,blockquote .small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote footer:before,blockquote small:before,blockquote .small:before{content:'— '}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0;text-align:right}.blockquote-reverse footer:before,blockquote.pull-right footer:before,.blockquote-reverse small:before,blockquote.pull-right small:before,.blockquote-reverse .small:before,blockquote.pull-right .small:before{content:''}.blockquote-reverse footer:after,blockquote.pull-right footer:after,.blockquote-reverse small:after,blockquote.pull-right small:after,.blockquote-reverse .small:after,blockquote.pull-right .small:after{content:' —'}blockquote:before,blockquote:after{content:""}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}.btn{display:inline-block;margin-bottom:0;font-weight:normal;text-align:center;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;white-space:nowrap;padding:6px 12px;font-size:14px;line-height:1.42857143;border-radius:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.btn:focus,.btn:active:focus,.btn.active:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{outline:0;background-image:none;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{cursor:not-allowed;pointer-events:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default:active,.btn-default.active,.open>.dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#333}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open>.dropdown-toggle.btn-primary{color:#fff;background-color:#3071a9;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open>.dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-primary .badge{color:#428bca;background-color:#fff}.btn-success{color:#fff;background-color:#2ecc71;border-color:#29b765}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open>.dropdown-toggle.btn-success{color:#fff;background-color:#25a25a;border-color:#1e854a}.btn-success:active,.btn-success.active,.open>.dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#2ecc71;border-color:#29b765}.btn-success .badge{color:#2ecc71;background-color:#fff}.btn-info{color:#fff;background-color:#3498db;border-color:#258cd1}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#217dbb;border-color:#1c699d}.btn-info:active,.btn-info.active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#3498db;border-color:#258cd1}.btn-info .badge{color:#3498db;background-color:#fff}.btn-warning{color:#fff;background-color:#f1c40f;border-color:#dab10d}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open>.dropdown-toggle.btn-warning{color:#fff;background-color:#c29d0b;border-color:#a08209}.btn-warning:active,.btn-warning.active,.open>.dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f1c40f;border-color:#dab10d}.btn-warning .badge{color:#f1c40f;background-color:#fff}.btn-danger{color:#fff;background-color:#e74c3c;border-color:#e43725}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open>.dropdown-toggle.btn-danger{color:#fff;background-color:#d62c1a;border-color:#b62516}.btn-danger:active,.btn-danger.active,.open>.dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#e74c3c;border-color:#e43725}.btn-danger .badge{color:#e74c3c;background-color:#fff}.btn-link{color:#428bca;font-weight:normal;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#777;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:0}.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:0}.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:0}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.modal-open{overflow:hidden}.modal{display:none;overflow:hidden;position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transform:translate3d(0,-25%,0);transform:translate3d(0,-25%,0);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,.2);border-radius:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5);background-clip:padding-box;outline:0}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5;min-height:16.42857143px}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer .btn+.btn{margin-left:5px;margin-bottom:0}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media(min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);box-shadow:0 5px 15px rgba(0,0,0,.5)}.modal-sm{width:300px}}@media(min-width:992px){.modal-lg{width:900px}}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:0}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{background-color:#2ecc71;border-color:#29b74e;color:#3c763d}.alert-success hr{border-top-color:#25a245}.alert-success .alert-link{color:#2b542c}.alert-info{background-color:#3498db;border-color:#23a1c8;color:#31708f}.alert-info hr{border-top-color:#2090b2}.alert-info .alert-link{color:#245269}.alert-warning{background-color:#f1c40f;border-color:#da8f0d;color:#8a6d3b}.alert-warning hr{border-top-color:#c27f0b}.alert-warning .alert-link{color:#66512c}.alert-danger{background-color:#e74c3c;border-color:#e42533;color:#a94442}.alert-danger hr{border-top-color:#d61a28}.alert-danger .alert-link{color:#843534}.upload-group{padding:3px 5px}.upload-group:before,.upload-group:after{content:" ";display:table}.upload-group:after{clear:both}.upload-group small{display:block;margin-top:3px}.upload-group .btn{display:block;float:left;margin-right:5px}
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/img/16/camera.png b/CkEditorSample/FileBrowser/img/16/camera.png
new file mode 100644
index 0000000..93b5560
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/camera.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-bookmark.png b/CkEditorSample/FileBrowser/img/16/file-bookmark.png
new file mode 100644
index 0000000..757d95a
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-bookmark.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-code.png b/CkEditorSample/FileBrowser/img/16/file-code.png
new file mode 100644
index 0000000..fb161cd
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-code.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-empty.png b/CkEditorSample/FileBrowser/img/16/file-empty.png
new file mode 100644
index 0000000..f2f3782
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-empty.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-excel-alt.png b/CkEditorSample/FileBrowser/img/16/file-excel-alt.png
new file mode 100644
index 0000000..4956666
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-excel-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-excel.png b/CkEditorSample/FileBrowser/img/16/file-excel.png
new file mode 100644
index 0000000..8482da1
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-excel.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-exe.png b/CkEditorSample/FileBrowser/img/16/file-exe.png
new file mode 100644
index 0000000..2585f3c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-exe.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-font.png b/CkEditorSample/FileBrowser/img/16/file-font.png
new file mode 100644
index 0000000..27c6bb4
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-font.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-illustrator.png b/CkEditorSample/FileBrowser/img/16/file-illustrator.png
new file mode 100644
index 0000000..e74be5c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-illustrator.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-indesign.png b/CkEditorSample/FileBrowser/img/16/file-indesign.png
new file mode 100644
index 0000000..07d3eac
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-indesign.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-link.png b/CkEditorSample/FileBrowser/img/16/file-link.png
new file mode 100644
index 0000000..abca4ee
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-link.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-note.png b/CkEditorSample/FileBrowser/img/16/file-note.png
new file mode 100644
index 0000000..fa2d291
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-note.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-pdf-alt.png b/CkEditorSample/FileBrowser/img/16/file-pdf-alt.png
new file mode 100644
index 0000000..833185f
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-pdf-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-pdf.png b/CkEditorSample/FileBrowser/img/16/file-pdf.png
new file mode 100644
index 0000000..059e10c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-pdf.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-photoshop.png b/CkEditorSample/FileBrowser/img/16/file-photoshop.png
new file mode 100644
index 0000000..a139df9
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-photoshop.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-picture.png b/CkEditorSample/FileBrowser/img/16/file-picture.png
new file mode 100644
index 0000000..c268e8c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-picture.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-powerpoint-alt.png b/CkEditorSample/FileBrowser/img/16/file-powerpoint-alt.png
new file mode 100644
index 0000000..278e73e
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-powerpoint-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-powerpoint.png b/CkEditorSample/FileBrowser/img/16/file-powerpoint.png
new file mode 100644
index 0000000..546d4fc
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-powerpoint.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-premiere.png b/CkEditorSample/FileBrowser/img/16/file-premiere.png
new file mode 100644
index 0000000..07e77a7
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-premiere.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-sound.png b/CkEditorSample/FileBrowser/img/16/file-sound.png
new file mode 100644
index 0000000..1b2086a
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-sound.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-text.png b/CkEditorSample/FileBrowser/img/16/file-text.png
new file mode 100644
index 0000000..096be26
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-text.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-video.png b/CkEditorSample/FileBrowser/img/16/file-video.png
new file mode 100644
index 0000000..cfdccf4
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-video.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-word-alt.png b/CkEditorSample/FileBrowser/img/16/file-word-alt.png
new file mode 100644
index 0000000..68c1471
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-word-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-word.png b/CkEditorSample/FileBrowser/img/16/file-word.png
new file mode 100644
index 0000000..6a476ff
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-word.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-zip-alt.png b/CkEditorSample/FileBrowser/img/16/file-zip-alt.png
new file mode 100644
index 0000000..609ec7b
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-zip-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/file-zip.png b/CkEditorSample/FileBrowser/img/16/file-zip.png
new file mode 100644
index 0000000..959b043
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/file-zip.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-document-alt.png b/CkEditorSample/FileBrowser/img/16/folder-document-alt.png
new file mode 100644
index 0000000..1d2a56b
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-document-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-document.png b/CkEditorSample/FileBrowser/img/16/folder-document.png
new file mode 100644
index 0000000..5b48b63
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-document.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-flash.png b/CkEditorSample/FileBrowser/img/16/folder-flash.png
new file mode 100644
index 0000000..6d2fa69
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-flash.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-house-alt.png b/CkEditorSample/FileBrowser/img/16/folder-house-alt.png
new file mode 100644
index 0000000..94c7761
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-house-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-house.png b/CkEditorSample/FileBrowser/img/16/folder-house.png
new file mode 100644
index 0000000..16e98a6
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-house.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-music.png b/CkEditorSample/FileBrowser/img/16/folder-music.png
new file mode 100644
index 0000000..6d7739f
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-music.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-picture-alt.png b/CkEditorSample/FileBrowser/img/16/folder-picture-alt.png
new file mode 100644
index 0000000..94668a7
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-picture-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-picture.png b/CkEditorSample/FileBrowser/img/16/folder-picture.png
new file mode 100644
index 0000000..03f3428
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-picture.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-video-alt.png b/CkEditorSample/FileBrowser/img/16/folder-video-alt.png
new file mode 100644
index 0000000..b5ad09c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-video-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder-video.png b/CkEditorSample/FileBrowser/img/16/folder-video.png
new file mode 100644
index 0000000..8a7e453
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder-video.png differ
diff --git a/CkEditorSample/FileBrowser/img/16/folder.png b/CkEditorSample/FileBrowser/img/16/folder.png
new file mode 100644
index 0000000..83343ab
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/16/folder.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/camera.png b/CkEditorSample/FileBrowser/img/32/camera.png
new file mode 100644
index 0000000..e8ffefd
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/camera.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-bookmark.png b/CkEditorSample/FileBrowser/img/32/file-bookmark.png
new file mode 100644
index 0000000..f9fa707
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-bookmark.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-code.png b/CkEditorSample/FileBrowser/img/32/file-code.png
new file mode 100644
index 0000000..3cf5aa0
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-code.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-empty.png b/CkEditorSample/FileBrowser/img/32/file-empty.png
new file mode 100644
index 0000000..ad91f24
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-empty.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-excel-alt.png b/CkEditorSample/FileBrowser/img/32/file-excel-alt.png
new file mode 100644
index 0000000..08235c2
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-excel-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-excel.png b/CkEditorSample/FileBrowser/img/32/file-excel.png
new file mode 100644
index 0000000..4dc46fa
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-excel.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-exe.png b/CkEditorSample/FileBrowser/img/32/file-exe.png
new file mode 100644
index 0000000..987daa4
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-exe.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-font.png b/CkEditorSample/FileBrowser/img/32/file-font.png
new file mode 100644
index 0000000..41269eb
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-font.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-illustrator.png b/CkEditorSample/FileBrowser/img/32/file-illustrator.png
new file mode 100644
index 0000000..794ca1b
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-illustrator.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-indesign.png b/CkEditorSample/FileBrowser/img/32/file-indesign.png
new file mode 100644
index 0000000..f54b8eb
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-indesign.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-link.png b/CkEditorSample/FileBrowser/img/32/file-link.png
new file mode 100644
index 0000000..28b4f6c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-link.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-note.png b/CkEditorSample/FileBrowser/img/32/file-note.png
new file mode 100644
index 0000000..c073ee8
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-note.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-pdf-alt.png b/CkEditorSample/FileBrowser/img/32/file-pdf-alt.png
new file mode 100644
index 0000000..c5ae639
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-pdf-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-pdf.png b/CkEditorSample/FileBrowser/img/32/file-pdf.png
new file mode 100644
index 0000000..a3818df
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-pdf.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-photoshop.png b/CkEditorSample/FileBrowser/img/32/file-photoshop.png
new file mode 100644
index 0000000..11240de
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-photoshop.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-picture.png b/CkEditorSample/FileBrowser/img/32/file-picture.png
new file mode 100644
index 0000000..b98f895
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-picture.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-powerpoint-alt.png b/CkEditorSample/FileBrowser/img/32/file-powerpoint-alt.png
new file mode 100644
index 0000000..9e7b735
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-powerpoint-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-powerpoint.png b/CkEditorSample/FileBrowser/img/32/file-powerpoint.png
new file mode 100644
index 0000000..3bb3476
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-powerpoint.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-premiere.png b/CkEditorSample/FileBrowser/img/32/file-premiere.png
new file mode 100644
index 0000000..36f9a1c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-premiere.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-sound.png b/CkEditorSample/FileBrowser/img/32/file-sound.png
new file mode 100644
index 0000000..e4aee1f
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-sound.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-text.png b/CkEditorSample/FileBrowser/img/32/file-text.png
new file mode 100644
index 0000000..585aaa2
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-text.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-video.png b/CkEditorSample/FileBrowser/img/32/file-video.png
new file mode 100644
index 0000000..9631327
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-video.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-word-alt.png b/CkEditorSample/FileBrowser/img/32/file-word-alt.png
new file mode 100644
index 0000000..0063d8d
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-word-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-word.png b/CkEditorSample/FileBrowser/img/32/file-word.png
new file mode 100644
index 0000000..4adcc77
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-word.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-zip-alt.png b/CkEditorSample/FileBrowser/img/32/file-zip-alt.png
new file mode 100644
index 0000000..8936f50
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-zip-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/file-zip.png b/CkEditorSample/FileBrowser/img/32/file-zip.png
new file mode 100644
index 0000000..d950038
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/file-zip.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-document-alt.png b/CkEditorSample/FileBrowser/img/32/folder-document-alt.png
new file mode 100644
index 0000000..f08fb6e
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-document-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-document.png b/CkEditorSample/FileBrowser/img/32/folder-document.png
new file mode 100644
index 0000000..885cb80
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-document.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-flash.png b/CkEditorSample/FileBrowser/img/32/folder-flash.png
new file mode 100644
index 0000000..ec8c78c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-flash.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-house-alt.png b/CkEditorSample/FileBrowser/img/32/folder-house-alt.png
new file mode 100644
index 0000000..05ea29c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-house-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-house.png b/CkEditorSample/FileBrowser/img/32/folder-house.png
new file mode 100644
index 0000000..2b6b96e
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-house.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-music.png b/CkEditorSample/FileBrowser/img/32/folder-music.png
new file mode 100644
index 0000000..30f4e55
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-music.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-picture-alt.png b/CkEditorSample/FileBrowser/img/32/folder-picture-alt.png
new file mode 100644
index 0000000..994e54a
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-picture-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-picture.png b/CkEditorSample/FileBrowser/img/32/folder-picture.png
new file mode 100644
index 0000000..1538f05
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-picture.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-video-alt.png b/CkEditorSample/FileBrowser/img/32/folder-video-alt.png
new file mode 100644
index 0000000..27555ef
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-video-alt.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder-video.png b/CkEditorSample/FileBrowser/img/32/folder-video.png
new file mode 100644
index 0000000..e06de2e
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder-video.png differ
diff --git a/CkEditorSample/FileBrowser/img/32/folder.png b/CkEditorSample/FileBrowser/img/32/folder.png
new file mode 100644
index 0000000..5c0f46c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/32/folder.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Copy.png b/CkEditorSample/FileBrowser/img/cmd/Copy.png
new file mode 100644
index 0000000..67b6783
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Copy.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Delete.png b/CkEditorSample/FileBrowser/img/cmd/Delete.png
new file mode 100644
index 0000000..1e07bd3
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Delete.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/FileLarge.png b/CkEditorSample/FileBrowser/img/cmd/FileLarge.png
new file mode 100644
index 0000000..ad91f24
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/FileLarge.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/FileSmall.png b/CkEditorSample/FileBrowser/img/cmd/FileSmall.png
new file mode 100644
index 0000000..f2f3782
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/FileSmall.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/FolderLarge.png b/CkEditorSample/FileBrowser/img/cmd/FolderLarge.png
new file mode 100644
index 0000000..5c0f46c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/FolderLarge.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/FolderSmall.png b/CkEditorSample/FileBrowser/img/cmd/FolderSmall.png
new file mode 100644
index 0000000..83343ab
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/FolderSmall.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/FolderUp.png b/CkEditorSample/FileBrowser/img/cmd/FolderUp.png
new file mode 100644
index 0000000..b11f347
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/FolderUp.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Move.png b/CkEditorSample/FileBrowser/img/cmd/Move.png
new file mode 100644
index 0000000..1ba0faf
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Move.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/NewFolder.png b/CkEditorSample/FileBrowser/img/cmd/NewFolder.png
new file mode 100644
index 0000000..b123a50
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/NewFolder.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Process.gif b/CkEditorSample/FileBrowser/img/cmd/Process.gif
new file mode 100644
index 0000000..085ccae
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Process.gif differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Refresh.png b/CkEditorSample/FileBrowser/img/cmd/Refresh.png
new file mode 100644
index 0000000..8adcdab
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Refresh.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Rename.png b/CkEditorSample/FileBrowser/img/cmd/Rename.png
new file mode 100644
index 0000000..2c03d10
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Rename.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/RootFolderLarge.png b/CkEditorSample/FileBrowser/img/cmd/RootFolderLarge.png
new file mode 100644
index 0000000..05ea29c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/RootFolderLarge.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/RootFolderSmall.png b/CkEditorSample/FileBrowser/img/cmd/RootFolderSmall.png
new file mode 100644
index 0000000..94c7761
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/RootFolderSmall.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/Show.png b/CkEditorSample/FileBrowser/img/cmd/Show.png
new file mode 100644
index 0000000..00f3889
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/Show.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/View.png b/CkEditorSample/FileBrowser/img/cmd/View.png
new file mode 100644
index 0000000..5c3f411
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/View.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/_View.png b/CkEditorSample/FileBrowser/img/cmd/_View.png
new file mode 100644
index 0000000..7f53740
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/_View.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/box-out.png b/CkEditorSample/FileBrowser/img/cmd/box-out.png
new file mode 100644
index 0000000..a60ba0c
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/box-out.png differ
diff --git a/CkEditorSample/FileBrowser/img/cmd/cloud-up.png b/CkEditorSample/FileBrowser/img/cmd/cloud-up.png
new file mode 100644
index 0000000..0eb9f97
Binary files /dev/null and b/CkEditorSample/FileBrowser/img/cmd/cloud-up.png differ
diff --git a/CkEditorSample/FileBrowser/js/FileManager.js b/CkEditorSample/FileBrowser/js/FileManager.js
new file mode 100644
index 0000000..3c833fb
--- /dev/null
+++ b/CkEditorSample/FileBrowser/js/FileManager.js
@@ -0,0 +1,13175 @@
+///#source 1 1 /Scripts/plugins/spin/spin.js
+/**
+ * Copyright (c) 2011-2014 Felix Gnass
+ * Licensed under the MIT license
+ */
+(function(root, factory) {
+
+ /* CommonJS */
+ if (typeof exports == 'object') module.exports = factory()
+
+ /* AMD module */
+ else if (typeof define == 'function' && define.amd) define(factory)
+
+ /* Browser global */
+ else root.Spinner = factory()
+}
+(this, function() {
+ "use strict";
+
+ var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
+ , animations = {} /* Animation rules keyed by their name */
+ , useCssAnimations /* Whether to use CSS animations or setTimeout */
+
+ /**
+ * Utility function to create elements. If no tag name is given,
+ * a DIV is created. Optionally properties can be passed.
+ */
+ function createEl(tag, prop) {
+ var el = document.createElement(tag || 'div')
+ , n
+
+ for(n in prop) el[n] = prop[n]
+ return el
+ }
+
+ /**
+ * Appends children and returns the parent.
+ */
+ function ins(parent /* child1, child2, ...*/) {
+ for (var i=1, n=arguments.length; i>1) + 'px'
+ })
+ }
+
+ for (; i < o.lines; i++) {
+ seg = css(createEl(), {
+ position: 'absolute',
+ top: 1+~(o.width/2) + 'px',
+ transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
+ opacity: o.opacity,
+ animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
+ })
+
+ if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
+ ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
+ }
+ return el
+ },
+
+ /**
+ * Internal method that adjusts the opacity of a single line.
+ * Will be overwritten in VML fallback mode below.
+ */
+ opacity: function(el, i, val) {
+ if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
+ }
+
+ })
+
+
+ function initVML() {
+
+ /* Utility function to create a VML tag */
+ function vml(tag, attr) {
+ return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
+ }
+
+ // No CSS transforms but VML support, add a CSS rule for VML elements:
+ sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
+
+ Spinner.prototype.lines = function(el, o) {
+ var r = o.length+o.width
+ , s = 2*r
+
+ function grp() {
+ return css(
+ vml('group', {
+ coordsize: s + ' ' + s,
+ coordorigin: -r + ' ' + -r
+ }),
+ { width: s, height: s }
+ )
+ }
+
+ var margin = -(o.width+o.length)*2 + 'px'
+ , g = css(grp(), {position: 'absolute', top: margin, left: margin})
+ , i
+
+ function seg(i, dx, filter) {
+ ins(g,
+ ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
+ ins(css(vml('roundrect', {arcsize: o.corners}), {
+ width: r,
+ height: o.width,
+ left: o.radius,
+ top: -o.width>>1,
+ filter: filter
+ }),
+ vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
+ vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
+ )
+ )
+ )
+ }
+
+ if (o.shadow)
+ for (i = 1; i <= o.lines; i++)
+ seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
+
+ for (i = 1; i <= o.lines; i++) seg(i)
+ return ins(el, g)
+ }
+
+ Spinner.prototype.opacity = function(el, i, val, o) {
+ var c = el.firstChild
+ o = o.shadow && o.lines || 0
+ if (c && i+o < c.childNodes.length) {
+ c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
+ if (c) c.opacity = val
+ }
+ }
+ }
+
+ var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
+
+ if (!vendor(probe, 'transform') && probe.adj) initVML()
+ else useCssAnimations = vendor(probe, 'animation')
+
+ return Spinner
+
+}));
+
+///#source 1 1 /Scripts/plugins/spin/jquery.spin.js
+/**
+ * Copyright (c) 2011-2014 Felix Gnass
+ * Licensed under the MIT license
+ */
+
+/*
+
+Basic Usage:
+============
+
+$('#el').spin(); // Creates a default Spinner using the text color of #el.
+$('#el').spin({ ... }); // Creates a Spinner using the provided options.
+
+$('#el').spin(false); // Stops and removes the spinner.
+
+Using Presets:
+==============
+
+$('#el').spin('small'); // Creates a 'small' Spinner using the text color of #el.
+$('#el').spin('large', '#fff'); // Creates a 'large' white Spinner.
+
+Adding a custom preset:
+=======================
+
+$.fn.spin.presets.flower = {
+ lines: 9,
+ length: 10,
+ width: 20,
+ radius: 0
+}
+
+$('#el').spin('flower', 'red');
+
+*/
+
+(function(factory) {
+
+ if (typeof exports == 'object') {
+ // CommonJS
+ factory(require('jquery'), require('spin'))
+ }
+ else if (typeof define == 'function' && define.amd) {
+ // AMD, register as anonymous module
+ define(['jquery', 'spin'], factory)
+ }
+ else {
+ // Browser globals
+ if (!window.Spinner) throw new Error('Spin.js not present')
+ factory(window.jQuery, window.Spinner)
+ }
+
+}(function($, Spinner) {
+
+ $.fn.spin = function(opts, color) {
+
+ return this.each(function() {
+ var $this = $(this),
+ data = $this.data();
+
+ if (data.spinner) {
+ data.spinner.stop();
+ delete data.spinner;
+ }
+ if (opts !== false) {
+ opts = $.extend(
+ { color: color || $this.css('color') },
+ $.fn.spin.presets[opts] || opts
+ )
+ data.spinner = new Spinner(opts).spin(this)
+ }
+ })
+ }
+
+ $.fn.spin.presets = {
+ tiny: { lines: 8, length: 2, width: 2, radius: 3 },
+ small: { lines: 8, length: 4, width: 3, radius: 5 },
+ large: { lines: 10, length: 8, width: 4, radius: 8 }
+ }
+
+}));
+
+///#source 1 1 /scripts/plugins/fineuploader/jquery.fineuploader.js
+/*!
+* Fine Uploader
+*
+* Copyright 2013, Widen Enterprises, Inc. info@fineuploader.com
+*
+* Version: 5.0.3
+*
+* Homepage: http://fineuploader.com
+*
+* Repository: git://github.com/Widen/fine-uploader.git
+*
+* Licensed under GNU GPL v3, see LICENSE
+*/
+
+
+/*globals window, navigator, document, FormData, File, HTMLInputElement, XMLHttpRequest, Blob, Storage, ActiveXObject */
+/* jshint -W079 */
+var qq = function(element) {
+ "use strict";
+
+ return {
+ hide: function() {
+ element.style.display = "none";
+ return this;
+ },
+
+ /** Returns the function which detaches attached event */
+ attach: function(type, fn) {
+ if (element.addEventListener){
+ element.addEventListener(type, fn, false);
+ } else if (element.attachEvent){
+ element.attachEvent("on" + type, fn);
+ }
+ return function() {
+ qq(element).detach(type, fn);
+ };
+ },
+
+ detach: function(type, fn) {
+ if (element.removeEventListener){
+ element.removeEventListener(type, fn, false);
+ } else if (element.attachEvent){
+ element.detachEvent("on" + type, fn);
+ }
+ return this;
+ },
+
+ contains: function(descendant) {
+ // The [W3C spec](http://www.w3.org/TR/domcore/#dom-node-contains)
+ // says a `null` (or ostensibly `undefined`) parameter
+ // passed into `Node.contains` should result in a false return value.
+ // IE7 throws an exception if the parameter is `undefined` though.
+ if (!descendant) {
+ return false;
+ }
+
+ // compareposition returns false in this case
+ if (element === descendant) {
+ return true;
+ }
+
+ if (element.contains){
+ return element.contains(descendant);
+ } else {
+ /*jslint bitwise: true*/
+ return !!(descendant.compareDocumentPosition(element) & 8);
+ }
+ },
+
+ /**
+ * Insert this element before elementB.
+ */
+ insertBefore: function(elementB) {
+ elementB.parentNode.insertBefore(element, elementB);
+ return this;
+ },
+
+ remove: function() {
+ element.parentNode.removeChild(element);
+ return this;
+ },
+
+ /**
+ * Sets styles for an element.
+ * Fixes opacity in IE6-8.
+ */
+ css: function(styles) {
+ /*jshint eqnull: true*/
+ if (element.style == null) {
+ throw new qq.Error("Can't apply style to node as it is not on the HTMLElement prototype chain!");
+ }
+
+ /*jshint -W116*/
+ if (styles.opacity != null){
+ if (typeof element.style.opacity !== "string" && typeof(element.filters) !== "undefined"){
+ styles.filter = "alpha(opacity=" + Math.round(100 * styles.opacity) + ")";
+ }
+ }
+ qq.extend(element.style, styles);
+
+ return this;
+ },
+
+ hasClass: function(name) {
+ var re = new RegExp("(^| )" + name + "( |$)");
+ return re.test(element.className);
+ },
+
+ addClass: function(name) {
+ if (!qq(element).hasClass(name)){
+ element.className += " " + name;
+ }
+ return this;
+ },
+
+ removeClass: function(name) {
+ var re = new RegExp("(^| )" + name + "( |$)");
+ element.className = element.className.replace(re, " ").replace(/^\s+|\s+$/g, "");
+ return this;
+ },
+
+ getByClass: function(className) {
+ var candidates,
+ result = [];
+
+ if (element.querySelectorAll){
+ return element.querySelectorAll("." + className);
+ }
+
+ candidates = element.getElementsByTagName("*");
+
+ qq.each(candidates, function(idx, val) {
+ if (qq(val).hasClass(className)){
+ result.push(val);
+ }
+ });
+ return result;
+ },
+
+ children: function() {
+ var children = [],
+ child = element.firstChild;
+
+ while (child){
+ if (child.nodeType === 1){
+ children.push(child);
+ }
+ child = child.nextSibling;
+ }
+
+ return children;
+ },
+
+ setText: function(text) {
+ element.innerText = text;
+ element.textContent = text;
+ return this;
+ },
+
+ clearText: function() {
+ return qq(element).setText("");
+ },
+
+ // Returns true if the attribute exists on the element
+ // AND the value of the attribute is NOT "false" (case-insensitive)
+ hasAttribute: function(attrName) {
+ var attrVal;
+
+ if (element.hasAttribute) {
+
+ if (!element.hasAttribute(attrName)) {
+ return false;
+ }
+
+ /*jshint -W116*/
+ return (/^false$/i).exec(element.getAttribute(attrName)) == null;
+ }
+ else {
+ attrVal = element[attrName];
+
+ if (attrVal === undefined) {
+ return false;
+ }
+
+ /*jshint -W116*/
+ return (/^false$/i).exec(attrVal) == null;
+ }
+ }
+ };
+};
+
+(function(){
+ "use strict";
+
+ qq.log = function(message, level) {
+ if (window.console) {
+ if (!level || level === "info") {
+ window.console.log(message);
+ }
+ else
+ {
+ if (window.console[level]) {
+ window.console[level](message);
+ }
+ else {
+ window.console.log("<" + level + "> " + message);
+ }
+ }
+ }
+ };
+
+ qq.isObject = function(variable) {
+ return variable && !variable.nodeType && Object.prototype.toString.call(variable) === "[object Object]";
+ };
+
+ qq.isFunction = function(variable) {
+ return typeof(variable) === "function";
+ };
+
+ /**
+ * Check the type of a value. Is it an "array"?
+ *
+ * @param value value to test.
+ * @returns true if the value is an array or associated with an `ArrayBuffer`
+ */
+ qq.isArray = function(value) {
+ return Object.prototype.toString.call(value) === "[object Array]" ||
+ (value && window.ArrayBuffer && value.buffer && value.buffer.constructor === ArrayBuffer);
+ };
+
+ // Looks for an object on a `DataTransfer` object that is associated with drop events when utilizing the Filesystem API.
+ qq.isItemList = function(maybeItemList) {
+ return Object.prototype.toString.call(maybeItemList) === "[object DataTransferItemList]";
+ };
+
+ // Looks for an object on a `NodeList` or an `HTMLCollection`|`HTMLFormElement`|`HTMLSelectElement`
+ // object that is associated with collections of Nodes.
+ qq.isNodeList = function(maybeNodeList) {
+ return Object.prototype.toString.call(maybeNodeList) === "[object NodeList]" ||
+ // If `HTMLCollection` is the actual type of the object, we must determine this
+ // by checking for expected properties/methods on the object
+ (maybeNodeList.item && maybeNodeList.namedItem);
+ };
+
+ qq.isString = function(maybeString) {
+ return Object.prototype.toString.call(maybeString) === "[object String]";
+ };
+
+ qq.trimStr = function(string) {
+ if (String.prototype.trim) {
+ return string.trim();
+ }
+
+ return string.replace(/^\s+|\s+$/g,"");
+ };
+
+
+ /**
+ * @param str String to format.
+ * @returns {string} A string, swapping argument values with the associated occurrence of {} in the passed string.
+ */
+ qq.format = function(str) {
+
+ var args = Array.prototype.slice.call(arguments, 1),
+ newStr = str,
+ nextIdxToReplace = newStr.indexOf("{}");
+
+ qq.each(args, function(idx, val) {
+ var strBefore = newStr.substring(0, nextIdxToReplace),
+ strAfter = newStr.substring(nextIdxToReplace+2);
+
+ newStr = strBefore + val + strAfter;
+ nextIdxToReplace = newStr.indexOf("{}", nextIdxToReplace + val.length);
+
+ // End the loop if we have run out of tokens (when the arguments exceed the # of tokens)
+ if (nextIdxToReplace < 0) {
+ return false;
+ }
+ });
+
+ return newStr;
+ };
+
+ qq.isFile = function(maybeFile) {
+ return window.File && Object.prototype.toString.call(maybeFile) === "[object File]";
+ };
+
+ qq.isFileList = function(maybeFileList) {
+ return window.FileList && Object.prototype.toString.call(maybeFileList) === "[object FileList]";
+ };
+
+ qq.isFileOrInput = function(maybeFileOrInput) {
+ return qq.isFile(maybeFileOrInput) || qq.isInput(maybeFileOrInput);
+ };
+
+ qq.isInput = function(maybeInput, notFile) {
+ var evaluateType = function(type) {
+ var normalizedType = type.toLowerCase();
+
+ if (notFile) {
+ return normalizedType !== "file";
+ }
+
+ return normalizedType === "file";
+ };
+
+ if (window.HTMLInputElement) {
+ if (Object.prototype.toString.call(maybeInput) === "[object HTMLInputElement]") {
+ if (maybeInput.type && evaluateType(maybeInput.type)) {
+ return true;
+ }
+ }
+ }
+ if (maybeInput.tagName) {
+ if (maybeInput.tagName.toLowerCase() === "input") {
+ if (maybeInput.type && evaluateType(maybeInput.type)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ qq.isBlob = function(maybeBlob) {
+ if (window.Blob && Object.prototype.toString.call(maybeBlob) === "[object Blob]") {
+ return true;
+ }
+ };
+
+ qq.isXhrUploadSupported = function() {
+ var input = document.createElement("input");
+ input.type = "file";
+
+ return (
+ input.multiple !== undefined &&
+ typeof File !== "undefined" &&
+ typeof FormData !== "undefined" &&
+ typeof (qq.createXhrInstance()).upload !== "undefined" );
+ };
+
+ // Fall back to ActiveX is native XHR is disabled (possible in any version of IE).
+ qq.createXhrInstance = function() {
+ if (window.XMLHttpRequest) {
+ return new XMLHttpRequest();
+ }
+
+ try {
+ return new ActiveXObject("MSXML2.XMLHTTP.3.0");
+ }
+ catch(error) {
+ qq.log("Neither XHR or ActiveX are supported!", "error");
+ return null;
+ }
+ };
+
+ qq.isFolderDropSupported = function(dataTransfer) {
+ return dataTransfer.items &&
+ dataTransfer.items.length > 0 &&
+ dataTransfer.items[0].webkitGetAsEntry;
+ };
+
+ qq.isFileChunkingSupported = function() {
+ return !qq.androidStock() && //Android's stock browser cannot upload Blobs correctly
+ qq.isXhrUploadSupported() &&
+ (File.prototype.slice !== undefined || File.prototype.webkitSlice !== undefined || File.prototype.mozSlice !== undefined);
+ };
+
+ qq.sliceBlob = function(fileOrBlob, start, end) {
+ var slicer = fileOrBlob.slice || fileOrBlob.mozSlice || fileOrBlob.webkitSlice;
+
+ return slicer.call(fileOrBlob, start, end);
+ };
+
+ qq.arrayBufferToHex = function(buffer) {
+ var bytesAsHex = "",
+ bytes = new Uint8Array(buffer);
+
+
+ qq.each(bytes, function(idx, byt) {
+ var byteAsHexStr = byt.toString(16);
+
+ if (byteAsHexStr.length < 2) {
+ byteAsHexStr = "0" + byteAsHexStr;
+ }
+
+ bytesAsHex += byteAsHexStr;
+ });
+
+ return bytesAsHex;
+ };
+
+ qq.readBlobToHex = function(blob, startOffset, length) {
+ var initialBlob = qq.sliceBlob(blob, startOffset, startOffset + length),
+ fileReader = new FileReader(),
+ promise = new qq.Promise();
+
+ fileReader.onload = function() {
+ promise.success(qq.arrayBufferToHex(fileReader.result));
+ };
+
+ fileReader.onerror = promise.failure;
+
+ fileReader.readAsArrayBuffer(initialBlob);
+
+ return promise;
+ };
+
+ qq.extend = function(first, second, extendNested) {
+ qq.each(second, function(prop, val) {
+ if (extendNested && qq.isObject(val)) {
+ if (first[prop] === undefined) {
+ first[prop] = {};
+ }
+ qq.extend(first[prop], val, true);
+ }
+ else {
+ first[prop] = val;
+ }
+ });
+
+ return first;
+ };
+
+ /**
+ * Allow properties in one object to override properties in another,
+ * keeping track of the original values from the target object.
+ *
+ * Note that the pre-overriden properties to be overriden by the source will be passed into the `sourceFn` when it is invoked.
+ *
+ * @param target Update properties in this object from some source
+ * @param sourceFn A function that, when invoked, will return properties that will replace properties with the same name in the target.
+ * @returns {object} The target object
+ */
+ qq.override = function(target, sourceFn) {
+ var super_ = {},
+ source = sourceFn(super_);
+
+ qq.each(source, function(srcPropName, srcPropVal) {
+ if (target[srcPropName] !== undefined) {
+ super_[srcPropName] = target[srcPropName];
+ }
+
+ target[srcPropName] = srcPropVal;
+ });
+
+ return target;
+ };
+
+ /**
+ * Searches for a given element in the array, returns -1 if it is not present.
+ * @param {Number} [from] The index at which to begin the search
+ */
+ qq.indexOf = function(arr, elt, from){
+ if (arr.indexOf) {
+ return arr.indexOf(elt, from);
+ }
+
+ from = from || 0;
+ var len = arr.length;
+
+ if (from < 0) {
+ from += len;
+ }
+
+ for (; from < len; from+=1){
+ if (arr.hasOwnProperty(from) && arr[from] === elt){
+ return from;
+ }
+ }
+ return -1;
+ };
+
+ //this is a version 4 UUID
+ qq.getUniqueId = function(){
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
+ /*jslint eqeq: true, bitwise: true*/
+ var r = Math.random()*16|0, v = c == "x" ? r : (r&0x3|0x8);
+ return v.toString(16);
+ });
+ };
+
+ //
+ // Browsers and platforms detection
+ qq.ie = function() {
+ return navigator.userAgent.indexOf("MSIE") !== -1;
+ };
+
+ qq.ie7 = function() {
+ return navigator.userAgent.indexOf("MSIE 7") !== -1;
+ };
+
+ qq.ie10 = function() {
+ return navigator.userAgent.indexOf("MSIE 10") !== -1;
+ };
+
+ qq.ie11 = function() {
+ return (navigator.userAgent.indexOf("Trident") !== -1 &&
+ navigator.userAgent.indexOf("rv:11") !== -1);
+ };
+
+ qq.safari = function() {
+ return navigator.vendor !== undefined && navigator.vendor.indexOf("Apple") !== -1;
+ };
+
+ qq.chrome = function() {
+ return navigator.vendor !== undefined && navigator.vendor.indexOf("Google") !== -1;
+ };
+
+ qq.opera = function() {
+ return navigator.vendor !== undefined && navigator.vendor.indexOf("Opera") !== -1;
+ };
+
+ qq.firefox = function() {
+ return (!qq.ie11() && navigator.userAgent.indexOf("Mozilla") !== -1 && navigator.vendor !== undefined && navigator.vendor === "");
+ };
+
+ qq.windows = function() {
+ return navigator.platform === "Win32";
+ };
+
+ qq.android = function() {
+ return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
+ };
+
+ // We need to identify the Android stock browser via the UA string to work around various bugs in this browser,
+ // such as the one that prevents a `Blob` from being uploaded.
+ qq.androidStock = function() {
+ return qq.android() && navigator.userAgent.toLowerCase().indexOf("chrome") < 0;
+ };
+
+ qq.ios7 = function() {
+ return qq.ios() && navigator.userAgent.indexOf(" OS 7_") !== -1;
+ };
+
+ qq.ios = function() {
+ /*jshint -W014 */
+ return navigator.userAgent.indexOf("iPad") !== -1
+ || navigator.userAgent.indexOf("iPod") !== -1
+ || navigator.userAgent.indexOf("iPhone") !== -1;
+ };
+
+ //
+ // Events
+
+ qq.preventDefault = function(e){
+ if (e.preventDefault){
+ e.preventDefault();
+ } else{
+ e.returnValue = false;
+ }
+ };
+
+ /**
+ * Creates and returns element from html string
+ * Uses innerHTML to create an element
+ */
+ qq.toElement = (function(){
+ var div = document.createElement("div");
+ return function(html){
+ div.innerHTML = html;
+ var element = div.firstChild;
+ div.removeChild(element);
+ return element;
+ };
+ }());
+
+ //key and value are passed to callback for each entry in the iterable item
+ qq.each = function(iterableItem, callback) {
+ var keyOrIndex, retVal;
+
+ if (iterableItem) {
+ // Iterate through [`Storage`](http://www.w3.org/TR/webstorage/#the-storage-interface) items
+ if (window.Storage && iterableItem.constructor === window.Storage) {
+ for (keyOrIndex = 0; keyOrIndex < iterableItem.length; keyOrIndex++) {
+ retVal = callback(iterableItem.key(keyOrIndex), iterableItem.getItem(iterableItem.key(keyOrIndex)));
+ if (retVal === false) {
+ break;
+ }
+ }
+ }
+ // `DataTransferItemList` & `NodeList` objects are array-like and should be treated as arrays
+ // when iterating over items inside the object.
+ else if (qq.isArray(iterableItem) || qq.isItemList(iterableItem) || qq.isNodeList(iterableItem)) {
+ for (keyOrIndex = 0; keyOrIndex < iterableItem.length; keyOrIndex++) {
+ retVal = callback(keyOrIndex, iterableItem[keyOrIndex]);
+ if (retVal === false) {
+ break;
+ }
+ }
+ }
+ else if (qq.isString(iterableItem)) {
+ for (keyOrIndex = 0; keyOrIndex < iterableItem.length; keyOrIndex++) {
+ retVal = callback(keyOrIndex, iterableItem.charAt(keyOrIndex));
+ if (retVal === false) {
+ break;
+ }
+ }
+ }
+ else {
+ for (keyOrIndex in iterableItem) {
+ if (Object.prototype.hasOwnProperty.call(iterableItem, keyOrIndex)) {
+ retVal = callback(keyOrIndex, iterableItem[keyOrIndex]);
+ if (retVal === false) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ //include any args that should be passed to the new function after the context arg
+ qq.bind = function(oldFunc, context) {
+ if (qq.isFunction(oldFunc)) {
+ var args = Array.prototype.slice.call(arguments, 2);
+
+ return function() {
+ var newArgs = qq.extend([], args);
+ if (arguments.length) {
+ newArgs = newArgs.concat(Array.prototype.slice.call(arguments));
+ }
+ return oldFunc.apply(context, newArgs);
+ };
+ }
+
+ throw new Error("first parameter must be a function!");
+ };
+
+ /**
+ * obj2url() takes a json-object as argument and generates
+ * a querystring. pretty much like jQuery.param()
+ *
+ * how to use:
+ *
+ * `qq.obj2url({a:'b',c:'d'},'http://any.url/upload?otherParam=value');`
+ *
+ * will result in:
+ *
+ * `http://any.url/upload?otherParam=value&a=b&c=d`
+ *
+ * @param Object JSON-Object
+ * @param String current querystring-part
+ * @return String encoded querystring
+ */
+ qq.obj2url = function(obj, temp, prefixDone){
+ /*jshint laxbreak: true*/
+ var uristrings = [],
+ prefix = "&",
+ add = function(nextObj, i){
+ var nextTemp = temp
+ ? (/\[\]$/.test(temp)) // prevent double-encoding
+ ? temp
+ : temp+"["+i+"]"
+ : i;
+ if ((nextTemp !== "undefined") && (i !== "undefined")) {
+ uristrings.push(
+ (typeof nextObj === "object")
+ ? qq.obj2url(nextObj, nextTemp, true)
+ : (Object.prototype.toString.call(nextObj) === "[object Function]")
+ ? encodeURIComponent(nextTemp) + "=" + encodeURIComponent(nextObj())
+ : encodeURIComponent(nextTemp) + "=" + encodeURIComponent(nextObj)
+ );
+ }
+ };
+
+ if (!prefixDone && temp) {
+ prefix = (/\?/.test(temp)) ? (/\?$/.test(temp)) ? "" : "&" : "?";
+ uristrings.push(temp);
+ uristrings.push(qq.obj2url(obj));
+ } else if ((Object.prototype.toString.call(obj) === "[object Array]") && (typeof obj !== "undefined") ) {
+ qq.each(obj, function(idx, val) {
+ add(val, idx);
+ });
+ } else if ((typeof obj !== "undefined") && (obj !== null) && (typeof obj === "object")){
+ qq.each(obj, function(prop, val) {
+ add(val, prop);
+ });
+ } else {
+ uristrings.push(encodeURIComponent(temp) + "=" + encodeURIComponent(obj));
+ }
+
+ if (temp) {
+ return uristrings.join(prefix);
+ } else {
+ return uristrings.join(prefix)
+ .replace(/^&/, "")
+ .replace(/%20/g, "+");
+ }
+ };
+
+ qq.obj2FormData = function(obj, formData, arrayKeyName) {
+ if (!formData) {
+ formData = new FormData();
+ }
+
+ qq.each(obj, function(key, val) {
+ key = arrayKeyName ? arrayKeyName + "[" + key + "]" : key;
+
+ if (qq.isObject(val)) {
+ qq.obj2FormData(val, formData, key);
+ }
+ else if (qq.isFunction(val)) {
+ formData.append(key, val());
+ }
+ else {
+ formData.append(key, val);
+ }
+ });
+
+ return formData;
+ };
+
+ qq.obj2Inputs = function(obj, form) {
+ var input;
+
+ if (!form) {
+ form = document.createElement("form");
+ }
+
+ qq.obj2FormData(obj, {
+ append: function(key, val) {
+ input = document.createElement("input");
+ input.setAttribute("name", key);
+ input.setAttribute("value", val);
+ form.appendChild(input);
+ }
+ });
+
+ return form;
+ };
+
+ /**
+ * Not recommended for use outside of Fine Uploader since this falls back to an unchecked eval if JSON.parse is not
+ * implemented. For a more secure JSON.parse polyfill, use Douglas Crockford's json2.js.
+ */
+ qq.parseJson = function(json) {
+ /*jshint evil: true*/
+ if (window.JSON && qq.isFunction(JSON.parse)) {
+ return JSON.parse(json);
+ } else {
+ return eval("(" + json + ")");
+ }
+ };
+
+ /**
+ * Retrieve the extension of a file, if it exists.
+ *
+ * @param filename
+ * @returns {string || undefined}
+ */
+ qq.getExtension = function(filename) {
+ var extIdx = filename.lastIndexOf(".") + 1;
+
+ if (extIdx > 0) {
+ return filename.substr(extIdx, filename.length - extIdx);
+ }
+ };
+
+ qq.getFilename = function(blobOrFileInput) {
+ /*jslint regexp: true*/
+
+ if (qq.isInput(blobOrFileInput)) {
+ // get input value and remove path to normalize
+ return blobOrFileInput.value.replace(/.*(\/|\\)/, "");
+ }
+ else if (qq.isFile(blobOrFileInput)) {
+ if (blobOrFileInput.fileName !== null && blobOrFileInput.fileName !== undefined) {
+ return blobOrFileInput.fileName;
+ }
+ }
+
+ return blobOrFileInput.name;
+ };
+
+ /**
+ * A generic module which supports object disposing in dispose() method.
+ * */
+ qq.DisposeSupport = function() {
+ var disposers = [];
+
+ return {
+ /** Run all registered disposers */
+ dispose: function() {
+ var disposer;
+ do {
+ disposer = disposers.shift();
+ if (disposer) {
+ disposer();
+ }
+ }
+ while (disposer);
+ },
+
+ /** Attach event handler and register de-attacher as a disposer */
+ attach: function() {
+ var args = arguments;
+ /*jslint undef:true*/
+ this.addDisposer(qq(args[0]).attach.apply(this, Array.prototype.slice.call(arguments, 1)));
+ },
+
+ /** Add disposer to the collection */
+ addDisposer: function(disposeFunction) {
+ disposers.push(disposeFunction);
+ }
+ };
+ };
+}());
+
+/* globals qq */
+/**
+ * Fine Uploader top-level Error container. Inherits from `Error`.
+ */
+(function() {
+ "use strict";
+
+ qq.Error = function(message) {
+ this.message = "[Fine Uploader " + qq.version + "] " + message;
+ };
+
+ qq.Error.prototype = new Error();
+}());
+
+/*global qq */
+qq.version="5.0.3";
+
+/* globals qq */
+qq.supportedFeatures = (function () {
+ "use strict";
+
+ var supportsUploading,
+ supportsUploadingBlobs,
+ supportsAjaxFileUploading,
+ supportsFolderDrop,
+ supportsChunking,
+ supportsResume,
+ supportsUploadViaPaste,
+ supportsUploadCors,
+ supportsDeleteFileXdr,
+ supportsDeleteFileCorsXhr,
+ supportsDeleteFileCors,
+ supportsFolderSelection,
+ supportsImagePreviews,
+ supportsUploadProgress;
+
+
+ function testSupportsFileInputElement() {
+ var supported = true,
+ tempInput;
+
+ try {
+ tempInput = document.createElement("input");
+ tempInput.type = "file";
+ qq(tempInput).hide();
+
+ if (tempInput.disabled) {
+ supported = false;
+ }
+ }
+ catch (ex) {
+ supported = false;
+ }
+
+ return supported;
+ }
+
+ //only way to test for Filesystem API support since webkit does not expose the DataTransfer interface
+ function isChrome21OrHigher() {
+ return (qq.chrome() || qq.opera()) &&
+ navigator.userAgent.match(/Chrome\/[2][1-9]|Chrome\/[3-9][0-9]/) !== undefined;
+ }
+
+ //only way to test for complete Clipboard API support at this time
+ function isChrome14OrHigher() {
+ return (qq.chrome() || qq.opera()) &&
+ navigator.userAgent.match(/Chrome\/[1][4-9]|Chrome\/[2-9][0-9]/) !== undefined;
+ }
+
+ //Ensure we can send cross-origin `XMLHttpRequest`s
+ function isCrossOriginXhrSupported() {
+ if (window.XMLHttpRequest) {
+ var xhr = qq.createXhrInstance();
+
+ //Commonly accepted test for XHR CORS support.
+ return xhr.withCredentials !== undefined;
+ }
+
+ return false;
+ }
+
+ //Test for (terrible) cross-origin ajax transport fallback for IE9 and IE8
+ function isXdrSupported() {
+ return window.XDomainRequest !== undefined;
+ }
+
+ // CORS Ajax requests are supported if it is either possible to send credentialed `XMLHttpRequest`s,
+ // or if `XDomainRequest` is an available alternative.
+ function isCrossOriginAjaxSupported() {
+ if (isCrossOriginXhrSupported()) {
+ return true;
+ }
+
+ return isXdrSupported();
+ }
+
+ function isFolderSelectionSupported() {
+ // We know that folder selection is only supported in Chrome via this proprietary attribute for now
+ return document.createElement("input").webkitdirectory !== undefined;
+ }
+
+
+ supportsUploading = testSupportsFileInputElement();
+
+ supportsAjaxFileUploading = supportsUploading && qq.isXhrUploadSupported();
+
+ supportsUploadingBlobs = supportsAjaxFileUploading && !qq.androidStock();
+
+ supportsFolderDrop = supportsAjaxFileUploading && isChrome21OrHigher();
+
+ supportsChunking = supportsAjaxFileUploading && qq.isFileChunkingSupported();
+
+ supportsResume = supportsAjaxFileUploading && supportsChunking && !!window.localStorage;
+
+ supportsUploadViaPaste = supportsAjaxFileUploading && isChrome14OrHigher();
+
+ supportsUploadCors = supportsUploading && (window.postMessage !== undefined || supportsAjaxFileUploading);
+
+ supportsDeleteFileCorsXhr = isCrossOriginXhrSupported();
+
+ supportsDeleteFileXdr = isXdrSupported();
+
+ supportsDeleteFileCors = isCrossOriginAjaxSupported();
+
+ supportsFolderSelection = isFolderSelectionSupported();
+
+ supportsImagePreviews = supportsAjaxFileUploading && window.FileReader !== undefined;
+
+ supportsUploadProgress = (function() {
+ if (supportsAjaxFileUploading) {
+ return !qq.androidStock() &&
+ !(qq.ios() && navigator.userAgent.indexOf("CriOS") >= 0);
+ }
+ return false;
+ }());
+
+
+ return {
+ ajaxUploading: supportsAjaxFileUploading,
+ blobUploading: supportsUploadingBlobs,
+ canDetermineSize: supportsAjaxFileUploading,
+ chunking: supportsChunking,
+ deleteFileCors: supportsDeleteFileCors,
+ deleteFileCorsXdr: supportsDeleteFileXdr, //NOTE: will also return true in IE10, where XDR is also supported
+ deleteFileCorsXhr: supportsDeleteFileCorsXhr,
+ fileDrop: supportsAjaxFileUploading, //NOTE: will also return true for touch-only devices. It's not currently possible to accurately test for touch-only devices
+ folderDrop: supportsFolderDrop,
+ folderSelection: supportsFolderSelection,
+ imagePreviews: supportsImagePreviews,
+ imageValidation: supportsImagePreviews,
+ itemSizeValidation: supportsAjaxFileUploading,
+ pause: supportsChunking,
+ progressBar: supportsUploadProgress,
+ resume: supportsResume,
+ scaling: supportsImagePreviews && supportsUploadingBlobs,
+ tiffPreviews: qq.safari(), // Not the best solution, but simple and probably accurate enough (for now)
+ unlimitedScaledImageSize: !qq.ios(), // false simply indicates that there is some known limit
+ uploading: supportsUploading,
+ uploadCors: supportsUploadCors,
+ uploadCustomHeaders: supportsAjaxFileUploading,
+ uploadNonMultipart: supportsAjaxFileUploading,
+ uploadViaPaste: supportsUploadViaPaste
+ };
+
+}());
+
+/*globals qq*/
+
+// Is the passed object a promise instance?
+qq.isGenericPromise = function(maybePromise) {
+ "use strict";
+ return !!(maybePromise && maybePromise.then && qq.isFunction(maybePromise.then));
+};
+
+qq.Promise = function() {
+ "use strict";
+
+ var successArgs, failureArgs,
+ successCallbacks = [],
+ failureCallbacks = [],
+ doneCallbacks = [],
+ state = 0;
+
+ qq.extend(this, {
+ then: function(onSuccess, onFailure) {
+ if (state === 0) {
+ if (onSuccess) {
+ successCallbacks.push(onSuccess);
+ }
+ if (onFailure) {
+ failureCallbacks.push(onFailure);
+ }
+ }
+ else if (state === -1) {
+ onFailure && onFailure.apply(null, failureArgs);
+ }
+ else if (onSuccess) {
+ onSuccess.apply(null,successArgs);
+ }
+
+ return this;
+ },
+
+ done: function(callback) {
+ if (state === 0) {
+ doneCallbacks.push(callback);
+ }
+ else {
+ callback.apply(null, failureArgs === undefined ? successArgs : failureArgs);
+ }
+
+ return this;
+ },
+
+ success: function() {
+ state = 1;
+ successArgs = arguments;
+
+ if (successCallbacks.length) {
+ qq.each(successCallbacks, function(idx, callback) {
+ callback.apply(null, successArgs);
+ });
+ }
+
+ if(doneCallbacks.length) {
+ qq.each(doneCallbacks, function(idx, callback) {
+ callback.apply(null, successArgs);
+ });
+ }
+
+ return this;
+ },
+
+ failure: function() {
+ state = -1;
+ failureArgs = arguments;
+
+ if (failureCallbacks.length) {
+ qq.each(failureCallbacks, function(idx, callback) {
+ callback.apply(null, failureArgs);
+ });
+ }
+
+ if(doneCallbacks.length) {
+ qq.each(doneCallbacks, function(idx, callback) {
+ callback.apply(null, failureArgs);
+ });
+ }
+
+ return this;
+ }
+ });
+};
+
+/* globals qq */
+/**
+ * Placeholder for a Blob that will be generated on-demand.
+ *
+ * @param referenceBlob Parent of the generated blob
+ * @param onCreate Function to invoke when the blob must be created. Must be promissory.
+ * @constructor
+ */
+qq.BlobProxy = function(referenceBlob, onCreate) {
+ "use strict";
+
+ qq.extend(this, {
+ referenceBlob: referenceBlob,
+
+ create: function() {
+ return onCreate(referenceBlob);
+ }
+ });
+};
+
+/*globals qq*/
+
+/**
+ * This module represents an upload or "Select File(s)" button. It's job is to embed an opaque ` `
+ * element as a child of a provided "container" element. This "container" element (`options.element`) is used to provide
+ * a custom style for the ` ` element. The ability to change the style of the container element is also
+ * provided here by adding CSS classes to the container on hover/focus.
+ *
+ * TODO Eliminate the mouseover and mouseout event handlers since the :hover CSS pseudo-class should now be
+ * available on all supported browsers.
+ *
+ * @param o Options to override the default values
+ */
+qq.UploadButton = function(o) {
+ "use strict";
+
+
+ var disposeSupport = new qq.DisposeSupport(),
+
+ options = {
+ // "Container" element
+ element: null,
+
+ // If true adds `multiple` attribute to ` `
+ multiple: false,
+
+ // Corresponds to the `accept` attribute on the associated ` `
+ acceptFiles: null,
+
+ // A true value allows folders to be selected, if supported by the UA
+ folders: false,
+
+ // `name` attribute of ` `
+ name: "qqfile",
+
+ // Called when the browser invokes the onchange handler on the ` `
+ onChange: function(input) {},
+
+ // **This option will be removed** in the future as the :hover CSS pseudo-class is available on all supported browsers
+ hoverClass: "qq-upload-button-hover",
+
+ focusClass: "qq-upload-button-focus"
+ },
+ input, buttonId;
+
+ // Overrides any of the default option values with any option values passed in during construction.
+ qq.extend(options, o);
+
+ buttonId = qq.getUniqueId();
+
+ // Embed an opaque ` ` element as a child of `options.element`.
+ function createInput() {
+ var input = document.createElement("input");
+
+ input.setAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME, buttonId);
+
+ if (options.multiple) {
+ input.setAttribute("multiple", "");
+ }
+
+ if (options.folders && qq.supportedFeatures.folderSelection) {
+ // selecting directories is only possible in Chrome now, via a vendor-specific prefixed attribute
+ input.setAttribute("webkitdirectory", "");
+ }
+
+ if (options.acceptFiles) {
+ input.setAttribute("accept", options.acceptFiles);
+ }
+
+ input.setAttribute("type", "file");
+ input.setAttribute("name", options.name);
+
+ qq(input).css({
+ position: "absolute",
+ // in Opera only 'browse' button
+ // is clickable and it is located at
+ // the right side of the input
+ right: 0,
+ top: 0,
+ fontFamily: "Arial",
+ // 4 persons reported this, the max values that worked for them were 243, 236, 236, 118
+ fontSize: "118px",
+ margin: 0,
+ padding: 0,
+ cursor: "pointer",
+ opacity: 0
+ });
+
+ options.element.appendChild(input);
+
+ disposeSupport.attach(input, "change", function(){
+ options.onChange(input);
+ });
+
+ // **These event handlers will be removed** in the future as the :hover CSS pseudo-class is available on all supported browsers
+ disposeSupport.attach(input, "mouseover", function(){
+ qq(options.element).addClass(options.hoverClass);
+ });
+ disposeSupport.attach(input, "mouseout", function(){
+ qq(options.element).removeClass(options.hoverClass);
+ });
+
+ disposeSupport.attach(input, "focus", function(){
+ qq(options.element).addClass(options.focusClass);
+ });
+ disposeSupport.attach(input, "blur", function(){
+ qq(options.element).removeClass(options.focusClass);
+ });
+
+ // IE and Opera, unfortunately have 2 tab stops on file input
+ // which is unacceptable in our case, disable keyboard access
+ if (window.attachEvent) {
+ // it is IE or Opera
+ input.setAttribute("tabIndex", "-1");
+ }
+
+ return input;
+ }
+
+ // Make button suitable container for input
+ qq(options.element).css({
+ position: "relative",
+ overflow: "hidden",
+ // Make sure browse button is in the right side in Internet Explorer
+ direction: "ltr"
+ });
+
+ input = createInput();
+
+
+ // Exposed API
+ qq.extend(this, {
+ getInput: function() {
+ return input;
+ },
+
+ getButtonId: function() {
+ return buttonId;
+ },
+
+ setMultiple: function(isMultiple) {
+ if (isMultiple !== options.multiple) {
+ if (isMultiple) {
+ input.setAttribute("multiple", "");
+ }
+ else {
+ input.removeAttribute("multiple");
+ }
+ }
+ },
+
+ setAcceptFiles: function(acceptFiles) {
+ if (acceptFiles !== options.acceptFiles) {
+ input.setAttribute("accept", acceptFiles);
+ }
+ },
+
+ reset: function(){
+ if (input.parentNode){
+ qq(input).remove();
+ }
+
+ qq(options.element).removeClass(options.focusClass);
+ input = createInput();
+ }
+ });
+};
+
+qq.UploadButton.BUTTON_ID_ATTR_NAME = "qq-button-id";
+
+/*globals qq */
+qq.UploadData = function(uploaderProxy) {
+ "use strict";
+
+ var data = [],
+ byUuid = {},
+ byStatus = {},
+ byProxyGroupId = {},
+ byBatchId = {};
+
+
+ function getDataByIds(idOrIds) {
+ if (qq.isArray(idOrIds)) {
+ var entries = [];
+
+ qq.each(idOrIds, function(idx, id) {
+ entries.push(data[id]);
+ });
+
+ return entries;
+ }
+
+ return data[idOrIds];
+ }
+
+ function getDataByUuids(uuids) {
+ if (qq.isArray(uuids)) {
+ var entries = [];
+
+ qq.each(uuids, function(idx, uuid) {
+ entries.push(data[byUuid[uuid]]);
+ });
+
+ return entries;
+ }
+
+ return data[byUuid[uuids]];
+ }
+
+ function getDataByStatus(status) {
+ var statusResults = [],
+ statuses = [].concat(status);
+
+ qq.each(statuses, function(index, statusEnum) {
+ var statusResultIndexes = byStatus[statusEnum];
+
+ if (statusResultIndexes !== undefined) {
+ qq.each(statusResultIndexes, function(i, dataIndex) {
+ statusResults.push(data[dataIndex]);
+ });
+ }
+ });
+
+ return statusResults;
+ }
+
+ qq.extend(this, {
+ /**
+ * Adds a new file to the data cache for tracking purposes.
+ *
+ * @param spec Data that describes this file. Possible properties are:
+ *
+ * - uuid: Initial UUID for this file.
+ * - name: Initial name of this file.
+ * - size: Size of this file, omit if this cannot be determined
+ * - status: Initial `qq.status` for this file. Omit for `qq.status.SUBMITTING`.
+ * - batchId: ID of the batch this file belongs to
+ * - proxyGroupId: ID of the proxy group associated with this file
+ *
+ * @returns {number} Internal ID for this file.
+ */
+ addFile: function(spec) {
+ var status = spec.status || qq.status.SUBMITTING;
+
+ var id = data.push({
+ name: spec.name,
+ originalName: spec.name,
+ uuid: spec.uuid,
+ size: spec.size || -1,
+ status: status
+ }) - 1;
+
+ if (spec.batchId) {
+ data[id].batchId = spec.batchId;
+
+ if (byBatchId[spec.batchId] === undefined) {
+ byBatchId[spec.batchId] = [];
+ }
+ byBatchId[spec.batchId].push(id);
+ }
+
+ if (spec.proxyGroupId) {
+ data[id].proxyGroupId = spec.proxyGroupId;
+
+ if (byProxyGroupId[spec.proxyGroupId] === undefined) {
+ byProxyGroupId[spec.proxyGroupId] = [];
+ }
+ byProxyGroupId[spec.proxyGroupId].push(id);
+ }
+
+ data[id].id = id;
+ byUuid[spec.uuid] = id;
+
+ if (byStatus[status] === undefined) {
+ byStatus[status] = [];
+ }
+ byStatus[status].push(id);
+
+ uploaderProxy.onStatusChange(id, null, status);
+
+ return id;
+ },
+
+ retrieve: function(optionalFilter) {
+ if (qq.isObject(optionalFilter) && data.length) {
+ if (optionalFilter.id !== undefined) {
+ return getDataByIds(optionalFilter.id);
+ }
+
+ else if (optionalFilter.uuid !== undefined) {
+ return getDataByUuids(optionalFilter.uuid);
+ }
+
+ else if (optionalFilter.status) {
+ return getDataByStatus(optionalFilter.status);
+ }
+ }
+ else {
+ return qq.extend([], data, true);
+ }
+ },
+
+ reset: function() {
+ data = [];
+ byUuid = {};
+ byStatus = {};
+ byBatchId = {};
+ },
+
+ setStatus: function(id, newStatus) {
+ var oldStatus = data[id].status,
+ byStatusOldStatusIndex = qq.indexOf(byStatus[oldStatus], id);
+
+ byStatus[oldStatus].splice(byStatusOldStatusIndex, 1);
+
+ data[id].status = newStatus;
+
+ if (byStatus[newStatus] === undefined) {
+ byStatus[newStatus] = [];
+ }
+ byStatus[newStatus].push(id);
+
+ uploaderProxy.onStatusChange(id, oldStatus, newStatus);
+ },
+
+ uuidChanged: function(id, newUuid) {
+ var oldUuid = data[id].uuid;
+
+ data[id].uuid = newUuid;
+ byUuid[newUuid] = id;
+ delete byUuid[oldUuid];
+ },
+
+ updateName: function(id, newName) {
+ data[id].name = newName;
+ },
+
+ updateSize: function(id, newSize) {
+ data[id].size = newSize;
+ },
+
+ // Only applicable if this file has a parent that we may want to reference later.
+ setParentId: function(targetId, parentId) {
+ data[targetId].parentId = parentId;
+ },
+
+ getIdsInProxyGroup: function(id) {
+ var proxyGroupId = data[id].proxyGroupId;
+
+ if (proxyGroupId) {
+ return byProxyGroupId[proxyGroupId];
+ }
+ return [];
+ },
+
+ getIdsInBatch: function(id) {
+ var batchId = data[id].batchId;
+
+ return byBatchId[batchId];
+ }
+ });
+};
+
+qq.status = {
+ SUBMITTING: "submitting",
+ SUBMITTED: "submitted",
+ REJECTED: "rejected",
+ QUEUED: "queued",
+ CANCELED: "canceled",
+ PAUSED: "paused",
+ UPLOADING: "uploading",
+ UPLOAD_RETRYING: "retrying upload",
+ UPLOAD_SUCCESSFUL: "upload successful",
+ UPLOAD_FAILED: "upload failed",
+ DELETE_FAILED: "delete failed",
+ DELETING: "deleting",
+ DELETED: "deleted"
+};
+
+/*globals qq*/
+/**
+ * Defines the public API for FineUploaderBasic mode.
+ */
+(function(){
+ "use strict";
+
+ qq.basePublicApi = {
+ addBlobs: function(blobDataOrArray, params, endpoint) {
+ if (!qq.supportedFeatures.blobUploading) {
+ throw new qq.Error("Blob uploading is not supported in this browser!");
+ }
+
+ if (blobDataOrArray) {
+ var blobDataArray = [].concat(blobDataOrArray),
+ verifiedBlobDataList = [],
+ batchId = this._storedIds.length === 0 ? qq.getUniqueId() : this._currentBatchId,
+ self = this;
+
+ this._currentBatchId = batchId;
+
+ qq.each(blobDataArray, function(idx, blobData) {
+ var blobOrBlobData;
+
+ if (qq.isBlob(blobData) && !qq.isFileOrInput(blobData)) {
+ blobOrBlobData = {
+ blob: blobData,
+ name: self._options.blobs.defaultName
+ };
+ }
+ else if (qq.isObject(blobData) && blobData.blob && blobData.name) {
+ blobOrBlobData = blobData;
+ }
+ else {
+ self.log("addBlobs: entry at index " + idx + " is not a Blob or a BlobData object", "error");
+ }
+
+ blobOrBlobData && self._handleNewFile(blobOrBlobData, batchId, verifiedBlobDataList);
+ });
+
+ this._prepareItemsForUpload(verifiedBlobDataList, params, endpoint);
+ }
+ else {
+ this.log("undefined or non-array parameter passed into addBlobs", "error");
+ }
+ },
+
+ addFiles: function(filesOrInputs, params, endpoint) {
+ var verifiedFilesOrInputs = [],
+ batchId = this._storedIds.length === 0 ? qq.getUniqueId() : this._currentBatchId,
+ fileOrInputIndex, fileOrInput, fileIndex;
+
+ this._currentBatchId = batchId;
+
+ if (filesOrInputs) {
+ if (!qq.isFileList(filesOrInputs)) {
+ filesOrInputs = [].concat(filesOrInputs);
+ }
+
+ for (fileOrInputIndex = 0; fileOrInputIndex < filesOrInputs.length; fileOrInputIndex+=1) {
+ fileOrInput = filesOrInputs[fileOrInputIndex];
+
+ if (qq.isFileOrInput(fileOrInput)) {
+ if (qq.isInput(fileOrInput) && qq.supportedFeatures.ajaxUploading) {
+ for (fileIndex = 0; fileIndex < fileOrInput.files.length; fileIndex++) {
+ this._handleNewFile(fileOrInput.files[fileIndex], batchId, verifiedFilesOrInputs);
+ }
+ }
+ else {
+ this._handleNewFile(fileOrInput, batchId, verifiedFilesOrInputs);
+ }
+ }
+ else {
+ this.log(fileOrInput + " is not a File or INPUT element! Ignoring!", "warn");
+ }
+ }
+
+ this.log("Received " + verifiedFilesOrInputs.length + " files or inputs.");
+ this._prepareItemsForUpload(verifiedFilesOrInputs, params, endpoint);
+ }
+ },
+
+ cancel: function(id) {
+ this._handler.cancel(id);
+ },
+
+ cancelAll: function() {
+ var storedIdsCopy = [],
+ self = this;
+
+ qq.extend(storedIdsCopy, this._storedIds);
+ qq.each(storedIdsCopy, function(idx, storedFileId) {
+ self.cancel(storedFileId);
+ });
+
+ this._handler.cancelAll();
+ },
+
+ clearStoredFiles: function(){
+ this._storedIds = [];
+ },
+
+ continueUpload: function(id) {
+ var uploadData = this._uploadData.retrieve({id: id});
+
+ if (!qq.supportedFeatures.pause || !this._options.chunking.enabled) {
+ return false;
+ }
+
+ if (uploadData.status === qq.status.PAUSED) {
+ this.log(qq.format("Paused file ID {} ({}) will be continued. Not paused.", id, this.getName(id)));
+ this._uploadFile(id);
+ return true;
+ }
+ else {
+ this.log(qq.format("Ignoring continue for file ID {} ({}). Not paused.", id, this.getName(id)), "error");
+ }
+
+ return false;
+ },
+
+ deleteFile: function(id) {
+ return this._onSubmitDelete(id);
+ },
+
+ // TODO document?
+ doesExist: function(fileOrBlobId) {
+ return this._handler.isValid(fileOrBlobId);
+ },
+
+ // Generate a variable size thumbnail on an img or canvas,
+ // returning a promise that is fulfilled when the attempt completes.
+ // Thumbnail can either be based off of a URL for an image returned
+ // by the server in the upload response, or the associated `Blob`.
+ drawThumbnail: function(fileId, imgOrCanvas, maxSize, fromServer) {
+ var promiseToReturn = new qq.Promise();
+
+ if (this._imageGenerator) {
+ var fileOrUrl = this._thumbnailUrls[fileId],
+ options = {
+ scale: maxSize > 0,
+ maxSize: maxSize > 0 ? maxSize : null
+ };
+
+ // If client-side preview generation is possible
+ // and we are not specifically looking for the image URl returned by the server...
+ if (!fromServer && qq.supportedFeatures.imagePreviews) {
+ fileOrUrl = this.getFile(fileId);
+ }
+
+ /* jshint eqeqeq:false,eqnull:true */
+ if (fileOrUrl == null) {
+ promiseToReturn.failure({container: imgOrCanvas, error: "File or URL not found."});
+ }
+ else {
+ this._imageGenerator.generate(fileOrUrl, imgOrCanvas, options).then(
+ function success(modifiedContainer) {
+ promiseToReturn.success(modifiedContainer);
+ },
+
+ function failure(container, reason) {
+ promiseToReturn.failure({container: container, error: reason || "Problem generating thumbnail"});
+ }
+ );
+ }
+ }
+ else {
+ promiseToReturn.failure({container: imgOrCanvas, error: "Missing image generator module"});
+ }
+
+ return promiseToReturn;
+ },
+
+ getButton: function(fileId) {
+ return this._getButton(this._buttonIdsForFileIds[fileId]);
+ },
+
+ getFile: function(fileOrBlobId) {
+ return this._handler.getFile(fileOrBlobId) || null;
+ },
+
+ getInProgress: function() {
+ return this._uploadData.retrieve({
+ status: [
+ qq.status.UPLOADING,
+ qq.status.UPLOAD_RETRYING,
+ qq.status.QUEUED
+ ]
+ }).length;
+ },
+
+ getName: function(id) {
+ return this._uploadData.retrieve({id: id}).name;
+ },
+
+ // Parent ID for a specific file, or null if this is the parent, or if it has no parent.
+ getParentId: function(id) {
+ var uploadDataEntry = this.getUploads({id: id}),
+ parentId = null;
+
+ if (uploadDataEntry) {
+ if (uploadDataEntry.parentId !== undefined) {
+ parentId = uploadDataEntry.parentId;
+ }
+ }
+
+ return parentId;
+ },
+
+ getResumableFilesData: function() {
+ return this._handler.getResumableFilesData();
+ },
+
+ getSize: function(id) {
+ return this._uploadData.retrieve({id: id}).size;
+ },
+
+ getNetUploads: function() {
+ return this._netUploaded;
+ },
+
+ getRemainingAllowedItems: function() {
+ var allowedItems = this._options.validation.itemLimit;
+
+ if (allowedItems > 0) {
+ return this._options.validation.itemLimit - this._netUploadedOrQueued;
+ }
+
+ return null;
+ },
+
+ getUploads: function(optionalFilter) {
+ return this._uploadData.retrieve(optionalFilter);
+ },
+
+ getUuid: function(id) {
+ return this._uploadData.retrieve({id: id}).uuid;
+ },
+
+ log: function(str, level) {
+ if (this._options.debug && (!level || level === "info")) {
+ qq.log("[Fine Uploader " + qq.version + "] " + str);
+ }
+ else if (level && level !== "info") {
+ qq.log("[Fine Uploader " + qq.version + "] " + str, level);
+
+ }
+ },
+
+ pauseUpload: function(id) {
+ var uploadData = this._uploadData.retrieve({id: id});
+
+ if (!qq.supportedFeatures.pause || !this._options.chunking.enabled) {
+ return false;
+ }
+
+ // Pause only really makes sense if the file is uploading or retrying
+ if (qq.indexOf([qq.status.UPLOADING, qq.status.UPLOAD_RETRYING], uploadData.status) >= 0) {
+ if (this._handler.pause(id)) {
+ this._uploadData.setStatus(id, qq.status.PAUSED);
+ return true;
+ }
+ else {
+ this.log(qq.format("Unable to pause file ID {} ({}).", id, this.getName(id)), "error");
+ }
+ }
+ else {
+ this.log(qq.format("Ignoring pause for file ID {} ({}). Not in progress.", id, this.getName(id)), "error");
+ }
+
+ return false;
+ },
+
+ reset: function() {
+ this.log("Resetting uploader...");
+
+ this._handler.reset();
+ this._storedIds = [];
+ this._autoRetries = [];
+ this._retryTimeouts = [];
+ this._preventRetries = [];
+ this._thumbnailUrls = [];
+
+ qq.each(this._buttons, function(idx, button) {
+ button.reset();
+ });
+
+ this._paramsStore.reset();
+ this._endpointStore.reset();
+ this._netUploadedOrQueued = 0;
+ this._netUploaded = 0;
+ this._uploadData.reset();
+ this._buttonIdsForFileIds = [];
+
+ this._pasteHandler && this._pasteHandler.reset();
+ this._options.session.refreshOnReset && this._refreshSessionData();
+
+ this._succeededSinceLastAllComplete = [];
+ this._failedSinceLastAllComplete = [];
+
+ this._totalProgress && this._totalProgress.reset();
+ },
+
+ retry: function(id) {
+ return this._manualRetry(id);
+ },
+
+ scaleImage: function(id, specs) {
+ var self = this;
+
+ return qq.Scaler.prototype.scaleImage(id, specs, {
+ log: qq.bind(self.log, self),
+ getFile: qq.bind(self.getFile, self),
+ uploadData: self._uploadData
+ });
+ },
+
+ setCustomHeaders: function(headers, id) {
+ this._customHeadersStore.set(headers, id);
+ },
+
+ setDeleteFileCustomHeaders: function(headers, id) {
+ this._deleteFileCustomHeadersStore.set(headers, id);
+ },
+
+ setDeleteFileEndpoint: function(endpoint, id) {
+ this._deleteFileEndpointStore.set(endpoint, id);
+ },
+
+ setDeleteFileParams: function(params, id) {
+ this._deleteFileParamsStore.set(params, id);
+ },
+
+ // Re-sets the default endpoint, an endpoint for a specific file, or an endpoint for a specific button
+ setEndpoint: function(endpoint, id) {
+ this._endpointStore.set(endpoint, id);
+ },
+
+ setName: function(id, newName) {
+ this._uploadData.updateName(id, newName);
+ },
+
+ setParams: function(params, id) {
+ this._paramsStore.set(params, id);
+ },
+
+ setUuid: function(id, newUuid) {
+ return this._uploadData.uuidChanged(id, newUuid);
+ },
+
+ uploadStoredFiles: function() {
+ var idToUpload;
+
+ if (this._storedIds.length === 0) {
+ this._itemError("noFilesError");
+ }
+ else {
+ while (this._storedIds.length) {
+ idToUpload = this._storedIds.shift();
+ this._uploadFile(idToUpload);
+ }
+ }
+ }
+ };
+
+
+
+
+ /**
+ * Defines the private (internal) API for FineUploaderBasic mode.
+ */
+ qq.basePrivateApi = {
+ // Updates internal state with a file record (not backed by a live file). Returns the assigned ID.
+ _addCannedFile: function(sessionData) {
+ var id = this._uploadData.addFile({
+ uuid: sessionData.uuid,
+ name: sessionData.name,
+ size: sessionData.size,
+ status: qq.status.UPLOAD_SUCCESSFUL
+ });
+
+ sessionData.deleteFileEndpoint && this.setDeleteFileEndpoint(sessionData.deleteFileEndpoint, id);
+ sessionData.deleteFileParams && this.setDeleteFileParams(sessionData.deleteFileParams, id);
+
+ if (sessionData.thumbnailUrl) {
+ this._thumbnailUrls[id] = sessionData.thumbnailUrl;
+ }
+
+ this._netUploaded++;
+ this._netUploadedOrQueued++;
+
+ return id;
+ },
+
+ _annotateWithButtonId: function(file, associatedInput) {
+ if (qq.isFile(file)) {
+ file.qqButtonId = this._getButtonId(associatedInput);
+ }
+ },
+
+ _batchError: function(message) {
+ this._options.callbacks.onError(null, null, message, undefined);
+ },
+
+ _createDeleteHandler: function() {
+ var self = this;
+
+ return new qq.DeleteFileAjaxRequester({
+ method: this._options.deleteFile.method.toUpperCase(),
+ maxConnections: this._options.maxConnections,
+ uuidParamName: this._options.request.uuidName,
+ customHeaders: this._deleteFileCustomHeadersStore,
+ paramsStore: this._deleteFileParamsStore,
+ endpointStore: this._deleteFileEndpointStore,
+ demoMode: this._options.demoMode,
+ cors: this._options.cors,
+ log: qq.bind(self.log, self),
+ onDelete: function(id) {
+ self._onDelete(id);
+ self._options.callbacks.onDelete(id);
+ },
+ onDeleteComplete: function(id, xhrOrXdr, isError) {
+ self._onDeleteComplete(id, xhrOrXdr, isError);
+ self._options.callbacks.onDeleteComplete(id, xhrOrXdr, isError);
+ }
+
+ });
+ },
+
+ _createPasteHandler: function() {
+ var self = this;
+
+ return new qq.PasteSupport({
+ targetElement: this._options.paste.targetElement,
+ callbacks: {
+ log: qq.bind(self.log, self),
+ pasteReceived: function(blob) {
+ self._handleCheckedCallback({
+ name: "onPasteReceived",
+ callback: qq.bind(self._options.callbacks.onPasteReceived, self, blob),
+ onSuccess: qq.bind(self._handlePasteSuccess, self, blob),
+ identifier: "pasted image"
+ });
+ }
+ }
+ });
+ },
+
+ _createStore: function(initialValue, readOnlyValues) {
+ var store = {},
+ catchall = initialValue,
+ perIdReadOnlyValues = {},
+ copy = function(orig) {
+ if (qq.isObject(orig)) {
+ return qq.extend({}, orig);
+ }
+ return orig;
+ },
+ getReadOnlyValues = function() {
+ if (qq.isFunction(readOnlyValues)) {
+ return readOnlyValues();
+ }
+ return readOnlyValues;
+ },
+ includeReadOnlyValues = function(id, existing) {
+ if (readOnlyValues && qq.isObject(existing)) {
+ qq.extend(existing, getReadOnlyValues());
+ }
+
+ if (perIdReadOnlyValues[id]) {
+ qq.extend(existing, perIdReadOnlyValues[id]);
+ }
+ };
+
+ return {
+ set: function(val, id) {
+ /*jshint eqeqeq: true, eqnull: true*/
+ if (id == null) {
+ store = {};
+ catchall = copy(val);
+ }
+ else {
+ store[id] = copy(val);
+ }
+ },
+
+ get: function(id) {
+ var values;
+
+ /*jshint eqeqeq: true, eqnull: true*/
+ if (id != null && store[id]) {
+ values = store[id];
+ }
+ else {
+ values = copy(catchall);
+ }
+
+ includeReadOnlyValues(id, values);
+
+ return copy(values);
+ },
+
+ addReadOnly: function(id, values) {
+ // Only applicable to Object stores
+ if (qq.isObject(store)) {
+ perIdReadOnlyValues[id] = perIdReadOnlyValues[id] || {};
+ qq.extend(perIdReadOnlyValues[id], values);
+ }
+ },
+
+ remove: function(fileId) {
+ return delete store[fileId];
+ },
+
+ reset: function() {
+ store = {};
+ perIdReadOnlyValues = {};
+ catchall = initialValue;
+ }
+ };
+ },
+
+ _createUploadDataTracker: function() {
+ var self = this;
+
+ return new qq.UploadData({
+ getName: function(id) {
+ return self.getName(id);
+ },
+ getUuid: function(id) {
+ return self.getUuid(id);
+ },
+ getSize: function(id) {
+ return self.getSize(id);
+ },
+ onStatusChange: function(id, oldStatus, newStatus) {
+ self._onUploadStatusChange(id, oldStatus, newStatus);
+ self._options.callbacks.onStatusChange(id, oldStatus, newStatus);
+ self._maybeAllComplete(id, newStatus);
+
+ if (self._totalProgress) {
+ setTimeout(function() {
+ self._totalProgress.onStatusChange(id, oldStatus, newStatus);
+ }, 0);
+ }
+ }
+ });
+ },
+
+ /**
+ * Generate a tracked upload button.
+ *
+ * @param spec Object containing a required `element` property
+ * along with optional `multiple`, `accept`, and `folders`.
+ * @returns {qq.UploadButton}
+ * @private
+ */
+ _createUploadButton: function(spec) {
+ var self = this,
+ acceptFiles = spec.accept || this._options.validation.acceptFiles,
+ allowedExtensions = spec.allowedExtensions || this._options.validation.allowedExtensions;
+
+ function allowMultiple() {
+ if (qq.supportedFeatures.ajaxUploading) {
+ // Workaround for bug in iOS7 (see #1039)
+ if (qq.ios7() && self._isAllowedExtension(allowedExtensions, ".mov")) {
+ return false;
+ }
+
+ if (spec.multiple === undefined) {
+ return self._options.multiple;
+ }
+
+ return spec.multiple;
+ }
+
+ return false;
+ }
+
+ var button = new qq.UploadButton({
+ element: spec.element,
+ folders: spec.folders,
+ name: this._options.request.inputName,
+ multiple: allowMultiple(),
+ acceptFiles: acceptFiles,
+ onChange: function(input) {
+ self._onInputChange(input);
+ },
+ hoverClass: this._options.classes.buttonHover,
+ focusClass: this._options.classes.buttonFocus
+ });
+
+ this._disposeSupport.addDisposer(function() {
+ button.dispose();
+ });
+
+ self._buttons.push(button);
+
+ return button;
+ },
+
+ _createUploadHandler: function(additionalOptions, namespace) {
+ var self = this,
+ lastOnProgress = {},
+ options = {
+ debug: this._options.debug,
+ maxConnections: this._options.maxConnections,
+ cors: this._options.cors,
+ demoMode: this._options.demoMode,
+ paramsStore: this._paramsStore,
+ endpointStore: this._endpointStore,
+ chunking: this._options.chunking,
+ resume: this._options.resume,
+ blobs: this._options.blobs,
+ log: qq.bind(self.log, self),
+ preventRetryParam: this._options.retry.preventRetryResponseProperty,
+ onProgress: function(id, name, loaded, total) {
+ if (lastOnProgress[id]) {
+ if (lastOnProgress[id].loaded !== loaded || lastOnProgress[id].total !== total) {
+ self._onProgress(id, name, loaded, total);
+ self._options.callbacks.onProgress(id, name, loaded, total);
+ }
+ }
+ else {
+ self._onProgress(id, name, loaded, total);
+ self._options.callbacks.onProgress(id, name, loaded, total);
+ }
+
+ lastOnProgress[id] = {loaded: loaded, total: total};
+
+ },
+ onComplete: function(id, name, result, xhr) {
+ delete lastOnProgress[id];
+
+ var status = self.getUploads({id: id}).status;
+
+ // This is to deal with some observed cases where the XHR readyStateChange handler is
+ // invoked by the browser multiple times for the same XHR instance with the same state
+ // readyState value. Higher level: don't invoke complete-related code if we've already
+ // done this.
+ if (status === qq.status.UPLOAD_SUCCESSFUL || status === qq.status.UPLOAD_FAILED) {
+ return;
+ }
+
+ var retVal = self._onComplete(id, name, result, xhr);
+
+ // If the internal `_onComplete` handler returns a promise, don't invoke the `onComplete` callback
+ // until the promise has been fulfilled.
+ if (retVal instanceof qq.Promise) {
+ retVal.done(function() {
+ self._options.callbacks.onComplete(id, name, result, xhr);
+ });
+ }
+ else {
+ self._options.callbacks.onComplete(id, name, result, xhr);
+ }
+ },
+ onCancel: function(id, name, cancelFinalizationEffort) {
+ var promise = new qq.Promise();
+
+ self._handleCheckedCallback({
+ name: "onCancel",
+ callback: qq.bind(self._options.callbacks.onCancel, self, id, name),
+ onFailure: promise.failure,
+ onSuccess: function() {
+ cancelFinalizationEffort.then(function() {
+ self._onCancel(id, name);
+ });
+
+ promise.success();
+ },
+ identifier: id
+ });
+
+ return promise;
+ },
+ onUploadPrep: qq.bind(this._onUploadPrep, this),
+ onUpload: function(id, name) {
+ self._onUpload(id, name);
+ self._options.callbacks.onUpload(id, name);
+ },
+ onUploadChunk: function(id, name, chunkData) {
+ self._onUploadChunk(id, chunkData);
+ self._options.callbacks.onUploadChunk(id, name, chunkData);
+ },
+ onUploadChunkSuccess: function(id, chunkData, result, xhr) {
+ self._options.callbacks.onUploadChunkSuccess.apply(self, arguments);
+ },
+ onResume: function(id, name, chunkData) {
+ return self._options.callbacks.onResume(id, name, chunkData);
+ },
+ onAutoRetry: function(id, name, responseJSON, xhr) {
+ return self._onAutoRetry.apply(self, arguments);
+ },
+ onUuidChanged: function(id, newUuid) {
+ self.log("Server requested UUID change from '" + self.getUuid(id) + "' to '" + newUuid + "'");
+ self.setUuid(id, newUuid);
+ },
+ getName: qq.bind(self.getName, self),
+ getUuid: qq.bind(self.getUuid, self),
+ getSize: qq.bind(self.getSize, self),
+ setSize: qq.bind(self._setSize, self),
+ getDataByUuid: function(uuid) {
+ return self.getUploads({uuid: uuid});
+ },
+ isQueued: function(id) {
+ var status = self.getUploads({id: id}).status;
+ return status === qq.status.QUEUED ||
+ status === qq.status.SUBMITTED ||
+ status === qq.status.UPLOAD_RETRYING ||
+ status === qq.status.PAUSED;
+ },
+ getIdsInProxyGroup: self._uploadData.getIdsInProxyGroup,
+ getIdsInBatch: self._uploadData.getIdsInBatch
+ };
+
+ qq.each(this._options.request, function(prop, val) {
+ options[prop] = val;
+ });
+
+ options.customHeaders = this._customHeadersStore;
+
+ if (additionalOptions) {
+ qq.each(additionalOptions, function(key, val) {
+ options[key] = val;
+ });
+ }
+
+ return new qq.UploadHandlerController(options, namespace);
+ },
+
+ _fileOrBlobRejected: function(id) {
+ this._netUploadedOrQueued--;
+ this._uploadData.setStatus(id, qq.status.REJECTED);
+ },
+
+ _formatSize: function(bytes){
+ var i = -1;
+ do {
+ bytes = bytes / 1000;
+ i++;
+ } while (bytes > 999);
+
+ return Math.max(bytes, 0.1).toFixed(1) + this._options.text.sizeSymbols[i];
+ },
+
+ // Creates an internal object that tracks various properties of each extra button,
+ // and then actually creates the extra button.
+ _generateExtraButtonSpecs: function() {
+ var self = this;
+
+ this._extraButtonSpecs = {};
+
+ qq.each(this._options.extraButtons, function(idx, extraButtonOptionEntry) {
+ var multiple = extraButtonOptionEntry.multiple,
+ validation = qq.extend({}, self._options.validation, true),
+ extraButtonSpec = qq.extend({}, extraButtonOptionEntry);
+
+ if (multiple === undefined) {
+ multiple = self._options.multiple;
+ }
+
+ if (extraButtonSpec.validation) {
+ qq.extend(validation, extraButtonOptionEntry.validation, true);
+ }
+
+ qq.extend(extraButtonSpec, {
+ multiple: multiple,
+ validation: validation
+ }, true);
+
+ self._initExtraButton(extraButtonSpec);
+ });
+ },
+
+ _getButton: function(buttonId) {
+ var extraButtonsSpec = this._extraButtonSpecs[buttonId];
+
+ if (extraButtonsSpec) {
+ return extraButtonsSpec.element;
+ }
+ else if (buttonId === this._defaultButtonId) {
+ return this._options.button;
+ }
+ },
+
+ /**
+ * Gets the internally used tracking ID for a button.
+ *
+ * @param buttonOrFileInputOrFile `File`, ` `, or a button container element
+ * @returns {*} The button's ID, or undefined if no ID is recoverable
+ * @private
+ */
+ _getButtonId: function(buttonOrFileInputOrFile) {
+ var inputs, fileInput,
+ fileBlobOrInput = buttonOrFileInputOrFile;
+
+ // We want the reference file/blob here if this is a proxy (a file that will be generated on-demand later)
+ if (fileBlobOrInput instanceof qq.BlobProxy) {
+ fileBlobOrInput = fileBlobOrInput.referenceBlob;
+ }
+
+ // If the item is a `Blob` it will never be associated with a button or drop zone.
+ if (fileBlobOrInput && !qq.isBlob(fileBlobOrInput)) {
+ if (qq.isFile(fileBlobOrInput)) {
+ return fileBlobOrInput.qqButtonId;
+ }
+ else if (fileBlobOrInput.tagName.toLowerCase() === "input" &&
+ fileBlobOrInput.type.toLowerCase() === "file") {
+
+ return fileBlobOrInput.getAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME);
+ }
+
+ inputs = fileBlobOrInput.getElementsByTagName("input");
+
+ qq.each(inputs, function(idx, input) {
+ if (input.getAttribute("type") === "file") {
+ fileInput = input;
+ return false;
+ }
+ });
+
+ if (fileInput) {
+ return fileInput.getAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME);
+ }
+ }
+ },
+
+ _getNotFinished: function() {
+ return this._uploadData.retrieve({
+ status: [
+ qq.status.UPLOADING,
+ qq.status.UPLOAD_RETRYING,
+ qq.status.QUEUED,
+ qq.status.SUBMITTING,
+ qq.status.SUBMITTED,
+ qq.status.PAUSED
+ ]
+ }).length;
+ },
+
+ // Get the validation options for this button. Could be the default validation option
+ // or a specific one assigned to this particular button.
+ _getValidationBase: function(buttonId) {
+ var extraButtonSpec = this._extraButtonSpecs[buttonId];
+
+ return extraButtonSpec ? extraButtonSpec.validation : this._options.validation;
+ },
+
+ _getValidationDescriptor: function(fileWrapper) {
+ if (fileWrapper.file instanceof qq.BlobProxy) {
+ return {
+ name: qq.getFilename(fileWrapper.file.referenceBlob),
+ size: fileWrapper.file.referenceBlob.size
+ };
+ }
+
+ return {
+ name: this.getUploads({id: fileWrapper.id}).name,
+ size: this.getUploads({id: fileWrapper.id}).size
+ };
+ },
+
+ _getValidationDescriptors: function(fileWrappers) {
+ var self = this,
+ fileDescriptors = [];
+
+ qq.each(fileWrappers, function(idx, fileWrapper) {
+ fileDescriptors.push(self._getValidationDescriptor(fileWrapper));
+ });
+
+ return fileDescriptors;
+ },
+
+ // Allows camera access on either the default or an extra button for iOS devices.
+ _handleCameraAccess: function() {
+ if (this._options.camera.ios && qq.ios()) {
+ var acceptIosCamera = "image/*;capture=camera",
+ button = this._options.camera.button,
+ buttonId = button ? this._getButtonId(button) : this._defaultButtonId,
+ optionRoot = this._options;
+
+ // If we are not targeting the default button, it is an "extra" button
+ if (buttonId && buttonId !== this._defaultButtonId) {
+ optionRoot = this._extraButtonSpecs[buttonId];
+ }
+
+ // Camera access won't work in iOS if the `multiple` attribute is present on the file input
+ optionRoot.multiple = false;
+
+ // update the options
+ if (optionRoot.validation.acceptFiles === null) {
+ optionRoot.validation.acceptFiles = acceptIosCamera;
+ }
+ else {
+ optionRoot.validation.acceptFiles += "," + acceptIosCamera;
+ }
+
+ // update the already-created button
+ qq.each(this._buttons, function(idx, button) {
+ if (button.getButtonId() === buttonId) {
+ button.setMultiple(optionRoot.multiple);
+ button.setAcceptFiles(optionRoot.acceptFiles);
+
+ return false;
+ }
+ });
+ }
+ },
+
+ _handleCheckedCallback: function(details) {
+ var self = this,
+ callbackRetVal = details.callback();
+
+ if (qq.isGenericPromise(callbackRetVal)) {
+ this.log(details.name + " - waiting for " + details.name + " promise to be fulfilled for " + details.identifier);
+ return callbackRetVal.then(
+ function(successParam) {
+ self.log(details.name + " promise success for " + details.identifier);
+ details.onSuccess(successParam);
+ },
+ function() {
+ if (details.onFailure) {
+ self.log(details.name + " promise failure for " + details.identifier);
+ details.onFailure();
+ }
+ else {
+ self.log(details.name + " promise failure for " + details.identifier);
+ }
+ });
+ }
+
+ if (callbackRetVal !== false) {
+ details.onSuccess(callbackRetVal);
+ }
+ else {
+ if (details.onFailure) {
+ this.log(details.name + " - return value was 'false' for " + details.identifier + ". Invoking failure callback.");
+ details.onFailure();
+ }
+ else {
+ this.log(details.name + " - return value was 'false' for " + details.identifier + ". Will not proceed.");
+ }
+ }
+
+ return callbackRetVal;
+ },
+
+ // Updates internal state when a new file has been received, and adds it along with its ID to a passed array.
+ _handleNewFile: function(file, batchId, newFileWrapperList) {
+ var self = this,
+ uuid = qq.getUniqueId(),
+ size = -1,
+ name = qq.getFilename(file),
+ actualFile = file.blob || file,
+ handler = this._customNewFileHandler ?
+ this._customNewFileHandler :
+ qq.bind(self._handleNewFileGeneric, self);
+
+ if (!qq.isInput(actualFile) && actualFile.size >= 0) {
+ size = actualFile.size;
+ }
+
+ handler(actualFile, name, uuid, size, newFileWrapperList, batchId, this._options.request.uuidName, {
+ uploadData: self._uploadData,
+ paramsStore: self._paramsStore,
+ addFileToHandler: function(id, file) {
+ self._handler.add(id, file);
+ self._netUploadedOrQueued++;
+ self._trackButton(id);
+ }
+ });
+ },
+
+ _handleNewFileGeneric: function(file, name, uuid, size, fileList, batchId) {
+ var id = this._uploadData.addFile({uuid: uuid, name: name, size: size, batchId: batchId});
+
+ this._handler.add(id, file);
+ this._trackButton(id);
+
+ this._netUploadedOrQueued++;
+
+ fileList.push({id: id, file: file});
+ },
+
+ _handlePasteSuccess: function(blob, extSuppliedName) {
+ var extension = blob.type.split("/")[1],
+ name = extSuppliedName;
+
+ /*jshint eqeqeq: true, eqnull: true*/
+ if (name == null) {
+ name = this._options.paste.defaultName;
+ }
+
+ name += "." + extension;
+
+ this.addBlobs({
+ name: name,
+ blob: blob
+ });
+ },
+
+ // Creates an extra button element
+ _initExtraButton: function(spec) {
+ var button = this._createUploadButton({
+ element: spec.element,
+ multiple: spec.multiple,
+ accept: spec.validation.acceptFiles,
+ folders: spec.folders,
+ allowedExtensions: spec.validation.allowedExtensions
+ });
+
+ this._extraButtonSpecs[button.getButtonId()] = spec;
+ },
+
+ _initFormSupportAndParams: function() {
+ this._formSupport = qq.FormSupport && new qq.FormSupport(
+ this._options.form, qq.bind(this.uploadStoredFiles, this), qq.bind(this.log, this)
+ );
+
+ if (this._formSupport && this._formSupport.attachedToForm) {
+ this._paramsStore = this._createStore(
+ this._options.request.params, this._formSupport.getFormInputsAsObject
+ );
+
+ this._options.autoUpload = this._formSupport.newAutoUpload;
+ if (this._formSupport.newEndpoint) {
+ this._options.request.endpoint = this._formSupport.newEndpoint;
+ }
+ }
+ else {
+ this._paramsStore = this._createStore(this._options.request.params);
+ }
+ },
+
+ _isDeletePossible: function() {
+ if (!qq.DeleteFileAjaxRequester || !this._options.deleteFile.enabled) {
+ return false;
+ }
+
+ if (this._options.cors.expected) {
+ if (qq.supportedFeatures.deleteFileCorsXhr) {
+ return true;
+ }
+
+ if (qq.supportedFeatures.deleteFileCorsXdr && this._options.cors.allowXdr) {
+ return true;
+ }
+
+ return false;
+ }
+
+ return true;
+ },
+
+ _isAllowedExtension: function(allowed, fileName) {
+ var valid = false;
+
+ if (!allowed.length) {
+ return true;
+ }
+
+ qq.each(allowed, function(idx, allowedExt) {
+ /**
+ * If an argument is not a string, ignore it. Added when a possible issue with MooTools hijacking the
+ * `allowedExtensions` array was discovered. See case #735 in the issue tracker for more details.
+ */
+ if (qq.isString(allowedExt)) {
+ /*jshint eqeqeq: true, eqnull: true*/
+ var extRegex = new RegExp("\\." + allowedExt + "$", "i");
+
+ if (fileName.match(extRegex) != null) {
+ valid = true;
+ return false;
+ }
+ }
+ });
+
+ return valid;
+ },
+
+ /**
+ * Constructs and returns a message that describes an item/file error. Also calls `onError` callback.
+ *
+ * @param code REQUIRED - a code that corresponds to a stock message describing this type of error
+ * @param maybeNameOrNames names of the items that have failed, if applicable
+ * @param item `File`, `Blob`, or ` `
+ * @private
+ */
+ _itemError: function(code, maybeNameOrNames, item) {
+ var message = this._options.messages[code],
+ allowedExtensions = [],
+ names = [].concat(maybeNameOrNames),
+ name = names[0],
+ buttonId = this._getButtonId(item),
+ validationBase = this._getValidationBase(buttonId),
+ extensionsForMessage, placeholderMatch;
+
+ function r(name, replacement){ message = message.replace(name, replacement); }
+
+ qq.each(validationBase.allowedExtensions, function(idx, allowedExtension) {
+ /**
+ * If an argument is not a string, ignore it. Added when a possible issue with MooTools hijacking the
+ * `allowedExtensions` array was discovered. See case #735 in the issue tracker for more details.
+ */
+ if (qq.isString(allowedExtension)) {
+ allowedExtensions.push(allowedExtension);
+ }
+ });
+
+ extensionsForMessage = allowedExtensions.join(", ").toLowerCase();
+
+ r("{file}", this._options.formatFileName(name));
+ r("{extensions}", extensionsForMessage);
+ r("{sizeLimit}", this._formatSize(validationBase.sizeLimit));
+ r("{minSizeLimit}", this._formatSize(validationBase.minSizeLimit));
+
+ placeholderMatch = message.match(/(\{\w+\})/g);
+ if (placeholderMatch !== null) {
+ qq.each(placeholderMatch, function(idx, placeholder) {
+ r(placeholder, names[idx]);
+ });
+ }
+
+ this._options.callbacks.onError(null, name, message, undefined);
+
+ return message;
+ },
+
+ /**
+ * Conditionally orders a manual retry of a failed upload.
+ *
+ * @param id File ID of the failed upload
+ * @param callback Optional callback to invoke if a retry is prudent.
+ * In lieu of asking the upload handler to retry.
+ * @returns {boolean} true if a manual retry will occur
+ * @private
+ */
+ _manualRetry: function(id, callback) {
+ if (this._onBeforeManualRetry(id)) {
+ this._netUploadedOrQueued++;
+ this._uploadData.setStatus(id, qq.status.UPLOAD_RETRYING);
+
+ if (callback) {
+ callback(id);
+ }
+ else {
+ this._handler.retry(id);
+ }
+
+ return true;
+ }
+ },
+
+ _maybeAllComplete: function(id, status) {
+ var self = this,
+ notFinished = this._getNotFinished();
+
+ if (status === qq.status.UPLOAD_SUCCESSFUL) {
+ this._succeededSinceLastAllComplete.push(id);
+ }
+ else if (status === qq.status.UPLOAD_FAILED) {
+ this._failedSinceLastAllComplete.push(id);
+ }
+
+ if (notFinished === 0 &&
+ (this._succeededSinceLastAllComplete.length || this._failedSinceLastAllComplete.length)) {
+ // Attempt to ensure onAllComplete is not invoked before other callbacks, such as onCancel & onComplete
+ setTimeout(function() {
+ self._onAllComplete(self._succeededSinceLastAllComplete, self._failedSinceLastAllComplete);
+ }, 0);
+ }
+ },
+
+ _maybeParseAndSendUploadError: function(id, name, response, xhr) {
+ // Assuming no one will actually set the response code to something other than 200
+ // and still set 'success' to true...
+ if (!response.success){
+ if (xhr && xhr.status !== 200 && !response.error) {
+ this._options.callbacks.onError(id, name, "XHR returned response code " + xhr.status, xhr);
+ }
+ else {
+ var errorReason = response.error ? response.error : this._options.text.defaultResponseError;
+ this._options.callbacks.onError(id, name, errorReason, xhr);
+ }
+ }
+ },
+
+ _maybeProcessNextItemAfterOnValidateCallback: function(validItem, items, index, params, endpoint) {
+ var self = this;
+
+ if (items.length > index) {
+ if (validItem || !this._options.validation.stopOnFirstInvalidFile) {
+ //use setTimeout to prevent a stack overflow with a large number of files in the batch & non-promissory callbacks
+ setTimeout(function() {
+ var validationDescriptor = self._getValidationDescriptor(items[index]);
+
+ self._handleCheckedCallback({
+ name: "onValidate",
+ callback: qq.bind(self._options.callbacks.onValidate, self, items[index].file),
+ onSuccess: qq.bind(self._onValidateCallbackSuccess, self, items, index, params, endpoint),
+ onFailure: qq.bind(self._onValidateCallbackFailure, self, items, index, params, endpoint),
+ identifier: "Item '" + validationDescriptor.name + "', size: " + validationDescriptor.size
+ });
+ }, 0);
+ }
+ else if (!validItem) {
+ for (; index < items.length; index++) {
+ self._fileOrBlobRejected(items[index].id);
+ }
+ }
+ }
+ },
+
+ _onAllComplete: function(successful, failed) {
+ this._totalProgress && this._totalProgress.onAllComplete(successful, failed, this._preventRetries);
+
+ this._options.callbacks.onAllComplete(qq.extend([], successful), qq.extend([], failed));
+
+ this._succeededSinceLastAllComplete = [];
+ this._failedSinceLastAllComplete = [];
+ },
+
+ /**
+ * Attempt to automatically retry a failed upload.
+ *
+ * @param id The file ID of the failed upload
+ * @param name The name of the file associated with the failed upload
+ * @param responseJSON Response from the server, parsed into a javascript object
+ * @param xhr Ajax transport used to send the failed request
+ * @param callback Optional callback to be invoked if a retry is prudent.
+ * Invoked in lieu of asking the upload handler to retry.
+ * @returns {boolean} true if an auto-retry will occur
+ * @private
+ */
+ _onAutoRetry: function(id, name, responseJSON, xhr, callback) {
+ var self = this;
+
+ self._preventRetries[id] = responseJSON[self._options.retry.preventRetryResponseProperty];
+
+ if (self._shouldAutoRetry(id, name, responseJSON)) {
+ self._maybeParseAndSendUploadError.apply(self, arguments);
+ self._options.callbacks.onAutoRetry(id, name, self._autoRetries[id]);
+ self._onBeforeAutoRetry(id, name);
+
+ self._retryTimeouts[id] = setTimeout(function() {
+ self.log("Retrying " + name + "...");
+ self._uploadData.setStatus(id, qq.status.UPLOAD_RETRYING);
+
+ if (callback) {
+ callback(id);
+ }
+ else {
+ self._handler.retry(id);
+ }
+ }, self._options.retry.autoAttemptDelay * 1000);
+
+ return true;
+ }
+ },
+
+ _onBeforeAutoRetry: function(id, name) {
+ this.log("Waiting " + this._options.retry.autoAttemptDelay + " seconds before retrying " + name + "...");
+ },
+
+ //return false if we should not attempt the requested retry
+ _onBeforeManualRetry: function(id) {
+ var itemLimit = this._options.validation.itemLimit;
+
+ if (this._preventRetries[id]) {
+ this.log("Retries are forbidden for id " + id, "warn");
+ return false;
+ }
+ else if (this._handler.isValid(id)) {
+ var fileName = this.getName(id);
+
+ if (this._options.callbacks.onManualRetry(id, fileName) === false) {
+ return false;
+ }
+
+ if (itemLimit > 0 && this._netUploadedOrQueued+1 > itemLimit) {
+ this._itemError("retryFailTooManyItems");
+ return false;
+ }
+
+ this.log("Retrying upload for '" + fileName + "' (id: " + id + ")...");
+ return true;
+ }
+ else {
+ this.log("'" + id + "' is not a valid file ID", "error");
+ return false;
+ }
+ },
+
+ _onCancel: function(id, name) {
+ this._netUploadedOrQueued--;
+
+ clearTimeout(this._retryTimeouts[id]);
+
+ var storedItemIndex = qq.indexOf(this._storedIds, id);
+ if (!this._options.autoUpload && storedItemIndex >= 0) {
+ this._storedIds.splice(storedItemIndex, 1);
+ }
+
+ this._uploadData.setStatus(id, qq.status.CANCELED);
+ },
+
+ _onComplete: function(id, name, result, xhr) {
+ if (!result.success) {
+ this._netUploadedOrQueued--;
+ this._uploadData.setStatus(id, qq.status.UPLOAD_FAILED);
+
+ if (result[this._options.retry.preventRetryResponseProperty] === true) {
+ this._preventRetries[id] = true;
+ }
+ }
+ else {
+ if (result.thumbnailUrl) {
+ this._thumbnailUrls[id] = result.thumbnailUrl;
+ }
+
+ this._netUploaded++;
+ this._uploadData.setStatus(id, qq.status.UPLOAD_SUCCESSFUL);
+ }
+
+ this._maybeParseAndSendUploadError(id, name, result, xhr);
+
+ return result.success ? true : false;
+ },
+
+ _onDelete: function(id) {
+ this._uploadData.setStatus(id, qq.status.DELETING);
+ },
+
+ _onDeleteComplete: function(id, xhrOrXdr, isError) {
+ var name = this.getName(id);
+
+ if (isError) {
+ this._uploadData.setStatus(id, qq.status.DELETE_FAILED);
+ this.log("Delete request for '" + name + "' has failed.", "error");
+
+ // For error reporing, we only have accesss to the response status if this is not
+ // an `XDomainRequest`.
+ if (xhrOrXdr.withCredentials === undefined) {
+ this._options.callbacks.onError(id, name, "Delete request failed", xhrOrXdr);
+ }
+ else {
+ this._options.callbacks.onError(id, name, "Delete request failed with response code " + xhrOrXdr.status, xhrOrXdr);
+ }
+ }
+ else {
+ this._netUploadedOrQueued--;
+ this._netUploaded--;
+ this._handler.expunge(id);
+ this._uploadData.setStatus(id, qq.status.DELETED);
+ this.log("Delete request for '" + name + "' has succeeded.");
+ }
+ },
+
+ _onInputChange: function(input) {
+ var fileIndex;
+
+ if (qq.supportedFeatures.ajaxUploading) {
+ for (fileIndex = 0; fileIndex < input.files.length; fileIndex++) {
+ this._annotateWithButtonId(input.files[fileIndex], input);
+ }
+
+ this.addFiles(input.files);
+ }
+ // Android 2.3.x will fire `onchange` even if no file has been selected
+ else if (input.value.length > 0) {
+ this.addFiles(input);
+ }
+
+ qq.each(this._buttons, function(idx, button) {
+ button.reset();
+ });
+ },
+
+ _onProgress: function(id, name, loaded, total) {
+ this._totalProgress && this._totalProgress.onIndividualProgress(id, loaded, total);
+ },
+
+ _onSubmit: function(id, name) {
+ //nothing to do yet in core uploader
+ },
+
+ _onSubmitCallbackSuccess: function(id, name) {
+ this._onSubmit.apply(this, arguments);
+ this._uploadData.setStatus(id, qq.status.SUBMITTED);
+ this._onSubmitted.apply(this, arguments);
+ this._options.callbacks.onSubmitted.apply(this, arguments);
+
+ if (this._options.autoUpload) {
+ this._uploadFile(id);
+ }
+ else {
+ this._storeForLater(id);
+ }
+ },
+
+ _onSubmitDelete: function(id, onSuccessCallback, additionalMandatedParams) {
+ var uuid = this.getUuid(id),
+ adjustedOnSuccessCallback;
+
+ if (onSuccessCallback) {
+ adjustedOnSuccessCallback = qq.bind(onSuccessCallback, this, id, uuid, additionalMandatedParams);
+ }
+
+ if (this._isDeletePossible()) {
+ this._handleCheckedCallback({
+ name: "onSubmitDelete",
+ callback: qq.bind(this._options.callbacks.onSubmitDelete, this, id),
+ onSuccess: adjustedOnSuccessCallback ||
+ qq.bind(this._deleteHandler.sendDelete, this, id, uuid, additionalMandatedParams),
+ identifier: id
+ });
+ return true;
+ }
+ else {
+ this.log("Delete request ignored for ID " + id + ", delete feature is disabled or request not possible " +
+ "due to CORS on a user agent that does not support pre-flighting.", "warn");
+ return false;
+ }
+ },
+
+ _onSubmitted: function(id) {
+ //nothing to do in the base uploader
+ },
+
+ _onTotalProgress: function(loaded, total) {
+ this._options.callbacks.onTotalProgress(loaded, total);
+ },
+
+ _onUploadPrep: function(id) {
+ // nothing to do in the core uploader for now
+ },
+
+ _onUpload: function(id, name) {
+ this._uploadData.setStatus(id, qq.status.UPLOADING);
+ },
+
+ _onUploadChunk: function(id, chunkData) {
+ //nothing to do in the base uploader
+ },
+
+ _onUploadStatusChange: function(id, oldStatus, newStatus) {
+ // Make sure a "queued" retry attempt is canceled if the upload has been paused
+ if (newStatus === qq.status.PAUSED) {
+ clearTimeout(this._retryTimeouts[id]);
+ }
+ },
+
+ _onValidateBatchCallbackFailure: function(fileWrappers) {
+ var self = this;
+
+ qq.each(fileWrappers, function(idx, fileWrapper) {
+ self._fileOrBlobRejected(fileWrapper.id);
+ });
+ },
+
+ _onValidateBatchCallbackSuccess: function(validationDescriptors, items, params, endpoint, button) {
+ var errorMessage,
+ itemLimit = this._options.validation.itemLimit,
+ proposedNetFilesUploadedOrQueued = this._netUploadedOrQueued;
+
+ if (itemLimit === 0 || proposedNetFilesUploadedOrQueued <= itemLimit) {
+ if (items.length > 0) {
+ this._handleCheckedCallback({
+ name: "onValidate",
+ callback: qq.bind(this._options.callbacks.onValidate, this, validationDescriptors[0], button),
+ onSuccess: qq.bind(this._onValidateCallbackSuccess, this, items, 0, params, endpoint),
+ onFailure: qq.bind(this._onValidateCallbackFailure, this, items, 0, params, endpoint),
+ identifier: "Item '" + items[0].file.name + "', size: " + items[0].file.size
+ });
+ }
+ else {
+ this._itemError("noFilesError");
+ }
+ }
+ else {
+ this._onValidateBatchCallbackFailure(items);
+ errorMessage = this._options.messages.tooManyItemsError
+ .replace(/\{netItems\}/g, proposedNetFilesUploadedOrQueued)
+ .replace(/\{itemLimit\}/g, itemLimit);
+ this._batchError(errorMessage);
+ }
+ },
+
+ _onValidateCallbackFailure: function(items, index, params, endpoint) {
+ var nextIndex = index+ 1;
+
+ this._fileOrBlobRejected(items[0].id, items[0].file.name);
+
+ this._maybeProcessNextItemAfterOnValidateCallback(false, items, nextIndex, params, endpoint);
+ },
+
+ _onValidateCallbackSuccess: function(items, index, params, endpoint) {
+ var self = this,
+ nextIndex = index+1,
+ validationDescriptor = this._getValidationDescriptor(items[index]);
+
+ this._validateFileOrBlobData(items[index], validationDescriptor)
+ .then(
+ function() {
+ self._upload(items[index].id, params, endpoint);
+ self._maybeProcessNextItemAfterOnValidateCallback(true, items, nextIndex, params, endpoint);
+ },
+ function() {
+ self._maybeProcessNextItemAfterOnValidateCallback(false, items, nextIndex, params, endpoint);
+ }
+ );
+ },
+
+ _prepareItemsForUpload: function(items, params, endpoint) {
+ if (items.length === 0) {
+ this._itemError("noFilesError");
+ return;
+ }
+
+ var validationDescriptors = this._getValidationDescriptors(items),
+ buttonId = this._getButtonId(items[0].file),
+ button = this._getButton(buttonId);
+
+ this._handleCheckedCallback({
+ name: "onValidateBatch",
+ callback: qq.bind(this._options.callbacks.onValidateBatch, this, validationDescriptors, button),
+ onSuccess: qq.bind(this._onValidateBatchCallbackSuccess, this, validationDescriptors, items, params, endpoint, button),
+ onFailure: qq.bind(this._onValidateBatchCallbackFailure, this, items),
+ identifier: "batch validation"
+ });
+ },
+
+ _preventLeaveInProgress: function(){
+ var self = this;
+
+ this._disposeSupport.attach(window, "beforeunload", function(e){
+ if (self.getInProgress()) {
+ e = e || window.event;
+ // for ie, ff
+ e.returnValue = self._options.messages.onLeave;
+ // for webkit
+ return self._options.messages.onLeave;
+ }
+ });
+ },
+
+ // Attempts to refresh session data only if the `qq.Session` module exists
+ // and a session endpoint has been specified. The `onSessionRequestComplete`
+ // callback will be invoked once the refresh is complete.
+ _refreshSessionData: function() {
+ var self = this,
+ options = this._options.session;
+
+ /* jshint eqnull:true */
+ if (qq.Session && this._options.session.endpoint != null) {
+ if (!this._session) {
+ qq.extend(options, this._options.cors);
+
+ options.log = qq.bind(this.log, this);
+ options.addFileRecord = qq.bind(this._addCannedFile, this);
+
+ this._session = new qq.Session(options);
+ }
+
+ setTimeout(function() {
+ self._session.refresh().then(function(response, xhrOrXdr) {
+
+ self._options.callbacks.onSessionRequestComplete(response, true, xhrOrXdr);
+
+ }, function(response, xhrOrXdr) {
+
+ self._options.callbacks.onSessionRequestComplete(response, false, xhrOrXdr);
+ });
+ }, 0);
+ }
+ },
+
+ _setSize: function(id, newSize) {
+ this._uploadData.updateSize(id, newSize);
+ this._totalProgress && this._totalProgress.onNewSize(id);
+ },
+
+ _shouldAutoRetry: function(id, name, responseJSON) {
+ var uploadData = this._uploadData.retrieve({id: id});
+
+ /*jshint laxbreak: true */
+ if (!this._preventRetries[id]
+ && this._options.retry.enableAuto
+ && uploadData.status !== qq.status.PAUSED) {
+
+ if (this._autoRetries[id] === undefined) {
+ this._autoRetries[id] = 0;
+ }
+
+ if (this._autoRetries[id] < this._options.retry.maxAutoAttempts) {
+ this._autoRetries[id] += 1;
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ _storeForLater: function(id) {
+ this._storedIds.push(id);
+ },
+
+ // Maps a file with the button that was used to select it.
+ _trackButton: function(id) {
+ var buttonId;
+
+ if (qq.supportedFeatures.ajaxUploading) {
+ buttonId = this._handler.getFile(id).qqButtonId;
+ }
+ else {
+ buttonId = this._getButtonId(this._handler.getInput(id));
+ }
+
+ if (buttonId) {
+ this._buttonIdsForFileIds[id] = buttonId;
+ }
+ },
+
+ _upload: function(id, params, endpoint) {
+ var name = this.getName(id);
+
+ if (params) {
+ this.setParams(params, id);
+ }
+
+ if (endpoint) {
+ this.setEndpoint(endpoint, id);
+ }
+
+ this._handleCheckedCallback({
+ name: "onSubmit",
+ callback: qq.bind(this._options.callbacks.onSubmit, this, id, name),
+ onSuccess: qq.bind(this._onSubmitCallbackSuccess, this, id, name),
+ onFailure: qq.bind(this._fileOrBlobRejected, this, id, name),
+ identifier: id
+ });
+ },
+
+ _uploadFile: function(id) {
+ if (!this._handler.upload(id)) {
+ this._uploadData.setStatus(id, qq.status.QUEUED);
+ }
+ },
+
+ /**
+ * Performs some internal validation checks on an item, defined in the `validation` option.
+ *
+ * @param fileWrapper Wrapper containing a `file` along with an `id`
+ * @param validationDescriptor Normalized information about the item (`size`, `name`).
+ * @returns qq.Promise with appropriate callbacks invoked depending on the validity of the file
+ * @private
+ */
+ _validateFileOrBlobData: function(fileWrapper, validationDescriptor) {
+ var self = this,
+ file = (function() {
+ if (fileWrapper.file instanceof qq.BlobProxy) {
+ return fileWrapper.file.referenceBlob;
+ }
+ return fileWrapper.file;
+ }()),
+ name = validationDescriptor.name,
+ size = validationDescriptor.size,
+ buttonId = this._getButtonId(fileWrapper.file),
+ validationBase = this._getValidationBase(buttonId),
+ validityChecker = new qq.Promise();
+
+ validityChecker.then(
+ function() {},
+ function() {
+ self._fileOrBlobRejected(fileWrapper.id, name);
+ });
+
+ if (qq.isFileOrInput(file) && !this._isAllowedExtension(validationBase.allowedExtensions, name)) {
+ this._itemError("typeError", name, file);
+ return validityChecker.failure();
+ }
+
+ if (size === 0) {
+ this._itemError("emptyError", name, file);
+ return validityChecker.failure();
+ }
+
+ if (size > 0 && validationBase.sizeLimit && size > validationBase.sizeLimit) {
+ this._itemError("sizeError", name, file);
+ return validityChecker.failure();
+ }
+
+ if (size > 0 && size < validationBase.minSizeLimit) {
+ this._itemError("minSizeError", name, file);
+ return validityChecker.failure();
+ }
+
+ if (qq.ImageValidation && qq.supportedFeatures.imagePreviews && qq.isFile(file)) {
+ new qq.ImageValidation(file, qq.bind(self.log, self)).validate(validationBase.image).then(
+ validityChecker.success,
+ function(errorCode) {
+ self._itemError(errorCode + "ImageError", name, file);
+ validityChecker.failure();
+ }
+ );
+ }
+ else {
+ validityChecker.success();
+ }
+
+ return validityChecker;
+ },
+
+ _wrapCallbacks: function() {
+ var self, safeCallback;
+
+ self = this;
+
+ safeCallback = function(name, callback, args) {
+ var errorMsg;
+
+ try {
+ return callback.apply(self, args);
+ }
+ catch (exception) {
+ errorMsg = exception.message || exception.toString();
+ self.log("Caught exception in '" + name + "' callback - " + errorMsg, "error");
+ }
+ };
+
+ /* jshint forin: false, loopfunc: true */
+ for (var prop in this._options.callbacks) {
+ (function() {
+ var callbackName, callbackFunc;
+ callbackName = prop;
+ callbackFunc = self._options.callbacks[callbackName];
+ self._options.callbacks[callbackName] = function() {
+ return safeCallback(callbackName, callbackFunc, arguments);
+ };
+ }());
+ }
+ }
+ };
+}());
+
+/*globals qq*/
+(function(){
+ "use strict";
+
+ qq.FineUploaderBasic = function(o) {
+ var self = this;
+
+ // These options define FineUploaderBasic mode.
+ this._options = {
+ debug: false,
+ button: null,
+ multiple: true,
+ maxConnections: 3,
+ disableCancelForFormUploads: false,
+ autoUpload: true,
+
+ request: {
+ endpoint: "/server/upload",
+ params: {},
+ paramsInBody: true,
+ customHeaders: {},
+ forceMultipart: true,
+ inputName: "qqfile",
+ uuidName: "qquuid",
+ totalFileSizeName: "qqtotalfilesize",
+ filenameParam: "qqfilename"
+ },
+
+ validation: {
+ allowedExtensions: [],
+ sizeLimit: 0,
+ minSizeLimit: 0,
+ itemLimit: 0,
+ stopOnFirstInvalidFile: true,
+ acceptFiles: null,
+ image: {
+ maxHeight: 0,
+ maxWidth: 0,
+ minHeight: 0,
+ minWidth: 0
+ }
+ },
+
+ callbacks: {
+ onSubmit: function(id, name){},
+ onSubmitted: function(id, name){},
+ onComplete: function(id, name, responseJSON, maybeXhr){},
+ onAllComplete: function(successful, failed) {},
+ onCancel: function(id, name){},
+ onUpload: function(id, name){},
+ onUploadChunk: function(id, name, chunkData){},
+ onUploadChunkSuccess: function(id, chunkData, responseJSON, xhr){},
+ onResume: function(id, fileName, chunkData){},
+ onProgress: function(id, name, loaded, total){},
+ onTotalProgress: function(loaded, total){},
+ onError: function(id, name, reason, maybeXhrOrXdr) {},
+ onAutoRetry: function(id, name, attemptNumber) {},
+ onManualRetry: function(id, name) {},
+ onValidateBatch: function(fileOrBlobData) {},
+ onValidate: function(fileOrBlobData) {},
+ onSubmitDelete: function(id) {},
+ onDelete: function(id){},
+ onDeleteComplete: function(id, xhrOrXdr, isError){},
+ onPasteReceived: function(blob) {},
+ onStatusChange: function(id, oldStatus, newStatus) {},
+ onSessionRequestComplete: function(response, success, xhrOrXdr) {}
+ },
+
+ messages: {
+ typeError: "{file} has an invalid extension. Valid extension(s): {extensions}.",
+ sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
+ minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
+ emptyError: "{file} is empty, please select files again without it.",
+ noFilesError: "No files to upload.",
+ tooManyItemsError: "Too many items ({netItems}) would be uploaded. Item limit is {itemLimit}.",
+ maxHeightImageError: "Image is too tall.",
+ maxWidthImageError: "Image is too wide.",
+ minHeightImageError: "Image is not tall enough.",
+ minWidthImageError: "Image is not wide enough.",
+ retryFailTooManyItems: "Retry failed - you have reached your file limit.",
+ onLeave: "The files are being uploaded, if you leave now the upload will be canceled."
+ },
+
+ retry: {
+ enableAuto: false,
+ maxAutoAttempts: 3,
+ autoAttemptDelay: 5,
+ preventRetryResponseProperty: "preventRetry"
+ },
+
+ classes: {
+ buttonHover: "qq-upload-button-hover",
+ buttonFocus: "qq-upload-button-focus"
+ },
+
+ chunking: {
+ enabled: false,
+ concurrent: {
+ enabled: false
+ },
+ paramNames: {
+ partIndex: "qqpartindex",
+ partByteOffset: "qqpartbyteoffset",
+ chunkSize: "qqchunksize",
+ totalFileSize: "qqtotalfilesize",
+ totalParts: "qqtotalparts"
+ },
+ partSize: 2000000,
+ // only relevant for traditional endpoints, only required when concurrent.enabled === true
+ success: {
+ endpoint: null
+ }
+ },
+
+ resume: {
+ enabled: false,
+ recordsExpireIn: 7, //days
+ paramNames: {
+ resuming: "qqresume"
+ }
+ },
+
+ formatFileName: function(fileOrBlobName) {
+ if (fileOrBlobName !== undefined && fileOrBlobName.length > 33) {
+ fileOrBlobName = fileOrBlobName.slice(0, 19) + "..." + fileOrBlobName.slice(-14);
+ }
+ return fileOrBlobName;
+ },
+
+ text: {
+ defaultResponseError: "Upload failure reason unknown",
+ sizeSymbols: ["kB", "MB", "GB", "TB", "PB", "EB"]
+ },
+
+ deleteFile : {
+ enabled: false,
+ method: "DELETE",
+ endpoint: "/server/upload",
+ customHeaders: {},
+ params: {}
+ },
+
+ cors: {
+ expected: false,
+ sendCredentials: false,
+ allowXdr: false
+ },
+
+ blobs: {
+ defaultName: "misc_data"
+ },
+
+ paste: {
+ targetElement: null,
+ defaultName: "pasted_image"
+ },
+
+ camera: {
+ ios: false,
+
+ // if ios is true: button is null means target the default button, otherwise target the button specified
+ button: null
+ },
+
+ // This refers to additional upload buttons to be handled by Fine Uploader.
+ // Each element is an object, containing `element` as the only required
+ // property. The `element` must be a container that will ultimately
+ // contain an invisible ` ` created by Fine Uploader.
+ // Optional properties of each object include `multiple`, `validation`,
+ // and `folders`.
+ extraButtons: [],
+
+ // Depends on the session module. Used to query the server for an initial file list
+ // during initialization and optionally after a `reset`.
+ session: {
+ endpoint: null,
+ params: {},
+ customHeaders: {},
+ refreshOnReset: true
+ },
+
+ // Send parameters associated with an existing form along with the files
+ form: {
+ // Element ID, HTMLElement, or null
+ element: "qq-form",
+
+ // Overrides the base `autoUpload`, unless `element` is null.
+ autoUpload: false,
+
+ // true = upload files on form submission (and squelch submit event)
+ interceptSubmit: true
+ },
+
+ // scale images client side, upload a new file for each scaled version
+ scaling: {
+ // send the original file as well
+ sendOriginal: true,
+
+ // fox orientation for scaled images
+ orient: true,
+
+ // If null, scaled image type will match reference image type. This value will be referred to
+ // for any size record that does not specific a type.
+ defaultType: null,
+
+ defaultQuality: 80,
+
+ failureText: "Failed to scale",
+
+ includeExif: false,
+
+ // metadata about each requested scaled version
+ sizes: []
+ }
+ };
+
+ // Replace any default options with user defined ones
+ qq.extend(this._options, o, true);
+
+ this._buttons = [];
+ this._extraButtonSpecs = {};
+ this._buttonIdsForFileIds = [];
+
+ this._wrapCallbacks();
+ this._disposeSupport = new qq.DisposeSupport();
+
+ this._storedIds = [];
+ this._autoRetries = [];
+ this._retryTimeouts = [];
+ this._preventRetries = [];
+ this._thumbnailUrls = [];
+
+ this._netUploadedOrQueued = 0;
+ this._netUploaded = 0;
+ this._uploadData = this._createUploadDataTracker();
+
+ this._initFormSupportAndParams();
+
+ this._customHeadersStore = this._createStore(this._options.request.customHeaders);
+ this._deleteFileCustomHeadersStore = this._createStore(this._options.deleteFile.customHeaders);
+
+ this._deleteFileParamsStore = this._createStore(this._options.deleteFile.params);
+
+ this._endpointStore = this._createStore(this._options.request.endpoint);
+ this._deleteFileEndpointStore = this._createStore(this._options.deleteFile.endpoint);
+
+ this._handler = this._createUploadHandler();
+
+ this._deleteHandler = qq.DeleteFileAjaxRequester && this._createDeleteHandler();
+
+ if (this._options.button) {
+ this._defaultButtonId = this._createUploadButton({element: this._options.button}).getButtonId();
+ }
+
+ this._generateExtraButtonSpecs();
+
+ this._handleCameraAccess();
+
+ if (this._options.paste.targetElement) {
+ if (qq.PasteSupport) {
+ this._pasteHandler = this._createPasteHandler();
+ }
+ else {
+ this.log("Paste support module not found", "error");
+ }
+ }
+
+ this._preventLeaveInProgress();
+
+ this._imageGenerator = qq.ImageGenerator && new qq.ImageGenerator(qq.bind(this.log, this));
+ this._refreshSessionData();
+
+ this._succeededSinceLastAllComplete = [];
+ this._failedSinceLastAllComplete = [];
+
+ this._scaler = (qq.Scaler && new qq.Scaler(this._options.scaling, qq.bind(this.log, this))) || {};
+ if (this._scaler.enabled) {
+ this._customNewFileHandler = qq.bind(this._scaler.handleNewFile, this._scaler);
+ }
+
+ if (qq.TotalProgress && qq.supportedFeatures.progressBar) {
+ this._totalProgress = new qq.TotalProgress(
+ qq.bind(this._onTotalProgress, this),
+
+ function(id) {
+ var entry = self._uploadData.retrieve({id: id});
+ return (entry && entry.size) || 0;
+ }
+ );
+ }
+ };
+
+ // Define the private & public API methods.
+ qq.FineUploaderBasic.prototype = qq.basePublicApi;
+ qq.extend(qq.FineUploaderBasic.prototype, qq.basePrivateApi);
+}());
+
+/*globals qq, XDomainRequest*/
+/** Generic class for sending non-upload ajax requests and handling the associated responses **/
+qq.AjaxRequester = function (o) {
+ "use strict";
+
+ var log, shouldParamsBeInQueryString,
+ queue = [],
+ requestData = {},
+ options = {
+ acceptHeader: null,
+ validMethods: ["POST"],
+ method: "POST",
+ contentType: "application/x-www-form-urlencoded",
+ maxConnections: 3,
+ customHeaders: {},
+ endpointStore: {},
+ paramsStore: {},
+ mandatedParams: {},
+ allowXRequestedWithAndCacheControl: true,
+ successfulResponseCodes: {
+ "DELETE": [200, 202, 204],
+ "POST": [200, 204],
+ "GET": [200]
+ },
+ cors: {
+ expected: false,
+ sendCredentials: false
+ },
+ log: function (str, level) {},
+ onSend: function (id) {},
+ onComplete: function (id, xhrOrXdr, isError) {},
+ onProgress: null
+ };
+
+ qq.extend(options, o);
+ log = options.log;
+
+ if (qq.indexOf(options.validMethods, options.method) < 0) {
+ throw new Error("'" + options.method + "' is not a supported method for this type of request!");
+ }
+
+ // [Simple methods](http://www.w3.org/TR/cors/#simple-method)
+ // are defined by the W3C in the CORS spec as a list of methods that, in part,
+ // make a CORS request eligible to be exempt from preflighting.
+ function isSimpleMethod() {
+ return qq.indexOf(["GET", "POST", "HEAD"], options.method) >= 0;
+ }
+
+ // [Simple headers](http://www.w3.org/TR/cors/#simple-header)
+ // are defined by the W3C in the CORS spec as a list of headers that, in part,
+ // make a CORS request eligible to be exempt from preflighting.
+ function containsNonSimpleHeaders(headers) {
+ var containsNonSimple = false;
+
+ qq.each(containsNonSimple, function(idx, header) {
+ if (qq.indexOf(["Accept", "Accept-Language", "Content-Language", "Content-Type"], header) < 0) {
+ containsNonSimple = true;
+ return false;
+ }
+ });
+
+ return containsNonSimple;
+ }
+
+ function isXdr(xhr) {
+ //The `withCredentials` test is a commonly accepted way to determine if XHR supports CORS.
+ return options.cors.expected && xhr.withCredentials === undefined;
+ }
+
+ // Returns either a new `XMLHttpRequest` or `XDomainRequest` instance.
+ function getCorsAjaxTransport() {
+ var xhrOrXdr;
+
+ if (window.XMLHttpRequest || window.ActiveXObject) {
+ xhrOrXdr = qq.createXhrInstance();
+
+ if (xhrOrXdr.withCredentials === undefined) {
+ xhrOrXdr = new XDomainRequest();
+ }
+ }
+
+ return xhrOrXdr;
+ }
+
+ // Returns either a new XHR/XDR instance, or an existing one for the associated `File` or `Blob`.
+ function getXhrOrXdr(id, suppliedXhr) {
+ var xhrOrXdr = requestData[id].xhr;
+
+ if (!xhrOrXdr) {
+ if (suppliedXhr) {
+ xhrOrXdr = suppliedXhr;
+ }
+ else {
+ if (options.cors.expected) {
+ xhrOrXdr = getCorsAjaxTransport();
+ }
+ else {
+ xhrOrXdr = qq.createXhrInstance();
+ }
+ }
+
+ requestData[id].xhr = xhrOrXdr;
+ }
+
+ return xhrOrXdr;
+ }
+
+ // Removes element from queue, sends next request
+ function dequeue(id) {
+ var i = qq.indexOf(queue, id),
+ max = options.maxConnections,
+ nextId;
+
+ delete requestData[id];
+ queue.splice(i, 1);
+
+ if (queue.length >= max && i < max) {
+ nextId = queue[max - 1];
+ sendRequest(nextId);
+ }
+ }
+
+ function onComplete(id, xdrError) {
+ var xhr = getXhrOrXdr(id),
+ method = options.method,
+ isError = xdrError === true;
+
+ dequeue(id);
+
+ if (isError) {
+ log(method + " request for " + id + " has failed", "error");
+ }
+ else if (!isXdr(xhr) && !isResponseSuccessful(xhr.status)) {
+ isError = true;
+ log(method + " request for " + id + " has failed - response code " + xhr.status, "error");
+ }
+
+ options.onComplete(id, xhr, isError);
+ }
+
+ function getParams(id) {
+ var onDemandParams = requestData[id].additionalParams,
+ mandatedParams = options.mandatedParams,
+ params;
+
+ if (options.paramsStore.get) {
+ params = options.paramsStore.get(id);
+ }
+
+ if (onDemandParams) {
+ qq.each(onDemandParams, function (name, val) {
+ params = params || {};
+ params[name] = val;
+ });
+ }
+
+ if (mandatedParams) {
+ qq.each(mandatedParams, function (name, val) {
+ params = params || {};
+ params[name] = val;
+ });
+ }
+
+ return params;
+ }
+
+ function sendRequest(id, opt_xhr) {
+ var xhr = getXhrOrXdr(id, opt_xhr),
+ method = options.method,
+ params = getParams(id),
+ payload = requestData[id].payload,
+ url;
+
+ options.onSend(id);
+
+ url = createUrl(id, params);
+
+ // XDR and XHR status detection APIs differ a bit.
+ if (isXdr(xhr)) {
+ xhr.onload = getXdrLoadHandler(id);
+ xhr.onerror = getXdrErrorHandler(id);
+ }
+ else {
+ xhr.onreadystatechange = getXhrReadyStateChangeHandler(id);
+ }
+
+
+ registerForUploadProgress(id);
+
+ // The last parameter is assumed to be ignored if we are actually using `XDomainRequest`.
+ xhr.open(method, url, true);
+
+ // Instruct the transport to send cookies along with the CORS request,
+ // unless we are using `XDomainRequest`, which is not capable of this.
+ if (options.cors.expected && options.cors.sendCredentials && !isXdr(xhr)) {
+ xhr.withCredentials = true;
+ }
+
+ setHeaders(id);
+
+ log("Sending " + method + " request for " + id);
+
+ if (payload) {
+ xhr.send(payload);
+ }
+ else if (shouldParamsBeInQueryString || !params) {
+ xhr.send();
+ }
+ else if (params && options.contentType && options.contentType.toLowerCase().indexOf("application/x-www-form-urlencoded") >= 0) {
+ xhr.send(qq.obj2url(params, ""));
+ }
+ else if (params && options.contentType && options.contentType.toLowerCase().indexOf("application/json") >= 0) {
+ xhr.send(JSON.stringify(params));
+ }
+ else {
+ xhr.send(params);
+ }
+
+ return xhr;
+ }
+
+ function createUrl(id, params) {
+ var endpoint = options.endpointStore.get(id),
+ addToPath = requestData[id].addToPath;
+
+ /*jshint -W116,-W041 */
+ if (addToPath != undefined) {
+ endpoint += "/" + addToPath;
+ }
+
+ if (shouldParamsBeInQueryString && params) {
+ return qq.obj2url(params, endpoint);
+ }
+ else {
+ return endpoint;
+ }
+ }
+
+ // Invoked by the UA to indicate a number of possible states that describe
+ // a live `XMLHttpRequest` transport.
+ function getXhrReadyStateChangeHandler(id) {
+ return function () {
+ if (getXhrOrXdr(id).readyState === 4) {
+ onComplete(id);
+ }
+ };
+ }
+
+ function registerForUploadProgress(id) {
+ var onProgress = options.onProgress;
+
+ if (onProgress) {
+ getXhrOrXdr(id).upload.onprogress = function(e) {
+ if (e.lengthComputable) {
+ onProgress(id, e.loaded, e.total);
+ }
+ };
+ }
+ }
+
+ // This will be called by IE to indicate **success** for an associated
+ // `XDomainRequest` transported request.
+ function getXdrLoadHandler(id) {
+ return function () {
+ onComplete(id);
+ };
+ }
+
+ // This will be called by IE to indicate **failure** for an associated
+ // `XDomainRequest` transported request.
+ function getXdrErrorHandler(id) {
+ return function () {
+ onComplete(id, true);
+ };
+ }
+
+ function setHeaders(id) {
+ var xhr = getXhrOrXdr(id),
+ customHeaders = options.customHeaders,
+ onDemandHeaders = requestData[id].additionalHeaders || {},
+ method = options.method,
+ allHeaders = {};
+
+ // If XDomainRequest is being used, we can't set headers, so just ignore this block.
+ if (!isXdr(xhr)) {
+ options.acceptHeader && xhr.setRequestHeader("Accept", options.acceptHeader);
+
+ // Only attempt to add X-Requested-With & Cache-Control if permitted
+ if (options.allowXRequestedWithAndCacheControl) {
+ // Do not add X-Requested-With & Cache-Control if this is a cross-origin request
+ // OR the cross-origin request contains a non-simple method or header.
+ // This is done to ensure a preflight is not triggered exclusively based on the
+ // addition of these 2 non-simple headers.
+ if (!options.cors.expected || (!isSimpleMethod() || containsNonSimpleHeaders(customHeaders))) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ xhr.setRequestHeader("Cache-Control", "no-cache");
+ }
+ }
+
+ if (options.contentType && (method === "POST" || method === "PUT")) {
+ xhr.setRequestHeader("Content-Type", options.contentType);
+ }
+
+ qq.extend(allHeaders, qq.isFunction(customHeaders) ? customHeaders(id) : customHeaders);
+ qq.extend(allHeaders, onDemandHeaders);
+
+ qq.each(allHeaders, function (name, val) {
+ xhr.setRequestHeader(name, val);
+ });
+ }
+ }
+
+ function isResponseSuccessful(responseCode) {
+ return qq.indexOf(options.successfulResponseCodes[options.method], responseCode) >= 0;
+ }
+
+ function prepareToSend(id, opt_xhr, addToPath, additionalParams, additionalHeaders, payload) {
+ requestData[id] = {
+ addToPath: addToPath,
+ additionalParams: additionalParams,
+ additionalHeaders: additionalHeaders,
+ payload: payload
+ };
+
+ var len = queue.push(id);
+
+ // if too many active connections, wait...
+ if (len <= options.maxConnections) {
+ return sendRequest(id, opt_xhr);
+ }
+ }
+
+
+ shouldParamsBeInQueryString = options.method === "GET" || options.method === "DELETE";
+
+ qq.extend(this, {
+ // Start the process of sending the request. The ID refers to the file associated with the request.
+ initTransport: function(id) {
+ var path, params, headers, payload, cacheBuster;
+
+ return {
+ // Optionally specify the end of the endpoint path for the request.
+ withPath: function(appendToPath) {
+ path = appendToPath;
+ return this;
+ },
+
+ // Optionally specify additional parameters to send along with the request.
+ // These will be added to the query string for GET/DELETE requests or the payload
+ // for POST/PUT requests. The Content-Type of the request will be used to determine
+ // how these parameters should be formatted as well.
+ withParams: function(additionalParams) {
+ params = additionalParams;
+ return this;
+ },
+
+ // Optionally specify additional headers to send along with the request.
+ withHeaders: function(additionalHeaders) {
+ headers = additionalHeaders;
+ return this;
+ },
+
+ // Optionally specify a payload/body for the request.
+ withPayload: function(thePayload) {
+ payload = thePayload;
+ return this;
+ },
+
+ // Appends a cache buster (timestamp) to the request URL as a query parameter (only if GET or DELETE)
+ withCacheBuster: function() {
+ cacheBuster = true;
+ return this;
+ },
+
+ // Send the constructed request.
+ send: function(opt_xhr) {
+ if (cacheBuster && qq.indexOf(["GET", "DELETE"], options.method) >= 0) {
+ params.qqtimestamp = new Date().getTime();
+ }
+
+ return prepareToSend(id, opt_xhr, path, params, headers, payload);
+ }
+ };
+ },
+
+ canceled: function(id) {
+ dequeue(id);
+ }
+ });
+};
+
+/* globals qq */
+/**
+ * Common upload handler functions.
+ *
+ * @constructor
+ */
+qq.UploadHandler = function(spec) {
+ "use strict";
+
+ var proxy = spec.proxy,
+ fileState = {},
+ onCancel = proxy.onCancel,
+ getName = proxy.getName;
+
+
+ qq.extend(this, {
+ add: function(id, fileItem) {
+ fileState[id] = fileItem;
+ fileState[id].temp = {};
+ },
+
+ cancel: function(id) {
+ var self = this,
+ cancelFinalizationEffort = new qq.Promise(),
+ onCancelRetVal = onCancel(id, getName(id), cancelFinalizationEffort);
+
+ onCancelRetVal.then(function() {
+ if (self.isValid(id)) {
+ fileState[id].canceled = true;
+ self.expunge(id);
+ }
+ cancelFinalizationEffort.success();
+ });
+ },
+
+ expunge: function(id) {
+ delete fileState[id];
+ },
+
+ getThirdPartyFileId: function(id) {
+ return fileState[id].key;
+ },
+
+ isValid: function(id) {
+ return fileState[id] !== undefined;
+ },
+
+ reset: function() {
+ fileState = {};
+ },
+
+ _getFileState: function(id) {
+ return fileState[id];
+ },
+
+ _setThirdPartyFileId: function(id, thirdPartyFileId) {
+ fileState[id].key = thirdPartyFileId;
+ },
+
+ _wasCanceled: function(id) {
+ return !!fileState[id].canceled;
+ }
+ });
+};
+
+/*globals qq*/
+/**
+ * Base upload handler module. Controls more specific handlers.
+ *
+ * @param o Options. Passed along to the specific handler submodule as well.
+ * @param namespace [optional] Namespace for the specific handler.
+ */
+qq.UploadHandlerController = function(o, namespace) {
+ "use strict";
+
+ var controller = this,
+ chunkingPossible = false,
+ concurrentChunkingPossible = false,
+ chunking, preventRetryResponse, log, handler,
+
+ options = {
+ paramsStore: {},
+ maxConnections: 3, // maximum number of concurrent uploads
+ chunking: {
+ enabled: false,
+ multiple: {
+ enabled: false
+ }
+ },
+ log: function(str, level) {},
+ onProgress: function(id, fileName, loaded, total){},
+ onComplete: function(id, fileName, response, xhr){},
+ onCancel: function(id, fileName){},
+ onUploadPrep: function(id){}, // Called if non-trivial operations will be performed before onUpload
+ onUpload: function(id, fileName){},
+ onUploadChunk: function(id, fileName, chunkData){},
+ onUploadChunkSuccess: function(id, chunkData, response, xhr){},
+ onAutoRetry: function(id, fileName, response, xhr){},
+ onResume: function(id, fileName, chunkData){},
+ onUuidChanged: function(id, newUuid){},
+ getName: function(id) {},
+ setSize: function(id, newSize) {},
+ isQueued: function(id) {},
+ getIdsInProxyGroup: function(id) {},
+ getIdsInBatch: function(id) {}
+ },
+
+
+ chunked = {
+ // Called when each chunk has uploaded successfully
+ done: function(id, chunkIdx, response, xhr) {
+ var chunkData = handler._getChunkData(id, chunkIdx);
+
+ handler._getFileState(id).attemptingResume = false;
+
+ delete handler._getFileState(id).temp.chunkProgress[chunkIdx];
+ handler._getFileState(id).loaded += chunkData.size;
+
+ options.onUploadChunkSuccess(id, handler._getChunkDataForCallback(chunkData), response, xhr);
+ },
+
+ // Called when all chunks have been successfully uploaded and we want to ask the handler to perform any
+ // logic associated with closing out the file, such as combining the chunks.
+ finalize: function(id) {
+ var size = options.getSize(id),
+ name = options.getName(id);
+
+ log("All chunks have been uploaded for " + id + " - finalizing....");
+ handler.finalizeChunks(id).then(
+ function(response, xhr) {
+ log("Finalize successful for " + id);
+
+ var normaizedResponse = upload.normalizeResponse(response, true);
+
+ options.onProgress(id, name, size, size);
+ handler._maybeDeletePersistedChunkData(id);
+ upload.cleanup(id, normaizedResponse, xhr);
+ },
+ function(response, xhr) {
+ var normaizedResponse = upload.normalizeResponse(response, false);
+
+ log("Problem finalizing chunks for file ID " + id + " - " + normaizedResponse.error, "error");
+
+ if (normaizedResponse.reset) {
+ chunked.reset(id);
+ }
+
+ if (!options.onAutoRetry(id, name, normaizedResponse, xhr)) {
+ upload.cleanup(id, normaizedResponse, xhr);
+ }
+ }
+ );
+ },
+
+ hasMoreParts: function(id) {
+ return !!handler._getFileState(id).chunking.remaining.length;
+ },
+
+ nextPart: function(id) {
+ var nextIdx = handler._getFileState(id).chunking.remaining.shift();
+
+ if (nextIdx >= handler._getTotalChunks(id)) {
+ nextIdx = null;
+ }
+
+ return nextIdx;
+ },
+
+ reset: function(id) {
+ log("Server or callback has ordered chunking effort to be restarted on next attempt for item ID " + id, "error");
+
+ handler._maybeDeletePersistedChunkData(id);
+ handler.reevaluateChunking(id);
+ handler._getFileState(id).loaded = 0;
+ },
+
+ sendNext: function(id) {
+ var size = options.getSize(id),
+ name = options.getName(id),
+ chunkIdx = chunked.nextPart(id),
+ chunkData = handler._getChunkData(id, chunkIdx),
+ resuming = handler._getFileState(id).attemptingResume,
+ inProgressChunks = handler._getFileState(id).chunking.inProgress || [];
+
+ if (handler._getFileState(id).loaded == null) {
+ handler._getFileState(id).loaded = 0;
+ }
+
+ // Don't follow-through with the resume attempt if the integrator returns false from onResume
+ if (resuming && options.onResume(id, name, chunkData) === false) {
+ chunked.reset(id);
+ chunkIdx = chunked.nextPart(id);
+ chunkData = handler._getChunkData(id, chunkIdx);
+ resuming = false;
+ }
+
+ // If all chunks have already uploaded successfully, we must be re-attempting the finalize step.
+ if (chunkIdx == null && inProgressChunks.length === 0) {
+ chunked.finalize(id);
+ }
+
+ // Send the next chunk
+ else {
+ log("Sending chunked upload request for item " + id + ": bytes " + (chunkData.start+1) + "-" + chunkData.end + " of " + size);
+ options.onUploadChunk(id, name, handler._getChunkDataForCallback(chunkData));
+
+ inProgressChunks.push(chunkIdx);
+ handler._getFileState(id).chunking.inProgress = inProgressChunks;
+
+ if (concurrentChunkingPossible) {
+ connectionManager.open(id, chunkIdx);
+ }
+
+ if (concurrentChunkingPossible && connectionManager.available() && handler._getFileState(id).chunking.remaining.length) {
+ chunked.sendNext(id);
+ }
+
+ handler.uploadChunk(id, chunkIdx, resuming).then(
+ // upload chunk success
+ function success(response, xhr) {
+ log("Chunked upload request succeeded for " + id + ", chunk " + chunkIdx);
+
+ handler.clearCachedChunk(id, chunkIdx);
+
+ var inProgressChunks = handler._getFileState(id).chunking.inProgress || [],
+ responseToReport = upload.normalizeResponse(response, true),
+ inProgressChunkIdx = qq.indexOf(inProgressChunks, chunkIdx);
+
+ log(qq.format("Chunk {} for file {} uploaded successfully.", chunkIdx, id));
+
+ chunked.done(id, chunkIdx, responseToReport, xhr);
+
+ if (inProgressChunkIdx >= 0) {
+ inProgressChunks.splice(inProgressChunkIdx, 1);
+ }
+
+ handler._maybePersistChunkedState(id);
+
+ if (!chunked.hasMoreParts(id) && inProgressChunks.length === 0) {
+ chunked.finalize(id);
+ }
+ else if (chunked.hasMoreParts(id)) {
+ chunked.sendNext(id);
+ }
+ },
+
+ // upload chunk failure
+ function failure(response, xhr) {
+ log("Chunked upload request failed for " + id + ", chunk " + chunkIdx);
+
+ handler.clearCachedChunk(id, chunkIdx);
+
+ var responseToReport = upload.normalizeResponse(response, false);
+
+ if (responseToReport.reset) {
+ chunked.reset(id);
+ }
+ else {
+ var inProgressIdx = qq.indexOf(handler._getFileState(id).chunking.inProgress, chunkIdx);
+ if (inProgressIdx >= 0) {
+ handler._getFileState(id).chunking.inProgress.splice(inProgressIdx, 1);
+ handler._getFileState(id).chunking.remaining.unshift(chunkIdx);
+ }
+ }
+
+ // We may have aborted all other in-progress chunks for this file due to a failure.
+ // If so, ignore the failures associated with those aborts.
+ if (!handler._getFileState(id).temp.ignoreFailure) {
+ // If this chunk has failed, we want to ignore all other failures of currently in-progress
+ // chunks since they will be explicitly aborted
+ if (concurrentChunkingPossible) {
+ handler._getFileState(id).temp.ignoreFailure = true;
+
+ qq.each(handler._getXhrs(id), function(ckid, ckXhr) {
+ ckXhr.abort();
+ });
+
+ // We must indicate that all aborted chunks are no longer in progress
+ handler.moveInProgressToRemaining(id);
+
+ // Free up any connections used by these chunks, but don't allow any
+ // other files to take up the connections (until we have exhausted all auto-retries)
+ connectionManager.free(id, true);
+ }
+
+ if (!options.onAutoRetry(id, name, responseToReport, xhr)) {
+ // If one chunk fails, abort all of the others to avoid odd race conditions that occur
+ // if a chunk succeeds immediately after one fails before we have determined if the upload
+ // is a failure or not.
+ upload.cleanup(id, responseToReport, xhr);
+ }
+ }
+ }
+ )
+ .done(function() {
+ handler.clearXhr(id, chunkIdx);
+ }) ;
+ }
+ }
+ },
+
+ connectionManager = {
+ _open: [],
+ _openChunks: {},
+ _waiting: [],
+
+ available: function() {
+ var max = options.maxConnections,
+ openChunkEntriesCount = 0,
+ openChunksCount = 0;
+
+ qq.each(connectionManager._openChunks, function(fileId, openChunkIndexes) {
+ openChunkEntriesCount++;
+ openChunksCount += openChunkIndexes.length;
+ });
+
+ return max - (connectionManager._open.length - openChunkEntriesCount + openChunksCount);
+ },
+
+ /**
+ * Removes element from queue, starts upload of next
+ */
+ free: function(id, dontAllowNext) {
+ var allowNext = !dontAllowNext,
+ waitingIndex = qq.indexOf(connectionManager._waiting, id),
+ connectionsIndex = qq.indexOf(connectionManager._open, id),
+ nextId;
+
+ delete connectionManager._openChunks[id];
+
+ if (upload.getProxyOrBlob(id) instanceof qq.BlobProxy) {
+ log("Generated blob upload has ended for " + id + ", disposing generated blob.");
+ delete handler._getFileState(id).file;
+ }
+
+ // If this file was not consuming a connection, it was just waiting, so remove it from the waiting array
+ if (waitingIndex >= 0) {
+ connectionManager._waiting.splice(waitingIndex, 1);
+ }
+ // If this file was consuming a connection, allow the next file to be uploaded
+ else if (allowNext && connectionsIndex >= 0) {
+ connectionManager._open.splice(connectionsIndex, 1);
+
+ nextId = connectionManager._waiting.shift();
+ if (nextId >= 0) {
+ connectionManager._open.push(nextId);
+ upload.start(nextId);
+ }
+ }
+ },
+
+ getWaitingOrConnected: function() {
+ var waitingOrConnected = [];
+
+ qq.each(waitingOrConnected, connectionManager._open);
+ return qq.each(waitingOrConnected, connectionManager._waiting);
+ },
+
+ isUsingConnection: function(id) {
+ return qq.indexOf(connectionManager._open, id) >= 0;
+ },
+
+ open: function(id, chunkIdx) {
+ if (chunkIdx == null) {
+ connectionManager._waiting.push(id);
+ }
+
+ if (connectionManager.available()) {
+ if (chunkIdx == null) {
+ connectionManager._waiting.pop();
+ connectionManager._open.push(id);
+ }
+ else {
+ (function() {
+ var openChunksEntry = connectionManager._openChunks[id] || [];
+ openChunksEntry.push(chunkIdx);
+ connectionManager._openChunks[id] = openChunksEntry;
+ }());
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ reset: function() {
+ connectionManager._waiting = [];
+ connectionManager._open = [];
+ }
+ },
+
+ simple = {
+ send: function(id, name) {
+ handler._getFileState(id).loaded = 0;
+
+ log("Sending simple upload request for " + id);
+ handler.uploadFile(id).then(
+ function(response, opt_xhr) {
+ log("Simple upload request succeeded for " + id);
+
+ var responseToReport = upload.normalizeResponse(response, true);
+
+ var size = options.getSize(id);
+
+ options.onProgress(id, name, size, size);
+ upload.maybeNewUuid(id, responseToReport);
+ upload.cleanup(id, responseToReport, opt_xhr);
+ },
+
+ function(response, opt_xhr) {
+ log("Simple upload request failed for " + id);
+
+ var responseToReport = upload.normalizeResponse(response, false);
+
+ if (!options.onAutoRetry(id, name, responseToReport, opt_xhr)) {
+ upload.cleanup(id, responseToReport, opt_xhr);
+ }
+ }
+ );
+ }
+ },
+
+
+ upload = {
+ cancel: function(id) {
+ log("Cancelling " + id);
+ options.paramsStore.remove(id);
+ connectionManager.free(id);
+ },
+
+ cleanup: function(id, response, opt_xhr) {
+ var name = options.getName(id);
+
+ options.onComplete(id, name, response, opt_xhr);
+
+ if (handler._getFileState(id)) {
+ handler._clearXhrs && handler._clearXhrs(id);
+ }
+
+ connectionManager.free(id);
+ },
+
+ // Returns a qq.BlobProxy, or an actual File/Blob if no proxy is involved, or undefined
+ // if none of these are available for the ID
+ getProxyOrBlob: function(id) {
+ return (handler.getProxy && handler.getProxy(id)) ||
+ (handler.getFile && handler.getFile(id));
+ },
+
+ initHandler: function() {
+ var handlerType = namespace ? qq[namespace] : qq.traditional,
+ handlerModuleSubtype = qq.supportedFeatures.ajaxUploading ? "Xhr" : "Form";
+
+ handler = new handlerType[handlerModuleSubtype + "UploadHandler"](
+ options,
+ {
+ getDataByUuid: options.getDataByUuid,
+ getName: options.getName,
+ getSize: options.getSize,
+ getUuid: options.getUuid,
+ log: log,
+ onCancel: options.onCancel,
+ onProgress: options.onProgress,
+ onUuidChanged: options.onUuidChanged
+ }
+ );
+
+ if (handler._removeExpiredChunkingRecords) {
+ handler._removeExpiredChunkingRecords();
+ }
+ },
+
+ isDeferredEligibleForUpload: function(id) {
+ return options.isQueued(id);
+ },
+
+ // For Blobs that are part of a group of generated images, along with a reference image,
+ // this will ensure the blobs in the group are uploaded in the order they were triggered,
+ // even if some async processing must be completed on one or more Blobs first.
+ maybeDefer: function(id, blob) {
+ // If we don't have a file/blob yet & no file/blob exists for this item, request it,
+ // and then submit the upload to the specific handler once the blob is available.
+ // ASSUMPTION: This condition will only ever be true if XHR uploading is supported.
+ if (blob && !handler.getFile(id) && blob instanceof qq.BlobProxy) {
+
+ // Blob creation may take some time, so the caller may want to update the
+ // UI to indicate that an operation is in progress, even before the actual
+ // upload begins and an onUpload callback is invoked.
+ options.onUploadPrep(id);
+
+ log("Attempting to generate a blob on-demand for " + id);
+ blob.create().then(function(generatedBlob) {
+ log("Generated an on-demand blob for " + id);
+
+ // Update record associated with this file by providing the generated Blob
+ handler.updateBlob(id, generatedBlob);
+
+ // Propagate the size for this generated Blob
+ options.setSize(id, generatedBlob.size);
+
+ // Order handler to recalculate chunking possibility, if applicable
+ handler.reevaluateChunking(id);
+
+ upload.maybeSendDeferredFiles(id);
+ },
+
+ // Blob could not be generated. Fail the upload & attempt to prevent retries. Also bubble error message.
+ function(errorMessage) {
+ var errorResponse = {};
+
+ if (errorMessage) {
+ errorResponse.error = errorMessage;
+ }
+
+ log(qq.format("Failed to generate blob for ID {}. Error message: {}.", id, errorMessage), "error");
+
+ options.onComplete(id, options.getName(id), qq.extend(errorResponse, preventRetryResponse), null);
+ upload.maybeSendDeferredFiles(id);
+ connectionManager.free(id);
+ });
+ }
+ else {
+ return upload.maybeSendDeferredFiles(id);
+ }
+
+ return false;
+ },
+
+ // Upload any grouped blobs, in the proper order, that are ready to be uploaded
+ maybeSendDeferredFiles: function(id) {
+ var idsInGroup = options.getIdsInProxyGroup(id),
+ uploadedThisId = false;
+
+ if (idsInGroup && idsInGroup.length) {
+ log("Maybe ready to upload proxy group file " + id);
+
+ qq.each(idsInGroup, function(idx, idInGroup) {
+ if (upload.isDeferredEligibleForUpload(idInGroup) && !!handler.getFile(idInGroup)) {
+ uploadedThisId = idInGroup === id;
+ upload.now(idInGroup);
+ }
+ else if (upload.isDeferredEligibleForUpload(idInGroup)) {
+ return false;
+ }
+ });
+ }
+ else {
+ uploadedThisId = true;
+ upload.now(id);
+ }
+
+ return uploadedThisId;
+ },
+
+ maybeNewUuid: function (id, response) {
+ if (response.newUuid !== undefined) {
+ options.onUuidChanged(id, response.newUuid);
+ }
+ },
+
+ // The response coming from handler implementations may be in various formats.
+ // Instead of hoping a promise nested 5 levels deep will always return an object
+ // as its first param, let's just normalize the response here.
+ normalizeResponse: function(originalResponse, successful) {
+ var response = originalResponse;
+
+ // The passed "response" param may not be a response at all.
+ // It could be a string, detailing the error, for example.
+ if (!qq.isObject(originalResponse)) {
+ response = {};
+
+ if (qq.isString(originalResponse) && !successful) {
+ response.error = originalResponse;
+ }
+ }
+
+ response.success = successful;
+
+ return response;
+ },
+
+ now: function(id) {
+ var name = options.getName(id);
+
+ if (!controller.isValid(id)) {
+ throw new qq.Error(id + " is not a valid file ID to upload!");
+ }
+
+ options.onUpload(id, name);
+
+ if (chunkingPossible && handler._shouldChunkThisFile(id)) {
+ chunked.sendNext(id);
+ }
+ else {
+ simple.send(id, name);
+ }
+ },
+
+ start: function(id) {
+ var blobToUpload = upload.getProxyOrBlob(id);
+
+ if (blobToUpload) {
+ return upload.maybeDefer(id, blobToUpload);
+ }
+ else {
+ upload.now(id);
+ return true;
+ }
+ }
+ };
+
+ qq.extend(this, {
+ /**
+ * Adds file or file input to the queue
+ **/
+ add: function(id, file) {
+ handler.add.apply(this, arguments);
+ },
+
+ /**
+ * Sends the file identified by id
+ */
+ upload: function(id) {
+ if(connectionManager.open(id)) {
+ return upload.start(id);
+ }
+ return false;
+ },
+
+ retry: function(id) {
+ // On retry, if concurrent chunking has been enabled, we may have aborted all other in-progress chunks
+ // for a file when encountering a failed chunk upload. We then signaled the controller to ignore
+ // all failures associated with these aborts. We are now retrying, so we don't want to ignore
+ // any more failures at this point.
+ if (concurrentChunkingPossible) {
+ handler._getFileState(id).temp.ignoreFailure = false;
+ }
+
+ // If we are attempting to retry a file that is already consuming a connection, this is likely an auto-retry.
+ // Just go ahead and ask the handler to upload again.
+ if (connectionManager.isUsingConnection(id)) {
+ return upload.start(id);
+ }
+
+ // If we are attempting to retry a file that is not currently consuming a connection,
+ // this is likely a manual retry attempt. We will need to ensure a connection is available
+ // before the retry commences.
+ else {
+ return controller.upload(id);
+ }
+ },
+
+ /**
+ * Cancels file upload by id
+ */
+ cancel: function(id) {
+ var cancelRetVal = handler.cancel(id);
+
+ if (qq.isGenericPromise(cancelRetVal)) {
+ cancelRetVal.then(function() {
+ upload.cancel(id);
+ });
+ }
+ else if (cancelRetVal !== false) {
+ upload.cancel(id);
+ }
+ },
+
+ /**
+ * Cancels all queued or in-progress uploads
+ */
+ cancelAll: function() {
+ var waitingOrConnected = connectionManager.getWaitingOrConnected();
+
+ qq.each(waitingOrConnected, function(idx, fileId) {
+ controller.cancel(fileId);
+ });
+
+ connectionManager.reset();
+ },
+
+ // Returns a File, Blob, or the Blob/File for the reference/parent file if the targeted blob is a proxy.
+ // Undefined if no file record is available.
+ getFile: function(id) {
+ if (handler.getProxy && handler.getProxy(id)) {
+ return handler.getProxy(id).referenceBlob;
+ }
+
+ return handler.getFile && handler.getFile(id);
+ },
+
+ // Returns true if the Blob associated with the ID is related to a proxy s
+ isProxied: function(id) {
+ return !!(handler.getProxy && handler.getProxy(id));
+ },
+
+ getInput: function(id) {
+ if (handler.getInput) {
+ return handler.getInput(id);
+ }
+ },
+
+ reset: function() {
+ log("Resetting upload handler");
+ controller.cancelAll();
+ connectionManager.reset();
+ handler.reset();
+ },
+
+ expunge: function(id) {
+ if (controller.isValid(id)) {
+ return handler.expunge(id);
+ }
+ },
+
+ /**
+ * Determine if the file exists.
+ */
+ isValid: function(id) {
+ return handler.isValid(id);
+ },
+
+ getResumableFilesData: function() {
+ if (handler.getResumableFilesData) {
+ return handler.getResumableFilesData();
+ }
+ return [];
+ },
+
+ /**
+ * This may or may not be implemented, depending on the handler. For handlers where a third-party ID is
+ * available (such as the "key" for Amazon S3), this will return that value. Otherwise, the return value
+ * will be undefined.
+ *
+ * @param id Internal file ID
+ * @returns {*} Some identifier used by a 3rd-party service involved in the upload process
+ */
+ getThirdPartyFileId: function(id) {
+ if (controller.isValid(id)) {
+ return handler.getThirdPartyFileId(id);
+ }
+ },
+
+ /**
+ * Attempts to pause the associated upload if the specific handler supports this and the file is "valid".
+ * @param id ID of the upload/file to pause
+ * @returns {boolean} true if the upload was paused
+ */
+ pause: function(id) {
+ if (controller.isResumable(id) && handler.pause && controller.isValid(id) && handler.pause(id)) {
+ connectionManager.free(id);
+ handler.moveInProgressToRemaining(id);
+ return true;
+ }
+ return false;
+ },
+
+ // True if the file is eligible for pause/resume.
+ isResumable: function(id) {
+ return !!handler.isResumable && handler.isResumable(id);
+ }
+ });
+
+ qq.extend(options, o);
+ log = options.log;
+ chunkingPossible = options.chunking.enabled && qq.supportedFeatures.chunking;
+ concurrentChunkingPossible = chunkingPossible && options.chunking.concurrent.enabled;
+
+ preventRetryResponse = (function() {
+ var response = {};
+
+ response[options.preventRetryParam] = true;
+
+ return response;
+ }());
+
+ upload.initHandler();
+};
+
+/* globals qq */
+/**
+ * Common APIs exposed to creators of upload via form/iframe handlers. This is reused and possibly overridden
+ * in some cases by specific form upload handlers.
+ *
+ * @constructor
+ */
+qq.FormUploadHandler = function(spec) {
+ "use strict";
+
+ var options = spec.options,
+ handler = this,
+ proxy = spec.proxy,
+ formHandlerInstanceId = qq.getUniqueId(),
+ onloadCallbacks = {},
+ detachLoadEvents = {},
+ postMessageCallbackTimers = {},
+ isCors = options.isCors,
+ inputName = options.inputName,
+ getUuid = proxy.getUuid,
+ log = proxy.log,
+ corsMessageReceiver = new qq.WindowReceiveMessage({log: log});
+
+
+ /**
+ * Remove any trace of the file from the handler.
+ *
+ * @param id ID of the associated file
+ */
+ function expungeFile(id) {
+ delete detachLoadEvents[id];
+
+ // If we are dealing with CORS, we might still be waiting for a response from a loaded iframe.
+ // In that case, terminate the timer waiting for a message from the loaded iframe
+ // and stop listening for any more messages coming from this iframe.
+ if (isCors) {
+ clearTimeout(postMessageCallbackTimers[id]);
+ delete postMessageCallbackTimers[id];
+ corsMessageReceiver.stopReceivingMessages(id);
+ }
+
+ var iframe = document.getElementById(handler._getIframeName(id));
+ if (iframe) {
+ // To cancel request set src to something else. We use src="javascript:false;"
+ // because it doesn't trigger ie6 prompt on https
+ /* jshint scripturl:true */
+ iframe.setAttribute("src", "javascript:false;");
+
+ qq(iframe).remove();
+ }
+ }
+
+ /**
+ * @param iframeName `document`-unique Name of the associated iframe
+ * @returns {*} ID of the associated file
+ */
+ function getFileIdForIframeName(iframeName) {
+ return iframeName.split("_")[0];
+ }
+
+ /**
+ * Generates an iframe to be used as a target for upload-related form submits. This also adds the iframe
+ * to the current `document`. Note that the iframe is hidden from view.
+ *
+ * @param name Name of the iframe.
+ * @returns {HTMLIFrameElement} The created iframe
+ */
+ function initIframeForUpload(name) {
+ var iframe = qq.toElement("");
+
+ iframe.setAttribute("id", name);
+
+ iframe.style.display = "none";
+ document.body.appendChild(iframe);
+
+ return iframe;
+ }
+
+ /**
+ * If we are in CORS mode, we must listen for messages (containing the server response) from the associated
+ * iframe, since we cannot directly parse the content of the iframe due to cross-origin restrictions.
+ *
+ * @param iframe Listen for messages on this iframe.
+ * @param callback Invoke this callback with the message from the iframe.
+ */
+ function registerPostMessageCallback(iframe, callback) {
+ var iframeName = iframe.id,
+ fileId = getFileIdForIframeName(iframeName),
+ uuid = getUuid(fileId);
+
+ onloadCallbacks[uuid] = callback;
+
+ // When the iframe has loaded (after the server responds to an upload request)
+ // declare the attempt a failure if we don't receive a valid message shortly after the response comes in.
+ detachLoadEvents[fileId] = qq(iframe).attach("load", function() {
+ if (handler.getInput(fileId)) {
+ log("Received iframe load event for CORS upload request (iframe name " + iframeName + ")");
+
+ postMessageCallbackTimers[iframeName] = setTimeout(function() {
+ var errorMessage = "No valid message received from loaded iframe for iframe name " + iframeName;
+ log(errorMessage, "error");
+ callback({
+ error: errorMessage
+ });
+ }, 1000);
+ }
+ });
+
+ // Listen for messages coming from this iframe. When a message has been received, cancel the timer
+ // that declares the upload a failure if a message is not received within a reasonable amount of time.
+ corsMessageReceiver.receiveMessage(iframeName, function(message) {
+ log("Received the following window message: '" + message + "'");
+ var fileId = getFileIdForIframeName(iframeName),
+ response = handler._parseJsonResponse(fileId, message),
+ uuid = response.uuid,
+ onloadCallback;
+
+ if (uuid && onloadCallbacks[uuid]) {
+ log("Handling response for iframe name " + iframeName);
+ clearTimeout(postMessageCallbackTimers[iframeName]);
+ delete postMessageCallbackTimers[iframeName];
+
+ handler._detachLoadEvent(iframeName);
+
+ onloadCallback = onloadCallbacks[uuid];
+
+ delete onloadCallbacks[uuid];
+ corsMessageReceiver.stopReceivingMessages(iframeName);
+ onloadCallback(response);
+ }
+ else if (!uuid) {
+ log("'" + message + "' does not contain a UUID - ignoring.");
+ }
+ });
+ }
+
+ qq.extend(this, new qq.UploadHandler(spec));
+
+ qq.override(this, function(super_) {
+ return {
+ /**
+ * Adds File or Blob to the queue
+ **/
+ add: function(id, fileInput) {
+ super_.add(id, {input: fileInput});
+
+ fileInput.setAttribute("name", inputName);
+
+ // remove file input from DOM
+ if (fileInput.parentNode){
+ qq(fileInput).remove();
+ }
+ },
+
+ expunge: function(id) {
+ expungeFile(id);
+ super_.expunge(id);
+ },
+
+ isValid: function(id) {
+ return super_.isValid(id) &&
+ handler._getFileState(id).input !== undefined;
+ }
+ };
+ });
+
+ qq.extend(this, {
+ /**
+ * This function either delegates to a more specific message handler if CORS is involved,
+ * or simply registers a callback when the iframe has been loaded that invokes the passed callback
+ * after determining if the content of the iframe is accessible.
+ *
+ * @param iframe Associated iframe
+ * @param callback Callback to invoke after we have determined if the iframe content is accessible.
+ */
+ _attachLoadEvent: function(iframe, callback) {
+ /*jslint eqeq: true*/
+ var responseDescriptor;
+
+ if (isCors) {
+ registerPostMessageCallback(iframe, callback);
+ }
+ else {
+ detachLoadEvents[iframe.id] = qq(iframe).attach("load", function(){
+ log("Received response for " + iframe.id);
+
+ // when we remove iframe from dom
+ // the request stops, but in IE load
+ // event fires
+ if (!iframe.parentNode){
+ return;
+ }
+
+ try {
+ // fixing Opera 10.53
+ if (iframe.contentDocument &&
+ iframe.contentDocument.body &&
+ iframe.contentDocument.body.innerHTML == "false"){
+ // In Opera event is fired second time
+ // when body.innerHTML changed from false
+ // to server response approx. after 1 sec
+ // when we upload file with iframe
+ return;
+ }
+ }
+ catch (error) {
+ //IE may throw an "access is denied" error when attempting to access contentDocument on the iframe in some cases
+ log("Error when attempting to access iframe during handling of upload response (" + error.message + ")", "error");
+ responseDescriptor = {success: false};
+ }
+
+ callback(responseDescriptor);
+ });
+ }
+ },
+
+ /**
+ * Creates an iframe with a specific document-unique name.
+ *
+ * @param id ID of the associated file
+ * @returns {HTMLIFrameElement}
+ */
+ _createIframe: function(id) {
+ var iframeName = handler._getIframeName(id);
+
+ return initIframeForUpload(iframeName);
+ },
+
+ /**
+ * Called when we are no longer interested in being notified when an iframe has loaded.
+ *
+ * @param id Associated file ID
+ */
+ _detachLoadEvent: function(id) {
+ if (detachLoadEvents[id] !== undefined) {
+ detachLoadEvents[id]();
+ delete detachLoadEvents[id];
+ }
+ },
+
+ /**
+ * @param fileId ID of the associated file
+ * @returns {string} The `document`-unique name of the iframe
+ */
+ _getIframeName: function(fileId) {
+ return fileId + "_" + formHandlerInstanceId;
+ },
+
+ getInput: function(id) {
+ return handler._getFileState(id).input;
+ },
+
+ /**
+ * Generates a form element and appends it to the `document`. When the form is submitted, a specific iframe is targeted.
+ * The name of the iframe is passed in as a property of the spec parameter, and must be unique in the `document`. Note
+ * that the form is hidden from view.
+ *
+ * @param spec An object containing various properties to be used when constructing the form. Required properties are
+ * currently: `method`, `endpoint`, `params`, `paramsInBody`, and `targetName`.
+ * @returns {HTMLFormElement} The created form
+ */
+ _initFormForUpload: function(spec) {
+ var method = spec.method,
+ endpoint = spec.endpoint,
+ params = spec.params,
+ paramsInBody = spec.paramsInBody,
+ targetName = spec.targetName,
+ form = qq.toElement(" "),
+ url = endpoint;
+
+ if (paramsInBody) {
+ qq.obj2Inputs(params, form);
+ }
+ else {
+ url = qq.obj2url(params, endpoint);
+ }
+
+ form.setAttribute("action", url);
+ form.setAttribute("target", targetName);
+ form.style.display = "none";
+ document.body.appendChild(form);
+
+ return form;
+ }
+ });
+};
+
+/* globals qq */
+/**
+ * Common API exposed to creators of XHR handlers. This is reused and possibly overriding in some cases by specific
+ * XHR upload handlers.
+ *
+ * @constructor
+ */
+qq.XhrUploadHandler = function(spec) {
+ "use strict";
+
+ var handler = this,
+ namespace = spec.options.namespace,
+ proxy = spec.proxy,
+ chunking = spec.options.chunking,
+ resume = spec.options.resume,
+ chunkFiles = chunking && spec.options.chunking.enabled && qq.supportedFeatures.chunking,
+ resumeEnabled = resume && spec.options.resume.enabled && chunkFiles && qq.supportedFeatures.resume,
+ getName = proxy.getName,
+ getSize = proxy.getSize,
+ getUuid = proxy.getUuid,
+ getEndpoint = proxy.getEndpoint,
+ getDataByUuid = proxy.getDataByUuid,
+ onUuidChanged = proxy.onUuidChanged,
+ onProgress = proxy.onProgress,
+ log = proxy.log;
+
+
+ function abort(id) {
+ qq.each(handler._getXhrs(id), function(xhrId, xhr) {
+ var ajaxRequester = handler._getAjaxRequester(id, xhrId);
+
+ xhr.onreadystatechange = null;
+ xhr.upload.onprogress = null;
+ xhr.abort();
+ ajaxRequester && ajaxRequester.canceled && ajaxRequester.canceled(id);
+ });
+ }
+
+ qq.extend(this, new qq.UploadHandler(spec));
+
+ qq.override(this, function(super_) {
+ return {
+ /**
+ * Adds File or Blob to the queue
+ **/
+ add: function(id, blobOrProxy) {
+ if (qq.isFile(blobOrProxy) || qq.isBlob(blobOrProxy)) {
+ super_.add(id, {file: blobOrProxy});
+ }
+ else if (blobOrProxy instanceof qq.BlobProxy) {
+ super_.add(id, {proxy: blobOrProxy});
+ }
+ else {
+ throw new Error("Passed obj is not a File, Blob, or proxy");
+ }
+
+ handler._initTempState(id);
+ resumeEnabled && handler._maybePrepareForResume(id);
+ },
+
+ expunge: function(id) {
+ abort(id);
+ handler._maybeDeletePersistedChunkData(id);
+ handler._clearXhrs(id);
+ super_.expunge(id);
+ }
+ };
+ });
+
+ qq.extend(this, {
+ // Clear the cached chunk `Blob` after we are done with it, just in case the `Blob` bytes are stored in memory.
+ clearCachedChunk: function(id, chunkIdx) {
+ delete handler._getFileState(id).temp.cachedChunks[chunkIdx];
+ },
+
+ clearXhr: function(id, chunkIdx) {
+ var tempState = handler._getFileState(id).temp;
+
+ if (tempState.xhrs) {
+ delete tempState.xhrs[chunkIdx];
+ }
+ if (tempState.ajaxRequesters) {
+ delete tempState.ajaxRequesters[chunkIdx];
+ }
+ },
+
+ // Called when all chunks have been successfully uploaded. Expected promissory return type.
+ // This defines the default behavior if nothing further is required when all chunks have been uploaded.
+ finalizeChunks: function(id, responseParser) {
+ var lastChunkIdx = handler._getTotalChunks(id) - 1,
+ xhr = handler._getXhr(id, lastChunkIdx);
+
+ if (responseParser) {
+ return new qq.Promise().success(responseParser(xhr), xhr);
+ }
+
+ return new qq.Promise().success({}, xhr);
+ },
+
+ getFile: function(id) {
+ return handler.isValid(id) && handler._getFileState(id).file;
+ },
+
+ getProxy: function(id) {
+ return handler.isValid(id) && handler._getFileState(id).proxy;
+ },
+
+ /**
+ * @returns {Array} Array of objects containing properties useful to integrators
+ * when it is important to determine which files are potentially resumable.
+ */
+ getResumableFilesData: function() {
+ var resumableFilesData = [];
+
+ handler._iterateResumeRecords(function(key, uploadData) {
+ handler.moveInProgressToRemaining(null, uploadData.chunking.inProgress, uploadData.chunking.remaining);
+
+ var data = {
+ name: uploadData.name,
+ remaining: uploadData.chunking.remaining,
+ size: uploadData.size,
+ uuid: uploadData.uuid
+ };
+
+ if (uploadData.key) {
+ data.key = uploadData.key;
+ }
+
+ resumableFilesData.push(data);
+ });
+
+ return resumableFilesData;
+ },
+
+ isResumable: function(id) {
+ return !!chunking && handler.isValid(id) && !handler._getFileState(id).notResumable;
+ },
+
+ moveInProgressToRemaining: function(id, opt_inProgress, opt_remaining) {
+ var inProgress = opt_inProgress || handler._getFileState(id).chunking.inProgress,
+ remaining = opt_remaining || handler._getFileState(id).chunking.remaining;
+
+ if (inProgress) {
+ inProgress.reverse();
+ qq.each(inProgress, function(idx, chunkIdx) {
+ remaining.unshift(chunkIdx);
+ });
+ inProgress.length = 0;
+ }
+ },
+
+ pause: function(id) {
+ if(handler.isValid(id)) {
+ log(qq.format("Aborting XHR upload for {} '{}' due to pause instruction.", id, getName(id)));
+ handler._getFileState(id).paused = true;
+ abort(id);
+ return true;
+ }
+ },
+
+ reevaluateChunking: function(id) {
+ if (chunking && handler.isValid(id)) {
+ var state = handler._getFileState(id),
+ totalChunks;
+
+ delete state.chunking;
+
+ state.chunking = {};
+ totalChunks = handler._getTotalChunks(id);
+ if (totalChunks > 1) {
+ state.chunking.enabled = true;
+ state.chunking.parts = totalChunks;
+ state.chunking.remaining = [];
+
+ for (var i = 0; i < totalChunks; i++) {
+ state.chunking.remaining.push(i);
+ }
+
+ handler._initTempState(id);
+ }
+ else {
+ state.chunking.enabled = false;
+ }
+ }
+ },
+
+ updateBlob: function(id, newBlob) {
+ if (handler.isValid(id)) {
+ handler._getFileState(id).file = newBlob;
+ }
+ },
+
+ _clearXhrs: function(id) {
+ var tempState = handler._getFileState(id).temp;
+
+ qq.each(tempState.ajaxRequesters, function(chunkId) {
+ delete tempState.ajaxRequesters[chunkId];
+ });
+
+ qq.each(tempState.xhrs, function(chunkId) {
+ delete tempState.xhrs[chunkId];
+ });
+ },
+
+ /**
+ * Creates an XHR instance for this file and stores it in the fileState.
+ *
+ * @param id File ID
+ * @param opt_chunkIdx The chunk index associated with this XHR, if applicable
+ * @returns {XMLHttpRequest}
+ */
+ _createXhr: function(id, opt_chunkIdx) {
+ return handler._registerXhr(id, opt_chunkIdx, qq.createXhrInstance());
+ },
+
+ _getAjaxRequester: function(id, opt_chunkIdx) {
+ var chunkIdx = opt_chunkIdx == null ? -1 : opt_chunkIdx;
+ return handler._getFileState(id).temp.ajaxRequesters[chunkIdx];
+ },
+
+ _getChunkData: function(id, chunkIndex) {
+ var chunkSize = chunking.partSize,
+ fileSize = getSize(id),
+ fileOrBlob = handler.getFile(id),
+ startBytes = chunkSize * chunkIndex,
+ endBytes = startBytes+chunkSize >= fileSize ? fileSize : startBytes+chunkSize,
+ totalChunks = handler._getTotalChunks(id),
+ cachedChunks = this._getFileState(id).temp.cachedChunks,
+
+ // To work around a Webkit GC bug, we must keep each chunk `Blob` in scope until we are done with it.
+ // See https://github.com/Widen/fine-uploader/issues/937#issuecomment-41418760
+ blob = cachedChunks[chunkIndex] || qq.sliceBlob(fileOrBlob, startBytes, endBytes);
+
+ cachedChunks[chunkIndex] = blob;
+
+ return {
+ part: chunkIndex,
+ start: startBytes,
+ end: endBytes,
+ count: totalChunks,
+ blob: blob,
+ size: endBytes - startBytes
+ };
+ },
+
+ _getChunkDataForCallback: function(chunkData) {
+ return {
+ partIndex: chunkData.part,
+ startByte: chunkData.start + 1,
+ endByte: chunkData.end,
+ totalParts: chunkData.count
+ };
+ },
+
+ /**
+ * @param id File ID
+ * @returns {string} Identifier for this item that may appear in the browser's local storage
+ */
+ _getLocalStorageId: function(id) {
+ var formatVersion = "5.0",
+ name = getName(id),
+ size = getSize(id),
+ chunkSize = chunking.partSize,
+ endpoint = getEndpoint(id);
+
+ return qq.format("qq{}resume{}-{}-{}-{}-{}", namespace, formatVersion, name, size, chunkSize, endpoint);
+ },
+
+ _getMimeType: function(id) {
+ return handler.getFile(id).type;
+ },
+
+ _getPersistableData: function(id) {
+ return handler._getFileState(id).chunking;
+ },
+
+ /**
+ * @param id ID of the associated file
+ * @returns {number} Number of parts this file can be divided into, or undefined if chunking is not supported in this UA
+ */
+ _getTotalChunks: function(id) {
+ if (chunking) {
+ var fileSize = getSize(id),
+ chunkSize = chunking.partSize;
+
+ return Math.ceil(fileSize / chunkSize);
+ }
+ },
+
+ _getXhr: function(id, opt_chunkIdx) {
+ var chunkIdx = opt_chunkIdx == null ? -1 : opt_chunkIdx;
+ return handler._getFileState(id).temp.xhrs[chunkIdx];
+ },
+
+ _getXhrs: function(id) {
+ return handler._getFileState(id).temp.xhrs;
+ },
+
+ // Iterates through all XHR handler-created resume records (in local storage),
+ // invoking the passed callback and passing in the key and value of each local storage record.
+ _iterateResumeRecords: function(callback) {
+ if (resumeEnabled) {
+ qq.each(localStorage, function(key, item) {
+ if (key.indexOf(qq.format("qq{}resume-", namespace)) === 0) {
+ var uploadData = JSON.parse(item);
+ callback(key, uploadData);
+ }
+ });
+ }
+ },
+
+ _initTempState: function(id) {
+ handler._getFileState(id).temp = {
+ ajaxRequesters: {},
+ chunkProgress: {},
+ xhrs: {},
+ cachedChunks: {}
+ };
+ },
+
+ _markNotResumable: function(id) {
+ handler._getFileState(id).notResumable = true;
+ },
+
+ // Removes a chunked upload record from local storage, if possible.
+ // Returns true if the item was removed, false otherwise.
+ _maybeDeletePersistedChunkData: function(id) {
+ var localStorageId;
+
+ if (resumeEnabled && handler.isResumable(id)) {
+ localStorageId = handler._getLocalStorageId(id);
+
+ if (localStorageId && localStorage.getItem(localStorageId)) {
+ localStorage.removeItem(localStorageId);
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ // If this is a resumable upload, grab the relevant data from storage and items in memory that track this upload
+ // so we can pick up from where we left off.
+ _maybePrepareForResume: function(id) {
+ var state = handler._getFileState(id),
+ localStorageId, persistedData;
+
+ // Resume is enabled and possible and this is the first time we've tried to upload this file in this session,
+ // so prepare for a resume attempt.
+ if (resumeEnabled && state.key === undefined) {
+ localStorageId = handler._getLocalStorageId(id);
+ persistedData = localStorage.getItem(localStorageId);
+
+ // If we found this item in local storage, maybe we should resume it.
+ if (persistedData) {
+ persistedData = JSON.parse(persistedData);
+
+ // If we found a resume record but we have already handled this file in this session,
+ // don't try to resume it & ensure we don't persist future check data
+ if (getDataByUuid(persistedData.uuid)) {
+ handler._markNotResumable(id);
+ }
+ else {
+ log(qq.format("Identified file with ID {} and name of {} as resumable.", id, getName(id)));
+
+ onUuidChanged(id, persistedData.uuid);
+
+ state.key = persistedData.key;
+ state.chunking = persistedData.chunking;
+ state.loaded = persistedData.loaded;
+ state.attemptingResume = true;
+
+ handler.moveInProgressToRemaining(id);
+ }
+ }
+ }
+ },
+
+ // Persist any data needed to resume this upload in a new session.
+ _maybePersistChunkedState: function(id) {
+ var state = handler._getFileState(id),
+ localStorageId, persistedData;
+
+ // If local storage isn't supported by the browser, or if resume isn't enabled or possible, give up
+ if (resumeEnabled && handler.isResumable(id)) {
+ localStorageId = handler._getLocalStorageId(id);
+
+ persistedData = {
+ name: getName(id),
+ size: getSize(id),
+ uuid: getUuid(id),
+ key: state.key,
+ chunking: state.chunking,
+ loaded: state.loaded,
+ lastUpdated: Date.now()
+ };
+
+ localStorage.setItem(localStorageId, JSON.stringify(persistedData));
+ }
+ },
+
+ _registerProgressHandler: function(id, chunkIdx, chunkSize) {
+ var xhr = handler._getXhr(id, chunkIdx),
+ progressCalculator = {
+ simple: function(loaded, total) {
+ var fileSize = getSize(id);
+
+ if (loaded === total) {
+ onProgress(id, name, fileSize, fileSize);
+ }
+ else {
+ onProgress(id, name, (loaded >= fileSize ? fileSize-1 : loaded), fileSize);
+ }
+ },
+
+ chunked: function(loaded, total) {
+ var chunkProgress = handler._getFileState(id).temp.chunkProgress,
+ totalSuccessfullyLoadedForFile = handler._getFileState(id).loaded,
+ loadedForRequest = loaded,
+ totalForRequest = total,
+ totalFileSize = getSize(id),
+ estActualChunkLoaded = loadedForRequest - (totalForRequest - chunkSize),
+ totalLoadedForFile = totalSuccessfullyLoadedForFile;
+
+ chunkProgress[chunkIdx] = estActualChunkLoaded;
+
+ qq.each(chunkProgress, function(chunkIdx, chunkLoaded) {
+ totalLoadedForFile += chunkLoaded;
+ });
+
+ onProgress(id, name, totalLoadedForFile, totalFileSize);
+ }
+ };
+
+ xhr.upload.onprogress = function(e) {
+ if (e.lengthComputable) {
+ /* jshint eqnull: true */
+ var type = chunkSize == null ? "simple" : "chunked";
+ progressCalculator[type](e.loaded, e.total);
+ }
+ };
+ },
+
+ /**
+ * Registers an XHR transport instance created elsewhere.
+ *
+ * @param id ID of the associated file
+ * @param opt_chunkIdx The chunk index associated with this XHR, if applicable
+ * @param xhr XMLHttpRequest object instance
+ * @param opt_ajaxRequester `qq.AjaxRequester` associated with this request, if applicable.
+ * @returns {XMLHttpRequest}
+ */
+ _registerXhr: function(id, opt_chunkIdx, xhr, opt_ajaxRequester) {
+ var xhrsId = opt_chunkIdx == null ? -1 : opt_chunkIdx,
+ tempState = handler._getFileState(id).temp;
+
+ tempState.xhrs = tempState.xhrs || {};
+ tempState.ajaxRequesters = tempState.ajaxRequesters || {};
+
+ tempState.xhrs[xhrsId] = xhr;
+
+ if (opt_ajaxRequester) {
+ tempState.ajaxRequesters[xhrsId] = opt_ajaxRequester;
+ }
+
+ return xhr;
+ },
+
+ // Deletes any local storage records that are "expired".
+ _removeExpiredChunkingRecords: function() {
+ var expirationDays = resume.recordsExpireIn;
+
+ handler._iterateResumeRecords(function(key, uploadData) {
+ var expirationDate = new Date(uploadData.lastUpdated);
+
+ // transform updated date into expiration date
+ expirationDate.setDate(expirationDate.getDate() + expirationDays);
+
+ if (expirationDate.getTime() <= Date.now()) {
+ log("Removing expired resume record with key " + key);
+ localStorage.removeItem(key);
+ }
+ });
+ },
+
+ /**
+ * Determine if the associated file should be chunked.
+ *
+ * @param id ID of the associated file
+ * @returns {*} true if chunking is enabled, possible, and the file can be split into more than 1 part
+ */
+ _shouldChunkThisFile: function(id) {
+ var state = handler._getFileState(id);
+
+ if (!state.chunking) {
+ handler.reevaluateChunking(id);
+ }
+
+ return state.chunking.enabled;
+ }
+ });
+};
+
+/*globals qq */
+/*jshint -W117 */
+qq.WindowReceiveMessage = function(o) {
+ "use strict";
+
+ var options = {
+ log: function(message, level) {}
+ },
+ callbackWrapperDetachers = {};
+
+ qq.extend(options, o);
+
+ qq.extend(this, {
+ receiveMessage : function(id, callback) {
+ var onMessageCallbackWrapper = function(event) {
+ callback(event.data);
+ };
+
+ if (window.postMessage) {
+ callbackWrapperDetachers[id] = qq(window).attach("message", onMessageCallbackWrapper);
+ }
+ else {
+ log("iframe message passing not supported in this browser!", "error");
+ }
+ },
+
+ stopReceivingMessages : function(id) {
+ if (window.postMessage) {
+ var detacher = callbackWrapperDetachers[id];
+ if (detacher) {
+ detacher();
+ }
+ }
+ }
+ });
+};
+
+/*globals qq */
+/**
+ * Defines the public API for FineUploader mode.
+ */
+(function(){
+ "use strict";
+
+ qq.uiPublicApi = {
+ clearStoredFiles: function() {
+ this._parent.prototype.clearStoredFiles.apply(this, arguments);
+ this._templating.clearFiles();
+ },
+
+ addExtraDropzone: function(element){
+ this._dnd && this._dnd.setupExtraDropzone(element);
+ },
+
+ removeExtraDropzone: function(element){
+ if (this._dnd) {
+ return this._dnd.removeDropzone(element);
+ }
+ },
+
+ getItemByFileId: function(id) {
+ return this._templating.getFileContainer(id);
+ },
+
+ reset: function() {
+ this._parent.prototype.reset.apply(this, arguments);
+ this._templating.reset();
+
+ if (!this._options.button && this._templating.getButton()) {
+ this._defaultButtonId = this._createUploadButton({element: this._templating.getButton()}).getButtonId();
+ }
+
+ if (this._dnd) {
+ this._dnd.dispose();
+ this._dnd = this._setupDragAndDrop();
+ }
+
+ this._totalFilesInBatch = 0;
+ this._filesInBatchAddedToUi = 0;
+
+ this._setupClickAndEditEventHandlers();
+ },
+
+ setName: function(id, newName) {
+ var formattedFilename = this._options.formatFileName(newName);
+
+ this._parent.prototype.setName.apply(this, arguments);
+ this._templating.updateFilename(id, formattedFilename);
+ },
+
+ pauseUpload: function(id) {
+ var paused = this._parent.prototype.pauseUpload.apply(this, arguments);
+
+ paused && this._templating.uploadPaused(id);
+ return paused;
+ },
+
+ continueUpload: function(id) {
+ var continued = this._parent.prototype.continueUpload.apply(this, arguments);
+
+ continued && this._templating.uploadContinued(id);
+ return continued;
+ },
+
+ getId: function(fileContainerOrChildEl) {
+ return this._templating.getFileId(fileContainerOrChildEl);
+ },
+
+ getDropTarget: function(fileId) {
+ var file = this.getFile(fileId);
+
+ return file.qqDropTarget;
+ }
+ };
+
+
+
+
+ /**
+ * Defines the private (internal) API for FineUploader mode.
+ */
+ qq.uiPrivateApi = {
+ _getButton: function(buttonId) {
+ var button = this._parent.prototype._getButton.apply(this, arguments);
+
+ if (!button) {
+ if (buttonId === this._defaultButtonId) {
+ button = this._templating.getButton();
+ }
+ }
+
+ return button;
+ },
+
+ _removeFileItem: function(fileId) {
+ this._templating.removeFile(fileId);
+ },
+
+ _setupClickAndEditEventHandlers: function() {
+ this._fileButtonsClickHandler = qq.FileButtonsClickHandler && this._bindFileButtonsClickEvent();
+
+ // A better approach would be to check specifically for focusin event support by querying the DOM API,
+ // but the DOMFocusIn event is not exposed as a property, so we have to resort to UA string sniffing.
+ this._focusinEventSupported = !qq.firefox();
+
+ if (this._isEditFilenameEnabled())
+ {
+ this._filenameClickHandler = this._bindFilenameClickEvent();
+ this._filenameInputFocusInHandler = this._bindFilenameInputFocusInEvent();
+ this._filenameInputFocusHandler = this._bindFilenameInputFocusEvent();
+ }
+ },
+
+ _setupDragAndDrop: function() {
+ var self = this,
+ dropZoneElements = this._options.dragAndDrop.extraDropzones,
+ templating = this._templating,
+ defaultDropZone = templating.getDropZone();
+
+ defaultDropZone && dropZoneElements.push(defaultDropZone);
+
+ return new qq.DragAndDrop({
+ dropZoneElements: dropZoneElements,
+ allowMultipleItems: this._options.multiple,
+ classes: {
+ dropActive: this._options.classes.dropActive
+ },
+ callbacks: {
+ processingDroppedFiles: function() {
+ templating.showDropProcessing();
+ },
+ processingDroppedFilesComplete: function(files, targetEl) {
+ templating.hideDropProcessing();
+
+ qq.each(files, function(idx, file) {
+ file.qqDropTarget = targetEl;
+ });
+
+ if (files.length) {
+ self.addFiles(files, null, null);
+ }
+ },
+ dropError: function(code, errorData) {
+ self._itemError(code, errorData);
+ },
+ dropLog: function(message, level) {
+ self.log(message, level);
+ }
+ }
+ });
+ },
+
+ _bindFileButtonsClickEvent: function() {
+ var self = this;
+
+ return new qq.FileButtonsClickHandler({
+ templating: this._templating,
+
+ log: function(message, lvl) {
+ self.log(message, lvl);
+ },
+
+ onDeleteFile: function(fileId) {
+ self.deleteFile(fileId);
+ },
+
+ onCancel: function(fileId) {
+ self.cancel(fileId);
+ },
+
+ onRetry: function(fileId) {
+ qq(self._templating.getFileContainer(fileId)).removeClass(self._classes.retryable);
+ self._templating.hideRetry(fileId);
+ self.retry(fileId);
+ },
+
+ onPause: function(fileId) {
+ self.pauseUpload(fileId);
+ },
+
+ onContinue: function(fileId) {
+ self.continueUpload(fileId);
+ },
+
+ onGetName: function(fileId) {
+ return self.getName(fileId);
+ }
+ });
+ },
+
+ _isEditFilenameEnabled: function() {
+ /*jshint -W014 */
+ return this._templating.isEditFilenamePossible()
+ && !this._options.autoUpload
+ && qq.FilenameClickHandler
+ && qq.FilenameInputFocusHandler
+ && qq.FilenameInputFocusHandler;
+ },
+
+ _filenameEditHandler: function() {
+ var self = this,
+ templating = this._templating;
+
+ return {
+ templating: templating,
+ log: function(message, lvl) {
+ self.log(message, lvl);
+ },
+ onGetUploadStatus: function(fileId) {
+ return self.getUploads({id: fileId}).status;
+ },
+ onGetName: function(fileId) {
+ return self.getName(fileId);
+ },
+ onSetName: function(id, newName) {
+ self.setName(id, newName);
+ },
+ onEditingStatusChange: function(id, isEditing) {
+ var qqInput = qq(templating.getEditInput(id)),
+ qqFileContainer = qq(templating.getFileContainer(id));
+
+ if (isEditing) {
+ qqInput.addClass("qq-editing");
+ templating.hideFilename(id);
+ templating.hideEditIcon(id);
+ }
+ else {
+ qqInput.removeClass("qq-editing");
+ templating.showFilename(id);
+ templating.showEditIcon(id);
+ }
+
+ // Force IE8 and older to repaint
+ qqFileContainer.addClass("qq-temp").removeClass("qq-temp");
+ }
+ };
+ },
+
+ _onUploadStatusChange: function(id, oldStatus, newStatus) {
+ this._parent.prototype._onUploadStatusChange.apply(this, arguments);
+
+ if (this._isEditFilenameEnabled()) {
+ // Status for a file exists before it has been added to the DOM, so we must be careful here.
+ if (this._templating.getFileContainer(id) && newStatus !== qq.status.SUBMITTED) {
+ this._templating.markFilenameEditable(id);
+ this._templating.hideEditIcon(id);
+ }
+ }
+ },
+
+ _bindFilenameInputFocusInEvent: function() {
+ var spec = qq.extend({}, this._filenameEditHandler());
+
+ return new qq.FilenameInputFocusInHandler(spec);
+ },
+
+ _bindFilenameInputFocusEvent: function() {
+ var spec = qq.extend({}, this._filenameEditHandler());
+
+ return new qq.FilenameInputFocusHandler(spec);
+ },
+
+ _bindFilenameClickEvent: function() {
+ var spec = qq.extend({}, this._filenameEditHandler());
+
+ return new qq.FilenameClickHandler(spec);
+ },
+
+ _storeForLater: function(id) {
+ this._parent.prototype._storeForLater.apply(this, arguments);
+ this._templating.hideSpinner(id);
+ },
+
+ _onAllComplete: function(successful, failed) {
+ this._parent.prototype._onAllComplete.apply(this, arguments);
+ this._templating.resetTotalProgress();
+ },
+
+ _onSubmit: function(id, name) {
+ var file = this.getFile(id);
+
+ if (file && file.qqPath && this._options.dragAndDrop.reportDirectoryPaths) {
+ this._paramsStore.addReadOnly(id, {
+ qqpath: file.qqPath
+ });
+ }
+
+ this._parent.prototype._onSubmit.apply(this, arguments);
+ this._addToList(id, name);
+ },
+
+ // The file item has been added to the DOM.
+ _onSubmitted: function(id) {
+ // If the edit filename feature is enabled, mark the filename element as "editable" and the associated edit icon
+ if (this._isEditFilenameEnabled()) {
+ this._templating.markFilenameEditable(id);
+ this._templating.showEditIcon(id);
+
+ // If the focusin event is not supported, we must add a focus handler to the newly create edit filename text input
+ if (!this._focusinEventSupported) {
+ this._filenameInputFocusHandler.addHandler(this._templating.getEditInput(id));
+ }
+ }
+ },
+
+ // Update the progress bar & percentage as the file is uploaded
+ _onProgress: function(id, name, loaded, total){
+ this._parent.prototype._onProgress.apply(this, arguments);
+
+ this._templating.updateProgress(id, loaded, total);
+
+ if (Math.round(loaded / total * 100) === 100) {
+ this._templating.hideCancel(id);
+ this._templating.hidePause(id);
+ this._templating.hideProgress(id);
+ this._templating.setStatusText(id, this._options.text.waitingForResponse);
+
+ // If ~last byte was sent, display total file size
+ this._displayFileSize(id);
+ }
+ else {
+ // If still uploading, display percentage - total size is actually the total request(s) size
+ this._displayFileSize(id, loaded, total);
+ }
+ },
+
+ _onTotalProgress: function(loaded, total) {
+ this._parent.prototype._onTotalProgress.apply(this, arguments);
+ this._templating.updateTotalProgress(loaded, total);
+ },
+
+ _onComplete: function(id, name, result, xhr) {
+ var parentRetVal = this._parent.prototype._onComplete.apply(this, arguments),
+ templating = this._templating,
+ fileContainer = templating.getFileContainer(id),
+ self = this;
+
+ function completeUpload(result) {
+ // If this file is not represented in the templating module, perhaps it was hidden intentionally.
+ // If so, don't perform any UI-related tasks related to this file.
+ if (!fileContainer) {
+ return;
+ }
+
+ templating.setStatusText(id);
+
+ qq(fileContainer).removeClass(self._classes.retrying);
+ templating.hideProgress(id);
+
+ if (!self._options.disableCancelForFormUploads || qq.supportedFeatures.ajaxUploading) {
+ templating.hideCancel(id);
+ }
+ templating.hideSpinner(id);
+
+ if (result.success) {
+ self._markFileAsSuccessful(id);
+ }
+ else {
+ qq(fileContainer).addClass(self._classes.fail);
+
+ if (templating.isRetryPossible() && !self._preventRetries[id]) {
+ qq(fileContainer).addClass(self._classes.retryable);
+ templating.showRetry(id);
+ }
+ self._controlFailureTextDisplay(id, result);
+ }
+ }
+
+ // The parent may need to perform some async operation before we can accurately determine the status of the upload.
+ if (parentRetVal instanceof qq.Promise) {
+ parentRetVal.done(function(newResult) {
+ completeUpload(newResult);
+ });
+
+ }
+ else {
+ completeUpload(result);
+ }
+
+ return parentRetVal;
+ },
+
+ _markFileAsSuccessful: function(id) {
+ var templating = this._templating;
+
+ if (this._isDeletePossible()) {
+ templating.showDeleteButton(id);
+ }
+
+ qq(templating.getFileContainer(id)).addClass(this._classes.success);
+
+ this._maybeUpdateThumbnail(id);
+ },
+
+ _onUploadPrep: function(id) {
+ this._parent.prototype._onUploadPrep.apply(this, arguments);
+ this._templating.showSpinner(id);
+ },
+
+ _onUpload: function(id, name){
+ var parentRetVal = this._parent.prototype._onUpload.apply(this, arguments);
+
+ this._templating.showSpinner(id);
+
+ return parentRetVal;
+ },
+
+ _onUploadChunk: function(id, chunkData) {
+ this._parent.prototype._onUploadChunk.apply(this, arguments);
+
+ // Only display the pause button if we have finished uploading at least one chunk
+ // & this file can be resumed
+ if (chunkData.partIndex > 0 && this._handler.isResumable(id)) {
+ this._templating.allowPause(id);
+ }
+ },
+
+ _onCancel: function(id, name) {
+ this._parent.prototype._onCancel.apply(this, arguments);
+ this._removeFileItem(id);
+
+ if (this._getNotFinished() === 0) {
+ this._templating.resetTotalProgress();
+ }
+ },
+
+ _onBeforeAutoRetry: function(id) {
+ var retryNumForDisplay, maxAuto, retryNote;
+
+ this._parent.prototype._onBeforeAutoRetry.apply(this, arguments);
+
+ this._showCancelLink(id);
+
+ if (this._options.retry.showAutoRetryNote) {
+ retryNumForDisplay = this._autoRetries[id];
+ maxAuto = this._options.retry.maxAutoAttempts;
+
+ retryNote = this._options.retry.autoRetryNote.replace(/\{retryNum\}/g, retryNumForDisplay);
+ retryNote = retryNote.replace(/\{maxAuto\}/g, maxAuto);
+
+ this._templating.setStatusText(id, retryNote);
+ qq(this._templating.getFileContainer(id)).addClass(this._classes.retrying);
+ }
+ },
+
+ //return false if we should not attempt the requested retry
+ _onBeforeManualRetry: function(id) {
+ if (this._parent.prototype._onBeforeManualRetry.apply(this, arguments)) {
+ this._templating.resetProgress(id);
+ qq(this._templating.getFileContainer(id)).removeClass(this._classes.fail);
+ this._templating.setStatusText(id);
+ this._templating.showSpinner(id);
+ this._showCancelLink(id);
+ return true;
+ }
+ else {
+ qq(this._templating.getFileContainer(id)).addClass(this._classes.retryable);
+ this._templating.showRetry(id);
+ return false;
+ }
+ },
+
+ _onSubmitDelete: function(id) {
+ var onSuccessCallback = qq.bind(this._onSubmitDeleteSuccess, this);
+
+ this._parent.prototype._onSubmitDelete.call(this, id, onSuccessCallback);
+ },
+
+ _onSubmitDeleteSuccess: function(id, uuid, additionalMandatedParams) {
+ if (this._options.deleteFile.forceConfirm) {
+ this._showDeleteConfirm.apply(this, arguments);
+ }
+ else {
+ this._sendDeleteRequest.apply(this, arguments);
+ }
+ },
+
+ _onDeleteComplete: function(id, xhr, isError) {
+ this._parent.prototype._onDeleteComplete.apply(this, arguments);
+
+ this._templating.hideSpinner(id);
+
+ if (isError) {
+ this._templating.setStatusText(id, this._options.deleteFile.deletingFailedText);
+ this._templating.showDeleteButton(id);
+ }
+ else {
+ this._removeFileItem(id);
+ }
+ },
+
+ _sendDeleteRequest: function(id, uuid, additionalMandatedParams) {
+ this._templating.hideDeleteButton(id);
+ this._templating.showSpinner(id);
+ this._templating.setStatusText(id, this._options.deleteFile.deletingStatusText);
+ this._deleteHandler.sendDelete.apply(this, arguments);
+ },
+
+ _showDeleteConfirm: function(id, uuid, mandatedParams) {
+ /*jshint -W004 */
+ var fileName = this.getName(id),
+ confirmMessage = this._options.deleteFile.confirmMessage.replace(/\{filename\}/g, fileName),
+ uuid = this.getUuid(id),
+ deleteRequestArgs = arguments,
+ self = this,
+ retVal;
+
+ retVal = this._options.showConfirm(confirmMessage);
+
+ if (qq.isGenericPromise(retVal)) {
+ retVal.then(function () {
+ self._sendDeleteRequest.apply(self, deleteRequestArgs);
+ });
+ }
+ else if (retVal !== false) {
+ self._sendDeleteRequest.apply(self, deleteRequestArgs);
+ }
+ },
+
+ _addToList: function(id, name, canned) {
+ var prependData,
+ prependIndex = 0,
+ dontDisplay = this._handler.isProxied(id) && this._options.scaling.hideScaled;
+
+ // If we don't want this file to appear in the UI, skip all of this UI-related logic.
+ if (dontDisplay) {
+ return;
+ }
+
+ if (this._options.display.prependFiles) {
+ if (this._totalFilesInBatch > 1 && this._filesInBatchAddedToUi > 0) {
+ prependIndex = this._filesInBatchAddedToUi - 1;
+ }
+
+ prependData = {
+ index: prependIndex
+ };
+ }
+
+ if (!canned) {
+ if (this._options.disableCancelForFormUploads && !qq.supportedFeatures.ajaxUploading) {
+ this._templating.disableCancel();
+ }
+
+ if (!this._options.multiple) {
+ this._handler.cancelAll();
+ this._clearList();
+ }
+ }
+
+ this._templating.addFile(id, this._options.formatFileName(name), prependData);
+
+ if (canned) {
+ this._thumbnailUrls[id] && this._templating.updateThumbnail(id, this._thumbnailUrls[id], true);
+ }
+ else {
+ this._templating.generatePreview(id, this.getFile(id));
+ }
+
+ this._filesInBatchAddedToUi += 1;
+
+ if (canned ||
+ (this._options.display.fileSizeOnSubmit && qq.supportedFeatures.ajaxUploading)) {
+
+ this._displayFileSize(id);
+ }
+ },
+
+ _clearList: function(){
+ this._templating.clearFiles();
+ this.clearStoredFiles();
+ },
+
+ _displayFileSize: function(id, loadedSize, totalSize) {
+ var size = this.getSize(id),
+ sizeForDisplay = this._formatSize(size);
+
+ if (size >= 0) {
+ if (loadedSize !== undefined && totalSize !== undefined) {
+ sizeForDisplay = this._formatProgress(loadedSize, totalSize);
+ }
+
+ this._templating.updateSize(id, sizeForDisplay);
+ }
+ },
+
+ _formatProgress: function (uploadedSize, totalSize) {
+ var message = this._options.text.formatProgress;
+ function r(name, replacement) { message = message.replace(name, replacement); }
+
+ r("{percent}", Math.round(uploadedSize / totalSize * 100));
+ r("{total_size}", this._formatSize(totalSize));
+ return message;
+ },
+
+ _controlFailureTextDisplay: function(id, response) {
+ var mode, maxChars, responseProperty, failureReason, shortFailureReason;
+
+ mode = this._options.failedUploadTextDisplay.mode;
+ maxChars = this._options.failedUploadTextDisplay.maxChars;
+ responseProperty = this._options.failedUploadTextDisplay.responseProperty;
+
+ if (mode === "custom") {
+ failureReason = response[responseProperty];
+ if (failureReason) {
+ if (failureReason.length > maxChars) {
+ shortFailureReason = failureReason.substring(0, maxChars) + "...";
+ }
+ }
+ else {
+ failureReason = this._options.text.failUpload;
+ }
+
+ this._templating.setStatusText(id, shortFailureReason || failureReason);
+
+ if (this._options.failedUploadTextDisplay.enableTooltip) {
+ this._showTooltip(id, failureReason);
+ }
+ }
+ else if (mode === "default") {
+ this._templating.setStatusText(id, this._options.text.failUpload);
+ }
+ else if (mode !== "none") {
+ this.log("failedUploadTextDisplay.mode value of '" + mode + "' is not valid", "warn");
+ }
+ },
+
+ _showTooltip: function(id, text) {
+ this._templating.getFileContainer(id).title = text;
+ },
+
+ _showCancelLink: function(id) {
+ if (!this._options.disableCancelForFormUploads || qq.supportedFeatures.ajaxUploading) {
+ this._templating.showCancel(id);
+ }
+ },
+
+ _itemError: function(code, name, item) {
+ var message = this._parent.prototype._itemError.apply(this, arguments);
+ this._options.showMessage(message);
+ },
+
+ _batchError: function(message) {
+ this._parent.prototype._batchError.apply(this, arguments);
+ this._options.showMessage(message);
+ },
+
+ _setupPastePrompt: function() {
+ var self = this;
+
+ this._options.callbacks.onPasteReceived = function() {
+ var message = self._options.paste.namePromptMessage,
+ defaultVal = self._options.paste.defaultName;
+
+ return self._options.showPrompt(message, defaultVal);
+ };
+ },
+
+ _fileOrBlobRejected: function(id, name) {
+ this._totalFilesInBatch -= 1;
+ this._parent.prototype._fileOrBlobRejected.apply(this, arguments);
+ },
+
+ _prepareItemsForUpload: function(items, params, endpoint) {
+ this._totalFilesInBatch = items.length;
+ this._filesInBatchAddedToUi = 0;
+ this._parent.prototype._prepareItemsForUpload.apply(this, arguments);
+ },
+
+ _maybeUpdateThumbnail: function(fileId) {
+ var thumbnailUrl = this._thumbnailUrls[fileId];
+
+ this._templating.updateThumbnail(fileId, thumbnailUrl);
+ },
+
+ _addCannedFile: function(sessionData) {
+ var id = this._parent.prototype._addCannedFile.apply(this, arguments);
+
+ this._addToList(id, this.getName(id), true);
+ this._templating.hideSpinner(id);
+ this._templating.hideCancel(id);
+ this._markFileAsSuccessful(id);
+
+ return id;
+ },
+
+ _setSize: function(id, newSize) {
+ this._parent.prototype._setSize.apply(this, arguments);
+
+ this._templating.updateSize(id, this._formatSize(newSize));
+ }
+ };
+}());
+
+/*globals qq */
+/**
+ * This defines FineUploader mode, which is a default UI w/ drag & drop uploading.
+ */
+qq.FineUploader = function(o, namespace) {
+ "use strict";
+
+ // By default this should inherit instance data from FineUploaderBasic, but this can be overridden
+ // if the (internal) caller defines a different parent. The parent is also used by
+ // the private and public API functions that need to delegate to a parent function.
+ this._parent = namespace ? qq[namespace].FineUploaderBasic : qq.FineUploaderBasic;
+ this._parent.apply(this, arguments);
+
+ // Options provided by FineUploader mode
+ qq.extend(this._options, {
+ element: null,
+
+ button: null,
+
+ listElement: null,
+
+ dragAndDrop: {
+ extraDropzones: [],
+ reportDirectoryPaths: false
+ },
+
+ text: {
+ formatProgress: "{percent}% of {total_size}",
+ failUpload: "Upload failed",
+ waitingForResponse: "Processing...",
+ paused: "Paused"
+ },
+
+ template: "qq-template",
+
+ classes: {
+ retrying: "qq-upload-retrying",
+ retryable: "qq-upload-retryable",
+ success: "qq-upload-success",
+ fail: "qq-upload-fail",
+ editable: "qq-editable",
+ hide: "qq-hide",
+ dropActive: "qq-upload-drop-area-active"
+ },
+
+ failedUploadTextDisplay: {
+ mode: "default", //default, custom, or none
+ maxChars: 50,
+ responseProperty: "error",
+ enableTooltip: true
+ },
+
+ messages: {
+ tooManyFilesError: "You may only drop one file",
+ unsupportedBrowser: "Unrecoverable error - this browser does not permit file uploading of any kind."
+ },
+
+ retry: {
+ showAutoRetryNote: true,
+ autoRetryNote: "Retrying {retryNum}/{maxAuto}..."
+ },
+
+ deleteFile: {
+ forceConfirm: false,
+ confirmMessage: "Are you sure you want to delete {filename}?",
+ deletingStatusText: "Deleting...",
+ deletingFailedText: "Delete failed"
+
+ },
+
+ display: {
+ fileSizeOnSubmit: false,
+ prependFiles: false
+ },
+
+ paste: {
+ promptForName: false,
+ namePromptMessage: "Please name this image"
+ },
+
+ thumbnails: {
+ placeholders: {
+ waitUntilResponse: false,
+ notAvailablePath: null,
+ waitingPath: null
+ }
+ },
+
+ scaling: {
+ hideScaled: false
+ },
+
+ showMessage: function(message){
+ setTimeout(function() {
+ window.alert(message);
+ }, 0);
+ },
+
+ showConfirm: function(message) {
+ return window.confirm(message);
+ },
+
+ showPrompt: function(message, defaultValue) {
+ return window.prompt(message, defaultValue);
+ }
+ }, true);
+
+ // Replace any default options with user defined ones
+ qq.extend(this._options, o, true);
+
+ this._templating = new qq.Templating({
+ log: qq.bind(this.log, this),
+ templateIdOrEl: this._options.template,
+ containerEl: this._options.element,
+ fileContainerEl: this._options.listElement,
+ button: this._options.button,
+ imageGenerator: this._imageGenerator,
+ classes: {
+ hide: this._options.classes.hide,
+ editable: this._options.classes.editable
+ },
+ placeholders: {
+ waitUntilUpdate: this._options.thumbnails.placeholders.waitUntilResponse,
+ thumbnailNotAvailable: this._options.thumbnails.placeholders.notAvailablePath,
+ waitingForThumbnail: this._options.thumbnails.placeholders.waitingPath
+ },
+ text: this._options.text
+ });
+
+ if (!qq.supportedFeatures.uploading || (this._options.cors.expected && !qq.supportedFeatures.uploadCors)) {
+ this._templating.renderFailure(this._options.messages.unsupportedBrowser);
+ }
+ else {
+ this._wrapCallbacks();
+
+ this._templating.render();
+
+ this._classes = this._options.classes;
+
+ if (!this._options.button && this._templating.getButton()) {
+ this._defaultButtonId = this._createUploadButton({element: this._templating.getButton()}).getButtonId();
+ }
+
+ this._setupClickAndEditEventHandlers();
+
+ if (qq.DragAndDrop && qq.supportedFeatures.fileDrop) {
+ this._dnd = this._setupDragAndDrop();
+ }
+
+ if (this._options.paste.targetElement && this._options.paste.promptForName) {
+ if (qq.PasteSupport) {
+ this._setupPastePrompt();
+ }
+ else {
+ this.log("Paste support module not found.", "error");
+ }
+ }
+
+ this._totalFilesInBatch = 0;
+ this._filesInBatchAddedToUi = 0;
+ }
+};
+
+// Inherit the base public & private API methods
+qq.extend(qq.FineUploader.prototype, qq.basePublicApi);
+qq.extend(qq.FineUploader.prototype, qq.basePrivateApi);
+
+// Add the FineUploader/default UI public & private UI methods, which may override some base methods.
+qq.extend(qq.FineUploader.prototype, qq.uiPublicApi);
+qq.extend(qq.FineUploader.prototype, qq.uiPrivateApi);
+
+/* globals qq */
+/* jshint -W065 */
+/**
+ * Module responsible for rendering all Fine Uploader UI templates. This module also asserts at least
+ * a limited amount of control over the template elements after they are added to the DOM.
+ * Wherever possible, this module asserts total control over template elements present in the DOM.
+ *
+ * @param spec Specification object used to control various templating behaviors
+ * @constructor
+ */
+qq.Templating = function(spec) {
+ "use strict";
+
+ var FILE_ID_ATTR = "qq-file-id",
+ FILE_CLASS_PREFIX = "qq-file-id-",
+ THUMBNAIL_MAX_SIZE_ATTR = "qq-max-size",
+ THUMBNAIL_SERVER_SCALE_ATTR = "qq-server-scale",
+ // This variable is duplicated in the DnD module since it can function as a standalone as well
+ HIDE_DROPZONE_ATTR = "qq-hide-dropzone",
+ isCancelDisabled = false,
+ thumbnailMaxSize = -1,
+ options = {
+ log: null,
+ templateIdOrEl: "qq-template",
+ containerEl: null,
+ fileContainerEl: null,
+ button: null,
+ imageGenerator: null,
+ classes: {
+ hide: "qq-hide",
+ editable: "qq-editable"
+ },
+ placeholders: {
+ waitUntilUpdate: false,
+ thumbnailNotAvailable: null,
+ waitingForThumbnail: null
+ },
+ text: {
+ paused: "Paused"
+ }
+ },
+ selectorClasses = {
+ button: "qq-upload-button-selector",
+ drop: "qq-upload-drop-area-selector",
+ list: "qq-upload-list-selector",
+ progressBarContainer: "qq-progress-bar-container-selector",
+ progressBar: "qq-progress-bar-selector",
+ totalProgressBarContainer: "qq-total-progress-bar-container-selector",
+ totalProgressBar: "qq-total-progress-bar-selector",
+ file: "qq-upload-file-selector",
+ spinner: "qq-upload-spinner-selector",
+ size: "qq-upload-size-selector",
+ cancel: "qq-upload-cancel-selector",
+ pause: "qq-upload-pause-selector",
+ continueButton: "qq-upload-continue-selector",
+ deleteButton: "qq-upload-delete-selector",
+ retry: "qq-upload-retry-selector",
+ statusText: "qq-upload-status-text-selector",
+ editFilenameInput: "qq-edit-filename-selector",
+ editNameIcon: "qq-edit-filename-icon-selector",
+ dropProcessing: "qq-drop-processing-selector",
+ dropProcessingSpinner: "qq-drop-processing-spinner-selector",
+ thumbnail: "qq-thumbnail-selector"
+ },
+ previewGeneration = {},
+ cachedThumbnailNotAvailableImg = new qq.Promise(),
+ cachedWaitingForThumbnailImg = new qq.Promise(),
+ log,
+ isEditElementsExist,
+ isRetryElementExist,
+ templateHtml,
+ container,
+ fileList,
+ showThumbnails,
+ serverScale;
+
+ /**
+ * Grabs the HTML from the script tag holding the template markup. This function will also adjust
+ * some internally-tracked state variables based on the contents of the template.
+ * The template is filtered so that irrelevant elements (such as the drop zone if DnD is not supported)
+ * are omitted from the DOM. Useful errors will be thrown if the template cannot be parsed.
+ *
+ * @returns {{template: *, fileTemplate: *}} HTML for the top-level file items templates
+ */
+ function parseAndGetTemplate() {
+ var scriptEl,
+ scriptHtml,
+ fileListNode,
+ tempTemplateEl,
+ fileListHtml,
+ defaultButton,
+ dropArea,
+ thumbnail,
+ dropProcessing;
+
+ log("Parsing template");
+
+ /*jshint -W116*/
+ if (options.templateIdOrEl == null) {
+ throw new Error("You MUST specify either a template element or ID!");
+ }
+
+ // Grab the contents of the script tag holding the template.
+ if (qq.isString(options.templateIdOrEl)) {
+ scriptEl = document.getElementById(options.templateIdOrEl);
+
+ if (scriptEl === null) {
+ throw new Error(qq.format("Cannot find template script at ID '{}'!", options.templateIdOrEl));
+ }
+
+ scriptHtml = scriptEl.innerHTML;
+ }
+ else {
+ if (options.templateIdOrEl.innerHTML === undefined) {
+ throw new Error("You have specified an invalid value for the template option! " +
+ "It must be an ID or an Element.");
+ }
+
+ scriptHtml = options.templateIdOrEl.innerHTML;
+ }
+
+ scriptHtml = qq.trimStr(scriptHtml);
+ tempTemplateEl = document.createElement("div");
+ tempTemplateEl.appendChild(qq.toElement(scriptHtml));
+
+ // Don't include the default template button in the DOM
+ // if an alternate button container has been specified.
+ if (options.button) {
+ defaultButton = qq(tempTemplateEl).getByClass(selectorClasses.button)[0];
+ if (defaultButton) {
+ qq(defaultButton).remove();
+ }
+ }
+
+ // Omit the drop processing element from the DOM if DnD is not supported by the UA,
+ // or the drag and drop module is not found.
+ // NOTE: We are consciously not removing the drop zone if the UA doesn't support DnD
+ // to support layouts where the drop zone is also a container for visible elements,
+ // such as the file list.
+ if (!qq.DragAndDrop || !qq.supportedFeatures.fileDrop) {
+ dropProcessing = qq(tempTemplateEl).getByClass(selectorClasses.dropProcessing)[0];
+ if (dropProcessing) {
+ qq(dropProcessing).remove();
+ }
+
+ }
+
+ dropArea = qq(tempTemplateEl).getByClass(selectorClasses.drop)[0];
+
+ // If DnD is not available then remove
+ // it from the DOM as well.
+ if (dropArea && !qq.DragAndDrop) {
+ log("DnD module unavailable.", "info");
+ qq(dropArea).remove();
+ }
+
+ // If there is a drop area defined in the template, and the current UA doesn't support DnD,
+ // and the drop area is marked as "hide before enter", ensure it is hidden as the DnD module
+ // will not do this (since we will not be loading the DnD module)
+ if (dropArea && !qq.supportedFeatures.fileDrop &&
+ qq(dropArea).hasAttribute(HIDE_DROPZONE_ATTR)) {
+
+ qq(dropArea).css({
+ display: "none"
+ });
+ }
+
+ // Ensure the `showThumbnails` flag is only set if the thumbnail element
+ // is present in the template AND the current UA is capable of generating client-side previews.
+ thumbnail = qq(tempTemplateEl).getByClass(selectorClasses.thumbnail)[0];
+ if (!showThumbnails) {
+ thumbnail && qq(thumbnail).remove();
+ }
+ else if (thumbnail) {
+ thumbnailMaxSize = parseInt(thumbnail.getAttribute(THUMBNAIL_MAX_SIZE_ATTR));
+ // Only enforce max size if the attr value is non-zero
+ thumbnailMaxSize = thumbnailMaxSize > 0 ? thumbnailMaxSize : null;
+
+ serverScale = qq(thumbnail).hasAttribute(THUMBNAIL_SERVER_SCALE_ATTR);
+ }
+ showThumbnails = showThumbnails && thumbnail;
+
+ isEditElementsExist = qq(tempTemplateEl).getByClass(selectorClasses.editFilenameInput).length > 0;
+ isRetryElementExist = qq(tempTemplateEl).getByClass(selectorClasses.retry).length > 0;
+
+ fileListNode = qq(tempTemplateEl).getByClass(selectorClasses.list)[0];
+ /*jshint -W116*/
+ if (fileListNode == null) {
+ throw new Error("Could not find the file list container in the template!");
+ }
+
+ fileListHtml = fileListNode.innerHTML;
+ fileListNode.innerHTML = "";
+
+ log("Template parsing complete");
+
+ return {
+ template: qq.trimStr(tempTemplateEl.innerHTML),
+ fileTemplate: qq.trimStr(fileListHtml)
+ };
+ }
+
+ function getFile(id) {
+ return qq(fileList).getByClass(FILE_CLASS_PREFIX + id)[0];
+ }
+
+ function getTemplateEl(context, cssClass) {
+ return context && qq(context).getByClass(cssClass)[0];
+ }
+
+ function prependFile(el, index) {
+ var parentEl = fileList,
+ beforeEl = parentEl.firstChild;
+
+ if (index > 0) {
+ beforeEl = qq(parentEl).children()[index].nextSibling;
+
+ }
+
+ parentEl.insertBefore(el, beforeEl);
+ }
+
+ function getCancel(id) {
+ return getTemplateEl(getFile(id), selectorClasses.cancel);
+ }
+
+ function getPause(id) {
+ return getTemplateEl(getFile(id), selectorClasses.pause);
+ }
+
+ function getContinue(id) {
+ return getTemplateEl(getFile(id), selectorClasses.continueButton);
+ }
+
+ function getProgress(id) {
+ /* jshint eqnull:true */
+ // Total progress bar
+ if (id == null) {
+ return getTemplateEl(container, selectorClasses.totalProgressBarContainer) ||
+ getTemplateEl(container, selectorClasses.totalProgressBar);
+ }
+
+ // Per-file progress bar
+ return getTemplateEl(getFile(id), selectorClasses.progressBarContainer) ||
+ getTemplateEl(getFile(id), selectorClasses.progressBar);
+ }
+
+ function getSpinner(id) {
+ return getTemplateEl(getFile(id), selectorClasses.spinner);
+ }
+
+ function getEditIcon(id) {
+ return getTemplateEl(getFile(id), selectorClasses.editNameIcon);
+ }
+
+ function getSize(id) {
+ return getTemplateEl(getFile(id), selectorClasses.size);
+ }
+
+ function getDelete(id) {
+ return getTemplateEl(getFile(id), selectorClasses.deleteButton);
+ }
+
+ function getRetry(id) {
+ return getTemplateEl(getFile(id), selectorClasses.retry);
+ }
+
+ function getFilename(id) {
+ return getTemplateEl(getFile(id), selectorClasses.file);
+ }
+
+ function getDropProcessing() {
+ return getTemplateEl(container, selectorClasses.dropProcessing);
+ }
+
+ function getThumbnail(id) {
+ return showThumbnails && getTemplateEl(getFile(id), selectorClasses.thumbnail);
+ }
+
+ function hide(el) {
+ el && qq(el).addClass(options.classes.hide);
+ }
+
+ function show(el) {
+ el && qq(el).removeClass(options.classes.hide);
+ }
+
+ function setProgressBarWidth(id, percent) {
+ var bar = getProgress(id),
+ /* jshint eqnull:true */
+ progressBarSelector = id == null ? selectorClasses.totalProgressBar : selectorClasses.progressBar;
+
+ if (bar && !qq(bar).hasClass(progressBarSelector)) {
+ bar = qq(bar).getByClass(progressBarSelector)[0];
+ }
+
+ bar && qq(bar).css({width: percent + "%"});
+ }
+
+ // During initialization of the templating module we should cache any
+ // placeholder images so we can quickly swap them into the file list on demand.
+ // Any placeholder images that cannot be loaded/found are simply ignored.
+ function cacheThumbnailPlaceholders() {
+ var notAvailableUrl = options.placeholders.thumbnailNotAvailable,
+ waitingUrl = options.placeholders.waitingForThumbnail,
+ spec = {
+ maxSize: thumbnailMaxSize,
+ scale: serverScale
+ };
+
+ if (showThumbnails) {
+ if (notAvailableUrl) {
+ options.imageGenerator.generate(notAvailableUrl, new Image(), spec).then(
+ function(updatedImg) {
+ cachedThumbnailNotAvailableImg.success(updatedImg);
+ },
+ function() {
+ cachedThumbnailNotAvailableImg.failure();
+ log("Problem loading 'not available' placeholder image at " + notAvailableUrl, "error");
+ }
+ );
+ }
+ else {
+ cachedThumbnailNotAvailableImg.failure();
+ }
+
+ if (waitingUrl) {
+ options.imageGenerator.generate(waitingUrl, new Image(), spec).then(
+ function(updatedImg) {
+ cachedWaitingForThumbnailImg.success(updatedImg);
+ },
+ function() {
+ cachedWaitingForThumbnailImg.failure();
+ log("Problem loading 'waiting for thumbnail' placeholder image at " + waitingUrl, "error");
+ }
+ );
+ }
+ else {
+ cachedWaitingForThumbnailImg.failure();
+ }
+ }
+ }
+
+ // Displays a "waiting for thumbnail" type placeholder image
+ // iff we were able to load it during initialization of the templating module.
+ function displayWaitingImg(thumbnail) {
+ var waitingImgPlacement = new qq.Promise();
+
+ cachedWaitingForThumbnailImg.then(function(img) {
+ maybeScalePlaceholderViaCss(img, thumbnail);
+ /* jshint eqnull:true */
+ if (!thumbnail.src) {
+ thumbnail.src = img.src;
+ thumbnail.onload = function() {
+ show(thumbnail);
+ waitingImgPlacement.success();
+ };
+ }
+ else {
+ waitingImgPlacement.success();
+ }
+ }, function() {
+ // In some browsers (such as IE9 and older) an img w/out a src attribute
+ // are displayed as "broken" images, so we should just hide the img tag
+ // if we aren't going to display the "waiting" placeholder.
+ hide(thumbnail);
+ waitingImgPlacement.success();
+ });
+
+ return waitingImgPlacement;
+ }
+
+ // Displays a "thumbnail not available" type placeholder image
+ // iff we were able to load this placeholder during initialization
+ // of the templating module or after preview generation has failed.
+ function maybeSetDisplayNotAvailableImg(id, thumbnail) {
+ var previewing = previewGeneration[id] || new qq.Promise().failure(),
+ notAvailableImgPlacement = new qq.Promise();
+
+ cachedThumbnailNotAvailableImg.then(function(img) {
+ previewing.then(
+ function() {
+ notAvailableImgPlacement.success();
+ },
+ function() {
+ maybeScalePlaceholderViaCss(img, thumbnail);
+ thumbnail.onload = function() {
+ notAvailableImgPlacement.success();
+ };
+ thumbnail.src = img.src;
+ show(thumbnail);
+ }
+ );
+ });
+
+ return notAvailableImgPlacement;
+ }
+
+ // Ensures a placeholder image does not exceed any max size specified
+ // via `style` attribute properties iff was not used to scale
+ // the placeholder AND the target doesn't already have these `style` attribute properties set.
+ function maybeScalePlaceholderViaCss(placeholder, thumbnail) {
+ var maxWidth = placeholder.style.maxWidth,
+ maxHeight = placeholder.style.maxHeight;
+
+ if (maxHeight && maxWidth && !thumbnail.style.maxWidth && !thumbnail.style.maxHeight) {
+ qq(thumbnail).css({
+ maxWidth: maxWidth,
+ maxHeight: maxHeight
+ });
+ }
+ }
+
+ function useCachedPreview(targetThumbnailId, cachedThumbnailId) {
+ var targetThumnail = getThumbnail(targetThumbnailId),
+ cachedThumbnail = getThumbnail(cachedThumbnailId);
+
+ log(qq.format("ID {} is the same file as ID {}. Will use generated thumbnail from ID {} instead.", targetThumbnailId, cachedThumbnailId, cachedThumbnailId));
+
+ // Generation of the related thumbnail may still be in progress, so, wait until it is done.
+ previewGeneration[cachedThumbnailId].then(function() {
+ previewGeneration[targetThumbnailId].success();
+ log(qq.format("Now using previously generated thumbnail created for ID {} on ID {}.", cachedThumbnailId, targetThumbnailId));
+ targetThumnail.src = cachedThumbnail.src;
+ show(targetThumnail);
+ },
+ function() {
+ previewGeneration[targetThumbnailId].failure();
+ if (!options.placeholders.waitUntilUpdate) {
+ maybeSetDisplayNotAvailableImg(targetThumbnailId, targetThumnail);
+ }
+ });
+ }
+
+ function generateNewPreview(id, blob, spec) {
+ var thumbnail = getThumbnail(id);
+
+ log("Generating new thumbnail for " + id);
+ blob.qqThumbnailId = id;
+
+ return options.imageGenerator.generate(blob, thumbnail, spec).then(
+ function() {
+ show(thumbnail);
+ previewGeneration[id].success();
+ },
+ function() {
+ previewGeneration[id].failure();
+
+ // Display the "not available" placeholder img only if we are
+ // not expecting a thumbnail at a later point, such as in a server response.
+ if (!options.placeholders.waitUntilUpdate) {
+ maybeSetDisplayNotAvailableImg(id, thumbnail);
+ }
+ });
+ }
+
+
+ qq.extend(options, spec);
+ log = options.log;
+
+ container = options.containerEl;
+ showThumbnails = options.imageGenerator !== undefined;
+ templateHtml = parseAndGetTemplate();
+
+ cacheThumbnailPlaceholders();
+
+ qq.extend(this, {
+ render: function() {
+ log("Rendering template in DOM.");
+
+ container.innerHTML = templateHtml.template;
+ hide(getDropProcessing());
+ this.hideTotalProgress();
+ fileList = options.fileContainerEl || getTemplateEl(container, selectorClasses.list);
+
+ log("Template rendering complete");
+ },
+
+ renderFailure: function(message) {
+ var cantRenderEl = qq.toElement(message);
+ container.innerHTML = "";
+ container.appendChild(cantRenderEl);
+ },
+
+ reset: function() {
+ this.render();
+ },
+
+ clearFiles: function() {
+ fileList.innerHTML = "";
+ },
+
+ disableCancel: function() {
+ isCancelDisabled = true;
+ },
+
+ addFile: function(id, name, prependInfo) {
+ var fileEl = qq.toElement(templateHtml.fileTemplate),
+ fileNameEl = getTemplateEl(fileEl, selectorClasses.file);
+
+ qq(fileEl).addClass(FILE_CLASS_PREFIX + id);
+ fileNameEl && qq(fileNameEl).setText(name);
+ fileEl.setAttribute(FILE_ID_ATTR, id);
+
+ if (prependInfo) {
+ prependFile(fileEl, prependInfo.index);
+ }
+ else {
+ fileList.appendChild(fileEl);
+ }
+
+ hide(getProgress(id));
+ hide(getSize(id));
+ hide(getDelete(id));
+ hide(getRetry(id));
+ hide(getPause(id));
+ hide(getContinue(id));
+
+ if (isCancelDisabled) {
+ this.hideCancel(id);
+ }
+ },
+
+ removeFile: function(id) {
+ qq(getFile(id)).remove();
+ },
+
+ getFileId: function(el) {
+ var currentNode = el;
+
+ if (currentNode) {
+ /*jshint -W116*/
+ while (currentNode.getAttribute(FILE_ID_ATTR) == null) {
+ currentNode = currentNode.parentNode;
+ }
+
+ return parseInt(currentNode.getAttribute(FILE_ID_ATTR));
+ }
+ },
+
+ getFileList: function() {
+ return fileList;
+ },
+
+ markFilenameEditable: function(id) {
+ var filename = getFilename(id);
+
+ filename && qq(filename).addClass(options.classes.editable);
+ },
+
+ updateFilename: function(id, name) {
+ var filename = getFilename(id);
+
+ filename && qq(filename).setText(name);
+ },
+
+ hideFilename: function(id) {
+ hide(getFilename(id));
+ },
+
+ showFilename: function(id) {
+ show(getFilename(id));
+ },
+
+ isFileName: function(el) {
+ return qq(el).hasClass(selectorClasses.file);
+ },
+
+ getButton: function() {
+ return options.button || getTemplateEl(container, selectorClasses.button);
+ },
+
+ hideDropProcessing: function() {
+ hide(getDropProcessing());
+ },
+
+ showDropProcessing: function() {
+ show(getDropProcessing());
+ },
+
+ getDropZone: function() {
+ return getTemplateEl(container, selectorClasses.drop);
+ },
+
+ isEditFilenamePossible: function() {
+ return isEditElementsExist;
+ },
+
+ hideRetry: function(id) {
+ hide(getRetry(id));
+ },
+
+ isRetryPossible: function() {
+ return isRetryElementExist;
+ },
+
+ showRetry: function(id) {
+ show(getRetry(id));
+ },
+
+ getFileContainer: function(id) {
+ return getFile(id);
+ },
+
+ showEditIcon: function(id) {
+ var icon = getEditIcon(id);
+
+ icon && qq(icon).addClass(options.classes.editable);
+ },
+
+ hideEditIcon: function(id) {
+ var icon = getEditIcon(id);
+
+ icon && qq(icon).removeClass(options.classes.editable);
+ },
+
+ isEditIcon: function(el) {
+ return qq(el).hasClass(selectorClasses.editNameIcon);
+ },
+
+ getEditInput: function(id) {
+ return getTemplateEl(getFile(id), selectorClasses.editFilenameInput);
+ },
+
+ isEditInput: function(el) {
+ return qq(el).hasClass(selectorClasses.editFilenameInput);
+ },
+
+ updateProgress: function(id, loaded, total) {
+ var bar = getProgress(id),
+ percent;
+
+ if (bar) {
+ percent = Math.round(loaded / total * 100);
+
+ if (percent === 100) {
+ hide(bar);
+ }
+ else {
+ show(bar);
+ }
+
+ setProgressBarWidth(id, percent);
+ }
+ },
+
+ updateTotalProgress: function(loaded, total) {
+ this.updateProgress(null, loaded, total);
+ },
+
+ hideProgress: function(id) {
+ var bar = getProgress(id);
+
+ bar && hide(bar);
+ },
+
+ hideTotalProgress: function() {
+ this.hideProgress();
+ },
+
+ resetProgress: function(id) {
+ setProgressBarWidth(id, 0);
+ },
+
+ resetTotalProgress: function() {
+ this.resetProgress();
+ },
+
+ showCancel: function(id) {
+ if (!isCancelDisabled) {
+ var cancel = getCancel(id);
+
+ cancel && qq(cancel).removeClass(options.classes.hide);
+ }
+ },
+
+ hideCancel: function(id) {
+ hide(getCancel(id));
+ },
+
+ isCancel: function(el) {
+ return qq(el).hasClass(selectorClasses.cancel);
+ },
+
+ allowPause: function(id) {
+ show(getPause(id));
+ hide(getContinue(id));
+ },
+
+ uploadPaused: function(id) {
+ this.setStatusText(id, options.text.paused);
+ this.allowContinueButton(id);
+ hide(getSpinner(id));
+ },
+
+ hidePause: function(id) {
+ hide(getPause(id));
+ },
+
+ isPause: function(el) {
+ return qq(el).hasClass(selectorClasses.pause);
+ },
+
+ isContinueButton: function(el) {
+ return qq(el).hasClass(selectorClasses.continueButton);
+ },
+
+ allowContinueButton: function(id) {
+ show(getContinue(id));
+ hide(getPause(id));
+ },
+
+ uploadContinued: function(id) {
+ this.setStatusText(id, "");
+ this.allowPause(id);
+ show(getSpinner(id));
+ },
+
+ showDeleteButton: function(id) {
+ show(getDelete(id));
+ },
+
+ hideDeleteButton: function(id) {
+ hide(getDelete(id));
+ },
+
+ isDeleteButton: function(el) {
+ return qq(el).hasClass(selectorClasses.deleteButton);
+ },
+
+ isRetry: function(el) {
+ return qq(el).hasClass(selectorClasses.retry);
+ },
+
+ updateSize: function(id, text) {
+ var size = getSize(id);
+
+ if (size) {
+ show(size);
+ qq(size).setText(text);
+ }
+ },
+
+ setStatusText: function(id, text) {
+ var textEl = getTemplateEl(getFile(id), selectorClasses.statusText);
+
+ if (textEl) {
+ /*jshint -W116*/
+ if (text == null) {
+ qq(textEl).clearText();
+ }
+ else {
+ qq(textEl).setText(text);
+ }
+ }
+ },
+
+ hideSpinner: function(id) {
+ hide(getSpinner(id));
+ },
+
+ showSpinner: function(id) {
+ show(getSpinner(id));
+ },
+
+ generatePreview: function(id, opt_fileOrBlob) {
+ var relatedThumbnailId = opt_fileOrBlob && opt_fileOrBlob.qqThumbnailId,
+ thumbnail = getThumbnail(id),
+ spec = {
+ maxSize: thumbnailMaxSize,
+ scale: true,
+ orient: true
+ };
+
+ if (qq.supportedFeatures.imagePreviews) {
+ if (thumbnail) {
+ displayWaitingImg(thumbnail).done(function() {
+ previewGeneration[id] = new qq.Promise();
+
+ /* jshint eqnull: true */
+ // If we've already generated an for this file, use the one that exists,
+ // don't waste resources generating a new one.
+ if (relatedThumbnailId != null) {
+ useCachedPreview(id, relatedThumbnailId);
+ }
+ else {
+ generateNewPreview(id, opt_fileOrBlob, spec);
+ }
+ });
+ }
+ }
+ else if (thumbnail) {
+ displayWaitingImg(thumbnail);
+ }
+ },
+
+ updateThumbnail: function(id, thumbnailUrl, showWaitingImg) {
+ var thumbnail = getThumbnail(id),
+ spec = {
+ maxSize: thumbnailMaxSize,
+ scale: serverScale
+ };
+
+ if (thumbnail) {
+ if (thumbnailUrl) {
+ if (showWaitingImg) {
+ displayWaitingImg(thumbnail);
+ }
+
+ return options.imageGenerator.generate(thumbnailUrl, thumbnail, spec).then(
+ function() {
+ show(thumbnail);
+ },
+ function() {
+ maybeSetDisplayNotAvailableImg(id, thumbnail);
+ }
+ );
+ }
+ else {
+ maybeSetDisplayNotAvailableImg(id, thumbnail);
+ }
+ }
+ }
+ });
+};
+
+/*globals qq*/
+/**
+ * Upload handler used that assumes the current user agent does not have any support for the
+ * File API, and, therefore, makes use of iframes and forms to submit the files directly to
+ * a generic server.
+ *
+ * @param options Options passed from the base handler
+ * @param proxy Callbacks & methods used to query for or push out data/changes
+ */
+qq.traditional = qq.traditional || {};
+qq.traditional.FormUploadHandler = function(options, proxy) {
+ "use strict";
+
+ var handler = this,
+ getName = proxy.getName,
+ getUuid = proxy.getUuid,
+ log = proxy.log;
+
+ /**
+ * @param innerHtmlOrMessage JSON message
+ * @returns {*} The parsed response, or an empty object if the response could not be parsed
+ */
+ function parseJsonResponse(innerHtmlOrMessage) {
+ var response = {};
+
+ try {
+ response = qq.parseJson(innerHtmlOrMessage);
+ }
+ catch(error) {
+ log("Error when attempting to parse iframe upload response (" + error.message + ")", "error");
+ }
+
+ return response;
+ }
+
+ /**
+ * Returns json object received by iframe from server.
+ */
+ function getIframeContentJson(id, iframe) {
+ /*jshint evil: true*/
+
+ var response;
+
+ //IE may throw an "access is denied" error when attempting to access contentDocument on the iframe in some cases
+ try {
+ // iframe.contentWindow.document - for IE<7
+ var doc = iframe.contentDocument || iframe.contentWindow.document,
+ innerHtml = doc.body.innerHTML;
+
+ log("converting iframe's innerHTML to JSON");
+ log("innerHTML = " + innerHtml);
+ //plain text response may be wrapped in tag
+ if (innerHtml && innerHtml.match(/^ 1 && !options.allowMultipleItems) {
+ options.callbacks.processingDroppedFilesComplete([]);
+ options.callbacks.dropError("tooManyFilesError", "");
+ uploadDropZone.dropDisabled(false);
+ handleDataTransferPromise.failure();
+ }
+ else {
+ droppedFiles = [];
+
+ if (qq.isFolderDropSupported(dataTransfer)) {
+ qq.each(dataTransfer.items, function(idx, item) {
+ var entry = item.webkitGetAsEntry();
+
+ if (entry) {
+ //due to a bug in Chrome's File System API impl - #149735
+ if (entry.isFile) {
+ droppedFiles.push(item.getAsFile());
+ }
+
+ else {
+ pendingFolderPromises.push(traverseFileTree(entry).done(function() {
+ pendingFolderPromises.pop();
+ if (pendingFolderPromises.length === 0) {
+ handleDataTransferPromise.success();
+ }
+ }));
+ }
+ }
+ });
+ }
+ else {
+ droppedFiles = dataTransfer.files;
+ }
+
+ if (pendingFolderPromises.length === 0) {
+ handleDataTransferPromise.success();
+ }
+ }
+
+ return handleDataTransferPromise;
+ }
+
+ function setupDropzone(dropArea) {
+ var dropZone = new qq.UploadDropZone({
+ HIDE_ZONES_EVENT_NAME: HIDE_ZONES_EVENT_NAME,
+ element: dropArea,
+ onEnter: function(e){
+ qq(dropArea).addClass(options.classes.dropActive);
+ e.stopPropagation();
+ },
+ onLeaveNotDescendants: function(e){
+ qq(dropArea).removeClass(options.classes.dropActive);
+ },
+ onDrop: function(e){
+ handleDataTransfer(e.dataTransfer, dropZone).then(
+ function() {
+ uploadDroppedFiles(droppedFiles, dropZone);
+ },
+ function() {
+ options.callbacks.dropLog("Drop event DataTransfer parsing failed. No files will be uploaded.", "error");
+ }
+ );
+ }
+ });
+
+ disposeSupport.addDisposer(function() {
+ dropZone.dispose();
+ });
+
+ qq(dropArea).hasAttribute(HIDE_BEFORE_ENTER_ATTR) && qq(dropArea).hide();
+
+ uploadDropZones.push(dropZone);
+
+ return dropZone;
+ }
+
+ function isFileDrag(dragEvent) {
+ var fileDrag;
+
+ qq.each(dragEvent.dataTransfer.types, function(key, val) {
+ if (val === "Files") {
+ fileDrag = true;
+ return false;
+ }
+ });
+
+ return fileDrag;
+ }
+
+ // Attempt to determine when the file has left the document. It is not always possible to detect this
+ // in all cases, but it is generally possible in all browsers, with a few exceptions.
+ //
+ // Exceptions:
+ // * IE10+ & Safari: We can't detect a file leaving the document if the Explorer window housing the file
+ // overlays the browser window.
+ // * IE10+: If the file is dragged out of the window too quickly, IE does not set the expected values of the
+ // event's X & Y properties.
+ function leavingDocumentOut(e) {
+ if (qq.firefox()) {
+ return !e.relatedTarget;
+ }
+
+ if (qq.safari()) {
+ return e.x < 0 || e.y < 0;
+ }
+
+ return e.x === 0 && e.y === 0;
+ }
+
+ function setupDragDrop() {
+ var dropZones = options.dropZoneElements,
+
+ maybeHideDropZones = function() {
+ setTimeout(function() {
+ qq.each(dropZones, function(idx, dropZone) {
+ qq(dropZone).hasAttribute(HIDE_BEFORE_ENTER_ATTR) && qq(dropZone).hide();
+ qq(dropZone).removeClass(options.classes.dropActive);
+ });
+ }, 10);
+ };
+
+ qq.each(dropZones, function(idx, dropZone) {
+ var uploadDropZone = setupDropzone(dropZone);
+
+ // IE <= 9 does not support the File API used for drag+drop uploads
+ if (dropZones.length && (!qq.ie() || qq.ie10())) {
+ disposeSupport.attach(document, "dragenter", function(e) {
+ if (!uploadDropZone.dropDisabled() && isFileDrag(e)) {
+ qq.each(dropZones, function(idx, dropZone) {
+ // We can't apply styles to non-HTMLElements, since they lack the `style` property
+ if (dropZone instanceof HTMLElement) {
+ qq(dropZone).css({display: "block"});
+ }
+ });
+ }
+ });
+ }
+ });
+
+ disposeSupport.attach(document, "dragleave", function(e) {
+ if (leavingDocumentOut(e)) {
+ maybeHideDropZones();
+ }
+ });
+
+ // Just in case we were not able to detect when a dragged file has left the document,
+ // hide all relevant drop zones the next time the mouse enters the document.
+ // Note that mouse events such as this one are not fired during drag operations.
+ disposeSupport.attach(qq(document).children()[0], "mouseenter", function(e) {
+ maybeHideDropZones();
+ });
+
+ disposeSupport.attach(document, "drop", function(e){
+ e.preventDefault();
+ maybeHideDropZones();
+ });
+
+ disposeSupport.attach(document, HIDE_ZONES_EVENT_NAME, maybeHideDropZones);
+ }
+
+ setupDragDrop();
+
+ qq.extend(this, {
+ setupExtraDropzone: function(element) {
+ options.dropZoneElements.push(element);
+ setupDropzone(element);
+ },
+
+ removeDropzone: function(element) {
+ var i,
+ dzs = options.dropZoneElements;
+
+ for(i in dzs) {
+ if (dzs[i] === element) {
+ return dzs.splice(i, 1);
+ }
+ }
+ },
+
+ dispose: function() {
+ disposeSupport.dispose();
+ qq.each(uploadDropZones, function(idx, dropZone) {
+ dropZone.dispose();
+ });
+ }
+ });
+};
+
+qq.DragAndDrop.callbacks = function() {
+ "use strict";
+
+ return {
+ processingDroppedFiles: function() {},
+ processingDroppedFilesComplete: function(files, targetEl) {},
+ dropError: function(code, errorSpecifics) {
+ qq.log("Drag & drop error code '" + code + " with these specifics: '" + errorSpecifics + "'", "error");
+ },
+ dropLog: function(message, level) {
+ qq.log(message, level);
+ }
+ };
+};
+
+qq.UploadDropZone = function(o){
+ "use strict";
+
+ var disposeSupport = new qq.DisposeSupport(),
+ options, element, preventDrop, dropOutsideDisabled;
+
+ options = {
+ element: null,
+ onEnter: function(e){},
+ onLeave: function(e){},
+ // is not fired when leaving element by hovering descendants
+ onLeaveNotDescendants: function(e){},
+ onDrop: function(e){}
+ };
+
+ qq.extend(options, o);
+ element = options.element;
+
+ function dragover_should_be_canceled(){
+ return qq.safari() || (qq.firefox() && qq.windows());
+ }
+
+ function disableDropOutside(e){
+ // run only once for all instances
+ if (!dropOutsideDisabled ){
+
+ // for these cases we need to catch onDrop to reset dropArea
+ if (dragover_should_be_canceled){
+ disposeSupport.attach(document, "dragover", function(e){
+ e.preventDefault();
+ });
+ } else {
+ disposeSupport.attach(document, "dragover", function(e){
+ if (e.dataTransfer){
+ e.dataTransfer.dropEffect = "none";
+ e.preventDefault();
+ }
+ });
+ }
+
+ dropOutsideDisabled = true;
+ }
+ }
+
+ function isValidFileDrag(e){
+ // e.dataTransfer currently causing IE errors
+ // IE9 does NOT support file API, so drag-and-drop is not possible
+ if (qq.ie() && !qq.ie10()) {
+ return false;
+ }
+
+ var effectTest, dt = e.dataTransfer,
+ // do not check dt.types.contains in webkit, because it crashes safari 4
+ isSafari = qq.safari();
+
+ // dt.effectAllowed is none in Safari 5
+ // dt.types.contains check is for firefox
+
+ // dt.effectAllowed crashes IE11 when files have been dragged from
+ // the filesystem
+ effectTest = (qq.ie10() || qq.ie11()) ? true : dt.effectAllowed !== "none";
+ return dt && effectTest && (dt.files || (!isSafari && dt.types.contains && dt.types.contains("Files")));
+ }
+
+ function isOrSetDropDisabled(isDisabled) {
+ if (isDisabled !== undefined) {
+ preventDrop = isDisabled;
+ }
+ return preventDrop;
+ }
+
+ function triggerHidezonesEvent() {
+ var hideZonesEvent;
+
+ function triggerUsingOldApi() {
+ hideZonesEvent = document.createEvent("Event");
+ hideZonesEvent.initEvent(options.HIDE_ZONES_EVENT_NAME, true, true);
+ }
+
+ if (window.CustomEvent) {
+ try {
+ hideZonesEvent = new CustomEvent(options.HIDE_ZONES_EVENT_NAME);
+ }
+ catch (err) {
+ triggerUsingOldApi();
+ }
+ }
+ else {
+ triggerUsingOldApi();
+ }
+
+ document.dispatchEvent(hideZonesEvent);
+ }
+
+ function attachEvents(){
+ disposeSupport.attach(element, "dragover", function(e){
+ if (!isValidFileDrag(e)) {
+ return;
+ }
+
+ // dt.effectAllowed crashes IE11 when files have been dragged from
+ // the filesystem
+ var effect = (qq.ie() || qq.ie11()) ? null : e.dataTransfer.effectAllowed;
+ if (effect === "move" || effect === "linkMove"){
+ e.dataTransfer.dropEffect = "move"; // for FF (only move allowed)
+ } else {
+ e.dataTransfer.dropEffect = "copy"; // for Chrome
+ }
+
+ e.stopPropagation();
+ e.preventDefault();
+ });
+
+ disposeSupport.attach(element, "dragenter", function(e){
+ if (!isOrSetDropDisabled()) {
+ if (!isValidFileDrag(e)) {
+ return;
+ }
+ options.onEnter(e);
+ }
+ });
+
+ disposeSupport.attach(element, "dragleave", function(e){
+ if (!isValidFileDrag(e)) {
+ return;
+ }
+
+ options.onLeave(e);
+
+ var relatedTarget = document.elementFromPoint(e.clientX, e.clientY);
+ // do not fire when moving a mouse over a descendant
+ if (qq(this).contains(relatedTarget)) {
+ return;
+ }
+
+ options.onLeaveNotDescendants(e);
+ });
+
+ disposeSupport.attach(element, "drop", function(e) {
+ if (!isOrSetDropDisabled()) {
+ if (!isValidFileDrag(e)) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+ options.onDrop(e);
+
+ triggerHidezonesEvent();
+ }
+ });
+ }
+
+ disableDropOutside();
+ attachEvents();
+
+ qq.extend(this, {
+ dropDisabled: function(isDisabled) {
+ return isOrSetDropDisabled(isDisabled);
+ },
+
+ dispose: function() {
+ disposeSupport.dispose();
+ },
+
+ getElement: function() {
+ return element;
+ }
+ });
+};
+
+/*globals qq, XMLHttpRequest*/
+qq.DeleteFileAjaxRequester = function(o) {
+ "use strict";
+
+ var requester,
+ options = {
+ method: "DELETE",
+ uuidParamName: "qquuid",
+ endpointStore: {},
+ maxConnections: 3,
+ customHeaders: function(id) {return {};},
+ paramsStore: {},
+ demoMode: false,
+ cors: {
+ expected: false,
+ sendCredentials: false
+ },
+ log: function(str, level) {},
+ onDelete: function(id) {},
+ onDeleteComplete: function(id, xhrOrXdr, isError) {}
+ };
+
+ qq.extend(options, o);
+
+ function getMandatedParams() {
+ if (options.method.toUpperCase() === "POST") {
+ return {
+ "_method": "DELETE"
+ };
+ }
+
+ return {};
+ }
+
+ requester = qq.extend(this, new qq.AjaxRequester({
+ acceptHeader: "application/json",
+ validMethods: ["POST", "DELETE"],
+ method: options.method,
+ endpointStore: options.endpointStore,
+ paramsStore: options.paramsStore,
+ mandatedParams: getMandatedParams(),
+ maxConnections: options.maxConnections,
+ customHeaders: function(id) {
+ return options.customHeaders.get(id);
+ },
+ demoMode: options.demoMode,
+ log: options.log,
+ onSend: options.onDelete,
+ onComplete: options.onDeleteComplete,
+ cors: options.cors
+ }));
+
+
+ qq.extend(this, {
+ sendDelete: function(id, uuid, additionalMandatedParams) {
+ var additionalOptions = additionalMandatedParams || {};
+
+ options.log("Submitting delete file request for " + id);
+
+ if (options.method === "DELETE") {
+ requester.initTransport(id)
+ .withPath(uuid)
+ .withParams(additionalOptions)
+ .send();
+ }
+ else {
+ additionalOptions[options.uuidParamName] = uuid;
+ requester.initTransport(id)
+ .withParams(additionalOptions)
+ .send();
+ }
+ }
+ });
+};
+
+/*global qq, define */
+/*jshint strict:false,bitwise:false,nonew:false,asi:true,-W064,-W116,-W089 */
+/**
+ * Mega pixel image rendering library for iOS6+
+ *
+ * Fixes iOS6+'s image file rendering issue for large size image (over mega-pixel),
+ * which causes unexpected subsampling when drawing it in canvas.
+ * By using this library, you can safely render the image with proper stretching.
+ *
+ * Copyright (c) 2012 Shinichi Tomita
+ * Released under the MIT license
+ *
+ * Modified by Widen for Fine Uploader
+ */
+(function() {
+
+ /**
+ * Detect subsampling in loaded image.
+ * In iOS, larger images than 2M pixels may be subsampled in rendering.
+ */
+ function detectSubsampling(img) {
+ var iw = img.naturalWidth, ih = img.naturalHeight;
+ if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image
+ var canvas = document.createElement("canvas");
+ canvas.width = canvas.height = 1;
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(img, -iw + 1, 0);
+ // subsampled image becomes half smaller in rendering size.
+ // check alpha channel value to confirm image is covering edge pixel or not.
+ // if alpha value is 0 image is not covering, hence subsampled.
+ return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Detecting vertical squash in loaded image.
+ * Fixes a bug which squash image vertically while drawing into canvas for some images.
+ */
+ function detectVerticalSquash(img, iw, ih) {
+ var canvas = document.createElement("canvas");
+ canvas.width = 1;
+ canvas.height = ih;
+ var ctx = canvas.getContext("2d");
+ ctx.drawImage(img, 0, 0);
+ var data = ctx.getImageData(0, 0, 1, ih).data;
+ // search image edge pixel position in case it is squashed vertically.
+ var sy = 0;
+ var ey = ih;
+ var py = ih;
+ while (py > sy) {
+ var alpha = data[(py - 1) * 4 + 3];
+ if (alpha === 0) {
+ ey = py;
+ } else {
+ sy = py;
+ }
+ py = (ey + sy) >> 1;
+ }
+ var ratio = (py / ih);
+ return (ratio===0)?1:ratio;
+ }
+
+ /**
+ * Rendering image element (with resizing) and get its data URL
+ */
+ function renderImageToDataURL(img, options, doSquash) {
+ var canvas = document.createElement("canvas"),
+ mime = options.mime || "image/jpeg";
+
+ renderImageToCanvas(img, canvas, options, doSquash);
+ return canvas.toDataURL(mime, options.quality || 0.8);
+ }
+
+ function maybeCalculateDownsampledDimensions(spec) {
+ var maxPixels = 5241000; //iOS specific value
+
+ if (!qq.ios()) {
+ throw new qq.Error("Downsampled dimensions can only be reliably calculated for iOS!");
+ }
+
+ if (spec.origHeight * spec.origWidth > maxPixels) {
+ return {
+ newHeight: Math.round(Math.sqrt(maxPixels * (spec.origHeight / spec.origWidth))),
+ newWidth: Math.round(Math.sqrt(maxPixels * (spec.origWidth / spec.origHeight)))
+ }
+ }
+ }
+
+ /**
+ * Rendering image element (with resizing) into the canvas element
+ */
+ function renderImageToCanvas(img, canvas, options, doSquash) {
+ var iw = img.naturalWidth, ih = img.naturalHeight;
+ var width = options.width, height = options.height;
+ var ctx = canvas.getContext("2d");
+ ctx.save();
+
+ if (!qq.supportedFeatures.unlimitedScaledImageSize) {
+ var modifiedDimensions = maybeCalculateDownsampledDimensions({
+ origWidth: width,
+ origHeight: height
+ });
+
+ if (modifiedDimensions) {
+ qq.log(qq.format("Had to reduce dimensions due to device limitations from {}w / {}h to {}w / {}h",
+ width, height, modifiedDimensions.newWidth, modifiedDimensions.newHeight),
+ "warn");
+
+ width = modifiedDimensions.newWidth;
+ height = modifiedDimensions.newHeight;
+ }
+ }
+
+ transformCoordinate(canvas, width, height, options.orientation);
+
+ // Fine Uploader specific: Save some CPU cycles if not using iOS
+ // Assumption: This logic is only needed to overcome iOS image sampling issues
+ if (qq.ios()) {
+ var subsampled = detectSubsampling(img);
+ if (subsampled) {
+ iw /= 2;
+ ih /= 2;
+ }
+ var d = 1024; // size of tiling canvas
+ var tmpCanvas = document.createElement("canvas");
+ tmpCanvas.width = tmpCanvas.height = d;
+ var tmpCtx = tmpCanvas.getContext("2d");
+ var vertSquashRatio = doSquash ? detectVerticalSquash(img, iw, ih) : 1;
+ var dw = Math.ceil(d * width / iw);
+ var dh = Math.ceil(d * height / ih / vertSquashRatio);
+ var sy = 0;
+ var dy = 0;
+ while (sy < ih) {
+ var sx = 0;
+ var dx = 0;
+ while (sx < iw) {
+ tmpCtx.clearRect(0, 0, d, d);
+ tmpCtx.drawImage(img, -sx, -sy);
+ ctx.drawImage(tmpCanvas, 0, 0, d, d, dx, dy, dw, dh);
+ sx += d;
+ dx += dw;
+ }
+ sy += d;
+ dy += dh;
+ }
+ ctx.restore();
+ tmpCanvas = tmpCtx = null;
+ }
+ else {
+ ctx.drawImage(img, 0, 0, width, height);
+ }
+
+ canvas.qqImageRendered && canvas.qqImageRendered();
+ }
+
+ /**
+ * Transform canvas coordination according to specified frame size and orientation
+ * Orientation value is from EXIF tag
+ */
+ function transformCoordinate(canvas, width, height, orientation) {
+ switch (orientation) {
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ canvas.width = height;
+ canvas.height = width;
+ break;
+ default:
+ canvas.width = width;
+ canvas.height = height;
+ }
+ var ctx = canvas.getContext("2d");
+ switch (orientation) {
+ case 2:
+ // horizontal flip
+ ctx.translate(width, 0);
+ ctx.scale(-1, 1);
+ break;
+ case 3:
+ // 180 rotate left
+ ctx.translate(width, height);
+ ctx.rotate(Math.PI);
+ break;
+ case 4:
+ // vertical flip
+ ctx.translate(0, height);
+ ctx.scale(1, -1);
+ break;
+ case 5:
+ // vertical flip + 90 rotate right
+ ctx.rotate(0.5 * Math.PI);
+ ctx.scale(1, -1);
+ break;
+ case 6:
+ // 90 rotate right
+ ctx.rotate(0.5 * Math.PI);
+ ctx.translate(0, -height);
+ break;
+ case 7:
+ // horizontal flip + 90 rotate right
+ ctx.rotate(0.5 * Math.PI);
+ ctx.translate(width, -height);
+ ctx.scale(-1, 1);
+ break;
+ case 8:
+ // 90 rotate left
+ ctx.rotate(-0.5 * Math.PI);
+ ctx.translate(-width, 0);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ /**
+ * MegaPixImage class
+ */
+ function MegaPixImage(srcImage, errorCallback) {
+ if (window.Blob && srcImage instanceof Blob) {
+ var img = new Image();
+ var URL = window.URL && window.URL.createObjectURL ? window.URL :
+ window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL :
+ null;
+ if (!URL) { throw Error("No createObjectURL function found to create blob url"); }
+ img.src = URL.createObjectURL(srcImage);
+ this.blob = srcImage;
+ srcImage = img;
+ }
+ if (!srcImage.naturalWidth && !srcImage.naturalHeight) {
+ var _this = this;
+ srcImage.onload = function() {
+ var listeners = _this.imageLoadListeners;
+ if (listeners) {
+ _this.imageLoadListeners = null;
+ // IE11 doesn't reliably report actual image dimensions immediately after onload for small files,
+ // so let's push this to the end of the UI thread queue.
+ setTimeout(function() {
+ for (var i=0, len=listeners.length; i maxWidth) {
+ width = maxWidth;
+ height = (imgHeight * width / imgWidth) << 0;
+ }
+ if (maxHeight && height > maxHeight) {
+ height = maxHeight;
+ width = (imgWidth * height / imgHeight) << 0;
+ }
+ var opt = { width : width, height : height };
+ for (var k in options) opt[k] = options[k];
+
+ var tagName = target.tagName.toLowerCase();
+ if (tagName === "img") {
+ target.src = renderImageToDataURL(this.srcImage, opt, doSquash);
+ } else if (tagName === "canvas") {
+ renderImageToCanvas(this.srcImage, target, opt, doSquash);
+ }
+ if (typeof this.onrender === "function") {
+ this.onrender(target);
+ }
+ };
+
+ qq.MegaPixImage = MegaPixImage;
+})();
+
+/*globals qq */
+/**
+ * Draws a thumbnail of a Blob/File/URL onto an or .
+ *
+ * @constructor
+ */
+qq.ImageGenerator = function(log) {
+ "use strict";
+
+ function isImg(el) {
+ return el.tagName.toLowerCase() === "img";
+ }
+
+ function isCanvas(el) {
+ return el.tagName.toLowerCase() === "canvas";
+ }
+
+ function isImgCorsSupported() {
+ return new Image().crossOrigin !== undefined;
+ }
+
+ function isCanvasSupported() {
+ var canvas = document.createElement("canvas");
+
+ return canvas.getContext && canvas.getContext("2d");
+ }
+
+ // This is only meant to determine the MIME type of a renderable image file.
+ // It is used to ensure images drawn from a URL that have transparent backgrounds
+ // are rendered correctly, among other things.
+ function determineMimeOfFileName(nameWithPath) {
+ /*jshint -W015 */
+ var pathSegments = nameWithPath.split("/"),
+ name = pathSegments[pathSegments.length - 1],
+ extension = qq.getExtension(name);
+
+ extension = extension && extension.toLowerCase();
+
+ switch(extension) {
+ case "jpeg":
+ case "jpg":
+ return "image/jpeg";
+ case "png":
+ return "image/png";
+ case "bmp":
+ return "image/bmp";
+ case "gif":
+ return "image/gif";
+ case "tiff":
+ case "tif":
+ return "image/tiff";
+ }
+ }
+
+ // This will likely not work correctly in IE8 and older.
+ // It's only used as part of a formula to determine
+ // if a canvas can be used to scale a server-hosted thumbnail.
+ // If canvas isn't supported by the UA (IE8 and older)
+ // this method should not even be called.
+ function isCrossOrigin(url) {
+ var targetAnchor = document.createElement("a"),
+ targetProtocol, targetHostname, targetPort;
+
+ targetAnchor.href = url;
+
+ targetProtocol = targetAnchor.protocol;
+ targetPort = targetAnchor.port;
+ targetHostname = targetAnchor.hostname;
+
+ if (targetProtocol.toLowerCase() !== window.location.protocol.toLowerCase()) {
+ return true;
+ }
+
+ if (targetHostname.toLowerCase() !== window.location.hostname.toLowerCase()) {
+ return true;
+ }
+
+ // IE doesn't take ports into consideration when determining if two endpoints are same origin.
+ if (targetPort !== window.location.port && !qq.ie()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function registerImgLoadListeners(img, promise) {
+ img.onload = function() {
+ img.onload = null;
+ img.onerror = null;
+ promise.success(img);
+ };
+
+ img.onerror = function() {
+ img.onload = null;
+ img.onerror = null;
+ log("Problem drawing thumbnail!", "error");
+ promise.failure(img, "Problem drawing thumbnail!");
+ };
+ }
+
+ function registerCanvasDrawImageListener(canvas, promise) {
+ // The image is drawn on the canvas by a third-party library,
+ // and we want to know when this is completed. Since the library
+ // may invoke drawImage many times in a loop, we need to be called
+ // back when the image is fully rendered. So, we are expecting the
+ // code that draws this image to follow a convention that involves a
+ // function attached to the canvas instance be invoked when it is done.
+ canvas.qqImageRendered = function() {
+ promise.success(canvas);
+ };
+ }
+
+ // Fulfills a `qq.Promise` when an image has been drawn onto the target,
+ // whether that is a or an . The attempt is considered a
+ // failure if the target is not an or a , or if the drawing
+ // attempt was not successful.
+ function registerThumbnailRenderedListener(imgOrCanvas, promise) {
+ var registered = isImg(imgOrCanvas) || isCanvas(imgOrCanvas);
+
+ if (isImg(imgOrCanvas)) {
+ registerImgLoadListeners(imgOrCanvas, promise);
+ }
+ else if (isCanvas(imgOrCanvas)) {
+ registerCanvasDrawImageListener(imgOrCanvas, promise);
+ }
+ else {
+ promise.failure(imgOrCanvas);
+ log(qq.format("Element container of type {} is not supported!", imgOrCanvas.tagName), "error");
+ }
+
+ return registered;
+ }
+
+ // Draw a preview iff the current UA can natively display it.
+ // Also rotate the image if necessary.
+ function draw(fileOrBlob, container, options) {
+ var drawPreview = new qq.Promise(),
+ identifier = new qq.Identify(fileOrBlob, log),
+ maxSize = options.maxSize,
+ // jshint eqnull:true
+ orient = options.orient == null ? true : options.orient,
+ megapixErrorHandler = function() {
+ container.onerror = null;
+ container.onload = null;
+ log("Could not render preview, file may be too large!", "error");
+ drawPreview.failure(container, "Browser cannot render image!");
+ };
+
+ identifier.isPreviewable().then(
+ function(mime) {
+ // If options explicitly specify that Orientation is not desired,
+ // replace the orient task with a dummy promise that "succeeds" immediately.
+ var dummyExif = {
+ parse: function() {
+ return new qq.Promise().success();
+ }
+ },
+ exif = orient ? new qq.Exif(fileOrBlob, log) : dummyExif,
+ mpImg = new qq.MegaPixImage(fileOrBlob, megapixErrorHandler);
+
+ if (registerThumbnailRenderedListener(container, drawPreview)) {
+ exif.parse().then(
+ function(exif) {
+ var orientation = exif && exif.Orientation;
+
+ mpImg.render(container, {
+ maxWidth: maxSize,
+ maxHeight: maxSize,
+ orientation: orientation,
+ mime: mime
+ });
+ },
+
+ function(failureMsg) {
+ log(qq.format("EXIF data could not be parsed ({}). Assuming orientation = 1.", failureMsg));
+
+ mpImg.render(container, {
+ maxWidth: maxSize,
+ maxHeight: maxSize,
+ mime: mime
+ });
+ }
+ );
+ }
+ },
+
+ function() {
+ log("Not previewable");
+ drawPreview.failure(container, "Not previewable");
+ }
+ );
+
+ return drawPreview;
+ }
+
+ function drawOnCanvasOrImgFromUrl(url, canvasOrImg, draw, maxSize) {
+ var tempImg = new Image(),
+ tempImgRender = new qq.Promise();
+
+ registerThumbnailRenderedListener(tempImg, tempImgRender);
+
+ if (isCrossOrigin(url)) {
+ tempImg.crossOrigin = "anonymous";
+ }
+
+ tempImg.src = url;
+
+ tempImgRender.then(function() {
+ registerThumbnailRenderedListener(canvasOrImg, draw);
+
+ var mpImg = new qq.MegaPixImage(tempImg);
+ mpImg.render(canvasOrImg, {
+ maxWidth: maxSize,
+ maxHeight: maxSize,
+ mime: determineMimeOfFileName(url)
+ });
+ });
+ }
+
+ function drawOnImgFromUrlWithCssScaling(url, img, draw, maxSize) {
+ registerThumbnailRenderedListener(img, draw);
+ qq(img).css({
+ maxWidth: maxSize + "px",
+ maxHeight: maxSize + "px"
+ });
+
+ img.src = url;
+ }
+
+ // Draw a (server-hosted) thumbnail given a URL.
+ // This will optionally scale the thumbnail as well.
+ // It attempts to use to scale, but will fall back
+ // to max-width and max-height style properties if the UA
+ // doesn't support canvas or if the images is cross-domain and
+ // the UA doesn't support the crossorigin attribute on img tags,
+ // which is required to scale a cross-origin image using &
+ // then export it back to an .
+ function drawFromUrl(url, container, options) {
+ var draw = new qq.Promise(),
+ scale = options.scale,
+ maxSize = scale ? options.maxSize : null;
+
+ // container is an img, scaling needed
+ if (scale && isImg(container)) {
+ // Iff canvas is available in this UA, try to use it for scaling.
+ // Otherwise, fall back to CSS scaling
+ if (isCanvasSupported()) {
+ // Attempt to use for image scaling,
+ // but we must fall back to scaling via CSS/styles
+ // if this is a cross-origin image and the UA doesn't support CORS.
+ if (isCrossOrigin(url) && !isImgCorsSupported()) {
+ drawOnImgFromUrlWithCssScaling(url, container, draw, maxSize);
+ }
+ else {
+ drawOnCanvasOrImgFromUrl(url, container, draw, maxSize);
+ }
+ }
+ else {
+ drawOnImgFromUrlWithCssScaling(url, container, draw, maxSize);
+ }
+ }
+ // container is a canvas, scaling optional
+ else if (isCanvas(container)) {
+ drawOnCanvasOrImgFromUrl(url, container, draw, maxSize);
+ }
+ // container is an img & no scaling: just set the src attr to the passed url
+ else if (registerThumbnailRenderedListener(container, draw)) {
+ container.src = url;
+ }
+
+ return draw;
+ }
+
+
+ qq.extend(this, {
+ /**
+ * Generate a thumbnail. Depending on the arguments, this may either result in
+ * a client-side rendering of an image (if a `Blob` is supplied) or a server-generated
+ * image that may optionally be scaled client-side using or CSS/styles (as a fallback).
+ *
+ * @param fileBlobOrUrl a `File`, `Blob`, or a URL pointing to the image
+ * @param container or to contain the preview
+ * @param options possible properties include `maxSize` (int), `orient` (bool - default true), and `resize` (bool - default true)
+ * @returns qq.Promise fulfilled when the preview has been drawn, or the attempt has failed
+ */
+ generate: function(fileBlobOrUrl, container, options) {
+ if (qq.isString(fileBlobOrUrl)) {
+ log("Attempting to update thumbnail based on server response.");
+ return drawFromUrl(fileBlobOrUrl, container, options || {});
+ }
+ else {
+ log("Attempting to draw client-side image preview.");
+ return draw(fileBlobOrUrl, container, options || {});
+ }
+ }
+ });
+
+ /**/
+ this._testing = {};
+ this._testing.isImg = isImg;
+ this._testing.isCanvas = isCanvas;
+ this._testing.isCrossOrigin = isCrossOrigin;
+ this._testing.determineMimeOfFileName = determineMimeOfFileName;
+ /* */
+};
+
+/*globals qq */
+/**
+ * EXIF image data parser. Currently only parses the Orientation tag value,
+ * but this may be expanded to other tags in the future.
+ *
+ * @param fileOrBlob Attempt to parse EXIF data in this `Blob`
+ * @constructor
+ */
+qq.Exif = function(fileOrBlob, log) {
+ "use strict";
+
+ // Orientation is the only tag parsed here at this time.
+ var TAG_IDS = [274],
+ TAG_INFO = {
+ 274: {
+ name: "Orientation",
+ bytes: 2
+ }
+ };
+
+ // Convert a little endian (hex string) to big endian (decimal).
+ function parseLittleEndian(hex) {
+ var result = 0,
+ pow = 0;
+
+ while (hex.length > 0) {
+ result += parseInt(hex.substring(0, 2), 16) * Math.pow(2, pow);
+ hex = hex.substring(2, hex.length);
+ pow += 8;
+ }
+
+ return result;
+ }
+
+ // Find the byte offset, of Application Segment 1 (EXIF).
+ // External callers need not supply any arguments.
+ function seekToApp1(offset, promise) {
+ var theOffset = offset,
+ thePromise = promise;
+ if (theOffset === undefined) {
+ theOffset = 2;
+ thePromise = new qq.Promise();
+ }
+
+ qq.readBlobToHex(fileOrBlob, theOffset, 4).then(function(hex) {
+ var match = /^ffe([0-9])/.exec(hex);
+ if (match) {
+ if (match[1] !== "1") {
+ var segmentLength = parseInt(hex.slice(4, 8), 16);
+ seekToApp1(theOffset + segmentLength + 2, thePromise);
+ }
+ else {
+ thePromise.success(theOffset);
+ }
+ }
+ else {
+ thePromise.failure("No EXIF header to be found!");
+ }
+ });
+
+ return thePromise;
+ }
+
+ // Find the byte offset of Application Segment 1 (EXIF) for valid JPEGs only.
+ function getApp1Offset() {
+ var promise = new qq.Promise();
+
+ qq.readBlobToHex(fileOrBlob, 0, 6).then(function(hex) {
+ if (hex.indexOf("ffd8") !== 0) {
+ promise.failure("Not a valid JPEG!");
+ }
+ else {
+ seekToApp1().then(function(offset) {
+ promise.success(offset);
+ },
+ function(error) {
+ promise.failure(error);
+ });
+ }
+ });
+
+ return promise;
+ }
+
+ // Determine the byte ordering of the EXIF header.
+ function isLittleEndian(app1Start) {
+ var promise = new qq.Promise();
+
+ qq.readBlobToHex(fileOrBlob, app1Start + 10, 2).then(function(hex) {
+ promise.success(hex === "4949");
+ });
+
+ return promise;
+ }
+
+ // Determine the number of directory entries in the EXIF header.
+ function getDirEntryCount(app1Start, littleEndian) {
+ var promise = new qq.Promise();
+
+ qq.readBlobToHex(fileOrBlob, app1Start + 18, 2).then(function(hex) {
+ if (littleEndian) {
+ return promise.success(parseLittleEndian(hex));
+ }
+ else {
+ promise.success(parseInt(hex, 16));
+ }
+ });
+
+ return promise;
+ }
+
+ // Get the IFD portion of the EXIF header as a hex string.
+ function getIfd(app1Start, dirEntries) {
+ var offset = app1Start + 20,
+ bytes = dirEntries * 12;
+
+ return qq.readBlobToHex(fileOrBlob, offset, bytes);
+ }
+
+ // Obtain an array of all directory entries (as hex strings) in the EXIF header.
+ function getDirEntries(ifdHex) {
+ var entries = [],
+ offset = 0;
+
+ while (offset+24 <= ifdHex.length) {
+ entries.push(ifdHex.slice(offset, offset + 24));
+ offset += 24;
+ }
+
+ return entries;
+ }
+
+ // Obtain values for all relevant tags and return them.
+ function getTagValues(littleEndian, dirEntries) {
+ var TAG_VAL_OFFSET = 16,
+ tagsToFind = qq.extend([], TAG_IDS),
+ vals = {};
+
+ qq.each(dirEntries, function(idx, entry) {
+ var idHex = entry.slice(0, 4),
+ id = littleEndian ? parseLittleEndian(idHex) : parseInt(idHex, 16),
+ tagsToFindIdx = tagsToFind.indexOf(id),
+ tagValHex, tagName, tagValLength;
+
+ if (tagsToFindIdx >= 0) {
+ tagName = TAG_INFO[id].name;
+ tagValLength = TAG_INFO[id].bytes;
+ tagValHex = entry.slice(TAG_VAL_OFFSET, TAG_VAL_OFFSET + (tagValLength*2));
+ vals[tagName] = littleEndian ? parseLittleEndian(tagValHex) : parseInt(tagValHex, 16);
+
+ tagsToFind.splice(tagsToFindIdx, 1);
+ }
+
+ if (tagsToFind.length === 0) {
+ return false;
+ }
+ });
+
+ return vals;
+ }
+
+ qq.extend(this, {
+ /**
+ * Attempt to parse the EXIF header for the `Blob` associated with this instance.
+ *
+ * @returns {qq.Promise} To be fulfilled when the parsing is complete.
+ * If successful, the parsed EXIF header as an object will be included.
+ */
+ parse: function() {
+ var parser = new qq.Promise(),
+ onParseFailure = function(message) {
+ log(qq.format("EXIF header parse failed: '{}' ", message));
+ parser.failure(message);
+ };
+
+ getApp1Offset().then(function(app1Offset) {
+ log(qq.format("Moving forward with EXIF header parsing for '{}'", fileOrBlob.name === undefined ? "blob" : fileOrBlob.name));
+
+ isLittleEndian(app1Offset).then(function(littleEndian) {
+
+ log(qq.format("EXIF Byte order is {} endian", littleEndian ? "little" : "big"));
+
+ getDirEntryCount(app1Offset, littleEndian).then(function(dirEntryCount) {
+
+ log(qq.format("Found {} APP1 directory entries", dirEntryCount));
+
+ getIfd(app1Offset, dirEntryCount).then(function(ifdHex) {
+ var dirEntries = getDirEntries(ifdHex),
+ tagValues = getTagValues(littleEndian, dirEntries);
+
+ log("Successfully parsed some EXIF tags");
+
+ parser.success(tagValues);
+ }, onParseFailure);
+ }, onParseFailure);
+ }, onParseFailure);
+ }, onParseFailure);
+
+ return parser;
+ }
+ });
+
+ /**/
+ this._testing = {};
+ this._testing.parseLittleEndian = parseLittleEndian;
+ /* */
+};
+
+/*globals qq */
+qq.Identify = function(fileOrBlob, log) {
+ "use strict";
+
+ function isIdentifiable(magicBytes, questionableBytes) {
+ var identifiable = false,
+ magicBytesEntries = [].concat(magicBytes);
+
+ qq.each(magicBytesEntries, function(idx, magicBytesArrayEntry) {
+ if (questionableBytes.indexOf(magicBytesArrayEntry) === 0) {
+ identifiable = true;
+ return false;
+ }
+ });
+
+ return identifiable;
+ }
+
+ qq.extend(this, {
+ /**
+ * Determines if a Blob can be displayed natively in the current browser. This is done by reading magic
+ * bytes in the beginning of the file, so this is an asynchronous operation. Before we attempt to read the
+ * file, we will examine the blob's type attribute to save CPU cycles.
+ *
+ * @returns {qq.Promise} Promise that is fulfilled when identification is complete.
+ * If successful, the MIME string is passed to the success handler.
+ */
+ isPreviewable: function() {
+ var self = this,
+ idenitifer = new qq.Promise(),
+ previewable = false,
+ name = fileOrBlob.name === undefined ? "blob" : fileOrBlob.name;
+
+ log(qq.format("Attempting to determine if {} can be rendered in this browser", name));
+
+ log("First pass: check type attribute of blob object.");
+
+ if (this.isPreviewableSync()) {
+ log("Second pass: check for magic bytes in file header.");
+
+ qq.readBlobToHex(fileOrBlob, 0, 4).then(function(hex) {
+ qq.each(self.PREVIEWABLE_MIME_TYPES, function(mime, bytes) {
+ if (isIdentifiable(bytes, hex)) {
+ // Safari is the only supported browser that can deal with TIFFs natively,
+ // so, if this is a TIFF and the UA isn't Safari, declare this file "non-previewable".
+ if (mime !== "image/tiff" || qq.supportedFeatures.tiffPreviews) {
+ previewable = true;
+ idenitifer.success(mime);
+ }
+
+ return false;
+ }
+ });
+
+ log(qq.format("'{}' is {} able to be rendered in this browser", name, previewable ? "" : "NOT"));
+
+ if (!previewable) {
+ idenitifer.failure();
+ }
+ },
+ function() {
+ log("Error reading file w/ name '" + name + "'. Not able to be rendered in this browser.");
+ idenitifer.failure();
+ });
+ }
+ else {
+ idenitifer.failure();
+ }
+
+ return idenitifer;
+ },
+
+ /**
+ * Determines if a Blob can be displayed natively in the current browser. This is done by checking the
+ * blob's type attribute. This is a synchronous operation, useful for situations where an asynchronous operation
+ * would be challenging to support. Note that the blob's type property is not as accurate as reading the
+ * file's magic bytes.
+ *
+ * @returns {Boolean} true if the blob can be rendered in the current browser
+ */
+ isPreviewableSync: function() {
+ var fileMime = fileOrBlob.type,
+ // Assumption: This will only ever be executed in browsers that support `Object.keys`.
+ isRecognizedImage = qq.indexOf(Object.keys(this.PREVIEWABLE_MIME_TYPES), fileMime) >= 0,
+ previewable = false,
+ name = fileOrBlob.name === undefined ? "blob" : fileOrBlob.name;
+
+ if (isRecognizedImage) {
+ if (fileMime === "image/tiff") {
+ previewable = qq.supportedFeatures.tiffPreviews;
+ }
+ else {
+ previewable = true;
+ }
+ }
+
+ !previewable && log(name + " is not previewable in this browser per the blob's type attr");
+
+ return previewable;
+ }
+ });
+};
+
+qq.Identify.prototype.PREVIEWABLE_MIME_TYPES = {
+ "image/jpeg": "ffd8ff",
+ "image/gif": "474946",
+ "image/png": "89504e",
+ "image/bmp": "424d",
+ "image/tiff": ["49492a00", "4d4d002a"]
+};
+
+/*globals qq*/
+/**
+ * Attempts to validate an image, wherever possible.
+ *
+ * @param blob File or Blob representing a user-selecting image.
+ * @param log Uses this to post log messages to the console.
+ * @constructor
+ */
+qq.ImageValidation = function(blob, log) {
+ "use strict";
+
+ /**
+ * @param limits Object with possible image-related limits to enforce.
+ * @returns {boolean} true if at least one of the limits has a non-zero value
+ */
+ function hasNonZeroLimits(limits) {
+ var atLeastOne = false;
+
+ qq.each(limits, function(limit, value) {
+ if (value > 0) {
+ atLeastOne = true;
+ return false;
+ }
+ });
+
+ return atLeastOne;
+ }
+
+ /**
+ * @returns {qq.Promise} The promise is a failure if we can't obtain the width & height.
+ * Otherwise, `success` is called on the returned promise with an object containing
+ * `width` and `height` properties.
+ */
+ function getWidthHeight() {
+ var sizeDetermination = new qq.Promise();
+
+ new qq.Identify(blob, log).isPreviewable().then(function() {
+ var image = new Image(),
+ url = window.URL && window.URL.createObjectURL ? window.URL :
+ window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL :
+ null;
+
+ if (url) {
+ image.onerror = function() {
+ log("Cannot determine dimensions for image. May be too large.", "error");
+ sizeDetermination.failure();
+ };
+
+ image.onload = function() {
+ sizeDetermination.success({
+ width: this.width,
+ height: this.height
+ });
+ };
+
+ image.src = url.createObjectURL(blob);
+ }
+ else {
+ log("No createObjectURL function available to generate image URL!", "error");
+ sizeDetermination.failure();
+ }
+ }, sizeDetermination.failure);
+
+ return sizeDetermination;
+ }
+
+ /**
+ *
+ * @param limits Object with possible image-related limits to enforce.
+ * @param dimensions Object containing `width` & `height` properties for the image to test.
+ * @returns {String || undefined} The name of the failing limit. Undefined if no failing limits.
+ */
+ function getFailingLimit(limits, dimensions) {
+ var failingLimit;
+
+ qq.each(limits, function(limitName, limitValue) {
+ if (limitValue > 0) {
+ var limitMatcher = /(max|min)(Width|Height)/.exec(limitName),
+ dimensionPropName = limitMatcher[2].charAt(0).toLowerCase() + limitMatcher[2].slice(1),
+ actualValue = dimensions[dimensionPropName];
+
+ /*jshint -W015*/
+ switch(limitMatcher[1]) {
+ case "min":
+ if (actualValue < limitValue) {
+ failingLimit = limitName;
+ return false;
+ }
+ break;
+ case "max":
+ if (actualValue > limitValue) {
+ failingLimit = limitName;
+ return false;
+ }
+ break;
+ }
+ }
+ });
+
+ return failingLimit;
+ }
+
+ /**
+ * Validate the associated blob.
+ *
+ * @param limits
+ * @returns {qq.Promise} `success` is called on the promise is the image is valid or
+ * if the blob is not an image, or if the image is not verifiable.
+ * Otherwise, `failure` with the name of the failing limit.
+ */
+ this.validate = function(limits) {
+ var validationEffort = new qq.Promise();
+
+ log("Attempting to validate image.");
+
+ if (hasNonZeroLimits(limits)) {
+ getWidthHeight().then(function(dimensions) {
+ var failingLimit = getFailingLimit(limits, dimensions);
+
+ if (failingLimit) {
+ validationEffort.failure(failingLimit);
+ }
+ else {
+ validationEffort.success();
+ }
+ }, validationEffort.success);
+ }
+ else {
+ validationEffort.success();
+ }
+
+ return validationEffort;
+ };
+};
+
+/* globals qq */
+/**
+ * Module used to control populating the initial list of files.
+ *
+ * @constructor
+ */
+qq.Session = function(spec) {
+ "use strict";
+
+ var options = {
+ endpoint: null,
+ params: {},
+ customHeaders: {},
+ cors: {},
+ addFileRecord: function(sessionData) {},
+ log: function(message, level) {}
+ };
+
+ qq.extend(options, spec, true);
+
+
+ function isJsonResponseValid(response) {
+ if (qq.isArray(response)) {
+ return true;
+ }
+
+ options.log("Session response is not an array.", "error");
+ }
+
+ function handleFileItems(fileItems, success, xhrOrXdr, promise) {
+ var someItemsIgnored = false;
+
+ success = success && isJsonResponseValid(fileItems);
+
+ if (success) {
+ qq.each(fileItems, function(idx, fileItem) {
+ /* jshint eqnull:true */
+ if (fileItem.uuid == null) {
+ someItemsIgnored = true;
+ options.log(qq.format("Session response item {} did not include a valid UUID - ignoring.", idx), "error");
+ }
+ else if (fileItem.name == null) {
+ someItemsIgnored = true;
+ options.log(qq.format("Session response item {} did not include a valid name - ignoring.", idx), "error");
+ }
+ else {
+ try {
+ options.addFileRecord(fileItem);
+ return true;
+ }
+ catch(err) {
+ someItemsIgnored = true;
+ options.log(err.message, "error");
+ }
+ }
+
+ return false;
+ });
+ }
+
+ promise[success && !someItemsIgnored ? "success" : "failure"](fileItems, xhrOrXdr);
+ }
+
+ // Initiate a call to the server that will be used to populate the initial file list.
+ // Returns a `qq.Promise`.
+ this.refresh = function() {
+ /*jshint indent:false */
+ var refreshEffort = new qq.Promise(),
+ refreshCompleteCallback = function(response, success, xhrOrXdr) {
+ handleFileItems(response, success, xhrOrXdr, refreshEffort);
+ },
+ requsterOptions = qq.extend({}, options),
+ requester = new qq.SessionAjaxRequester(
+ qq.extend(requsterOptions, {onComplete: refreshCompleteCallback})
+ );
+
+ requester.queryServer();
+
+ return refreshEffort;
+ };
+};
+
+/*globals qq, XMLHttpRequest*/
+/**
+ * Thin module used to send GET requests to the server, expecting information about session
+ * data used to initialize an uploader instance.
+ *
+ * @param spec Various options used to influence the associated request.
+ * @constructor
+ */
+qq.SessionAjaxRequester = function(spec) {
+ "use strict";
+
+ var requester,
+ options = {
+ endpoint: null,
+ customHeaders: {},
+ params: {},
+ cors: {
+ expected: false,
+ sendCredentials: false
+ },
+ onComplete: function(response, success, xhrOrXdr) {},
+ log: function(str, level) {}
+ };
+
+ qq.extend(options, spec);
+
+ function onComplete(id, xhrOrXdr, isError) {
+ var response = null;
+
+ /* jshint eqnull:true */
+ if (xhrOrXdr.responseText != null) {
+ try {
+ response = qq.parseJson(xhrOrXdr.responseText);
+ }
+ catch(err) {
+ options.log("Problem parsing session response: " + err.message, "error");
+ isError = true;
+ }
+ }
+
+ options.onComplete(response, !isError, xhrOrXdr);
+ }
+
+ requester = qq.extend(this, new qq.AjaxRequester({
+ acceptHeader: "application/json",
+ validMethods: ["GET"],
+ method: "GET",
+ endpointStore: {
+ get: function() {
+ return options.endpoint;
+ }
+ },
+ customHeaders: options.customHeaders,
+ log: options.log,
+ onComplete: onComplete,
+ cors: options.cors
+ }));
+
+
+ qq.extend(this, {
+ queryServer: function() {
+ var params = qq.extend({}, options.params);
+
+ options.log("Session query request.");
+
+ requester.initTransport("sessionRefresh")
+ .withParams(params)
+ .withCacheBuster()
+ .send();
+ }
+ });
+};
+
+/* globals qq */
+/**
+ * Module that handles support for existing forms.
+ *
+ * @param options Options passed from the integrator-supplied options related to form support.
+ * @param startUpload Callback to invoke when files "stored" should be uploaded.
+ * @param log Proxy for the logger
+ * @constructor
+ */
+qq.FormSupport = function(options, startUpload, log) {
+ "use strict";
+ var self = this,
+ interceptSubmit = options.interceptSubmit,
+ formEl = options.element,
+ autoUpload = options.autoUpload;
+
+ // Available on the public API associated with this module.
+ qq.extend(this, {
+ // To be used by the caller to determine if the endpoint will be determined by some processing
+ // that occurs in this module, such as if the form has an action attribute.
+ // Ignore if `attachToForm === false`.
+ newEndpoint: null,
+
+ // To be used by the caller to determine if auto uploading should be allowed.
+ // Ignore if `attachToForm === false`.
+ newAutoUpload: autoUpload,
+
+ // true if a form was detected and is being tracked by this module
+ attachedToForm: false,
+
+ // Returns an object with names and values for all valid form elements associated with the attached form.
+ getFormInputsAsObject: function() {
+ /* jshint eqnull:true */
+ if (formEl == null) {
+ return null;
+ }
+
+ return self._form2Obj(formEl);
+ }
+ });
+
+ // If the form contains an action attribute, this should be the new upload endpoint.
+ function determineNewEndpoint(formEl) {
+ if (formEl.getAttribute("action")) {
+ self.newEndpoint = formEl.getAttribute("action");
+ }
+ }
+
+ // Return true only if the form is valid, or if we cannot make this determination.
+ // If the form is invalid, ensure invalid field(s) are highlighted in the UI.
+ function validateForm(formEl, nativeSubmit) {
+ if (formEl.checkValidity && !formEl.checkValidity()) {
+ log("Form did not pass validation checks - will not upload.", "error");
+ nativeSubmit();
+ }
+ else {
+ return true;
+ }
+ }
+
+ // Intercept form submit attempts, unless the integrator has told us not to do this.
+ function maybeUploadOnSubmit(formEl) {
+ var nativeSubmit = formEl.submit;
+
+ // Intercept and squelch submit events.
+ qq(formEl).attach("submit", function(event) {
+ event = event || window.event;
+
+ if (event.preventDefault) {
+ event.preventDefault();
+ }
+ else {
+ event.returnValue = false;
+ }
+
+ validateForm(formEl, nativeSubmit) && startUpload();
+ });
+
+ // The form's `submit()` function may be called instead (i.e. via jQuery.submit()).
+ // Intercept that too.
+ formEl.submit = function() {
+ validateForm(formEl, nativeSubmit) && startUpload();
+ };
+ }
+
+ // If the element value passed from the uploader is a string, assume it is an element ID - select it.
+ // The rest of the code in this module depends on this being an HTMLElement.
+ function determineFormEl(formEl) {
+ if (formEl) {
+ if (qq.isString(formEl)) {
+ formEl = document.getElementById(formEl);
+ }
+
+ if (formEl) {
+ log("Attaching to form element.");
+ determineNewEndpoint(formEl);
+ interceptSubmit && maybeUploadOnSubmit(formEl);
+ }
+ }
+
+ return formEl;
+ }
+
+ formEl = determineFormEl(formEl);
+ this.attachedToForm = !!formEl;
+};
+
+qq.extend(qq.FormSupport.prototype, {
+ // Converts all relevant form fields to key/value pairs. This is meant to mimic the data a browser will
+ // construct from a given form when the form is submitted.
+ _form2Obj: function(form) {
+ "use strict";
+ var obj = {},
+ notIrrelevantType = function(type) {
+ var irrelevantTypes = [
+ "button",
+ "image",
+ "reset",
+ "submit"
+ ];
+
+ return qq.indexOf(irrelevantTypes, type.toLowerCase()) < 0;
+ },
+ radioOrCheckbox = function(type) {
+ return qq.indexOf(["checkbox", "radio"], type.toLowerCase()) >= 0;
+ },
+ ignoreValue = function(el) {
+ if (radioOrCheckbox(el.type) && !el.checked) {
+ return true;
+ }
+
+ return el.disabled && el.type.toLowerCase() !== "hidden";
+ },
+ selectValue = function(select) {
+ var value = null;
+
+ qq.each(qq(select).children(), function(idx, child) {
+ if (child.tagName.toLowerCase() === "option" && child.selected) {
+ value = child.value;
+ return false;
+ }
+ });
+
+ return value;
+ };
+
+ qq.each(form.elements, function(idx, el) {
+ if ((qq.isInput(el, true) || el.tagName.toLowerCase() === "textarea") &&
+ notIrrelevantType(el.type) &&
+ !ignoreValue(el)) {
+
+ obj[el.name] = el.value;
+ }
+ else if (el.tagName.toLowerCase() === "select" && !ignoreValue(el)) {
+ var value = selectValue(el);
+
+ if (value !== null) {
+ obj[el.name] = value;
+ }
+ }
+ });
+
+ return obj;
+ }
+});
+
+/* globals qq, ExifRestorer */
+/**
+ * Controls generation of scaled images based on a reference image encapsulated in a `File` or `Blob`.
+ * Scaled images are generated and converted to blobs on-demand.
+ * Multiple scaled images per reference image with varying sizes and other properties are supported.
+ *
+ * @param spec Information about the scaled images to generate.
+ * @param log Logger instance
+ * @constructor
+ */
+qq.Scaler = function(spec, log) {
+ "use strict";
+
+ var self = this,
+ includeReference = spec.sendOriginal,
+ orient = spec.orient,
+ defaultType = spec.defaultType,
+ defaultQuality = spec.defaultQuality / 100,
+ failedToScaleText = spec.failureText,
+ includeExif = spec.includeExif,
+ sizes = this._getSortedSizes(spec.sizes);
+
+ // Revealed API for instances of this module
+ qq.extend(this, {
+ // If no targeted sizes have been declared or if this browser doesn't support
+ // client-side image preview generation, there is no scaling to do.
+ enabled: qq.supportedFeatures.scaling && sizes.length > 0,
+
+ getFileRecords: function(originalFileUuid, originalFileName, originalBlobOrBlobData) {
+ var self = this,
+ records = [],
+ originalBlob = originalBlobOrBlobData.blob ? originalBlobOrBlobData.blob : originalBlobOrBlobData,
+ idenitifier = new qq.Identify(originalBlob, log);
+
+ // If the reference file cannot be rendered natively, we can't create scaled versions.
+ if (idenitifier.isPreviewableSync()) {
+ // Create records for each scaled version & add them to the records array, smallest first.
+ qq.each(sizes, function(idx, sizeRecord) {
+ var outputType = self._determineOutputType({
+ defaultType: defaultType,
+ requestedType: sizeRecord.type,
+ refType: originalBlob.type
+ });
+
+ records.push({
+ uuid: qq.getUniqueId(),
+ name: self._getName(originalFileName, {
+ name: sizeRecord.name,
+ type: outputType,
+ refType: originalBlob.type
+ }),
+ blob: new qq.BlobProxy(originalBlob,
+ qq.bind(self._generateScaledImage, self, {
+ maxSize: sizeRecord.maxSize,
+ orient: orient,
+ type: outputType,
+ quality: defaultQuality,
+ failedText: failedToScaleText,
+ includeExif: includeExif,
+ log: log
+ }))
+ }
+ );
+ });
+
+ includeReference && records.push({
+ uuid: originalFileUuid,
+ name: originalFileName,
+ blob: originalBlob
+ });
+ }
+ else {
+ records.push({
+ uuid: originalFileUuid,
+ name: originalFileName,
+ blob: originalBlob
+ });
+ }
+
+ return records;
+ },
+
+ handleNewFile: function(file, name, uuid, size, fileList, uuidParamName, batchId, api) {
+ var self = this,
+ buttonId = file.qqButtonId || (file.blob && file.blob.qqButtonId),
+ scaledIds = [],
+ originalId = null,
+ addFileToHandler = api.addFileToHandler,
+ uploadData = api.uploadData,
+ paramsStore = api.paramsStore,
+ proxyGroupId = qq.getUniqueId();
+
+ qq.each(self.getFileRecords(uuid, name, file), function(idx, record) {
+ var relatedBlob = file,
+ relatedSize = size,
+ id;
+
+ if (record.blob instanceof qq.BlobProxy) {
+ relatedBlob = record.blob;
+ relatedSize = -1;
+ }
+
+ id = uploadData.addFile({
+ uuid: record.uuid,
+ name: record.name,
+ size: relatedSize,
+ batchId: batchId,
+ proxyGroupId: proxyGroupId
+ });
+
+ if (record.blob instanceof qq.BlobProxy) {
+ scaledIds.push(id);
+ }
+ else {
+ originalId = id;
+ }
+
+ addFileToHandler(id, relatedBlob);
+
+ fileList.push({id: id, file: relatedBlob});
+
+ });
+
+ // If we are potentially uploading an original file and some scaled versions,
+ // ensure the scaled versions include reference's to the parent's UUID and size
+ // in their associated upload requests.
+ if (originalId !== null) {
+ qq.each(scaledIds, function(idx, scaledId) {
+ var params = {
+ qqparentuuid: uploadData.retrieve({id: originalId}).uuid,
+ qqparentsize: uploadData.retrieve({id: originalId}).size
+ };
+
+ // Make SURE the UUID for each scaled image is sent with the upload request,
+ // to be consistent (since we need to ensure it is sent for the original file as well).
+ params[uuidParamName] = uploadData.retrieve({id: scaledId}).uuid;
+
+ uploadData.setParentId(scaledId, originalId);
+ paramsStore.addReadOnly(scaledId, params);
+ });
+
+ // If any scaled images are tied to this parent image, be SURE we send its UUID as an upload request
+ // parameter as well.
+ if (scaledIds.length) {
+ (function() {
+ var param = {};
+ param[uuidParamName] = uploadData.retrieve({id: originalId}).uuid;
+ paramsStore.addReadOnly(originalId, param);
+ }());
+ }
+ }
+ }
+ });
+};
+
+qq.extend(qq.Scaler.prototype, {
+ scaleImage: function(id, specs, api) {
+ "use strict";
+
+ if (!qq.supportedFeatures.scaling) {
+ throw new qq.Error("Scaling is not supported in this browser!");
+ }
+
+ var scalingEffort = new qq.Promise(),
+ log = api.log,
+ file = api.getFile(id),
+ uploadData = api.uploadData.retrieve({id: id}),
+ name = uploadData && uploadData.name,
+ uuid = uploadData && uploadData.uuid,
+ scalingOptions = {
+ sendOriginal: false,
+ orient: specs.orient,
+ defaultType: specs.type || null,
+ defaultQuality: specs.quality,
+ failedToScaleText: "Unable to scale",
+ sizes: [{name: "", maxSize: specs.maxSize}]
+ },
+ scaler = new qq.Scaler(scalingOptions, log);
+
+ if (!qq.Scaler || !qq.supportedFeatures.imagePreviews || !file) {
+ scalingEffort.failure();
+
+ log("Could not generate requested scaled image for " + id + ". " +
+ "Scaling is either not possible in this browser, or the file could not be located.", "error");
+ }
+ else {
+ (qq.bind(function() {
+ // Assumption: There will never be more than one record
+ var record = scaler.getFileRecords(uuid, name, file)[0];
+
+ if (record && record.blob instanceof qq.BlobProxy) {
+ record.blob.create().then(scalingEffort.success, scalingEffort.failure);
+ }
+ else {
+ log(id + " is not a scalable image!", "error");
+ scalingEffort.failure();
+ }
+ }, this)());
+ }
+
+ return scalingEffort;
+ },
+
+ // NOTE: We cannot reliably determine at this time if the UA supports a specific MIME type for the target format.
+ // image/jpeg and image/png are the only safe choices at this time.
+ _determineOutputType: function(spec) {
+ "use strict";
+
+ var requestedType = spec.requestedType,
+ defaultType = spec.defaultType,
+ referenceType = spec.refType;
+
+ // If a default type and requested type have not been specified, this should be a
+ // JPEG if the original type is a JPEG, otherwise, a PNG.
+ if (!defaultType && !requestedType) {
+ if (referenceType !== "image/jpeg") {
+ return "image/png";
+ }
+ return referenceType;
+ }
+
+ // A specified default type is used when a requested type is not specified.
+ if (!requestedType) {
+ return defaultType;
+ }
+
+ // If requested type is specified, use it, as long as this recognized type is supported by the current UA
+ if (qq.indexOf(Object.keys(qq.Identify.prototype.PREVIEWABLE_MIME_TYPES), requestedType) >= 0) {
+ if (requestedType === "image/tiff") {
+ return qq.supportedFeatures.tiffPreviews ? requestedType : defaultType;
+ }
+
+ return requestedType;
+ }
+
+ return defaultType;
+ },
+
+ // Get a file name for a generated scaled file record, based on the provided scaled image description
+ _getName: function(originalName, scaledVersionProperties) {
+ "use strict";
+
+ var startOfExt = originalName.lastIndexOf("."),
+ nameAppendage = " (" + scaledVersionProperties.name + ")",
+ versionType = scaledVersionProperties.type || "image/png",
+ referenceType = scaledVersionProperties.refType,
+ scaledName = "",
+ scaledExt = qq.getExtension(originalName);
+
+ if (startOfExt >= 0) {
+ scaledName = originalName.substr(0, startOfExt);
+
+ if (referenceType !== versionType) {
+ scaledExt = versionType.split("/")[1];
+ }
+
+ scaledName += nameAppendage + "." + scaledExt;
+ }
+ else {
+ scaledName = originalName + nameAppendage;
+ }
+
+ return scaledName;
+ },
+
+ // We want the smallest scaled file to be uploaded first
+ _getSortedSizes: function(sizes) {
+ "use strict";
+
+ sizes = qq.extend([], sizes);
+
+ return sizes.sort(function(a, b) {
+ if (a.maxSize > b.maxSize) {
+ return 1;
+ }
+ if (a.maxSize < b.maxSize) {
+ return -1;
+ }
+ return 0;
+ });
+ },
+
+ _generateScaledImage: function(spec, sourceFile) {
+ "use strict";
+
+ var self = this,
+ log = spec.log,
+ maxSize = spec.maxSize,
+ orient = spec.orient,
+ type = spec.type,
+ quality = spec.quality,
+ failedText = spec.failedText,
+ includeExif = spec.includeExif && sourceFile.type === "image/jpeg" && type === "image/jpeg",
+ scalingEffort = new qq.Promise(),
+ imageGenerator = new qq.ImageGenerator(log),
+ canvas = document.createElement("canvas");
+
+ log("Attempting to generate scaled version for " + sourceFile.name);
+
+ imageGenerator.generate(sourceFile, canvas, {maxSize: maxSize, orient: orient}).then(function() {
+ var scaledImageDataUri = canvas.toDataURL(type, quality),
+ signalSuccess = function() {
+ log("Success generating scaled version for " + sourceFile.name);
+ var blob = self._dataUriToBlob(scaledImageDataUri);
+ scalingEffort.success(blob);
+ };
+
+ if (includeExif) {
+ self._insertExifHeader(sourceFile, scaledImageDataUri, log).then(function(scaledImageDataUriWithExif) {
+ scaledImageDataUri = scaledImageDataUriWithExif;
+ signalSuccess();
+ },
+ function() {
+ log("Problem inserting EXIF header into scaled image. Using scaled image w/out EXIF data.", "error");
+ signalSuccess();
+ });
+ }
+ else {
+ signalSuccess();
+ }
+ }, function() {
+ log("Failed attempt to generate scaled version for " + sourceFile.name, "error");
+ scalingEffort.failure(failedText);
+ });
+
+ return scalingEffort;
+ },
+
+ // Attempt to insert the original image's EXIF header into a scaled version.
+ _insertExifHeader: function(originalImage, scaledImageDataUri, log) {
+ "use strict";
+
+ var reader = new FileReader(),
+ insertionEffort = new qq.Promise(),
+ originalImageDataUri = "";
+
+ reader.onload = function() {
+ originalImageDataUri = reader.result;
+ insertionEffort.success(ExifRestorer.restore(originalImageDataUri, scaledImageDataUri));
+ };
+
+ reader.onerror = function() {
+ log("Problem reading " + originalImage.name + " during attempt to transfer EXIF data to scaled version.", "error");
+ insertionEffort.failure();
+ };
+
+ reader.readAsDataURL(originalImage);
+
+ return insertionEffort;
+ },
+
+
+ _dataUriToBlob: function(dataUri) {
+ "use strict";
+
+ var byteString, mimeString, arrayBuffer, intArray;
+
+ // convert base64 to raw binary data held in a string
+ if (dataUri.split(",")[0].indexOf("base64") >= 0) {
+ byteString = atob(dataUri.split(",")[1]);
+ }
+ else {
+ byteString = decodeURI(dataUri.split(",")[1]);
+ }
+
+ // extract the MIME
+ mimeString = dataUri.split(",")[0]
+ .split(":")[1]
+ .split(";")[0];
+
+ // write the bytes of the binary string to an ArrayBuffer
+ arrayBuffer = new ArrayBuffer(byteString.length);
+ intArray = new Uint8Array(arrayBuffer);
+ qq.each(byteString, function(idx, character) {
+ intArray[idx] = character.charCodeAt(0);
+ });
+
+ return this._createBlob(arrayBuffer, mimeString);
+ },
+
+ _createBlob: function(data, mime) {
+ "use strict";
+
+ var BlobBuilder = window.BlobBuilder ||
+ window.WebKitBlobBuilder ||
+ window.MozBlobBuilder ||
+ window.MSBlobBuilder,
+ blobBuilder = BlobBuilder && new BlobBuilder();
+
+ if (blobBuilder) {
+ blobBuilder.append(data);
+ return blobBuilder.getBlob(mime);
+ }
+ else {
+ return new Blob([data], {type: mime});
+ }
+ }
+});
+
+//Based on MinifyJpeg
+//http://elicon.blog57.fc2.com/blog-entry-206.html
+
+var ExifRestorer = (function()
+{
+
+ var ExifRestorer = {};
+
+ ExifRestorer.KEY_STR = "ABCDEFGHIJKLMNOP" +
+ "QRSTUVWXYZabcdef" +
+ "ghijklmnopqrstuv" +
+ "wxyz0123456789+/" +
+ "=";
+
+ ExifRestorer.encode64 = function(input)
+ {
+ var output = "",
+ chr1, chr2, chr3 = "",
+ enc1, enc2, enc3, enc4 = "",
+ i = 0;
+
+ do {
+ chr1 = input[i++];
+ chr2 = input[i++];
+ chr3 = input[i++];
+
+ enc1 = chr1 >> 2;
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+ enc4 = chr3 & 63;
+
+ if (isNaN(chr2)) {
+ enc3 = enc4 = 64;
+ } else if (isNaN(chr3)) {
+ enc4 = 64;
+ }
+
+ output = output +
+ this.KEY_STR.charAt(enc1) +
+ this.KEY_STR.charAt(enc2) +
+ this.KEY_STR.charAt(enc3) +
+ this.KEY_STR.charAt(enc4);
+ chr1 = chr2 = chr3 = "";
+ enc1 = enc2 = enc3 = enc4 = "";
+ } while (i < input.length);
+
+ return output;
+ };
+
+ ExifRestorer.restore = function(origFileBase64, resizedFileBase64)
+ {
+ var expectedBase64Header = "data:image/jpeg;base64,";
+
+ if (!origFileBase64.match(expectedBase64Header))
+ {
+ return resizedFileBase64;
+ }
+
+ var rawImage = this.decode64(origFileBase64.replace(expectedBase64Header, ""));
+ var segments = this.slice2Segments(rawImage);
+
+ var image = this.exifManipulation(resizedFileBase64, segments);
+
+ return expectedBase64Header + this.encode64(image);
+
+ };
+
+
+ ExifRestorer.exifManipulation = function(resizedFileBase64, segments)
+ {
+ var exifArray = this.getExifArray(segments),
+ newImageArray = this.insertExif(resizedFileBase64, exifArray),
+ aBuffer = new Uint8Array(newImageArray);
+
+ return aBuffer;
+ };
+
+
+ ExifRestorer.getExifArray = function(segments)
+ {
+ var seg;
+ for (var x = 0; x < segments.length; x++)
+ {
+ seg = segments[x];
+ if (seg[0] == 255 & seg[1] == 225) //(ff e1)
+ {
+ return seg;
+ }
+ }
+ return [];
+ };
+
+
+ ExifRestorer.insertExif = function(resizedFileBase64, exifArray)
+ {
+ var imageData = resizedFileBase64.replace("data:image/jpeg;base64,", ""),
+ buf = this.decode64(imageData),
+ separatePoint = buf.indexOf(255,3),
+ mae = buf.slice(0, separatePoint),
+ ato = buf.slice(separatePoint),
+ array = mae;
+
+ array = array.concat(exifArray);
+ array = array.concat(ato);
+ return array;
+ };
+
+
+
+ ExifRestorer.slice2Segments = function(rawImageArray)
+ {
+ var head = 0,
+ segments = [];
+
+ while (1)
+ {
+ if (rawImageArray[head] == 255 & rawImageArray[head + 1] == 218){break;}
+ if (rawImageArray[head] == 255 & rawImageArray[head + 1] == 216)
+ {
+ head += 2;
+ }
+ else
+ {
+ var length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3],
+ endPoint = head + length + 2,
+ seg = rawImageArray.slice(head, endPoint);
+ segments.push(seg);
+ head = endPoint;
+ }
+ if (head > rawImageArray.length){break;}
+ }
+
+ return segments;
+ };
+
+
+
+ ExifRestorer.decode64 = function(input)
+ {
+ var output = "",
+ chr1, chr2, chr3 = "",
+ enc1, enc2, enc3, enc4 = "",
+ i = 0,
+ buf = [];
+
+ // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
+ var base64test = /[^A-Za-z0-9\+\/\=]/g;
+ if (base64test.exec(input)) {
+ throw new Error("There were invalid base64 characters in the input text. " +
+ "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='");
+ }
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+
+ do {
+ enc1 = this.KEY_STR.indexOf(input.charAt(i++));
+ enc2 = this.KEY_STR.indexOf(input.charAt(i++));
+ enc3 = this.KEY_STR.indexOf(input.charAt(i++));
+ enc4 = this.KEY_STR.indexOf(input.charAt(i++));
+
+ chr1 = (enc1 << 2) | (enc2 >> 4);
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+ chr3 = ((enc3 & 3) << 6) | enc4;
+
+ buf.push(chr1);
+
+ if (enc3 != 64) {
+ buf.push(chr2);
+ }
+ if (enc4 != 64) {
+ buf.push(chr3);
+ }
+
+ chr1 = chr2 = chr3 = "";
+ enc1 = enc2 = enc3 = enc4 = "";
+
+ } while (i < input.length);
+
+ return buf;
+ };
+
+
+ return ExifRestorer;
+})();
+
+/* globals qq */
+/**
+ * Keeps a running tally of total upload progress for a batch of files.
+ *
+ * @param callback Invoked when total progress changes, passing calculated total loaded & total size values.
+ * @param getSize Function that returns the size of a file given its ID
+ * @constructor
+ */
+qq.TotalProgress = function(callback, getSize) {
+ "use strict";
+
+ var perFileProgress = {},
+ totalLoaded = 0,
+ totalSize = 0,
+
+ lastLoadedSent = -1,
+ lastTotalSent = -1,
+ callbackProxy = function(loaded, total) {
+ if (loaded !== lastLoadedSent || total !== lastTotalSent) {
+ callback(loaded, total);
+ }
+
+ lastLoadedSent = loaded;
+ lastTotalSent = total;
+ },
+
+ /**
+ * @param failed Array of file IDs that have failed
+ * @param retryable Array of file IDs that are retryable
+ * @returns true if none of the failed files are eligible for retry
+ */
+ noRetryableFiles = function(failed, retryable) {
+ var none = true;
+
+ qq.each(failed, function(idx, failedId) {
+ if (qq.indexOf(retryable, failedId) >= 0) {
+ none = false;
+ return false;
+ }
+ });
+
+ return none;
+ },
+
+ onCancel = function(id) {
+ updateTotalProgress(id, -1, -1);
+ delete perFileProgress[id];
+ },
+
+ onAllComplete = function(successful, failed, retryable) {
+ if (failed.length === 0 || noRetryableFiles(failed, retryable)) {
+ callbackProxy(totalSize, totalSize);
+ this.reset();
+ }
+ },
+
+ onNew = function(id) {
+ var size = getSize(id);
+
+ // We might not know the size yet, such as for blob proxies
+ if (size > 0) {
+ updateTotalProgress(id, 0, size);
+ perFileProgress[id] = {loaded: 0, total: size};
+ }
+ },
+
+ /**
+ * Invokes the callback with the current total progress of all files in the batch. Called whenever it may
+ * be appropriate to re-calculate and dissemenate this data.
+ *
+ * @param id ID of a file that has changed in some important way
+ * @param newLoaded New loaded value for this file. -1 if this value should no longer be part of calculations
+ * @param newTotal New total size of the file. -1 if this value should no longer be part of calculations
+ */
+ updateTotalProgress = function(id, newLoaded, newTotal) {
+ var oldLoaded = perFileProgress[id] ? perFileProgress[id].loaded : 0,
+ oldTotal = perFileProgress[id] ? perFileProgress[id].total : 0;
+
+ if (newLoaded === -1 && newTotal === -1) {
+ totalLoaded -= oldLoaded;
+ totalSize -= oldTotal;
+ }
+ else {
+ if (newLoaded) {
+ totalLoaded += newLoaded - oldLoaded;
+ }
+ if (newTotal) {
+ totalSize += newTotal - oldTotal;
+ }
+ }
+
+ callbackProxy(totalLoaded, totalSize);
+ };
+
+ qq.extend(this, {
+ // Called when a batch of files has completed uploading.
+ onAllComplete: onAllComplete,
+
+ // Called when the status of a file has changed.
+ onStatusChange: function(id, oldStatus, newStatus) {
+ if (newStatus === qq.status.CANCELED || newStatus === qq.status.REJECTED) {
+ onCancel(id);
+ }
+ else if (newStatus === qq.status.SUBMITTING) {
+ onNew(id);
+ }
+ },
+
+ // Called whenever the upload progress of an individual file has changed.
+ onIndividualProgress: function(id, loaded, total) {
+ updateTotalProgress(id, loaded, total);
+ perFileProgress[id] = {loaded: loaded, total: total};
+ },
+
+ // Called whenever the total size of a file has changed, such as when the size of a generated blob is known.
+ onNewSize: function(id) {
+ onNew(id);
+ },
+
+ reset: function() {
+ perFileProgress = {};
+ totalLoaded = 0;
+ totalSize = 0;
+ }
+ });
+};
+
+/*globals qq */
+// Base handler for UI (FineUploader mode) events.
+// Some more specific handlers inherit from this one.
+qq.UiEventHandler = function(s, protectedApi) {
+ "use strict";
+
+ var disposer = new qq.DisposeSupport(),
+ spec = {
+ eventType: "click",
+ attachTo: null,
+ onHandled: function(target, event) {}
+ };
+
+
+ // This makes up the "public" API methods that will be accessible
+ // to instances constructing a base or child handler
+ qq.extend(this, {
+ addHandler: function(element) {
+ addHandler(element);
+ },
+
+ dispose: function() {
+ disposer.dispose();
+ }
+ });
+
+ function addHandler(element) {
+ disposer.attach(element, spec.eventType, function(event) {
+ // Only in IE: the `event` is a property of the `window`.
+ event = event || window.event;
+
+ // On older browsers, we must check the `srcElement` instead of the `target`.
+ var target = event.target || event.srcElement;
+
+ spec.onHandled(target, event);
+ });
+ }
+
+ // These make up the "protected" API methods that children of this base handler will utilize.
+ qq.extend(protectedApi, {
+ getFileIdFromItem: function(item) {
+ return item.qqFileId;
+ },
+
+ getDisposeSupport: function() {
+ return disposer;
+ }
+ });
+
+
+ qq.extend(spec, s);
+
+ if (spec.attachTo) {
+ addHandler(spec.attachTo);
+ }
+};
+
+/* global qq */
+qq.FileButtonsClickHandler = function(s) {
+ "use strict";
+
+ var inheritedInternalApi = {},
+ spec = {
+ templating: null,
+ log: function(message, lvl) {},
+ onDeleteFile: function(fileId) {},
+ onCancel: function(fileId) {},
+ onRetry: function(fileId) {},
+ onPause: function(fileId) {},
+ onContinue: function(fileId) {},
+ onGetName: function(fileId) {}
+ },
+ buttonHandlers = {
+ cancel: function(id) { spec.onCancel(id); },
+ retry: function(id) { spec.onRetry(id); },
+ deleteButton: function(id) { spec.onDeleteFile(id); },
+ pause: function(id) { spec.onPause(id); },
+ continueButton: function(id) { spec.onContinue(id); }
+ };
+
+ function examineEvent(target, event) {
+ qq.each(buttonHandlers, function(buttonType, handler) {
+ var firstLetterCapButtonType = buttonType.charAt(0).toUpperCase() + buttonType.slice(1),
+ fileId;
+
+ if (spec.templating["is" + firstLetterCapButtonType](target)) {
+ fileId = spec.templating.getFileId(target);
+ qq.preventDefault(event);
+ spec.log(qq.format("Detected valid file button click event on file '{}', ID: {}.", spec.onGetName(fileId), fileId));
+ handler(fileId);
+ return false;
+ }
+ });
+ }
+
+ qq.extend(spec, s);
+
+ spec.eventType = "click";
+ spec.onHandled = examineEvent;
+ spec.attachTo = spec.templating.getFileList();
+
+ qq.extend(this, new qq.UiEventHandler(spec, inheritedInternalApi));
+};
+
+/*globals qq */
+// Child of FilenameEditHandler. Used to detect click events on filename display elements.
+qq.FilenameClickHandler = function(s) {
+ "use strict";
+
+ var inheritedInternalApi = {},
+ spec = {
+ templating: null,
+ log: function(message, lvl) {},
+ classes: {
+ file: "qq-upload-file",
+ editNameIcon: "qq-edit-filename-icon"
+ },
+ onGetUploadStatus: function(fileId) {},
+ onGetName: function(fileId) {}
+ };
+
+ qq.extend(spec, s);
+
+ // This will be called by the parent handler when a `click` event is received on the list element.
+ function examineEvent(target, event) {
+ if (spec.templating.isFileName(target) || spec.templating.isEditIcon(target)) {
+ var fileId = spec.templating.getFileId(target),
+ status = spec.onGetUploadStatus(fileId);
+
+ // We only allow users to change filenames of files that have been submitted but not yet uploaded.
+ if (status === qq.status.SUBMITTED) {
+ spec.log(qq.format("Detected valid filename click event on file '{}', ID: {}.", spec.onGetName(fileId), fileId));
+ qq.preventDefault(event);
+
+ inheritedInternalApi.handleFilenameEdit(fileId, target, true);
+ }
+ }
+ }
+
+ spec.eventType = "click";
+ spec.onHandled = examineEvent;
+
+ qq.extend(this, new qq.FilenameEditHandler(spec, inheritedInternalApi));
+};
+
+/*globals qq */
+// Child of FilenameEditHandler. Used to detect focusin events on file edit input elements.
+qq.FilenameInputFocusInHandler = function(s, inheritedInternalApi) {
+ "use strict";
+
+ var spec = {
+ templating: null,
+ onGetUploadStatus: function(fileId) {},
+ log: function(message, lvl) {}
+ };
+
+ if (!inheritedInternalApi) {
+ inheritedInternalApi = {};
+ }
+
+ // This will be called by the parent handler when a `focusin` event is received on the list element.
+ function handleInputFocus(target, event) {
+ if (spec.templating.isEditInput(target)) {
+ var fileId = spec.templating.getFileId(target),
+ status = spec.onGetUploadStatus(fileId);
+
+ if (status === qq.status.SUBMITTED) {
+ spec.log(qq.format("Detected valid filename input focus event on file '{}', ID: {}.", spec.onGetName(fileId), fileId));
+ inheritedInternalApi.handleFilenameEdit(fileId, target);
+ }
+ }
+ }
+
+ spec.eventType = "focusin";
+ spec.onHandled = handleInputFocus;
+
+ qq.extend(spec, s);
+ qq.extend(this, new qq.FilenameEditHandler(spec, inheritedInternalApi));
+};
+
+/*globals qq */
+/**
+ * Child of FilenameInputFocusInHandler. Used to detect focus events on file edit input elements. This child module is only
+ * needed for UAs that do not support the focusin event. Currently, only Firefox lacks this event.
+ *
+ * @param spec Overrides for default specifications
+ */
+qq.FilenameInputFocusHandler = function(spec) {
+ "use strict";
+
+ spec.eventType = "focus";
+ spec.attachTo = null;
+
+ qq.extend(this, new qq.FilenameInputFocusInHandler(spec, {}));
+};
+
+/*globals qq */
+// Handles edit-related events on a file item (FineUploader mode). This is meant to be a parent handler.
+// Children will delegate to this handler when specific edit-related actions are detected.
+qq.FilenameEditHandler = function(s, inheritedInternalApi) {
+ "use strict";
+
+ var spec = {
+ templating: null,
+ log: function(message, lvl) {},
+ onGetUploadStatus: function(fileId) {},
+ onGetName: function(fileId) {},
+ onSetName: function(fileId, newName) {},
+ onEditingStatusChange: function(fileId, isEditing) {}
+ };
+
+
+ function getFilenameSansExtension(fileId) {
+ var filenameSansExt = spec.onGetName(fileId),
+ extIdx = filenameSansExt.lastIndexOf(".");
+
+ if (extIdx > 0) {
+ filenameSansExt = filenameSansExt.substr(0, extIdx);
+ }
+
+ return filenameSansExt;
+ }
+
+ function getOriginalExtension(fileId) {
+ var origName = spec.onGetName(fileId);
+ return qq.getExtension(origName);
+ }
+
+ // Callback iff the name has been changed
+ function handleNameUpdate(newFilenameInputEl, fileId) {
+ var newName = newFilenameInputEl.value,
+ origExtension;
+
+ if (newName !== undefined && qq.trimStr(newName).length > 0) {
+ origExtension = getOriginalExtension(fileId);
+
+ if (origExtension !== undefined) {
+ newName = newName + "." + origExtension;
+ }
+
+ spec.onSetName(fileId, newName);
+ }
+
+ spec.onEditingStatusChange(fileId, false);
+ }
+
+ // The name has been updated if the filename edit input loses focus.
+ function registerInputBlurHandler(inputEl, fileId) {
+ inheritedInternalApi.getDisposeSupport().attach(inputEl, "blur", function() {
+ handleNameUpdate(inputEl, fileId);
+ });
+ }
+
+ // The name has been updated if the user presses enter.
+ function registerInputEnterKeyHandler(inputEl, fileId) {
+ inheritedInternalApi.getDisposeSupport().attach(inputEl, "keyup", function(event) {
+
+ var code = event.keyCode || event.which;
+
+ if (code === 13) {
+ handleNameUpdate(inputEl, fileId);
+ }
+ });
+ }
+
+ qq.extend(spec, s);
+
+ spec.attachTo = spec.templating.getFileList();
+
+ qq.extend(this, new qq.UiEventHandler(spec, inheritedInternalApi));
+
+ qq.extend(inheritedInternalApi, {
+ handleFilenameEdit: function(id, target, focusInput) {
+ var newFilenameInputEl = spec.templating.getEditInput(id);
+
+ spec.onEditingStatusChange(id, true);
+
+ newFilenameInputEl.value = getFilenameSansExtension(id);
+
+ if (focusInput) {
+ newFilenameInputEl.focus();
+ }
+
+ registerInputBlurHandler(newFilenameInputEl, id);
+ registerInputEnterKeyHandler(newFilenameInputEl, id);
+ }
+ });
+};
+
+/*globals jQuery, qq*/
+(function($) {
+ "use strict";
+ var $el,
+ pluginOptions = ["uploaderType", "endpointType"];
+
+ function init(options) {
+ var xformedOpts = transformVariables(options || {}),
+ newUploaderInstance = getNewUploaderInstance(xformedOpts);
+
+ uploader(newUploaderInstance);
+ addCallbacks(xformedOpts, newUploaderInstance);
+
+ return $el;
+ }
+
+ function getNewUploaderInstance(params) {
+ var uploaderType = pluginOption("uploaderType"),
+ namespace = pluginOption("endpointType");
+
+ // If the integrator has defined a specific type of uploader to load, use that, otherwise assume `qq.FineUploader`
+ if (uploaderType) {
+ // We can determine the correct constructor function to invoke by combining "FineUploader"
+ // with the upper camel cased `uploaderType` value.
+ uploaderType = uploaderType.charAt(0).toUpperCase() + uploaderType.slice(1).toLowerCase();
+
+ if (namespace) {
+ return new qq[namespace]["FineUploader" + uploaderType](params);
+ }
+
+ return new qq["FineUploader" + uploaderType](params);
+ }
+ else {
+ if (namespace) {
+ return new qq[namespace].FineUploader(params);
+ }
+
+ return new qq.FineUploader(params);
+ }
+ }
+
+ function dataStore(key, val) {
+ var data = $el.data("fineuploader");
+
+ if (val) {
+ if (data === undefined) {
+ data = {};
+ }
+ data[key] = val;
+ $el.data("fineuploader", data);
+ }
+ else {
+ if (data === undefined) {
+ return null;
+ }
+ return data[key];
+ }
+ }
+
+ //the underlying Fine Uploader instance is stored in jQuery's data stored, associated with the element
+ // tied to this instance of the plug-in
+ function uploader(instanceToStore) {
+ return dataStore("uploader", instanceToStore);
+ }
+
+ function pluginOption(option, optionVal) {
+ return dataStore(option, optionVal);
+ }
+
+ // Implement all callbacks defined in Fine Uploader as functions that trigger appropriately names events and
+ // return the result of executing the bound handler back to Fine Uploader
+ function addCallbacks(transformedOpts, newUploaderInstance) {
+ var callbacks = transformedOpts.callbacks = {};
+
+ $.each(newUploaderInstance._options.callbacks, function(prop, nonJqueryCallback) {
+ var name, callbackEventTarget;
+
+ name = /^on(\w+)/.exec(prop)[1];
+ name = name.substring(0, 1).toLowerCase() + name.substring(1);
+ callbackEventTarget = $el;
+
+ callbacks[prop] = function() {
+ var originalArgs = Array.prototype.slice.call(arguments),
+ transformedArgs = [],
+ nonJqueryCallbackRetVal, jqueryEventCallbackRetVal;
+
+ $.each(originalArgs, function(idx, arg) {
+ transformedArgs.push(maybeWrapInJquery(arg));
+ });
+
+ nonJqueryCallbackRetVal = nonJqueryCallback.apply(this, originalArgs);
+
+ try {
+ jqueryEventCallbackRetVal = callbackEventTarget.triggerHandler(name, transformedArgs);
+ }
+ catch (error) {
+ qq.log("Caught error in Fine Uploader jQuery event handler: " + error.message, "error");
+ }
+
+ /*jshint -W116*/
+ if (nonJqueryCallbackRetVal != null) {
+ return nonJqueryCallbackRetVal;
+ }
+ return jqueryEventCallbackRetVal;
+ };
+ });
+
+ newUploaderInstance._options.callbacks = callbacks;
+ }
+
+ //transform jQuery objects into HTMLElements, and pass along all other option properties
+ function transformVariables(source, dest) {
+ var xformed, arrayVals;
+
+ if (dest === undefined) {
+ if (source.uploaderType !== "basic") {
+ xformed = { element : $el[0] };
+ }
+ else {
+ xformed = {};
+ }
+ }
+ else {
+ xformed = dest;
+ }
+
+ $.each(source, function(prop, val) {
+ if ($.inArray(prop, pluginOptions) >= 0) {
+ pluginOption(prop, val);
+ }
+ else if (val instanceof $) {
+ xformed[prop] = val[0];
+ }
+ else if ($.isPlainObject(val)) {
+ xformed[prop] = {};
+ transformVariables(val, xformed[prop]);
+ }
+ else if ($.isArray(val)) {
+ arrayVals = [];
+ $.each(val, function(idx, arrayVal) {
+ var arrayObjDest = {};
+
+ if (arrayVal instanceof $) {
+ $.merge(arrayVals, arrayVal);
+ }
+ else if ($.isPlainObject(arrayVal)) {
+ transformVariables(arrayVal, arrayObjDest);
+ arrayVals.push(arrayObjDest);
+ }
+ else {
+ arrayVals.push(arrayVal);
+ }
+ });
+ xformed[prop] = arrayVals;
+ }
+ else {
+ xformed[prop] = val;
+ }
+ });
+
+ if (dest === undefined) {
+ return xformed;
+ }
+ }
+
+ function isValidCommand(command) {
+ return $.type(command) === "string" &&
+ !command.match(/^_/) && //enforce private methods convention
+ uploader()[command] !== undefined;
+ }
+
+ // Assuming we have already verified that this is a valid command, call the associated function in the underlying
+ // Fine Uploader instance (passing along the arguments from the caller) and return the result of the call back to the caller
+ function delegateCommand(command) {
+ var xformedArgs = [],
+ origArgs = Array.prototype.slice.call(arguments, 1),
+ retVal;
+
+ transformVariables(origArgs, xformedArgs);
+
+ retVal = uploader()[command].apply(uploader(), xformedArgs);
+
+ return maybeWrapInJquery(retVal);
+ }
+
+ // If the value is an `HTMLElement` or `HTMLDocument`, wrap it in a `jQuery` object
+ function maybeWrapInJquery(val) {
+ var transformedVal = val;
+
+ // If the command is returning an `HTMLElement` or `HTMLDocument`, wrap it in a `jQuery` object
+ /*jshint -W116*/
+ if (val != null && typeof val === "object" &&
+ (val.nodeType === 1 || val.nodeType === 9) && val.cloneNode) {
+
+ transformedVal = $(val);
+ }
+
+ return transformedVal;
+ }
+
+ $.fn.fineUploader = function(optionsOrCommand) {
+ var self = this, selfArgs = arguments, retVals = [];
+
+ this.each(function(index, el) {
+ $el = $(el);
+
+ if (uploader() && isValidCommand(optionsOrCommand)) {
+ retVals.push(delegateCommand.apply(self, selfArgs));
+
+ if (self.length === 1) {
+ return false;
+ }
+ }
+ else if (typeof optionsOrCommand === "object" || !optionsOrCommand) {
+ init.apply(self, selfArgs);
+ }
+ else {
+ $.error("Method " + optionsOrCommand + " does not exist on jQuery.fineUploader");
+ }
+ });
+
+ if (retVals.length === 1) {
+ return retVals[0];
+ }
+ else if (retVals.length > 1) {
+ return retVals;
+ }
+
+ return this;
+ };
+
+}(jQuery));
+
+/*globals jQuery, qq*/
+(function($) {
+ "use strict";
+ var rootDataKey = "fineUploaderDnd",
+ $el;
+
+ function init (options) {
+ if (!options) {
+ options = {};
+ }
+
+ options.dropZoneElements = [$el];
+ var xformedOpts = transformVariables(options);
+ addCallbacks(xformedOpts);
+ dnd(new qq.DragAndDrop(xformedOpts));
+
+ return $el;
+ }
+
+ function dataStore(key, val) {
+ var data = $el.data(rootDataKey);
+
+ if (val) {
+ if (data === undefined) {
+ data = {};
+ }
+ data[key] = val;
+ $el.data(rootDataKey, data);
+ }
+ else {
+ if (data === undefined) {
+ return null;
+ }
+ return data[key];
+ }
+ }
+
+ function dnd(instanceToStore) {
+ return dataStore("dndInstance", instanceToStore);
+ }
+
+ function addCallbacks(transformedOpts) {
+ var callbacks = transformedOpts.callbacks = {};
+
+ $.each(new qq.DragAndDrop.callbacks(), function(prop, func) {
+ var name = prop,
+ $callbackEl;
+
+ $callbackEl = $el;
+
+ callbacks[prop] = function() {
+ var args = Array.prototype.slice.call(arguments),
+ jqueryHandlerResult = $callbackEl.triggerHandler(name, args);
+
+ return jqueryHandlerResult;
+ };
+ });
+ }
+
+ //transform jQuery objects into HTMLElements, and pass along all other option properties
+ function transformVariables(source, dest) {
+ var xformed, arrayVals;
+
+ if (dest === undefined) {
+ xformed = {};
+ }
+ else {
+ xformed = dest;
+ }
+
+ $.each(source, function(prop, val) {
+ if (val instanceof $) {
+ xformed[prop] = val[0];
+ }
+ else if ($.isPlainObject(val)) {
+ xformed[prop] = {};
+ transformVariables(val, xformed[prop]);
+ }
+ else if ($.isArray(val)) {
+ arrayVals = [];
+ $.each(val, function(idx, arrayVal) {
+ if (arrayVal instanceof $) {
+ $.merge(arrayVals, arrayVal);
+ }
+ else {
+ arrayVals.push(arrayVal);
+ }
+ });
+ xformed[prop] = arrayVals;
+ }
+ else {
+ xformed[prop] = val;
+ }
+ });
+
+ if (dest === undefined) {
+ return xformed;
+ }
+ }
+
+ function isValidCommand(command) {
+ return $.type(command) === "string" &&
+ command === "dispose" &&
+ dnd()[command] !== undefined;
+ }
+
+ function delegateCommand(command) {
+ var xformedArgs = [], origArgs = Array.prototype.slice.call(arguments, 1);
+ transformVariables(origArgs, xformedArgs);
+ return dnd()[command].apply(dnd(), xformedArgs);
+ }
+
+ $.fn.fineUploaderDnd = function(optionsOrCommand) {
+ var self = this, selfArgs = arguments, retVals = [];
+
+ this.each(function(index, el) {
+ $el = $(el);
+
+ if (dnd() && isValidCommand(optionsOrCommand)) {
+ retVals.push(delegateCommand.apply(self, selfArgs));
+
+ if (self.length === 1) {
+ return false;
+ }
+ }
+ else if (typeof optionsOrCommand === "object" || !optionsOrCommand) {
+ init.apply(self, selfArgs);
+ }
+ else {
+ $.error("Method " + optionsOrCommand + " does not exist in Fine Uploader's DnD module.");
+ }
+ });
+
+ if (retVals.length === 1) {
+ return retVals[0];
+ }
+ else if (retVals.length > 1) {
+ return retVals;
+ }
+
+ return this;
+ };
+
+}(jQuery));
+
+/*! 2014-08-13 */
+
+///#source 1 1 /scripts/plugins/bootstrap/tooltip.js
+/* ========================================================================
+ * Bootstrap: tooltip.js v3.2.0
+ * http://getbootstrap.com/javascript/#tooltip
+ * Inspired by the original jQuery.tipsy by Jason Frame
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+ 'use strict';
+
+ // TOOLTIP PUBLIC CLASS DEFINITION
+ // ===============================
+
+ var Tooltip = function (element, options) {
+ this.type =
+ this.options =
+ this.enabled =
+ this.timeout =
+ this.hoverState =
+ this.$element = null
+
+ this.init('tooltip', element, options)
+ }
+
+ Tooltip.VERSION = '3.2.0'
+
+ Tooltip.TRANSITION_DURATION = 150
+
+ Tooltip.DEFAULTS = {
+ animation: true,
+ placement: 'top',
+ selector: false,
+ template: '',
+ trigger: 'hover focus',
+ title: '',
+ delay: 0,
+ html: false,
+ container: false,
+ viewport: {
+ selector: 'body',
+ padding: 0
+ }
+ }
+
+ Tooltip.prototype.init = function (type, element, options) {
+ this.enabled = true
+ this.type = type
+ this.$element = $(element)
+ this.options = this.getOptions(options)
+ this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
+
+ var triggers = this.options.trigger.split(' ')
+
+ for (var i = triggers.length; i--;) {
+ var trigger = triggers[i]
+
+ if (trigger == 'click') {
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+ } else if (trigger != 'manual') {
+ var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
+ var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
+
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+ }
+ }
+
+ this.options.selector ?
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
+ this.fixTitle()
+ }
+
+ Tooltip.prototype.getDefaults = function () {
+ return Tooltip.DEFAULTS
+ }
+
+ Tooltip.prototype.getOptions = function (options) {
+ options = $.extend({}, this.getDefaults(), this.$element.data(), options)
+
+ if (options.delay && typeof options.delay == 'number') {
+ options.delay = {
+ show: options.delay,
+ hide: options.delay
+ }
+ }
+
+ return options
+ }
+
+ Tooltip.prototype.getDelegateOptions = function () {
+ var options = {}
+ var defaults = this.getDefaults()
+
+ this._options && $.each(this._options, function (key, value) {
+ if (defaults[key] != value) options[key] = value
+ })
+
+ return options
+ }
+
+ Tooltip.prototype.enter = function (obj) {
+ var self = obj instanceof this.constructor ?
+ obj : $(obj.currentTarget).data('bs.' + this.type)
+
+ if (self && self.$tip && self.$tip.is(':visible')) {
+ self.hoverState = 'in'
+ return
+ }
+
+ if (!self) {
+ self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
+ $(obj.currentTarget).data('bs.' + this.type, self)
+ }
+
+ clearTimeout(self.timeout)
+
+ self.hoverState = 'in'
+
+ if (!self.options.delay || !self.options.delay.show) return self.show()
+
+ self.timeout = setTimeout(function () {
+ if (self.hoverState == 'in') self.show()
+ }, self.options.delay.show)
+ }
+
+ Tooltip.prototype.leave = function (obj) {
+ var self = obj instanceof this.constructor ?
+ obj : $(obj.currentTarget).data('bs.' + this.type)
+
+ if (!self) {
+ self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
+ $(obj.currentTarget).data('bs.' + this.type, self)
+ }
+
+ clearTimeout(self.timeout)
+
+ self.hoverState = 'out'
+
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
+
+ self.timeout = setTimeout(function () {
+ if (self.hoverState == 'out') self.hide()
+ }, self.options.delay.hide)
+ }
+
+ Tooltip.prototype.show = function () {
+ var e = $.Event('show.bs.' + this.type)
+
+ if (this.hasContent() && this.enabled) {
+ this.$element.trigger(e)
+
+ var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
+ if (e.isDefaultPrevented() || !inDom) return
+ var that = this
+
+ var $tip = this.tip()
+
+ var tipId = this.getUID(this.type)
+
+ this.setContent()
+ $tip.attr('id', tipId)
+ this.$element.attr('aria-describedby', tipId)
+
+ if (this.options.animation) $tip.addClass('fade')
+
+ var placement = typeof this.options.placement == 'function' ?
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
+ this.options.placement
+
+ var autoToken = /\s?auto?\s?/i
+ var autoPlace = autoToken.test(placement)
+ if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
+
+ $tip
+ .detach()
+ .css({ top: 0, left: 0, display: 'block' })
+ .addClass(placement)
+ .data('bs.' + this.type, this)
+
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
+
+ var pos = this.getPosition()
+ var actualWidth = $tip[0].offsetWidth
+ var actualHeight = $tip[0].offsetHeight
+
+ if (autoPlace) {
+ var orgPlacement = placement
+ var $parent = this.$element.parent()
+ var parentDim = this.getPosition($parent)
+
+ placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
+ placement == 'top' && pos.top - parentDim.scroll - actualHeight < parentDim.top ? 'bottom' :
+ placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
+ placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
+ placement
+
+ $tip
+ .removeClass(orgPlacement)
+ .addClass(placement)
+ }
+
+ var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
+
+ this.applyPlacement(calculatedOffset, placement)
+
+ var complete = function () {
+ that.$element.trigger('shown.bs.' + that.type)
+ that.hoverState = null
+ }
+
+ $.support.transition && this.$tip.hasClass('fade') ?
+ $tip
+ .one('bsTransitionEnd', complete)
+ .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
+ complete()
+ }
+ }
+
+ Tooltip.prototype.applyPlacement = function (offset, placement) {
+ var $tip = this.tip()
+ var width = $tip[0].offsetWidth
+ var height = $tip[0].offsetHeight
+
+ // manually read margins because getBoundingClientRect includes difference
+ var marginTop = parseInt($tip.css('margin-top'), 10)
+ var marginLeft = parseInt($tip.css('margin-left'), 10)
+
+ // we must check for NaN for ie 8/9
+ if (isNaN(marginTop)) marginTop = 0
+ if (isNaN(marginLeft)) marginLeft = 0
+
+ offset.top = offset.top + marginTop
+ offset.left = offset.left + marginLeft
+
+ // $.fn.offset doesn't round pixel values
+ // so we use setOffset directly with our own function B-0
+ $.offset.setOffset($tip[0], $.extend({
+ using: function (props) {
+ $tip.css({
+ top: Math.round(props.top),
+ left: Math.round(props.left)
+ })
+ }
+ }, offset), 0)
+
+ $tip.addClass('in')
+
+ // check to see if placing tip in new offset caused the tip to resize itself
+ var actualWidth = $tip[0].offsetWidth
+ var actualHeight = $tip[0].offsetHeight
+
+ if (placement == 'top' && actualHeight != height) {
+ offset.top = offset.top + height - actualHeight
+ }
+
+ var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
+
+ if (delta.left) offset.left += delta.left
+ else offset.top += delta.top
+
+ var isVertical = /top|bottom/.test(placement)
+ var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
+ var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
+
+ $tip.offset(offset)
+ this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
+ }
+
+ Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
+ this.arrow()
+ .css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
+ .css(isHorizontal ? 'top' : 'left', '')
+ }
+
+ Tooltip.prototype.setContent = function () {
+ var $tip = this.tip()
+ var title = this.getTitle()
+
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
+ $tip.removeClass('fade in top bottom left right')
+ }
+
+ Tooltip.prototype.hide = function (callback) {
+ var that = this
+ var $tip = this.tip()
+ var e = $.Event('hide.bs.' + this.type)
+
+ function complete() {
+ if (that.hoverState != 'in') $tip.detach()
+ that.$element
+ .removeAttr('aria-describedby')
+ .trigger('hidden.bs.' + that.type)
+ callback && callback()
+ }
+
+ this.$element.trigger(e)
+
+ if (e.isDefaultPrevented()) return
+
+ $tip.removeClass('in')
+
+ $.support.transition && this.$tip.hasClass('fade') ?
+ $tip
+ .one('bsTransitionEnd', complete)
+ .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
+ complete()
+
+ this.hoverState = null
+
+ return this
+ }
+
+ Tooltip.prototype.fixTitle = function () {
+ var $e = this.$element
+ if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
+ }
+ }
+
+ Tooltip.prototype.hasContent = function () {
+ return this.getTitle()
+ }
+
+ Tooltip.prototype.getPosition = function ($element) {
+ $element = $element || this.$element
+
+ var el = $element[0]
+ var isBody = el.tagName == 'BODY'
+ var isSvg = window.SVGElement && el instanceof window.SVGElement
+
+ var elRect = el.getBoundingClientRect()
+ if (elRect.width == null) {
+ // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
+ elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
+ }
+ var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
+ var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
+ var outerDims = isSvg ? {} : {
+ width: isBody ? $(window).width() : $element.outerWidth(),
+ height: isBody ? $(window).height() : $element.outerHeight()
+ }
+
+ return $.extend({}, elRect, scroll, outerDims, elOffset)
+ }
+
+ Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
+ return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
+ placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
+ placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
+ /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
+
+ }
+
+ Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
+ var delta = { top: 0, left: 0 }
+ if (!this.$viewport) return delta
+
+ var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
+ var viewportDimensions = this.getPosition(this.$viewport)
+
+ if (/right|left/.test(placement)) {
+ var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
+ var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
+ if (topEdgeOffset < viewportDimensions.top) { // top overflow
+ delta.top = viewportDimensions.top - topEdgeOffset
+ } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
+ delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
+ }
+ } else {
+ var leftEdgeOffset = pos.left - viewportPadding
+ var rightEdgeOffset = pos.left + viewportPadding + actualWidth
+ if (leftEdgeOffset < viewportDimensions.left) { // left overflow
+ delta.left = viewportDimensions.left - leftEdgeOffset
+ } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
+ delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
+ }
+ }
+
+ return delta
+ }
+
+ Tooltip.prototype.getTitle = function () {
+ var title
+ var $e = this.$element
+ var o = this.options
+
+ title = $e.attr('data-original-title')
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
+
+ return title
+ }
+
+ Tooltip.prototype.getUID = function (prefix) {
+ do prefix += ~~(Math.random() * 1000000)
+ while (document.getElementById(prefix))
+ return prefix
+ }
+
+ Tooltip.prototype.tip = function () {
+ return (this.$tip = this.$tip || $(this.options.template))
+ }
+
+ Tooltip.prototype.arrow = function () {
+ return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
+ }
+
+ Tooltip.prototype.enable = function () {
+ this.enabled = true
+ }
+
+ Tooltip.prototype.disable = function () {
+ this.enabled = false
+ }
+
+ Tooltip.prototype.toggleEnabled = function () {
+ this.enabled = !this.enabled
+ }
+
+ Tooltip.prototype.toggle = function (e) {
+ var self = this
+ if (e) {
+ self = $(e.currentTarget).data('bs.' + this.type)
+ if (!self) {
+ self = new this.constructor(e.currentTarget, this.getDelegateOptions())
+ $(e.currentTarget).data('bs.' + this.type, self)
+ }
+ }
+
+ self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
+ }
+
+ Tooltip.prototype.destroy = function () {
+ var that = this
+ clearTimeout(this.timeout)
+ this.hide(function () {
+ that.$element.off('.' + that.type).removeData('bs.' + that.type)
+ })
+ }
+
+
+ // TOOLTIP PLUGIN DEFINITION
+ // =========================
+
+ function Plugin(option) {
+ return this.each(function () {
+ var $this = $(this)
+ var data = $this.data('bs.tooltip')
+ var options = typeof option == 'object' && option
+
+ if (!data && option == 'destroy') return
+ if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ var old = $.fn.tooltip
+
+ $.fn.tooltip = Plugin
+ $.fn.tooltip.Constructor = Tooltip
+
+
+ // TOOLTIP NO CONFLICT
+ // ===================
+
+ $.fn.tooltip.noConflict = function () {
+ $.fn.tooltip = old
+ return this
+ }
+
+}(jQuery);
+
+///#source 1 1 /scripts/plugins/bootstrap/modal.js
+/* ========================================================================
+ * Bootstrap: modal.js v3.2.0
+ * http://getbootstrap.com/javascript/#modals
+ * ========================================================================
+ * Copyright 2011-2014 Twitter, Inc.
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * ======================================================================== */
+
+
++function ($) {
+ 'use strict';
+
+ // MODAL CLASS DEFINITION
+ // ======================
+
+ var Modal = function (element, options) {
+ this.options = options
+ this.$body = $(document.body)
+ this.$element = $(element)
+ this.$backdrop =
+ this.isShown = null
+ this.scrollbarWidth = 0
+
+ if (this.options.remote) {
+ this.$element
+ .find('.modal-content')
+ .load(this.options.remote, $.proxy(function () {
+ this.$element.trigger('loaded.bs.modal')
+ }, this))
+ }
+ }
+
+ Modal.VERSION = '3.2.0'
+
+ Modal.TRANSITION_DURATION = 300
+ Modal.BACKDROP_TRANSITION_DURATION = 150
+
+ Modal.DEFAULTS = {
+ backdrop: true,
+ keyboard: true,
+ show: true
+ }
+
+ Modal.prototype.toggle = function (_relatedTarget) {
+ return this.isShown ? this.hide() : this.show(_relatedTarget)
+ }
+
+ Modal.prototype.show = function (_relatedTarget) {
+ var that = this
+ var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
+
+ this.$element.trigger(e)
+
+ if (this.isShown || e.isDefaultPrevented()) return
+
+ this.isShown = true
+
+ this.checkScrollbar()
+ this.$body.addClass('modal-open')
+
+ this.setScrollbar()
+ this.escape()
+
+ this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+
+ this.backdrop(function () {
+ var transition = $.support.transition && that.$element.hasClass('fade')
+
+ if (!that.$element.parent().length) {
+ that.$element.appendTo(that.$body) // don't move modals dom position
+ }
+
+ that.$element
+ .show()
+ .scrollTop(0)
+
+ if (transition) {
+ that.$element[0].offsetWidth // force reflow
+ }
+
+ that.$element
+ .addClass('in')
+ .attr('aria-hidden', false)
+
+ that.enforceFocus()
+
+ var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
+
+ transition ?
+ that.$element.find('.modal-dialog') // wait for modal to slide in
+ .one('bsTransitionEnd', function () {
+ that.$element.trigger('focus').trigger(e)
+ })
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+ that.$element.trigger('focus').trigger(e)
+ })
+ }
+
+ Modal.prototype.hide = function (e) {
+ if (e) e.preventDefault()
+
+ e = $.Event('hide.bs.modal')
+
+ this.$element.trigger(e)
+
+ if (!this.isShown || e.isDefaultPrevented()) return
+
+ this.isShown = false
+
+ this.$body.removeClass('modal-open')
+
+ this.resetScrollbar()
+ this.escape()
+
+ $(document).off('focusin.bs.modal')
+
+ this.$element
+ .removeClass('in')
+ .attr('aria-hidden', true)
+ .off('click.dismiss.bs.modal')
+
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.$element
+ .one('bsTransitionEnd', $.proxy(this.hideModal, this))
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+ this.hideModal()
+ }
+
+ Modal.prototype.enforceFocus = function () {
+ $(document)
+ .off('focusin.bs.modal') // guard against infinite focus loop
+ .on('focusin.bs.modal', $.proxy(function (e) {
+ if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
+ this.$element.trigger('focus')
+ }
+ }, this))
+ }
+
+ Modal.prototype.escape = function () {
+ if (this.isShown && this.options.keyboard) {
+ this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
+ e.which == 27 && this.hide()
+ }, this))
+ } else if (!this.isShown) {
+ this.$element.off('keydown.dismiss.bs.modal')
+ }
+ }
+
+ Modal.prototype.hideModal = function () {
+ var that = this
+ this.$element.hide()
+ this.backdrop(function () {
+ that.$element.trigger('hidden.bs.modal')
+ })
+ }
+
+ Modal.prototype.removeBackdrop = function () {
+ this.$backdrop && this.$backdrop.remove()
+ this.$backdrop = null
+ }
+
+ Modal.prototype.backdrop = function (callback) {
+ var that = this
+ var animate = this.$element.hasClass('fade') ? 'fade' : ''
+
+ if (this.isShown && this.options.backdrop) {
+ var doAnimate = $.support.transition && animate
+
+ this.$backdrop = $('
')
+ .appendTo(this.$body)
+
+ this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
+ if (e.target !== e.currentTarget) return
+ this.options.backdrop == 'static'
+ ? this.$element[0].focus.call(this.$element[0])
+ : this.hide.call(this)
+ }, this))
+
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
+
+ this.$backdrop.addClass('in')
+
+ if (!callback) return
+
+ doAnimate ?
+ this.$backdrop
+ .one('bsTransitionEnd', callback)
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+ callback()
+
+ } else if (!this.isShown && this.$backdrop) {
+ this.$backdrop.removeClass('in')
+
+ var callbackRemove = function () {
+ that.removeBackdrop()
+ callback && callback()
+ }
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.$backdrop
+ .one('bsTransitionEnd', callbackRemove)
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+ callbackRemove()
+
+ } else if (callback) {
+ callback()
+ }
+ }
+
+ Modal.prototype.checkScrollbar = function () {
+ this.scrollbarWidth = this.measureScrollbar()
+ }
+
+ Modal.prototype.setScrollbar = function () {
+ var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
+ if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
+ }
+
+ Modal.prototype.resetScrollbar = function () {
+ this.$body.css('padding-right', '')
+ }
+
+ Modal.prototype.measureScrollbar = function () { // thx walsh
+ if (document.body.clientWidth >= window.innerWidth) return 0
+ var scrollDiv = document.createElement('div')
+ scrollDiv.className = 'modal-scrollbar-measure'
+ this.$body.append(scrollDiv)
+ var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
+ this.$body[0].removeChild(scrollDiv)
+ return scrollbarWidth
+ }
+
+
+ // MODAL PLUGIN DEFINITION
+ // =======================
+
+ function Plugin(option, _relatedTarget) {
+ return this.each(function () {
+ var $this = $(this)
+ var data = $this.data('bs.modal')
+ var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
+
+ if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
+ if (typeof option == 'string') data[option](_relatedTarget)
+ else if (options.show) data.show(_relatedTarget)
+ })
+ }
+
+ var old = $.fn.modal
+
+ $.fn.modal = Plugin
+ $.fn.modal.Constructor = Modal
+
+
+ // MODAL NO CONFLICT
+ // =================
+
+ $.fn.modal.noConflict = function () {
+ $.fn.modal = old
+ return this
+ }
+
+
+ // MODAL DATA-API
+ // ==============
+
+ $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
+ var $this = $(this)
+ var href = $this.attr('href')
+ var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
+ var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
+
+ if ($this.is('a')) e.preventDefault()
+
+ $target.one('show.bs.modal', function (showEvent) {
+ if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
+ $target.one('hidden.bs.modal', function () {
+ $this.is(':visible') && $this.trigger('focus')
+ })
+ })
+ Plugin.call($target, option, this)
+ })
+
+}(jQuery);
+
+///#source 1 1 /scripts/plugins/bootbox.js
+/**
+ * bootbox.js [v4.2.0]
+ *
+ * http://bootboxjs.com/license.txt
+ */
+
+// @see https://github.com/makeusabrew/bootbox/issues/180
+// @see https://github.com/makeusabrew/bootbox/issues/186
+(function (root, factory) {
+
+ "use strict";
+ if (typeof define === "function" && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(["jquery"], factory);
+ } else if (typeof exports === "object") {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like environments that support module.exports,
+ // like Node.
+ module.exports = factory(require("jquery"));
+ } else {
+ // Browser globals (root is window)
+ root.bootbox = factory(root.jQuery);
+ }
+
+}(this, function init($, undefined) {
+
+ "use strict";
+
+ // the base DOM structure needed to create a modal
+ var templates = {
+ dialog:
+ "",
+ header:
+ "",
+ footer:
+ "",
+ closeButton:
+ "× ",
+ form:
+ " ",
+ inputs: {
+ text:
+ " ",
+ textarea:
+ " ",
+ email:
+ " ",
+ select:
+ " ",
+ checkbox:
+ "
",
+ date:
+ " ",
+ time:
+ " ",
+ number:
+ " ",
+ password:
+ " "
+ }
+ };
+
+ var defaults = {
+ // default language
+ locale: "en",
+ // show backdrop or not
+ backdrop: true,
+ // animate the modal in/out
+ animate: true,
+ // additional class string applied to the top level dialog
+ className: null,
+ // whether or not to include a close button
+ closeButton: true,
+ // show the dialog immediately by default
+ show: true,
+ // dialog container
+ container: "body"
+ };
+
+ // our public object; augmented after our private API
+ var exports = {};
+
+ /**
+ * @private
+ */
+ function _t(key) {
+ var locale = locales[defaults.locale];
+ return locale ? locale[key] : locales.en[key];
+ }
+
+ function processCallback(e, dialog, callback) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ // by default we assume a callback will get rid of the dialog,
+ // although it is given the opportunity to override this
+
+ // so, if the callback can be invoked and it *explicitly returns false*
+ // then we'll set a flag to keep the dialog active...
+ var preserveDialog = $.isFunction(callback) && callback(e) === false;
+
+ // ... otherwise we'll bin it
+ if (!preserveDialog) {
+ dialog.modal("hide");
+ }
+ }
+
+ function getKeyLength(obj) {
+ // @TODO defer to Object.keys(x).length if available?
+ var k, t = 0;
+ for (k in obj) {
+ t ++;
+ }
+ return t;
+ }
+
+ function each(collection, iterator) {
+ var index = 0;
+ $.each(collection, function(key, value) {
+ iterator(key, value, index++);
+ });
+ }
+
+ function sanitize(options) {
+ var buttons;
+ var total;
+
+ if (typeof options !== "object") {
+ throw new Error("Please supply an object of options");
+ }
+
+ if (!options.message) {
+ throw new Error("Please specify a message");
+ }
+
+ // make sure any supplied options take precedence over defaults
+ options = $.extend({}, defaults, options);
+
+ if (!options.buttons) {
+ options.buttons = {};
+ }
+
+ // we only support Bootstrap's "static" and false backdrop args
+ // supporting true would mean you could dismiss the dialog without
+ // explicitly interacting with it
+ options.backdrop = options.backdrop ? "static" : false;
+
+ buttons = options.buttons;
+
+ total = getKeyLength(buttons);
+
+ each(buttons, function(key, button, index) {
+
+ if ($.isFunction(button)) {
+ // short form, assume value is our callback. Since button
+ // isn't an object it isn't a reference either so re-assign it
+ button = buttons[key] = {
+ callback: button
+ };
+ }
+
+ // before any further checks make sure by now button is the correct type
+ if ($.type(button) !== "object") {
+ throw new Error("button with key " + key + " must be an object");
+ }
+
+ if (!button.label) {
+ // the lack of an explicit label means we'll assume the key is good enough
+ button.label = key;
+ }
+
+ if (!button.className) {
+ if (total <= 2 && index === total-1) {
+ // always add a primary to the main option in a two-button dialog
+ button.className = "btn-primary";
+ } else {
+ button.className = "btn-default";
+ }
+ }
+ });
+
+ return options;
+ }
+
+ /**
+ * map a flexible set of arguments into a single returned object
+ * if args.length is already one just return it, otherwise
+ * use the properties argument to map the unnamed args to
+ * object properties
+ * so in the latter case:
+ * mapArguments(["foo", $.noop], ["message", "callback"])
+ * -> { message: "foo", callback: $.noop }
+ */
+ function mapArguments(args, properties) {
+ var argn = args.length;
+ var options = {};
+
+ if (argn < 1 || argn > 2) {
+ throw new Error("Invalid argument length");
+ }
+
+ if (argn === 2 || typeof args[0] === "string") {
+ options[properties[0]] = args[0];
+ options[properties[1]] = args[1];
+ } else {
+ options = args[0];
+ }
+
+ return options;
+ }
+
+ /**
+ * merge a set of default dialog options with user supplied arguments
+ */
+ function mergeArguments(defaults, args, properties) {
+ return $.extend(
+ // deep merge
+ true,
+ // ensure the target is an empty, unreferenced object
+ {},
+ // the base options object for this type of dialog (often just buttons)
+ defaults,
+ // args could be an object or array; if it's an array properties will
+ // map it to a proper options object
+ mapArguments(
+ args,
+ properties
+ )
+ );
+ }
+
+ /**
+ * this entry-level method makes heavy use of composition to take a simple
+ * range of inputs and return valid options suitable for passing to bootbox.dialog
+ */
+ function mergeDialogOptions(className, labels, properties, args) {
+ // build up a base set of dialog properties
+ var baseOptions = {
+ className: "bootbox-" + className,
+ buttons: createLabels.apply(null, labels)
+ };
+
+ // ensure the buttons properties generated, *after* merging
+ // with user args are still valid against the supplied labels
+ return validateButtons(
+ // merge the generated base properties with user supplied arguments
+ mergeArguments(
+ baseOptions,
+ args,
+ // if args.length > 1, properties specify how each arg maps to an object key
+ properties
+ ),
+ labels
+ );
+ }
+
+ /**
+ * from a given list of arguments return a suitable object of button labels
+ * all this does is normalise the given labels and translate them where possible
+ * e.g. "ok", "confirm" -> { ok: "OK, cancel: "Annuleren" }
+ */
+ function createLabels() {
+ var buttons = {};
+
+ for (var i = 0, j = arguments.length; i < j; i++) {
+ var argument = arguments[i];
+ var key = argument.toLowerCase();
+ var value = argument.toUpperCase();
+
+ buttons[key] = {
+ label: _t(value)
+ };
+ }
+
+ return buttons;
+ }
+
+ function validateButtons(options, buttons) {
+ var allowedButtons = {};
+ each(buttons, function(key, value) {
+ allowedButtons[value] = true;
+ });
+
+ each(options.buttons, function(key) {
+ if (allowedButtons[key] === undefined) {
+ throw new Error("button key " + key + " is not allowed (options are " + buttons.join("\n") + ")");
+ }
+ });
+
+ return options;
+ }
+
+ exports.alert = function() {
+ var options;
+
+ options = mergeDialogOptions("alert", ["ok"], ["message", "callback"], arguments);
+
+ if (options.callback && !$.isFunction(options.callback)) {
+ throw new Error("alert requires callback property to be a function when provided");
+ }
+
+ /**
+ * overrides
+ */
+ options.buttons.ok.callback = options.onEscape = function() {
+ if ($.isFunction(options.callback)) {
+ return options.callback();
+ }
+ return true;
+ };
+
+ return exports.dialog(options);
+ };
+
+ exports.confirm = function() {
+ var options;
+
+ options = mergeDialogOptions("confirm", ["cancel", "confirm"], ["message", "callback"], arguments);
+
+ /**
+ * overrides; undo anything the user tried to set they shouldn't have
+ */
+ options.buttons.cancel.callback = options.onEscape = function() {
+ return options.callback(false);
+ };
+
+ options.buttons.confirm.callback = function() {
+ return options.callback(true);
+ };
+
+ // confirm specific validation
+ if (!$.isFunction(options.callback)) {
+ throw new Error("confirm requires a callback");
+ }
+
+ return exports.dialog(options);
+ };
+
+ exports.prompt = function() {
+ var options;
+ var defaults;
+ var dialog;
+ var form;
+ var input;
+ var shouldShow;
+ var inputOptions;
+
+ // we have to create our form first otherwise
+ // its value is undefined when gearing up our options
+ // @TODO this could be solved by allowing message to
+ // be a function instead...
+ form = $(templates.form);
+
+ // prompt defaults are more complex than others in that
+ // users can override more defaults
+ // @TODO I don't like that prompt has to do a lot of heavy
+ // lifting which mergeDialogOptions can *almost* support already
+ // just because of 'value' and 'inputType' - can we refactor?
+ defaults = {
+ className: "bootbox-prompt",
+ buttons: createLabels("cancel", "confirm"),
+ value: "",
+ inputType: "text"
+ };
+
+ options = validateButtons(
+ mergeArguments(defaults, arguments, ["title", "callback"]),
+ ["cancel", "confirm"]
+ );
+
+ // capture the user's show value; we always set this to false before
+ // spawning the dialog to give us a chance to attach some handlers to
+ // it, but we need to make sure we respect a preference not to show it
+ shouldShow = (options.show === undefined) ? true : options.show;
+
+ // check if the browser supports the option.inputType
+ var html5inputs = ["date","time","number"];
+ var i = document.createElement("input");
+ i.setAttribute("type", options.inputType);
+ if(html5inputs[options.inputType]){
+ options.inputType = i.type;
+ }
+
+ /**
+ * overrides; undo anything the user tried to set they shouldn't have
+ */
+ options.message = form;
+
+ options.buttons.cancel.callback = options.onEscape = function() {
+ return options.callback(null);
+ };
+
+ options.buttons.confirm.callback = function() {
+ var value;
+
+ switch (options.inputType) {
+ case "text":
+ case "textarea":
+ case "email":
+ case "select":
+ case "date":
+ case "time":
+ case "number":
+ case "password":
+ value = input.val();
+ break;
+
+ case "checkbox":
+ var checkedItems = input.find("input:checked");
+
+ // we assume that checkboxes are always multiple,
+ // hence we default to an empty array
+ value = [];
+
+ each(checkedItems, function(_, item) {
+ value.push($(item).val());
+ });
+ break;
+ }
+
+ return options.callback(value);
+ };
+
+ options.show = false;
+
+ // prompt specific validation
+ if (!options.title) {
+ throw new Error("prompt requires a title");
+ }
+
+ if (!$.isFunction(options.callback)) {
+ throw new Error("prompt requires a callback");
+ }
+
+ if (!templates.inputs[options.inputType]) {
+ throw new Error("invalid prompt type");
+ }
+
+ // create the input based on the supplied type
+ input = $(templates.inputs[options.inputType]);
+
+ switch (options.inputType) {
+ case "text":
+ case "textarea":
+ case "email":
+ case "date":
+ case "time":
+ case "number":
+ case "password":
+ input.val(options.value);
+ break;
+
+ case "select":
+ var groups = {};
+ inputOptions = options.inputOptions || [];
+
+ if (!inputOptions.length) {
+ throw new Error("prompt with select requires options");
+ }
+
+ each(inputOptions, function(_, option) {
+
+ // assume the element to attach to is the input...
+ var elem = input;
+
+ if (option.value === undefined || option.text === undefined) {
+ throw new Error("given options in wrong format");
+ }
+
+
+ // ... but override that element if this option sits in a group
+
+ if (option.group) {
+ // initialise group if necessary
+ if (!groups[option.group]) {
+ groups[option.group] = $(" ").attr("label", option.group);
+ }
+
+ elem = groups[option.group];
+ }
+
+ elem.append("" + option.text + " ");
+ });
+
+ each(groups, function(_, group) {
+ input.append(group);
+ });
+
+ // safe to set a select's value as per a normal input
+ input.val(options.value);
+ break;
+
+ case "checkbox":
+ var values = $.isArray(options.value) ? options.value : [options.value];
+ inputOptions = options.inputOptions || [];
+
+ if (!inputOptions.length) {
+ throw new Error("prompt with checkbox requires options");
+ }
+
+ if (!inputOptions[0].value || !inputOptions[0].text) {
+ throw new Error("given options in wrong format");
+ }
+
+ // checkboxes have to nest within a containing element, so
+ // they break the rules a bit and we end up re-assigning
+ // our 'input' element to this container instead
+ input = $("
");
+
+ each(inputOptions, function(_, option) {
+ var checkbox = $(templates.inputs[options.inputType]);
+
+ checkbox.find("input").attr("value", option.value);
+ checkbox.find("label").append(option.text);
+
+ // we've ensured values is an array so we can always iterate over it
+ each(values, function(_, value) {
+ if (value === option.value) {
+ checkbox.find("input").prop("checked", true);
+ }
+ });
+
+ input.append(checkbox);
+ });
+ break;
+ }
+
+ if (options.placeholder) {
+ input.attr("placeholder", options.placeholder);
+ }
+
+ if(options.pattern){
+ input.attr("pattern", options.pattern);
+ }
+
+ // now place it in our form
+ form.append(input);
+
+ form.on("submit", function(e) {
+ e.preventDefault();
+ // @TODO can we actually click *the* button object instead?
+ // e.g. buttons.confirm.click() or similar
+ dialog.find(".btn-primary").click();
+ });
+
+ dialog = exports.dialog(options);
+
+ // clear the existing handler focusing the submit button...
+ dialog.off("shown.bs.modal");
+
+ // ...and replace it with one focusing our input, if possible
+ dialog.on("shown.bs.modal", function() {
+ input.focus();
+ });
+
+ if (shouldShow === true) {
+ dialog.modal("show");
+ }
+
+ return dialog;
+ };
+
+ exports.dialog = function(options) {
+ options = sanitize(options);
+
+ var dialog = $(templates.dialog);
+ var body = dialog.find(".modal-body");
+ var buttons = options.buttons;
+ var buttonStr = "";
+ var callbacks = {
+ onEscape: options.onEscape
+ };
+
+ each(buttons, function(key, button) {
+
+ // @TODO I don't like this string appending to itself; bit dirty. Needs reworking
+ // can we just build up button elements instead? slower but neater. Then button
+ // can just become a template too
+ buttonStr += "" + button.label + " ";
+ callbacks[key] = button.callback;
+ });
+
+ body.find(".bootbox-body").html(options.message);
+
+ if (options.animate === true) {
+ dialog.addClass("fade");
+ }
+
+ if (options.className) {
+ dialog.addClass(options.className);
+ }
+
+ if (options.title) {
+ body.before(templates.header);
+ }
+
+ if (options.closeButton) {
+ var closeButton = $(templates.closeButton);
+
+ if (options.title) {
+ dialog.find(".modal-header").prepend(closeButton);
+ } else {
+ closeButton.css("margin-top", "-10px").prependTo(body);
+ }
+ }
+
+ if (options.title) {
+ dialog.find(".modal-title").html(options.title);
+ }
+
+ if (buttonStr.length) {
+ body.after(templates.footer);
+ dialog.find(".modal-footer").html(buttonStr);
+ }
+
+
+ /**
+ * Bootstrap event listeners; used handle extra
+ * setup & teardown required after the underlying
+ * modal has performed certain actions
+ */
+
+ dialog.on("hidden.bs.modal", function(e) {
+ // ensure we don't accidentally intercept hidden events triggered
+ // by children of the current dialog. We shouldn't anymore now BS
+ // namespaces its events; but still worth doing
+ if (e.target === this) {
+ dialog.remove();
+ }
+ });
+
+ /*
+ dialog.on("show.bs.modal", function() {
+ // sadly this doesn't work; show is called *just* before
+ // the backdrop is added so we'd need a setTimeout hack or
+ // otherwise... leaving in as would be nice
+ if (options.backdrop) {
+ dialog.next(".modal-backdrop").addClass("bootbox-backdrop");
+ }
+ });
+ */
+
+ dialog.on("shown.bs.modal", function() {
+ dialog.find(".btn-primary:first").focus();
+ });
+
+ /**
+ * Bootbox event listeners; experimental and may not last
+ * just an attempt to decouple some behaviours from their
+ * respective triggers
+ */
+
+ dialog.on("escape.close.bb", function(e) {
+ if (callbacks.onEscape) {
+ processCallback(e, dialog, callbacks.onEscape);
+ }
+ });
+
+ /**
+ * Standard jQuery event listeners; used to handle user
+ * interaction with our dialog
+ */
+
+ dialog.on("click", ".modal-footer button", function(e) {
+ var callbackKey = $(this).data("bb-handler");
+
+ processCallback(e, dialog, callbacks[callbackKey]);
+
+ });
+
+ dialog.on("click", ".bootbox-close-button", function(e) {
+ // onEscape might be falsy but that's fine; the fact is
+ // if the user has managed to click the close button we
+ // have to close the dialog, callback or not
+ processCallback(e, dialog, callbacks.onEscape);
+ });
+
+ dialog.on("keyup", function(e) {
+ if (e.which === 27) {
+ dialog.trigger("escape.close.bb");
+ }
+ });
+
+ // the remainder of this method simply deals with adding our
+ // dialogent to the DOM, augmenting it with Bootstrap's modal
+ // functionality and then giving the resulting object back
+ // to our caller
+
+ $(options.container).append(dialog);
+
+ dialog.modal({
+ backdrop: options.backdrop,
+ keyboard: false,
+ show: false
+ });
+
+ if (options.show) {
+ dialog.modal("show");
+ }
+
+ // @TODO should we return the raw element here or should
+ // we wrap it in an object on which we can expose some neater
+ // methods, e.g. var d = bootbox.alert(); d.hide(); instead
+ // of d.modal("hide");
+
+ /*
+ function BBDialog(elem) {
+ this.elem = elem;
+ }
+
+ BBDialog.prototype = {
+ hide: function() {
+ return this.elem.modal("hide");
+ },
+ show: function() {
+ return this.elem.modal("show");
+ }
+ };
+ */
+
+ return dialog;
+
+ };
+
+ exports.setDefaults = function() {
+ var values = {};
+
+ if (arguments.length === 2) {
+ // allow passing of single key/value...
+ values[arguments[0]] = arguments[1];
+ } else {
+ // ... and as an object too
+ values = arguments[0];
+ }
+
+ $.extend(defaults, values);
+ };
+
+ exports.hideAll = function() {
+ $(".bootbox").modal("hide");
+ };
+
+
+ /**
+ * standard locales. Please add more according to ISO 639-1 standard. Multiple language variants are
+ * unlikely to be required. If this gets too large it can be split out into separate JS files.
+ */
+ var locales = {
+ br : {
+ OK : "OK",
+ CANCEL : "Cancelar",
+ CONFIRM : "Sim"
+ },
+ da : {
+ OK : "OK",
+ CANCEL : "Annuller",
+ CONFIRM : "Accepter"
+ },
+ de : {
+ OK : "OK",
+ CANCEL : "Abbrechen",
+ CONFIRM : "Akzeptieren"
+ },
+ en : {
+ OK : "OK",
+ CANCEL : "Cancel",
+ CONFIRM : "OK"
+ },
+ es : {
+ OK : "OK",
+ CANCEL : "Cancelar",
+ CONFIRM : "Aceptar"
+ },
+ fi : {
+ OK : "OK",
+ CANCEL : "Peruuta",
+ CONFIRM : "OK"
+ },
+ fr : {
+ OK : "OK",
+ CANCEL : "Annuler",
+ CONFIRM : "D'accord"
+ },
+ he : {
+ OK : "אישור",
+ CANCEL : "ביטול",
+ CONFIRM : "אישור"
+ },
+ it : {
+ OK : "OK",
+ CANCEL : "Annulla",
+ CONFIRM : "Conferma"
+ },
+ lt : {
+ OK : "Gerai",
+ CANCEL : "Atšaukti",
+ CONFIRM : "Patvirtinti"
+ },
+ lv : {
+ OK : "Labi",
+ CANCEL : "Atcelt",
+ CONFIRM : "Apstiprināt"
+ },
+ nl : {
+ OK : "OK",
+ CANCEL : "Annuleren",
+ CONFIRM : "Accepteren"
+ },
+ no : {
+ OK : "OK",
+ CANCEL : "Avbryt",
+ CONFIRM : "OK"
+ },
+ pl : {
+ OK : "OK",
+ CANCEL : "Anuluj",
+ CONFIRM : "Potwierdź"
+ },
+ ru : {
+ OK : "OK",
+ CANCEL : "Отмена",
+ CONFIRM : "Применить"
+ },
+ sv : {
+ OK : "OK",
+ CANCEL : "Avbryt",
+ CONFIRM : "OK"
+ },
+ tr : {
+ OK : "Tamam",
+ CANCEL : "İptal",
+ CONFIRM : "Onayla"
+ },
+ zh_CN : {
+ OK : "OK",
+ CANCEL : "取消",
+ CONFIRM : "确认"
+ },
+ zh_TW : {
+ OK : "OK",
+ CANCEL : "取消",
+ CONFIRM : "確認"
+ }
+ };
+
+ exports.init = function(_$) {
+ return init(_$ || $);
+ };
+
+ return exports;
+}));
+
+///#source 1 1 /scripts/plugins/jquery.mb-waitspinner.js
+///
+///
+/*******************************************
+ MbWaitSpinner
+ A simple spin.js implementation to
+ wondow load event
+ (c) Bruno Milgiaretti 2014
+********************************************/
+;var MbWaitSpinner;
+
+(function () {
+ "use strict";
+
+ MbWaitSpinner = function (opt) {
+ if (!$().spin ) throw (new Error('Spin.js required !!!'));
+ var defaults = {
+ locked: false,
+ overlayColor: "transparent",
+ color: "#000",
+ callback: null
+ };
+ var options = {};
+ $.extend(options, defaults, opt);
+ this.locked = options.locked;
+ this.overlayColor = options.windowColor;
+ this.spinOptions = options;
+ this.callback = options.callback;
+ }
+ MbWaitSpinner.prototype = {
+ show: function () {
+ this.$element = $('
');
+ if (this.locked) {
+ this.$element
+ .css({
+ position: "fixed",
+ top: 0,
+ bottom: 0,
+ left: 0,
+ right: 0,
+ "background-color": this.overlayColor,
+ "z-index": 1000
+ });
+ } else {
+ this.$element
+ .css({
+ position: "fixed",
+ top:"50%",
+ left:"50%",
+ height:"80px",
+ width: "80px",
+ margin: "-40px 0 0 -40px"
+ });
+ }
+ this.$element.appendTo("body").spin(this.spinOptions);
+ },
+ hide: function () {
+ this.$element.remove();
+ }
+ };
+
+ $.fn.mb_waitspinner = function(options) {
+ return $(this).each(function(index, element) {
+ var ws;
+ if(index == 0) {
+ ws = new MbWaitSpinner(options);
+ ws.show();
+ $(window).load(function () {
+ if ($.isFunction(ws.callback)) {
+ if (ws.callback(ws))
+ ws.hide();
+ }
+ else
+ {
+ ws.hide();
+ }
+ })
+ }
+ });
+ }
+
+}).call(this);
diff --git a/CkEditorSample/FileBrowser/js/FileManager.js.bundle b/CkEditorSample/FileBrowser/js/FileManager.js.bundle
new file mode 100644
index 0000000..e78fb98
--- /dev/null
+++ b/CkEditorSample/FileBrowser/js/FileManager.js.bundle
@@ -0,0 +1,11 @@
+
+
+
+ /Scripts/plugins/spin/spin.js
+ /Scripts/plugins/spin/jquery.spin.js
+ /scripts/plugins/fineuploader/jquery.fineuploader.js
+ /scripts/plugins/bootstrap/tooltip.js
+ /scripts/plugins/bootstrap/modal.js
+ /scripts/plugins/bootbox.js
+ /scripts/plugins/jquery.mb-waitspinner.js
+
\ No newline at end of file
diff --git a/CkEditorSample/FileBrowser/js/FileManager.min.js b/CkEditorSample/FileBrowser/js/FileManager.min.js
new file mode 100644
index 0000000..2b0f6db
--- /dev/null
+++ b/CkEditorSample/FileBrowser/js/FileManager.min.js
@@ -0,0 +1,4 @@
+var qq,ExifRestorer,MbWaitSpinner;(function(n,t){typeof exports=="object"?module.exports=t():typeof define=="function"&&define.amd?define(t):n.Spinner=t()})(this,function(){"use strict";function i(n,t){var i=document.createElement(n||"div");for(var r in t)i[r]=t[r];return i}function t(n){for(var t=1,i=arguments.length;t',t)}e.addRule(".spin-vml","behavior:url(#default#VML)");r.prototype.lines=function(i,r){function s(){return n(u("group",{coordsize:o+" "+o,coordorigin:-e+" "+-e}),{width:o,height:o})}function a(i,f,o){t(c,t(n(s(),{rotation:360/r.lines*i+"deg",left:~~f}),t(n(u("roundrect",{arcsize:r.corners}),{width:e,height:r.width,left:r.radius,top:-r.width>>1,filter:o}),u("fill",{color:l(r.color,i),opacity:r.opacity}),u("stroke",{opacity:0}))))}var e=r.length+r.width,o=2*e,h=-(r.width+r.length)*2+"px",c=n(s(),{position:"absolute",top:h,left:h}),f;if(r.shadow)for(f=1;f<=r.lines;f++)a(f,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(f=1;f<=r.lines;f++)a(f);return t(i,c)};r.prototype.opacity=function(n,t,i,r){var u=n.firstChild;r=r.shadow&&r.lines||0;u&&t+r>1)+"px"})}for(var e=0,h=(f.lines-1)*(1-f.direction)/2,o;e "+n):window.console.log(n))};qq.isObject=function(n){return n&&!n.nodeType&&Object.prototype.toString.call(n)==="[object Object]"};qq.isFunction=function(n){return typeof n=="function"};qq.isArray=function(n){return Object.prototype.toString.call(n)==="[object Array]"||n&&window.ArrayBuffer&&n.buffer&&n.buffer.constructor===ArrayBuffer};qq.isItemList=function(n){return Object.prototype.toString.call(n)==="[object DataTransferItemList]"};qq.isNodeList=function(n){return Object.prototype.toString.call(n)==="[object NodeList]"||n.item&&n.namedItem};qq.isString=function(n){return Object.prototype.toString.call(n)==="[object String]"};qq.trimStr=function(n){return String.prototype.trim?n.trim():n.replace(/^\s+|\s+$/g,"")};qq.format=function(n){var r=Array.prototype.slice.call(arguments,1),t=n,i=t.indexOf("{}");return qq.each(r,function(n,r){var u=t.substring(0,i),f=t.substring(i+2);return t=u+r+f,i=t.indexOf("{}",i+r.length),i<0?!1:void 0}),t};qq.isFile=function(n){return window.File&&Object.prototype.toString.call(n)==="[object File]"};qq.isFileList=function(n){return window.FileList&&Object.prototype.toString.call(n)==="[object FileList]"};qq.isFileOrInput=function(n){return qq.isFile(n)||qq.isInput(n)};qq.isInput=function(n,t){var i=function(n){var i=n.toLowerCase();return t?i!=="file":i==="file"};return window.HTMLInputElement&&Object.prototype.toString.call(n)==="[object HTMLInputElement]"&&n.type&&i(n.type)?!0:n.tagName&&n.tagName.toLowerCase()==="input"&&n.type&&i(n.type)?!0:!1};qq.isBlob=function(n){if(window.Blob&&Object.prototype.toString.call(n)==="[object Blob]")return!0};qq.isXhrUploadSupported=function(){var n=document.createElement("input");return n.type="file",n.multiple!==undefined&&typeof File!="undefined"&&typeof FormData!="undefined"&&typeof qq.createXhrInstance().upload!="undefined"};qq.createXhrInstance=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(n){return qq.log("Neither XHR or ActiveX are supported!","error"),null}};qq.isFolderDropSupported=function(n){return n.items&&n.items.length>0&&n.items[0].webkitGetAsEntry};qq.isFileChunkingSupported=function(){return!qq.androidStock()&&qq.isXhrUploadSupported()&&(File.prototype.slice!==undefined||File.prototype.webkitSlice!==undefined||File.prototype.mozSlice!==undefined)};qq.sliceBlob=function(n,t,i){var r=n.slice||n.mozSlice||n.webkitSlice;return r.call(n,t,i)};qq.arrayBufferToHex=function(n){var t="",i=new Uint8Array(n);return qq.each(i,function(n,i){var r=i.toString(16);r.length<2&&(r="0"+r);t+=r}),t};qq.readBlobToHex=function(n,t,i){var f=qq.sliceBlob(n,t,t+i),r=new FileReader,u=new qq.Promise;return r.onload=function(){u.success(qq.arrayBufferToHex(r.result))},r.onerror=u.failure,r.readAsArrayBuffer(f),u};qq.extend=function(n,t,i){return qq.each(t,function(t,r){i&&qq.isObject(r)?(n[t]===undefined&&(n[t]={}),qq.extend(n[t],r,!0)):n[t]=r}),n};qq.override=function(n,t){var i={},r=t(i);return qq.each(r,function(t,r){n[t]!==undefined&&(i[t]=n[t]);n[t]=r}),n};qq.indexOf=function(n,t,i){if(n.indexOf)return n.indexOf(t,i);i=i||0;var r=n.length;for(i<0&&(i+=r);i0)return n.substr(t,n.length-t)};qq.getFilename=function(n){return qq.isInput(n)?n.value.replace(/.*(\/|\\)/,""):qq.isFile(n)&&n.fileName!==null&&n.fileName!==undefined?n.fileName:n.name};qq.DisposeSupport=function(){var n=[];return{dispose:function(){var t;do t=n.shift(),t&&t();while(t)},attach:function(){var n=arguments;this.addDisposer(qq(n[0]).attach.apply(this,Array.prototype.slice.call(arguments,1)))},addDisposer:function(t){n.push(t)}}}}(),function(){"use strict";qq.Error=function(n){this.message="[Fine Uploader "+qq.version+"] "+n};qq.Error.prototype=new Error}();qq.version="5.0.3";qq.supportedFeatures=function(){"use strict";function w(){var t=!0,n;try{n=document.createElement("input");n.type="file";qq(n).hide();n.disabled&&(t=!1)}catch(i){t=!1}return t}function b(){return(qq.chrome()||qq.opera())&&navigator.userAgent.match(/Chrome\/[2][1-9]|Chrome\/[3-9][0-9]/)!==undefined}function k(){return(qq.chrome()||qq.opera())&&navigator.userAgent.match(/Chrome\/[1][4-9]|Chrome\/[2-9][0-9]/)!==undefined}function y(){if(window.XMLHttpRequest){var n=qq.createXhrInstance();return n.withCredentials!==undefined}return!1}function p(){return window.XDomainRequest!==undefined}function d(){return y()?!0:p()}function g(){return document.createElement("input").webkitdirectory!==undefined}var t,u,n,f,i,e,o,s,h,c,l,a,r,v;return t=w(),n=t&&qq.isXhrUploadSupported(),u=n&&!qq.androidStock(),f=n&&b(),i=n&&qq.isFileChunkingSupported(),e=n&&i&&!!window.localStorage,o=n&&k(),s=t&&(window.postMessage!==undefined||n),c=y(),h=p(),l=d(),a=g(),r=n&&window.FileReader!==undefined,v=function(){return n?!qq.androidStock()&&!(qq.ios()&&navigator.userAgent.indexOf("CriOS")>=0):!1}(),{ajaxUploading:n,blobUploading:u,canDetermineSize:n,chunking:i,deleteFileCors:l,deleteFileCorsXdr:h,deleteFileCorsXhr:c,fileDrop:n,folderDrop:f,folderSelection:a,imagePreviews:r,imageValidation:r,itemSizeValidation:n,pause:i,progressBar:v,resume:e,scaling:r&&u,tiffPreviews:qq.safari(),unlimitedScaledImageSize:!qq.ios(),uploading:t,uploadCors:s,uploadCustomHeaders:n,uploadNonMultipart:n,uploadViaPaste:o}}();qq.isGenericPromise=function(n){"use strict";return!!(n&&n.then&&qq.isFunction(n.then))};qq.Promise=function(){"use strict";var t,n,u=[],f=[],i=[],r=0;qq.extend(this,{then:function(i,e){return r===0?(i&&u.push(i),e&&f.push(e)):r===-1?e&&e.apply(null,n):i&&i.apply(null,t),this},done:function(u){return r===0?i.push(u):u.apply(null,n===undefined?t:n),this},success:function(){return r=1,t=arguments,u.length&&qq.each(u,function(n,i){i.apply(null,t)}),i.length&&qq.each(i,function(n,i){i.apply(null,t)}),this},failure:function(){return r=-1,n=arguments,f.length&&qq.each(f,function(t,i){i.apply(null,n)}),i.length&&qq.each(i,function(t,i){i.apply(null,n)}),this}})};qq.BlobProxy=function(n,t){"use strict";qq.extend(this,{referenceBlob:n,create:function(){return t(n)}})};qq.UploadButton=function(n){"use strict";function f(){var n=document.createElement("input");return n.setAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME,u),t.multiple&&n.setAttribute("multiple",""),t.folders&&qq.supportedFeatures.folderSelection&&n.setAttribute("webkitdirectory",""),t.acceptFiles&&n.setAttribute("accept",t.acceptFiles),n.setAttribute("type","file"),n.setAttribute("name",t.name),qq(n).css({position:"absolute",right:0,top:0,fontFamily:"Arial",fontSize:"118px",margin:0,padding:0,cursor:"pointer",opacity:0}),t.element.appendChild(n),r.attach(n,"change",function(){t.onChange(n)}),r.attach(n,"mouseover",function(){qq(t.element).addClass(t.hoverClass)}),r.attach(n,"mouseout",function(){qq(t.element).removeClass(t.hoverClass)}),r.attach(n,"focus",function(){qq(t.element).addClass(t.focusClass)}),r.attach(n,"blur",function(){qq(t.element).removeClass(t.focusClass)}),window.attachEvent&&n.setAttribute("tabIndex","-1"),n}var r=new qq.DisposeSupport,t={element:null,multiple:!1,acceptFiles:null,folders:!1,name:"qqfile",onChange:function(){},hoverClass:"qq-upload-button-hover",focusClass:"qq-upload-button-focus"},i,u;qq.extend(t,n);u=qq.getUniqueId();qq(t.element).css({position:"relative",overflow:"hidden",direction:"ltr"});i=f();qq.extend(this,{getInput:function(){return i},getButtonId:function(){return u},setMultiple:function(n){n!==t.multiple&&(n?i.setAttribute("multiple",""):i.removeAttribute("multiple"))},setAcceptFiles:function(n){n!==t.acceptFiles&&i.setAttribute("accept",n)},reset:function(){i.parentNode&&qq(i).remove();qq(t.element).removeClass(t.focusClass);i=f()}})};qq.UploadButton.BUTTON_ID_ATTR_NAME="qq-button-id";qq.UploadData=function(n){"use strict";function e(n){if(qq.isArray(n)){var i=[];return qq.each(n,function(n,r){i.push(t[r])}),i}return t[n]}function o(n){if(qq.isArray(n)){var i=[];return qq.each(n,function(n,u){i.push(t[r[u]])}),i}return t[r[n]]}function s(n){var r=[],u=[].concat(n);return qq.each(u,function(n,u){var f=i[u];f!==undefined&&qq.each(f,function(n,i){r.push(t[i])})}),r}var t=[],r={},i={},f={},u={};qq.extend(this,{addFile:function(e){var s=e.status||qq.status.SUBMITTING,o=t.push({name:e.name,originalName:e.name,uuid:e.uuid,size:e.size||-1,status:s})-1;e.batchId&&(t[o].batchId=e.batchId,u[e.batchId]===undefined&&(u[e.batchId]=[]),u[e.batchId].push(o));e.proxyGroupId&&(t[o].proxyGroupId=e.proxyGroupId,f[e.proxyGroupId]===undefined&&(f[e.proxyGroupId]=[]),f[e.proxyGroupId].push(o));t[o].id=o;r[e.uuid]=o;i[s]===undefined&&(i[s]=[]);i[s].push(o);n.onStatusChange(o,null,s);return o},retrieve:function(n){if(qq.isObject(n)&&t.length){if(n.id!==undefined)return e(n.id);if(n.uuid!==undefined)return o(n.uuid);if(n.status)return s(n.status)}else return qq.extend([],t,!0)},reset:function(){t=[];r={};i={};u={}},setStatus:function(r,u){var f=t[r].status,e=qq.indexOf(i[f],r);i[f].splice(e,1);t[r].status=u;i[u]===undefined&&(i[u]=[]);i[u].push(r);n.onStatusChange(r,f,u)},uuidChanged:function(n,i){var u=t[n].uuid;t[n].uuid=i;r[i]=n;delete r[u]},updateName:function(n,i){t[n].name=i},updateSize:function(n,i){t[n].size=i},setParentId:function(n,i){t[n].parentId=i},getIdsInProxyGroup:function(n){var i=t[n].proxyGroupId;return i?f[i]:[]},getIdsInBatch:function(n){var i=t[n].batchId;return u[i]}})};qq.status={SUBMITTING:"submitting",SUBMITTED:"submitted",REJECTED:"rejected",QUEUED:"queued",CANCELED:"canceled",PAUSED:"paused",UPLOADING:"uploading",UPLOAD_RETRYING:"retrying upload",UPLOAD_SUCCESSFUL:"upload successful",UPLOAD_FAILED:"upload failed",DELETE_FAILED:"delete failed",DELETING:"deleting",DELETED:"deleted"},function(){"use strict";qq.basePublicApi={addBlobs:function(n,t,i){if(!qq.supportedFeatures.blobUploading)throw new qq.Error("Blob uploading is not supported in this browser!");if(n){var e=[].concat(n),u=[],f=this._storedIds.length===0?qq.getUniqueId():this._currentBatchId,r=this;this._currentBatchId=f;qq.each(e,function(n,t){var i;qq.isBlob(t)&&!qq.isFileOrInput(t)?i={blob:t,name:r._options.blobs.defaultName}:qq.isObject(t)&&t.blob&&t.name?i=t:r.log("addBlobs: entry at index "+n+" is not a Blob or a BlobData object","error");i&&r._handleNewFile(i,f,u)});this._prepareItemsForUpload(u,t,i)}else this.log("undefined or non-array parameter passed into addBlobs","error")},addFiles:function(n,t,i){var u=[],o=this._storedIds.length===0?qq.getUniqueId():this._currentBatchId,f,r,e;if(this._currentBatchId=o,n){for(qq.isFileList(n)||(n=[].concat(n)),f=0;f0,maxSize:i>0?i:null},!r&&qq.supportedFeatures.imagePreviews&&(f=this.getFile(n)),f==null?u.failure({container:t,error:"File or URL not found."}):this._imageGenerator.generate(f,t,e).then(function(n){u.success(n)},function(n,t){u.failure({container:n,error:t||"Problem generating thumbnail"})})):u.failure({container:t,error:"Missing image generator module"}),u},getButton:function(n){return this._getButton(this._buttonIdsForFileIds[n])},getFile:function(n){return this._handler.getFile(n)||null},getInProgress:function(){return this._uploadData.retrieve({status:[qq.status.UPLOADING,qq.status.UPLOAD_RETRYING,qq.status.QUEUED]}).length},getName:function(n){return this._uploadData.retrieve({id:n}).name},getParentId:function(n){var t=this.getUploads({id:n}),i=null;return t&&t.parentId!==undefined&&(i=t.parentId),i},getResumableFilesData:function(){return this._handler.getResumableFilesData()},getSize:function(n){return this._uploadData.retrieve({id:n}).size},getNetUploads:function(){return this._netUploaded},getRemainingAllowedItems:function(){var n=this._options.validation.itemLimit;return n>0?this._options.validation.itemLimit-this._netUploadedOrQueued:null},getUploads:function(n){return this._uploadData.retrieve(n)},getUuid:function(n){return this._uploadData.retrieve({id:n}).uuid},log:function(n,t){this._options.debug&&(!t||t==="info")?qq.log("[Fine Uploader "+qq.version+"] "+n):t&&t!=="info"&&qq.log("[Fine Uploader "+qq.version+"] "+n,t)},pauseUpload:function(n){var t=this._uploadData.retrieve({id:n});if(!qq.supportedFeatures.pause||!this._options.chunking.enabled)return!1;if(qq.indexOf([qq.status.UPLOADING,qq.status.UPLOAD_RETRYING],t.status)>=0){if(this._handler.pause(n))return this._uploadData.setStatus(n,qq.status.PAUSED),!0;this.log(qq.format("Unable to pause file ID {} ({}).",n,this.getName(n)),"error")}else this.log(qq.format("Ignoring pause for file ID {} ({}). Not in progress.",n,this.getName(n)),"error");return!1},reset:function(){this.log("Resetting uploader...");this._handler.reset();this._storedIds=[];this._autoRetries=[];this._retryTimeouts=[];this._preventRetries=[];this._thumbnailUrls=[];qq.each(this._buttons,function(n,t){t.reset()});this._paramsStore.reset();this._endpointStore.reset();this._netUploadedOrQueued=0;this._netUploaded=0;this._uploadData.reset();this._buttonIdsForFileIds=[];this._pasteHandler&&this._pasteHandler.reset();this._options.session.refreshOnReset&&this._refreshSessionData();this._succeededSinceLastAllComplete=[];this._failedSinceLastAllComplete=[];this._totalProgress&&this._totalProgress.reset()},retry:function(n){return this._manualRetry(n)},scaleImage:function(n,t){var i=this;return qq.Scaler.prototype.scaleImage(n,t,{log:qq.bind(i.log,i),getFile:qq.bind(i.getFile,i),uploadData:i._uploadData})},setCustomHeaders:function(n,t){this._customHeadersStore.set(n,t)},setDeleteFileCustomHeaders:function(n,t){this._deleteFileCustomHeadersStore.set(n,t)},setDeleteFileEndpoint:function(n,t){this._deleteFileEndpointStore.set(n,t)},setDeleteFileParams:function(n,t){this._deleteFileParamsStore.set(n,t)},setEndpoint:function(n,t){this._endpointStore.set(n,t)},setName:function(n,t){this._uploadData.updateName(n,t)},setParams:function(n,t){this._paramsStore.set(n,t)},setUuid:function(n,t){return this._uploadData.uuidChanged(n,t)},uploadStoredFiles:function(){var n;if(this._storedIds.length===0)this._itemError("noFilesError");else while(this._storedIds.length)n=this._storedIds.shift(),this._uploadFile(n)}};qq.basePrivateApi={_addCannedFile:function(n){var t=this._uploadData.addFile({uuid:n.uuid,name:n.name,size:n.size,status:qq.status.UPLOAD_SUCCESSFUL});return n.deleteFileEndpoint&&this.setDeleteFileEndpoint(n.deleteFileEndpoint,t),n.deleteFileParams&&this.setDeleteFileParams(n.deleteFileParams,t),n.thumbnailUrl&&(this._thumbnailUrls[t]=n.thumbnailUrl),this._netUploaded++,this._netUploadedOrQueued++,t},_annotateWithButtonId:function(n,t){qq.isFile(n)&&(n.qqButtonId=this._getButtonId(t))},_batchError:function(n){this._options.callbacks.onError(null,null,n,undefined)},_createDeleteHandler:function(){var n=this;return new qq.DeleteFileAjaxRequester({method:this._options.deleteFile.method.toUpperCase(),maxConnections:this._options.maxConnections,uuidParamName:this._options.request.uuidName,customHeaders:this._deleteFileCustomHeadersStore,paramsStore:this._deleteFileParamsStore,endpointStore:this._deleteFileEndpointStore,demoMode:this._options.demoMode,cors:this._options.cors,log:qq.bind(n.log,n),onDelete:function(t){n._onDelete(t);n._options.callbacks.onDelete(t)},onDeleteComplete:function(t,i,r){n._onDeleteComplete(t,i,r);n._options.callbacks.onDeleteComplete(t,i,r)}})},_createPasteHandler:function(){var n=this;return new qq.PasteSupport({targetElement:this._options.paste.targetElement,callbacks:{log:qq.bind(n.log,n),pasteReceived:function(t){n._handleCheckedCallback({name:"onPasteReceived",callback:qq.bind(n._options.callbacks.onPasteReceived,n,t),onSuccess:qq.bind(n._handlePasteSuccess,n,t),identifier:"pasted image"})}}})},_createStore:function(n,t){var i={},f=n,r={},u=function(n){return qq.isObject(n)?qq.extend({},n):n},e=function(){return qq.isFunction(t)?t():t},o=function(n,i){t&&qq.isObject(i)&&qq.extend(i,e());r[n]&&qq.extend(i,r[n])};return{set:function(n,t){t==null?(i={},f=u(n)):i[t]=u(n)},get:function(n){var t;return t=n!=null&&i[n]?i[n]:u(f),o(n,t),u(t)},addReadOnly:function(n,t){qq.isObject(i)&&(r[n]=r[n]||{},qq.extend(r[n],t))},remove:function(n){return delete i[n]},reset:function(){i={};r={};f=n}}},_createUploadDataTracker:function(){var n=this;return new qq.UploadData({getName:function(t){return n.getName(t)},getUuid:function(t){return n.getUuid(t)},getSize:function(t){return n.getSize(t)},onStatusChange:function(t,i,r){n._onUploadStatusChange(t,i,r);n._options.callbacks.onStatusChange(t,i,r);n._maybeAllComplete(t,r);n._totalProgress&&setTimeout(function(){n._totalProgress.onStatusChange(t,i,r)},0)}})},_createUploadButton:function(n){function f(){return qq.supportedFeatures.ajaxUploading?qq.ios7()&&t._isAllowedExtension(u,".mov")?!1:n.multiple===undefined?t._options.multiple:n.multiple:!1}var t=this,r=n.accept||this._options.validation.acceptFiles,u=n.allowedExtensions||this._options.validation.allowedExtensions,i=new qq.UploadButton({element:n.element,folders:n.folders,name:this._options.request.inputName,multiple:f(),acceptFiles:r,onChange:function(n){t._onInputChange(n)},hoverClass:this._options.classes.buttonHover,focusClass:this._options.classes.buttonFocus});return this._disposeSupport.addDisposer(function(){i.dispose()}),t._buttons.push(i),i},_createUploadHandler:function(n,t){var i=this,r={},u={debug:this._options.debug,maxConnections:this._options.maxConnections,cors:this._options.cors,demoMode:this._options.demoMode,paramsStore:this._paramsStore,endpointStore:this._endpointStore,chunking:this._options.chunking,resume:this._options.resume,blobs:this._options.blobs,log:qq.bind(i.log,i),preventRetryParam:this._options.retry.preventRetryResponseProperty,onProgress:function(n,t,u,f){if(r[n]){if(r[n].loaded!==u||r[n].total!==f){i._onProgress(n,t,u,f);i._options.callbacks.onProgress(n,t,u,f)}}else{i._onProgress(n,t,u,f);i._options.callbacks.onProgress(n,t,u,f)}r[n]={loaded:u,total:f}},onComplete:function(n,t,u,f){var e,o;if(delete r[n],e=i.getUploads({id:n}).status,e!==qq.status.UPLOAD_SUCCESSFUL&&e!==qq.status.UPLOAD_FAILED)if(o=i._onComplete(n,t,u,f),o instanceof qq.Promise)o.done(function(){i._options.callbacks.onComplete(n,t,u,f)});else i._options.callbacks.onComplete(n,t,u,f)},onCancel:function(n,t,r){var u=new qq.Promise;return i._handleCheckedCallback({name:"onCancel",callback:qq.bind(i._options.callbacks.onCancel,i,n,t),onFailure:u.failure,onSuccess:function(){r.then(function(){i._onCancel(n,t)});u.success()},identifier:n}),u},onUploadPrep:qq.bind(this._onUploadPrep,this),onUpload:function(n,t){i._onUpload(n,t);i._options.callbacks.onUpload(n,t)},onUploadChunk:function(n,t,r){i._onUploadChunk(n,r);i._options.callbacks.onUploadChunk(n,t,r)},onUploadChunkSuccess:function(){i._options.callbacks.onUploadChunkSuccess.apply(i,arguments)},onResume:function(n,t,r){return i._options.callbacks.onResume(n,t,r)},onAutoRetry:function(){return i._onAutoRetry.apply(i,arguments)},onUuidChanged:function(n,t){i.log("Server requested UUID change from '"+i.getUuid(n)+"' to '"+t+"'");i.setUuid(n,t)},getName:qq.bind(i.getName,i),getUuid:qq.bind(i.getUuid,i),getSize:qq.bind(i.getSize,i),setSize:qq.bind(i._setSize,i),getDataByUuid:function(n){return i.getUploads({uuid:n})},isQueued:function(n){var t=i.getUploads({id:n}).status;return t===qq.status.QUEUED||t===qq.status.SUBMITTED||t===qq.status.UPLOAD_RETRYING||t===qq.status.PAUSED},getIdsInProxyGroup:i._uploadData.getIdsInProxyGroup,getIdsInBatch:i._uploadData.getIdsInBatch};return qq.each(this._options.request,function(n,t){u[n]=t}),u.customHeaders=this._customHeadersStore,n&&qq.each(n,function(n,t){u[n]=t}),new qq.UploadHandlerController(u,t)},_fileOrBlobRejected:function(n){this._netUploadedOrQueued--;this._uploadData.setStatus(n,qq.status.REJECTED)},_formatSize:function(n){var t=-1;do n=n/1e3,t++;while(n>999);return Math.max(n,.1).toFixed(1)+this._options.text.sizeSymbols[t]},_generateExtraButtonSpecs:function(){var n=this;this._extraButtonSpecs={};qq.each(this._options.extraButtons,function(t,i){var r=i.multiple,f=qq.extend({},n._options.validation,!0),u=qq.extend({},i);r===undefined&&(r=n._options.multiple);u.validation&&qq.extend(f,i.validation,!0);qq.extend(u,{multiple:r,validation:f},!0);n._initExtraButton(u)})},_getButton:function(n){var t=this._extraButtonSpecs[n];return t?t.element:n===this._defaultButtonId?this._options.button:void 0},_getButtonId:function(n){var r,i,t=n;if(t instanceof qq.BlobProxy&&(t=t.referenceBlob),t&&!qq.isBlob(t)){if(qq.isFile(t))return t.qqButtonId;if(t.tagName.toLowerCase()==="input"&&t.type.toLowerCase()==="file")return t.getAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME);if(r=t.getElementsByTagName("input"),qq.each(r,function(n,t){if(t.getAttribute("type")==="file")return i=t,!1}),i)return i.getAttribute(qq.UploadButton.BUTTON_ID_ATTR_NAME)}},_getNotFinished:function(){return this._uploadData.retrieve({status:[qq.status.UPLOADING,qq.status.UPLOAD_RETRYING,qq.status.QUEUED,qq.status.SUBMITTING,qq.status.SUBMITTED,qq.status.PAUSED]}).length},_getValidationBase:function(n){var t=this._extraButtonSpecs[n];return t?t.validation:this._options.validation},_getValidationDescriptor:function(n){return n.file instanceof qq.BlobProxy?{name:qq.getFilename(n.file.referenceBlob),size:n.file.referenceBlob.size}:{name:this.getUploads({id:n.id}).name,size:this.getUploads({id:n.id}).size}},_getValidationDescriptors:function(n){var i=this,t=[];return qq.each(n,function(n,r){t.push(i._getValidationDescriptor(r))}),t},_handleCameraAccess:function(){if(this._options.camera.ios&&qq.ios()){var i="image/*;capture=camera",r=this._options.camera.button,t=r?this._getButtonId(r):this._defaultButtonId,n=this._options;t&&t!==this._defaultButtonId&&(n=this._extraButtonSpecs[t]);n.multiple=!1;n.validation.acceptFiles===null?n.validation.acceptFiles=i:n.validation.acceptFiles+=","+i;qq.each(this._buttons,function(i,r){if(r.getButtonId()===t)return r.setMultiple(n.multiple),r.setAcceptFiles(n.acceptFiles),!1})}},_handleCheckedCallback:function(n){var i=this,t=n.callback();if(qq.isGenericPromise(t))return this.log(n.name+" - waiting for "+n.name+" promise to be fulfilled for "+n.identifier),t.then(function(t){i.log(n.name+" promise success for "+n.identifier);n.onSuccess(t)},function(){n.onFailure?(i.log(n.name+" promise failure for "+n.identifier),n.onFailure()):i.log(n.name+" promise failure for "+n.identifier)});if(t!==!1)n.onSuccess(t);else n.onFailure?(this.log(n.name+" - return value was 'false' for "+n.identifier+". Invoking failure callback."),n.onFailure()):this.log(n.name+" - return value was 'false' for "+n.identifier+". Will not proceed.");return t},_handleNewFile:function(n,t,i){var r=this,e=qq.getUniqueId(),f=-1,o=qq.getFilename(n),u=n.blob||n,s=this._customNewFileHandler?this._customNewFileHandler:qq.bind(r._handleNewFileGeneric,r);!qq.isInput(u)&&u.size>=0&&(f=u.size);s(u,o,e,f,i,t,this._options.request.uuidName,{uploadData:r._uploadData,paramsStore:r._paramsStore,addFileToHandler:function(n,t){r._handler.add(n,t);r._netUploadedOrQueued++;r._trackButton(n)}})},_handleNewFileGeneric:function(n,t,i,r,u,f){var e=this._uploadData.addFile({uuid:i,name:t,size:r,batchId:f});this._handler.add(e,n);this._trackButton(e);this._netUploadedOrQueued++;u.push({id:e,file:n})},_handlePasteSuccess:function(n,t){var r=n.type.split("/")[1],i=t;i==null&&(i=this._options.paste.defaultName);i+="."+r;this.addBlobs({name:i,blob:n})},_initExtraButton:function(n){var t=this._createUploadButton({element:n.element,multiple:n.multiple,accept:n.validation.acceptFiles,folders:n.folders,allowedExtensions:n.validation.allowedExtensions});this._extraButtonSpecs[t.getButtonId()]=n},_initFormSupportAndParams:function(){this._formSupport=qq.FormSupport&&new qq.FormSupport(this._options.form,qq.bind(this.uploadStoredFiles,this),qq.bind(this.log,this));this._formSupport&&this._formSupport.attachedToForm?(this._paramsStore=this._createStore(this._options.request.params,this._formSupport.getFormInputsAsObject),this._options.autoUpload=this._formSupport.newAutoUpload,this._formSupport.newEndpoint&&(this._options.request.endpoint=this._formSupport.newEndpoint)):this._paramsStore=this._createStore(this._options.request.params)},_isDeletePossible:function(){return!qq.DeleteFileAjaxRequester||!this._options.deleteFile.enabled?!1:this._options.cors.expected?qq.supportedFeatures.deleteFileCorsXhr?!0:qq.supportedFeatures.deleteFileCorsXdr&&this._options.cors.allowXdr?!0:!1:!0},_isAllowedExtension:function(n,t){var i=!1;return n.length?(qq.each(n,function(n,r){if(qq.isString(r)){var u=new RegExp("\\."+r+"$","i");if(t.match(u)!=null)return i=!0,!1}}),i):!0},_itemError:function(n,t,i){function u(n,t){r=r.replace(n,t)}var r=this._options.messages[n],o=[],s=[].concat(t),h=s[0],l=this._getButtonId(i),f=this._getValidationBase(l),c,e;qq.each(f.allowedExtensions,function(n,t){qq.isString(t)&&o.push(t)});c=o.join(", ").toLowerCase();u("{file}",this._options.formatFileName(h));u("{extensions}",c);u("{sizeLimit}",this._formatSize(f.sizeLimit));u("{minSizeLimit}",this._formatSize(f.minSizeLimit));e=r.match(/(\{\w+\})/g);e!==null&&qq.each(e,function(n,t){u(t,s[n])});this._options.callbacks.onError(null,h,r,undefined);return r},_manualRetry:function(n,t){if(this._onBeforeManualRetry(n))return this._netUploadedOrQueued++,this._uploadData.setStatus(n,qq.status.UPLOAD_RETRYING),t?t(n):this._handler.retry(n),!0},_maybeAllComplete:function(n,t){var i=this,r=this._getNotFinished();t===qq.status.UPLOAD_SUCCESSFUL?this._succeededSinceLastAllComplete.push(n):t===qq.status.UPLOAD_FAILED&&this._failedSinceLastAllComplete.push(n);r===0&&(this._succeededSinceLastAllComplete.length||this._failedSinceLastAllComplete.length)&&setTimeout(function(){i._onAllComplete(i._succeededSinceLastAllComplete,i._failedSinceLastAllComplete)},0)},_maybeParseAndSendUploadError:function(n,t,i,r){if(!i.success)if(r&&r.status!==200&&!i.error)this._options.callbacks.onError(n,t,"XHR returned response code "+r.status,r);else{var u=i.error?i.error:this._options.text.defaultResponseError;this._options.callbacks.onError(n,t,u,r)}},_maybeProcessNextItemAfterOnValidateCallback:function(n,t,i,r,u){var f=this;if(t.length>i)if(n||!this._options.validation.stopOnFirstInvalidFile)setTimeout(function(){var n=f._getValidationDescriptor(t[i]);f._handleCheckedCallback({name:"onValidate",callback:qq.bind(f._options.callbacks.onValidate,f,t[i].file),onSuccess:qq.bind(f._onValidateCallbackSuccess,f,t,i,r,u),onFailure:qq.bind(f._onValidateCallbackFailure,f,t,i,r,u),identifier:"Item '"+n.name+"', size: "+n.size})},0);else if(!n)for(;i0&&this._netUploadedOrQueued+1>i?(this._itemError("retryFailTooManyItems"),!1):(this.log("Retrying upload for '"+t+"' (id: "+n+")..."),!0):(this.log("'"+n+"' is not a valid file ID","error"),!1)},_onCancel:function(n){this._netUploadedOrQueued--;clearTimeout(this._retryTimeouts[n]);var t=qq.indexOf(this._storedIds,n);!this._options.autoUpload&&t>=0&&this._storedIds.splice(t,1);this._uploadData.setStatus(n,qq.status.CANCELED)},_onComplete:function(n,t,i,r){return i.success?(i.thumbnailUrl&&(this._thumbnailUrls[n]=i.thumbnailUrl),this._netUploaded++,this._uploadData.setStatus(n,qq.status.UPLOAD_SUCCESSFUL)):(this._netUploadedOrQueued--,this._uploadData.setStatus(n,qq.status.UPLOAD_FAILED),i[this._options.retry.preventRetryResponseProperty]===!0&&(this._preventRetries[n]=!0)),this._maybeParseAndSendUploadError(n,t,i,r),i.success?!0:!1},_onDelete:function(n){this._uploadData.setStatus(n,qq.status.DELETING)},_onDeleteComplete:function(n,t,i){var r=this.getName(n);if(i)if(this._uploadData.setStatus(n,qq.status.DELETE_FAILED),this.log("Delete request for '"+r+"' has failed.","error"),t.withCredentials===undefined)this._options.callbacks.onError(n,r,"Delete request failed",t);else this._options.callbacks.onError(n,r,"Delete request failed with response code "+t.status,t);else this._netUploadedOrQueued--,this._netUploaded--,this._handler.expunge(n),this._uploadData.setStatus(n,qq.status.DELETED),this.log("Delete request for '"+r+"' has succeeded.")},_onInputChange:function(n){var t;if(qq.supportedFeatures.ajaxUploading){for(t=0;t0&&this.addFiles(n);qq.each(this._buttons,function(n,t){t.reset()})},_onProgress:function(n,t,i,r){this._totalProgress&&this._totalProgress.onIndividualProgress(n,i,r)},_onSubmit:function(){},_onSubmitCallbackSuccess:function(n){this._onSubmit.apply(this,arguments);this._uploadData.setStatus(n,qq.status.SUBMITTED);this._onSubmitted.apply(this,arguments);this._options.callbacks.onSubmitted.apply(this,arguments);this._options.autoUpload?this._uploadFile(n):this._storeForLater(n)},_onSubmitDelete:function(n,t,i){var r=this.getUuid(n),u;return t&&(u=qq.bind(t,this,n,r,i)),this._isDeletePossible()?(this._handleCheckedCallback({name:"onSubmitDelete",callback:qq.bind(this._options.callbacks.onSubmitDelete,this,n),onSuccess:u||qq.bind(this._deleteHandler.sendDelete,this,n,r,i),identifier:n}),!0):(this.log("Delete request ignored for ID "+n+", delete feature is disabled or request not possible due to CORS on a user agent that does not support pre-flighting.","warn"),!1)},_onSubmitted:function(){},_onTotalProgress:function(n,t){this._options.callbacks.onTotalProgress(n,t)},_onUploadPrep:function(){},_onUpload:function(n){this._uploadData.setStatus(n,qq.status.UPLOADING)},_onUploadChunk:function(){},_onUploadStatusChange:function(n,t,i){i===qq.status.PAUSED&&clearTimeout(this._retryTimeouts[n])},_onValidateBatchCallbackFailure:function(n){var t=this;qq.each(n,function(n,i){t._fileOrBlobRejected(i.id)})},_onValidateBatchCallbackSuccess:function(n,t,i,r,u){var e,f=this._options.validation.itemLimit,o=this._netUploadedOrQueued;f===0||o<=f?t.length>0?this._handleCheckedCallback({name:"onValidate",callback:qq.bind(this._options.callbacks.onValidate,this,n[0],u),onSuccess:qq.bind(this._onValidateCallbackSuccess,this,t,0,i,r),onFailure:qq.bind(this._onValidateCallbackFailure,this,t,0,i,r),identifier:"Item '"+t[0].file.name+"', size: "+t[0].file.size}):this._itemError("noFilesError"):(this._onValidateBatchCallbackFailure(t),e=this._options.messages.tooManyItemsError.replace(/\{netItems\}/g,o).replace(/\{itemLimit\}/g,f),this._batchError(e))},_onValidateCallbackFailure:function(n,t,i,r){var u=t+1;this._fileOrBlobRejected(n[0].id,n[0].file.name);this._maybeProcessNextItemAfterOnValidateCallback(!1,n,u,i,r)},_onValidateCallbackSuccess:function(n,t,i,r){var u=this,f=t+1,e=this._getValidationDescriptor(n[t]);this._validateFileOrBlobData(n[t],e).then(function(){u._upload(n[t].id,i,r);u._maybeProcessNextItemAfterOnValidateCallback(!0,n,f,i,r)},function(){u._maybeProcessNextItemAfterOnValidateCallback(!1,n,f,i,r)})},_prepareItemsForUpload:function(n,t,i){if(n.length===0){this._itemError("noFilesError");return}var r=this._getValidationDescriptors(n),f=this._getButtonId(n[0].file),u=this._getButton(f);this._handleCheckedCallback({name:"onValidateBatch",callback:qq.bind(this._options.callbacks.onValidateBatch,this,r,u),onSuccess:qq.bind(this._onValidateBatchCallbackSuccess,this,r,n,t,i,u),onFailure:qq.bind(this._onValidateBatchCallbackFailure,this,n),identifier:"batch validation"})},_preventLeaveInProgress:function(){var n=this;this._disposeSupport.attach(window,"beforeunload",function(t){if(n.getInProgress())return t=t||window.event,t.returnValue=n._options.messages.onLeave,n._options.messages.onLeave})},_refreshSessionData:function(){var t=this,n=this._options.session;qq.Session&&this._options.session.endpoint!=null&&(this._session||(qq.extend(n,this._options.cors),n.log=qq.bind(this.log,this),n.addFileRecord=qq.bind(this._addCannedFile,this),this._session=new qq.Session(n)),setTimeout(function(){t._session.refresh().then(function(n,i){t._options.callbacks.onSessionRequestComplete(n,!0,i)},function(n,i){t._options.callbacks.onSessionRequestComplete(n,!1,i)})},0))},_setSize:function(n,t){this._uploadData.updateSize(n,t);this._totalProgress&&this._totalProgress.onNewSize(n)},_shouldAutoRetry:function(n){var t=this._uploadData.retrieve({id:n});return!this._preventRetries[n]&&this._options.retry.enableAuto&&t.status!==qq.status.PAUSED&&(this._autoRetries[n]===undefined&&(this._autoRetries[n]=0),this._autoRetries[n]0&&e.sizeLimit&&f>e.sizeLimit?(this._itemError("sizeError",u,r),i.failure()):f>0&&f33&&(n=n.slice(0,19)+"..."+n.slice(-14)),n},text:{defaultResponseError:"Upload failure reason unknown",sizeSymbols:["kB","MB","GB","TB","PB","EB"]},deleteFile:{enabled:!1,method:"DELETE",endpoint:"/server/upload",customHeaders:{},params:{}},cors:{expected:!1,sendCredentials:!1,allowXdr:!1},blobs:{defaultName:"misc_data"},paste:{targetElement:null,defaultName:"pasted_image"},camera:{ios:!1,button:null},extraButtons:[],session:{endpoint:null,params:{},customHeaders:{},refreshOnReset:!0},form:{element:"qq-form",autoUpload:!1,interceptSubmit:!0},scaling:{sendOriginal:!0,orient:!0,defaultType:null,defaultQuality:80,failureText:"Failed to scale",includeExif:!1,sizes:[]}};qq.extend(this._options,n,!0);this._buttons=[];this._extraButtonSpecs={};this._buttonIdsForFileIds=[];this._wrapCallbacks();this._disposeSupport=new qq.DisposeSupport;this._storedIds=[];this._autoRetries=[];this._retryTimeouts=[];this._preventRetries=[];this._thumbnailUrls=[];this._netUploadedOrQueued=0;this._netUploaded=0;this._uploadData=this._createUploadDataTracker();this._initFormSupportAndParams();this._customHeadersStore=this._createStore(this._options.request.customHeaders);this._deleteFileCustomHeadersStore=this._createStore(this._options.deleteFile.customHeaders);this._deleteFileParamsStore=this._createStore(this._options.deleteFile.params);this._endpointStore=this._createStore(this._options.request.endpoint);this._deleteFileEndpointStore=this._createStore(this._options.deleteFile.endpoint);this._handler=this._createUploadHandler();this._deleteHandler=qq.DeleteFileAjaxRequester&&this._createDeleteHandler();this._options.button&&(this._defaultButtonId=this._createUploadButton({element:this._options.button}).getButtonId());this._generateExtraButtonSpecs();this._handleCameraAccess();this._options.paste.targetElement&&(qq.PasteSupport?this._pasteHandler=this._createPasteHandler():this.log("Paste support module not found","error"));this._preventLeaveInProgress();this._imageGenerator=qq.ImageGenerator&&new qq.ImageGenerator(qq.bind(this.log,this));this._refreshSessionData();this._succeededSinceLastAllComplete=[];this._failedSinceLastAllComplete=[];this._scaler=qq.Scaler&&new qq.Scaler(this._options.scaling,qq.bind(this.log,this))||{};this._scaler.enabled&&(this._customNewFileHandler=qq.bind(this._scaler.handleNewFile,this._scaler));qq.TotalProgress&&qq.supportedFeatures.progressBar&&(this._totalProgress=new qq.TotalProgress(qq.bind(this._onTotalProgress,this),function(n){var i=t._uploadData.retrieve({id:n});return i&&i.size||0}))};qq.FineUploaderBasic.prototype=qq.basePublicApi;qq.extend(qq.FineUploaderBasic.prototype,qq.basePrivateApi)}();qq.AjaxRequester=function(n){"use strict";function l(){return qq.indexOf(["GET","POST","HEAD"],t.method)>=0}function a(){var n=!1;return qq.each(n,function(t,i){if(qq.indexOf(["Accept","Accept-Language","Content-Language","Content-Type"],i)<0)return n=!0,!1}),n}function e(n){return t.cors.expected&&n.withCredentials===undefined}function v(){var n;return(window.XMLHttpRequest||window.ActiveXObject)&&(n=qq.createXhrInstance(),n.withCredentials===undefined&&(n=new XDomainRequest)),n}function u(n,r){var u=i[n].xhr;return u||(u=r?r:t.cors.expected?v():qq.createXhrInstance(),i[n].xhr=u),u}function h(n){var f=qq.indexOf(r,n),u=t.maxConnections,e;delete i[n];r.splice(f,1);r.length>=u&&f=0?s.send(qq.obj2url(h,"")):h&&t.contentType&&t.contentType.toLowerCase().indexOf("application/json")>=0?s.send(JSON.stringify(h)):s.send(h),s}function p(n,r){var u=t.endpointStore.get(n),f=i[n].addToPath;return f!=undefined&&(u+="/"+f),o&&r?qq.obj2url(r,u):u}function w(n){return function(){u(n).readyState===4&&s(n)}}function b(n){var i=t.onProgress;i&&(u(n).upload.onprogress=function(t){t.lengthComputable&&i(n,t.loaded,t.total)})}function k(n){return function(){s(n)}}function d(n){return function(){s(n,!0)}}function g(n){var r=u(n),f=t.customHeaders,h=i[n].additionalHeaders||{},s=t.method,o={};e(r)||(t.acceptHeader&&r.setRequestHeader("Accept",t.acceptHeader),t.allowXRequestedWithAndCacheControl&&(t.cors.expected&&l()&&!a(f)||(r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.setRequestHeader("Cache-Control","no-cache"))),t.contentType&&(s==="POST"||s==="PUT")&&r.setRequestHeader("Content-Type",t.contentType),qq.extend(o,qq.isFunction(f)?f(n):f),qq.extend(o,h),qq.each(o,function(n,t){r.setRequestHeader(n,t)}))}function nt(n){return qq.indexOf(t.successfulResponseCodes[t.method],n)>=0}function tt(n,u,f,e,o,s){i[n]={addToPath:f,additionalParams:e,additionalHeaders:o,payload:s};var h=r.push(n);if(h<=t.maxConnections)return c(n,u)}var f,o,r=[],i={},t={acceptHeader:null,validMethods:["POST"],method:"POST",contentType:"application/x-www-form-urlencoded",maxConnections:3,customHeaders:{},endpointStore:{},paramsStore:{},mandatedParams:{},allowXRequestedWithAndCacheControl:!0,successfulResponseCodes:{DELETE:[200,202,204],POST:[200,204],GET:[200]},cors:{expected:!1,sendCredentials:!1},log:function(){},onSend:function(){},onComplete:function(){},onProgress:null};if(qq.extend(t,n),f=t.log,qq.indexOf(t.validMethods,t.method)<0)throw new Error("'"+t.method+"' is not a supported method for this type of request!");o=t.method==="GET"||t.method==="DELETE";qq.extend(this,{initTransport:function(n){var r,i,u,f,e;return{withPath:function(n){return r=n,this},withParams:function(n){return i=n,this},withHeaders:function(n){return u=n,this},withPayload:function(n){return f=n,this},withCacheBuster:function(){return e=!0,this},send:function(o){return e&&qq.indexOf(["GET","DELETE"],t.method)>=0&&(i.qqtimestamp=(new Date).getTime()),tt(n,o,r,i,u,f)}}},canceled:function(n){h(n)}})};qq.UploadHandler=function(n){"use strict";var i=n.proxy,t={},r=i.onCancel,u=i.getName;qq.extend(this,{add:function(n,i){t[n]=i;t[n].temp={}},cancel:function(n){var i=this,f=new qq.Promise,e=r(n,u(n),f);e.then(function(){i.isValid(n)&&(t[n].canceled=!0,i.expunge(n));f.success()})},expunge:function(n){delete t[n]},getThirdPartyFileId:function(n){return t[n].key},isValid:function(n){return t[n]!==undefined},reset:function(){t={}},_getFileState:function(n){return t[n]},_setThirdPartyFileId:function(n,i){t[n].key=i},_wasCanceled:function(n){return!!t[n].canceled}})};qq.UploadHandlerController=function(n,t){"use strict";var s=this,c=!1,h=!1,l,e,i,r={paramsStore:{},maxConnections:3,chunking:{enabled:!1,multiple:{enabled:!1}},log:function(){},onProgress:function(){},onComplete:function(){},onCancel:function(){},onUploadPrep:function(){},onUpload:function(){},onUploadChunk:function(){},onUploadChunkSuccess:function(){},onAutoRetry:function(){},onResume:function(){},onUuidChanged:function(){},getName:function(){},setSize:function(){},isQueued:function(){},getIdsInProxyGroup:function(){},getIdsInBatch:function(){}},o={done:function(n,t,u,f){var e=i._getChunkData(n,t);i._getFileState(n).attemptingResume=!1;delete i._getFileState(n).temp.chunkProgress[t];i._getFileState(n).loaded+=e.size;r.onUploadChunkSuccess(n,i._getChunkDataForCallback(e),u,f)},finalize:function(n){var t=r.getSize(n),u=r.getName(n);e("All chunks have been uploaded for "+n+" - finalizing....");i.finalizeChunks(n).then(function(o,s){e("Finalize successful for "+n);var h=f.normalizeResponse(o,!0);r.onProgress(n,u,t,t);i._maybeDeletePersistedChunkData(n);f.cleanup(n,h,s)},function(t,i){var s=f.normalizeResponse(t,!1);e("Problem finalizing chunks for file ID "+n+" - "+s.error,"error");s.reset&&o.reset(n);r.onAutoRetry(n,u,s,i)||f.cleanup(n,s,i)})},hasMoreParts:function(n){return!!i._getFileState(n).chunking.remaining.length},nextPart:function(n){var t=i._getFileState(n).chunking.remaining.shift();return t>=i._getTotalChunks(n)&&(t=null),t},reset:function(n){e("Server or callback has ordered chunking effort to be restarted on next attempt for item ID "+n,"error");i._maybeDeletePersistedChunkData(n);i.reevaluateChunking(n);i._getFileState(n).loaded=0},sendNext:function(n){var v=r.getSize(n),c=r.getName(n),t=o.nextPart(n),s=i._getChunkData(n,t),l=i._getFileState(n).attemptingResume,a=i._getFileState(n).chunking.inProgress||[];if(i._getFileState(n).loaded==null&&(i._getFileState(n).loaded=0),l&&r.onResume(n,c,s)===!1&&(o.reset(n),t=o.nextPart(n),s=i._getChunkData(n,t),l=!1),t==null&&a.length===0)o.finalize(n);else{e("Sending chunked upload request for item "+n+": bytes "+(s.start+1)+"-"+s.end+" of "+v);r.onUploadChunk(n,c,i._getChunkDataForCallback(s));a.push(t);i._getFileState(n).chunking.inProgress=a;h&&u.open(n,t);h&&u.available()&&i._getFileState(n).chunking.remaining.length&&o.sendNext(n);i.uploadChunk(n,t,l).then(function(r,u){e("Chunked upload request succeeded for "+n+", chunk "+t);i.clearCachedChunk(n,t);var s=i._getFileState(n).chunking.inProgress||[],c=f.normalizeResponse(r,!0),h=qq.indexOf(s,t);e(qq.format("Chunk {} for file {} uploaded successfully.",t,n));o.done(n,t,c,u);h>=0&&s.splice(h,1);i._maybePersistChunkedState(n);o.hasMoreParts(n)||s.length!==0?o.hasMoreParts(n)&&o.sendNext(n):o.finalize(n)},function(s,l){var a,v;e("Chunked upload request failed for "+n+", chunk "+t);i.clearCachedChunk(n,t);a=f.normalizeResponse(s,!1);a.reset?o.reset(n):(v=qq.indexOf(i._getFileState(n).chunking.inProgress,t),v>=0&&(i._getFileState(n).chunking.inProgress.splice(v,1),i._getFileState(n).chunking.remaining.unshift(t)));i._getFileState(n).temp.ignoreFailure||(h&&(i._getFileState(n).temp.ignoreFailure=!0,qq.each(i._getXhrs(n),function(n,t){t.abort()}),i.moveInProgressToRemaining(n),u.free(n,!0)),r.onAutoRetry(n,c,a,l)||f.cleanup(n,a,l))}).done(function(){i.clearXhr(n,t)})}}},u={_open:[],_openChunks:{},_waiting:[],available:function(){var i=r.maxConnections,n=0,t=0;return qq.each(u._openChunks,function(i,r){n++;t+=r.length}),i-(u._open.length-n+t)},free:function(n,t){var h=!t,o=qq.indexOf(u._waiting,n),s=qq.indexOf(u._open,n),r;delete u._openChunks[n];f.getProxyOrBlob(n)instanceof qq.BlobProxy&&(e("Generated blob upload has ended for "+n+", disposing generated blob."),delete i._getFileState(n).file);o>=0?u._waiting.splice(o,1):h&&s>=0&&(u._open.splice(s,1),r=u._waiting.shift(),r>=0&&(u._open.push(r),f.start(r)))},getWaitingOrConnected:function(){var n=[];return qq.each(n,u._open),qq.each(n,u._waiting)},isUsingConnection:function(n){return qq.indexOf(u._open,n)>=0},open:function(n,t){return(t==null&&u._waiting.push(n),u.available())?(t==null?(u._waiting.pop(),u._open.push(n)):function(){var i=u._openChunks[n]||[];i.push(t);u._openChunks[n]=i}(),!0):!1},reset:function(){u._waiting=[];u._open=[]}},a={send:function(n,t){i._getFileState(n).loaded=0;e("Sending simple upload request for "+n);i.uploadFile(n).then(function(i,u){e("Simple upload request succeeded for "+n);var o=f.normalizeResponse(i,!0),s=r.getSize(n);r.onProgress(n,t,s,s);f.maybeNewUuid(n,o);f.cleanup(n,o,u)},function(i,u){e("Simple upload request failed for "+n);var o=f.normalizeResponse(i,!1);r.onAutoRetry(n,t,o,u)||f.cleanup(n,o,u)})}},f={cancel:function(n){e("Cancelling "+n);r.paramsStore.remove(n);u.free(n)},cleanup:function(n,t,f){var e=r.getName(n);r.onComplete(n,e,t,f);i._getFileState(n)&&i._clearXhrs&&i._clearXhrs(n);u.free(n)},getProxyOrBlob:function(n){return i.getProxy&&i.getProxy(n)||i.getFile&&i.getFile(n)},initHandler:function(){var n=t?qq[t]:qq.traditional,u=qq.supportedFeatures.ajaxUploading?"Xhr":"Form";i=new n[u+"UploadHandler"](r,{getDataByUuid:r.getDataByUuid,getName:r.getName,getSize:r.getSize,getUuid:r.getUuid,log:e,onCancel:r.onCancel,onProgress:r.onProgress,onUuidChanged:r.onUuidChanged});i._removeExpiredChunkingRecords&&i._removeExpiredChunkingRecords()},isDeferredEligibleForUpload:function(n){return r.isQueued(n)},maybeDefer:function(n,t){if(t&&!i.getFile(n)&&t instanceof qq.BlobProxy){r.onUploadPrep(n);e("Attempting to generate a blob on-demand for "+n);t.create().then(function(t){e("Generated an on-demand blob for "+n);i.updateBlob(n,t);r.setSize(n,t.size);i.reevaluateChunking(n);f.maybeSendDeferredFiles(n)},function(t){var i={};t&&(i.error=t);e(qq.format("Failed to generate blob for ID {}. Error message: {}.",n,t),"error");r.onComplete(n,r.getName(n),qq.extend(i,l),null);f.maybeSendDeferredFiles(n);u.free(n)})}else return f.maybeSendDeferredFiles(n);return!1},maybeSendDeferredFiles:function(n){var t=r.getIdsInProxyGroup(n),u=!1;return t&&t.length?(e("Maybe ready to upload proxy group file "+n),qq.each(t,function(t,r){if(f.isDeferredEligibleForUpload(r)&&!!i.getFile(r))u=r===n,f.now(r);else if(f.isDeferredEligibleForUpload(r))return!1})):(u=!0,f.now(n)),u},maybeNewUuid:function(n,t){if(t.newUuid!==undefined)r.onUuidChanged(n,t.newUuid)},normalizeResponse:function(n,t){var i=n;return qq.isObject(n)||(i={},qq.isString(n)&&!t&&(i.error=n)),i.success=t,i},now:function(n){var t=r.getName(n);if(!s.isValid(n))throw new qq.Error(n+" is not a valid file ID to upload!");r.onUpload(n,t);c&&i._shouldChunkThisFile(n)?o.sendNext(n):a.send(n,t)},start:function(n){var t=f.getProxyOrBlob(n);return t?f.maybeDefer(n,t):(f.now(n),!0)}};qq.extend(this,{add:function(){i.add.apply(this,arguments)},upload:function(n){return u.open(n)?f.start(n):!1},retry:function(n){return h&&(i._getFileState(n).temp.ignoreFailure=!1),u.isUsingConnection(n)?f.start(n):s.upload(n)},cancel:function(n){var t=i.cancel(n);qq.isGenericPromise(t)?t.then(function(){f.cancel(n)}):t!==!1&&f.cancel(n)},cancelAll:function(){var n=u.getWaitingOrConnected();qq.each(n,function(n,t){s.cancel(t)});u.reset()},getFile:function(n){return i.getProxy&&i.getProxy(n)?i.getProxy(n).referenceBlob:i.getFile&&i.getFile(n)},isProxied:function(n){return!!(i.getProxy&&i.getProxy(n))},getInput:function(n){if(i.getInput)return i.getInput(n)},reset:function(){e("Resetting upload handler");s.cancelAll();u.reset();i.reset()},expunge:function(n){if(s.isValid(n))return i.expunge(n)},isValid:function(n){return i.isValid(n)},getResumableFilesData:function(){return i.getResumableFilesData?i.getResumableFilesData():[]},getThirdPartyFileId:function(n){if(s.isValid(n))return i.getThirdPartyFileId(n)},pause:function(n){return s.isResumable(n)&&i.pause&&s.isValid(n)&&i.pause(n)?(u.free(n),i.moveInProgressToRemaining(n),!0):!1},isResumable:function(n){return!!i.isResumable&&i.isResumable(n)}});qq.extend(r,n);e=r.log;c=r.chunking.enabled&&qq.supportedFeatures.chunking;h=c&&r.chunking.concurrent.enabled;l=function(){var n={};return n[r.preventRetryParam]=!0,n}();f.initHandler()};qq.FormUploadHandler=function(n){"use strict";function y(n){delete r[n];h&&(clearTimeout(u[n]),delete u[n],e.stopReceivingMessages(n));var t=document.getElementById(i._getIframeName(n));t&&(t.setAttribute("src","javascript:false;"),qq(t).remove())}function c(n){return n.split("_")[0]}function p(n){var t=qq.toElement("");return t.setAttribute("id",n),t.style.display="none",document.body.appendChild(t),t}function w(n,o){var s=n.id,h=c(s),l=v(h);f[l]=o;r[h]=qq(n).attach("load",function(){i.getInput(h)&&(t("Received iframe load event for CORS upload request (iframe name "+s+")"),u[s]=setTimeout(function(){var n="No valid message received from loaded iframe for iframe name "+s;t(n,"error");o({error:n})},1e3))});e.receiveMessage(s,function(n){t("Received the following window message: '"+n+"'");var l=c(s),o=i._parseJsonResponse(l,n),r=o.uuid,h;r&&f[r]?(t("Handling response for iframe name "+s),clearTimeout(u[s]),delete u[s],i._detachLoadEvent(s),h=f[r],delete f[r],e.stopReceivingMessages(s),h(o)):r||t("'"+n+"' does not contain a UUID - ignoring.")})}var o=n.options,i=this,s=n.proxy,l=qq.getUniqueId(),f={},r={},u={},h=o.isCors,a=o.inputName,v=s.getUuid,t=s.log,e=new qq.WindowReceiveMessage({log:t});qq.extend(this,new qq.UploadHandler(n));qq.override(this,function(n){return{add:function(t,i){n.add(t,{input:i});i.setAttribute("name",a);i.parentNode&&qq(i).remove()},expunge:function(t){y(t);n.expunge(t)},isValid:function(t){return n.isValid(t)&&i._getFileState(t).input!==undefined}}});qq.extend(this,{_attachLoadEvent:function(n,i){var u;h?w(n,i):r[n.id]=qq(n).attach("load",function(){if(t("Received response for "+n.id),n.parentNode){try{if(n.contentDocument&&n.contentDocument.body&&n.contentDocument.body.innerHTML=="false")return}catch(r){t("Error when attempting to access iframe during handling of upload response ("+r.message+")","error");u={success:!1}}i(u)}})},_createIframe:function(n){var t=i._getIframeName(n);return p(t)},_detachLoadEvent:function(n){r[n]!==undefined&&(r[n](),delete r[n])},_getIframeName:function(n){return n+"_"+l},getInput:function(n){return i._getFileState(n).input},_initFormForUpload:function(n){var f=n.method,i=n.endpoint,r=n.params,e=n.paramsInBody,o=n.targetName,t=qq.toElement("<\/form>"),u=i;return e?qq.obj2Inputs(r,t):u=qq.obj2url(r,i),t.setAttribute("action",u),t.setAttribute("target",o),t.style.display="none",document.body.appendChild(t),t}})};qq.XhrUploadHandler=function(n){"use strict";function l(n){qq.each(t._getXhrs(n),function(i,r){var u=t._getAjaxRequester(n,i);r.onreadystatechange=null;r.upload.onprogress=null;r.abort();u&&u.canceled&&u.canceled(n)})}var t=this,h=n.options.namespace,i=n.proxy,r=n.options.chunking,c=n.options.resume,a=r&&n.options.chunking.enabled&&qq.supportedFeatures.chunking,f=c&&n.options.resume.enabled&&a&&qq.supportedFeatures.resume,e=i.getName,u=i.getSize,v=i.getUuid,y=i.getEndpoint,p=i.getDataByUuid,w=i.onUuidChanged,o=i.onProgress,s=i.log;qq.extend(this,new qq.UploadHandler(n));qq.override(this,function(n){return{add:function(i,r){if(qq.isFile(r)||qq.isBlob(r))n.add(i,{file:r});else if(r instanceof qq.BlobProxy)n.add(i,{proxy:r});else throw new Error("Passed obj is not a File, Blob, or proxy");t._initTempState(i);f&&t._maybePrepareForResume(i)},expunge:function(i){l(i);t._maybeDeletePersistedChunkData(i);t._clearXhrs(i);n.expunge(i)}}});qq.extend(this,{clearCachedChunk:function(n,i){delete t._getFileState(n).temp.cachedChunks[i]},clearXhr:function(n,i){var r=t._getFileState(n).temp;r.xhrs&&delete r.xhrs[i];r.ajaxRequesters&&delete r.ajaxRequesters[i]},finalizeChunks:function(n,i){var u=t._getTotalChunks(n)-1,r=t._getXhr(n,u);return i?(new qq.Promise).success(i(r),r):(new qq.Promise).success({},r)},getFile:function(n){return t.isValid(n)&&t._getFileState(n).file},getProxy:function(n){return t.isValid(n)&&t._getFileState(n).proxy},getResumableFilesData:function(){var n=[];return t._iterateResumeRecords(function(i,r){t.moveInProgressToRemaining(null,r.chunking.inProgress,r.chunking.remaining);var u={name:r.name,remaining:r.chunking.remaining,size:r.size,uuid:r.uuid};r.key&&(u.key=r.key);n.push(u)}),n},isResumable:function(n){return!!r&&t.isValid(n)&&!t._getFileState(n).notResumable},moveInProgressToRemaining:function(n,i,r){var u=i||t._getFileState(n).chunking.inProgress,f=r||t._getFileState(n).chunking.remaining;u&&(u.reverse(),qq.each(u,function(n,t){f.unshift(t)}),u.length=0)},pause:function(n){if(t.isValid(n))return s(qq.format("Aborting XHR upload for {} '{}' due to pause instruction.",n,e(n))),t._getFileState(n).paused=!0,l(n),!0},reevaluateChunking:function(n){var i,u,f;if(r&&t.isValid(n))if(i=t._getFileState(n),delete i.chunking,i.chunking={},u=t._getTotalChunks(n),u>1){for(i.chunking.enabled=!0,i.chunking.parts=u,i.chunking.remaining=[],f=0;f=s?s:f+e,a=t._getTotalChunks(n),h=this._getFileState(n).temp.cachedChunks,c=h[i]||qq.sliceBlob(l,f,o);return h[i]=c,{part:i,start:f,end:o,count:a,blob:c,size:o-f}},_getChunkDataForCallback:function(n){return{partIndex:n.part,startByte:n.start+1,endByte:n.end,totalParts:n.count}},_getLocalStorageId:function(n){var t=e(n),i=u(n),f=r.partSize,o=y(n);return qq.format("qq{}resume{}-{}-{}-{}-{}",h,"5.0",t,i,f,o)},_getMimeType:function(n){return t.getFile(n).type},_getPersistableData:function(n){return t._getFileState(n).chunking},_getTotalChunks:function(n){if(r){var t=u(n),i=r.partSize;return Math.ceil(t/i)}},_getXhr:function(n,i){var r=i==null?-1:i;return t._getFileState(n).temp.xhrs[r]},_getXhrs:function(n){return t._getFileState(n).temp.xhrs},_iterateResumeRecords:function(n){f&&qq.each(localStorage,function(t,i){if(t.indexOf(qq.format("qq{}resume-",h))===0){var r=JSON.parse(i);n(t,r)}})},_initTempState:function(n){t._getFileState(n).temp={ajaxRequesters:{},chunkProgress:{},xhrs:{},cachedChunks:{}}},_markNotResumable:function(n){t._getFileState(n).notResumable=!0},_maybeDeletePersistedChunkData:function(n){var i;return f&&t.isResumable(n)&&(i=t._getLocalStorageId(n),i&&localStorage.getItem(i))?(localStorage.removeItem(i),!0):!1},_maybePrepareForResume:function(n){var r=t._getFileState(n),u,i;f&&r.key===undefined&&(u=t._getLocalStorageId(n),i=localStorage.getItem(u),i&&(i=JSON.parse(i),p(i.uuid)?t._markNotResumable(n):(s(qq.format("Identified file with ID {} and name of {} as resumable.",n,e(n))),w(n,i.uuid),r.key=i.key,r.chunking=i.chunking,r.loaded=i.loaded,r.attemptingResume=!0,t.moveInProgressToRemaining(n))))},_maybePersistChunkedState:function(n){var i=t._getFileState(n),r,o;f&&t.isResumable(n)&&(r=t._getLocalStorageId(n),o={name:e(n),size:u(n),uuid:v(n),key:i.key,chunking:i.chunking,loaded:i.loaded,lastUpdated:Date.now()},localStorage.setItem(r,JSON.stringify(o)))},_registerProgressHandler:function(n,i,r){var f=t._getXhr(n,i),e={simple:function(t,i){var r=u(n);t===i?o(n,name,r,r):o(n,name,t>=r?r-1:t,r)},chunked:function(f,e){var s=t._getFileState(n).temp.chunkProgress,c=t._getFileState(n).loaded,l=f,a=e,v=u(n),y=l-(a-r),h=c;s[i]=y;qq.each(s,function(n,t){h+=t});o(n,name,h,v)}};f.upload.onprogress=function(n){if(n.lengthComputable){var t=r==null?"simple":"chunked";e[t](n.loaded,n.total)}}},_registerXhr:function(n,i,r,u){var e=i==null?-1:i,f=t._getFileState(n).temp;return f.xhrs=f.xhrs||{},f.ajaxRequesters=f.ajaxRequesters||{},f.xhrs[e]=r,u&&(f.ajaxRequesters[e]=u),r},_removeExpiredChunkingRecords:function(){var n=c.recordsExpireIn;t._iterateResumeRecords(function(t,i){var r=new Date(i.lastUpdated);r.setDate(r.getDate()+n);r.getTime()<=Date.now()&&(s("Removing expired resume record with key "+t),localStorage.removeItem(t))})},_shouldChunkThisFile:function(n){var i=t._getFileState(n);return i.chunking||t.reevaluateChunking(n),i.chunking.enabled}})};qq.WindowReceiveMessage=function(n){"use strict";var i={log:function(){}},t={};qq.extend(i,n);qq.extend(this,{receiveMessage:function(n,i){var r=function(n){i(n.data)};window.postMessage?t[n]=qq(window).attach("message",r):log("iframe message passing not supported in this browser!","error")},stopReceivingMessages:function(n){if(window.postMessage){var i=t[n];i&&i()}}})},function(){"use strict";qq.uiPublicApi={clearStoredFiles:function(){this._parent.prototype.clearStoredFiles.apply(this,arguments);this._templating.clearFiles()},addExtraDropzone:function(n){this._dnd&&this._dnd.setupExtraDropzone(n)},removeExtraDropzone:function(n){if(this._dnd)return this._dnd.removeDropzone(n)},getItemByFileId:function(n){return this._templating.getFileContainer(n)},reset:function(){this._parent.prototype.reset.apply(this,arguments);this._templating.reset();!this._options.button&&this._templating.getButton()&&(this._defaultButtonId=this._createUploadButton({element:this._templating.getButton()}).getButtonId());this._dnd&&(this._dnd.dispose(),this._dnd=this._setupDragAndDrop());this._totalFilesInBatch=0;this._filesInBatchAddedToUi=0;this._setupClickAndEditEventHandlers()},setName:function(n,t){var i=this._options.formatFileName(t);this._parent.prototype.setName.apply(this,arguments);this._templating.updateFilename(n,i)},pauseUpload:function(n){var t=this._parent.prototype.pauseUpload.apply(this,arguments);return t&&this._templating.uploadPaused(n),t},continueUpload:function(n){var t=this._parent.prototype.continueUpload.apply(this,arguments);return t&&this._templating.uploadContinued(n),t},getId:function(n){return this._templating.getFileId(n)},getDropTarget:function(n){var t=this.getFile(n);return t.qqDropTarget}};qq.uiPrivateApi={_getButton:function(n){var t=this._parent.prototype._getButton.apply(this,arguments);return t||n===this._defaultButtonId&&(t=this._templating.getButton()),t},_removeFileItem:function(n){this._templating.removeFile(n)},_setupClickAndEditEventHandlers:function(){this._fileButtonsClickHandler=qq.FileButtonsClickHandler&&this._bindFileButtonsClickEvent();this._focusinEventSupported=!qq.firefox();this._isEditFilenameEnabled()&&(this._filenameClickHandler=this._bindFilenameClickEvent(),this._filenameInputFocusInHandler=this._bindFilenameInputFocusInEvent(),this._filenameInputFocusHandler=this._bindFilenameInputFocusEvent())},_setupDragAndDrop:function(){var n=this,i=this._options.dragAndDrop.extraDropzones,t=this._templating,r=t.getDropZone();return r&&i.push(r),new qq.DragAndDrop({dropZoneElements:i,allowMultipleItems:this._options.multiple,classes:{dropActive:this._options.classes.dropActive},callbacks:{processingDroppedFiles:function(){t.showDropProcessing()},processingDroppedFilesComplete:function(i,r){t.hideDropProcessing();qq.each(i,function(n,t){t.qqDropTarget=r});i.length&&n.addFiles(i,null,null)},dropError:function(t,i){n._itemError(t,i)},dropLog:function(t,i){n.log(t,i)}}})},_bindFileButtonsClickEvent:function(){var n=this;return new qq.FileButtonsClickHandler({templating:this._templating,log:function(t,i){n.log(t,i)},onDeleteFile:function(t){n.deleteFile(t)},onCancel:function(t){n.cancel(t)},onRetry:function(t){qq(n._templating.getFileContainer(t)).removeClass(n._classes.retryable);n._templating.hideRetry(t);n.retry(t)},onPause:function(t){n.pauseUpload(t)},onContinue:function(t){n.continueUpload(t)},onGetName:function(t){return n.getName(t)}})},_isEditFilenameEnabled:function(){return this._templating.isEditFilenamePossible()&&!this._options.autoUpload&&qq.FilenameClickHandler&&qq.FilenameInputFocusHandler&&qq.FilenameInputFocusHandler},_filenameEditHandler:function(){var t=this,n=this._templating;return{templating:n,log:function(n,i){t.log(n,i)},onGetUploadStatus:function(n){return t.getUploads({id:n}).status},onGetName:function(n){return t.getName(n)},onSetName:function(n,i){t.setName(n,i)},onEditingStatusChange:function(t,i){var r=qq(n.getEditInput(t)),u=qq(n.getFileContainer(t));i?(r.addClass("qq-editing"),n.hideFilename(t),n.hideEditIcon(t)):(r.removeClass("qq-editing"),n.showFilename(t),n.showEditIcon(t));u.addClass("qq-temp").removeClass("qq-temp")}}},_onUploadStatusChange:function(n,t,i){this._parent.prototype._onUploadStatusChange.apply(this,arguments);this._isEditFilenameEnabled()&&this._templating.getFileContainer(n)&&i!==qq.status.SUBMITTED&&(this._templating.markFilenameEditable(n),this._templating.hideEditIcon(n))},_bindFilenameInputFocusInEvent:function(){var n=qq.extend({},this._filenameEditHandler());return new qq.FilenameInputFocusInHandler(n)},_bindFilenameInputFocusEvent:function(){var n=qq.extend({},this._filenameEditHandler());return new qq.FilenameInputFocusHandler(n)},_bindFilenameClickEvent:function(){var n=qq.extend({},this._filenameEditHandler());return new qq.FilenameClickHandler(n)},_storeForLater:function(n){this._parent.prototype._storeForLater.apply(this,arguments);this._templating.hideSpinner(n)},_onAllComplete:function(){this._parent.prototype._onAllComplete.apply(this,arguments);this._templating.resetTotalProgress()},_onSubmit:function(n,t){var i=this.getFile(n);i&&i.qqPath&&this._options.dragAndDrop.reportDirectoryPaths&&this._paramsStore.addReadOnly(n,{qqpath:i.qqPath});this._parent.prototype._onSubmit.apply(this,arguments);this._addToList(n,t)},_onSubmitted:function(n){this._isEditFilenameEnabled()&&(this._templating.markFilenameEditable(n),this._templating.showEditIcon(n),this._focusinEventSupported||this._filenameInputFocusHandler.addHandler(this._templating.getEditInput(n)))},_onProgress:function(n,t,i,r){this._parent.prototype._onProgress.apply(this,arguments);this._templating.updateProgress(n,i,r);Math.round(i/r*100)===100?(this._templating.hideCancel(n),this._templating.hidePause(n),this._templating.hideProgress(n),this._templating.setStatusText(n,this._options.text.waitingForResponse),this._displayFileSize(n)):this._displayFileSize(n,i,r)},_onTotalProgress:function(n,t){this._parent.prototype._onTotalProgress.apply(this,arguments);this._templating.updateTotalProgress(n,t)},_onComplete:function(n,t,i){function o(t){f&&(r.setStatusText(n),qq(f).removeClass(u._classes.retrying),r.hideProgress(n),(!u._options.disableCancelForFormUploads||qq.supportedFeatures.ajaxUploading)&&r.hideCancel(n),r.hideSpinner(n),t.success?u._markFileAsSuccessful(n):(qq(f).addClass(u._classes.fail),r.isRetryPossible()&&!u._preventRetries[n]&&(qq(f).addClass(u._classes.retryable),r.showRetry(n)),u._controlFailureTextDisplay(n,t)))}var e=this._parent.prototype._onComplete.apply(this,arguments),r=this._templating,f=r.getFileContainer(n),u=this;return e instanceof qq.Promise?e.done(function(n){o(n)}):o(i),e},_markFileAsSuccessful:function(n){var t=this._templating;this._isDeletePossible()&&t.showDeleteButton(n);qq(t.getFileContainer(n)).addClass(this._classes.success);this._maybeUpdateThumbnail(n)},_onUploadPrep:function(n){this._parent.prototype._onUploadPrep.apply(this,arguments);this._templating.showSpinner(n)},_onUpload:function(n){var t=this._parent.prototype._onUpload.apply(this,arguments);return this._templating.showSpinner(n),t},_onUploadChunk:function(n,t){this._parent.prototype._onUploadChunk.apply(this,arguments);t.partIndex>0&&this._handler.isResumable(n)&&this._templating.allowPause(n)},_onCancel:function(n){this._parent.prototype._onCancel.apply(this,arguments);this._removeFileItem(n);this._getNotFinished()===0&&this._templating.resetTotalProgress()},_onBeforeAutoRetry:function(n){var i,r,t;this._parent.prototype._onBeforeAutoRetry.apply(this,arguments);this._showCancelLink(n);this._options.retry.showAutoRetryNote&&(i=this._autoRetries[n],r=this._options.retry.maxAutoAttempts,t=this._options.retry.autoRetryNote.replace(/\{retryNum\}/g,i),t=t.replace(/\{maxAuto\}/g,r),this._templating.setStatusText(n,t),qq(this._templating.getFileContainer(n)).addClass(this._classes.retrying))},_onBeforeManualRetry:function(n){return this._parent.prototype._onBeforeManualRetry.apply(this,arguments)?(this._templating.resetProgress(n),qq(this._templating.getFileContainer(n)).removeClass(this._classes.fail),this._templating.setStatusText(n),this._templating.showSpinner(n),this._showCancelLink(n),!0):(qq(this._templating.getFileContainer(n)).addClass(this._classes.retryable),this._templating.showRetry(n),!1)},_onSubmitDelete:function(n){var t=qq.bind(this._onSubmitDeleteSuccess,this);this._parent.prototype._onSubmitDelete.call(this,n,t)},_onSubmitDeleteSuccess:function(){this._options.deleteFile.forceConfirm?this._showDeleteConfirm.apply(this,arguments):this._sendDeleteRequest.apply(this,arguments)},_onDeleteComplete:function(n,t,i){this._parent.prototype._onDeleteComplete.apply(this,arguments);this._templating.hideSpinner(n);i?(this._templating.setStatusText(n,this._options.deleteFile.deletingFailedText),this._templating.showDeleteButton(n)):this._removeFileItem(n)},_sendDeleteRequest:function(n){this._templating.hideDeleteButton(n);this._templating.showSpinner(n);this._templating.setStatusText(n,this._options.deleteFile.deletingStatusText);this._deleteHandler.sendDelete.apply(this,arguments)},_showDeleteConfirm:function(n){var u=this.getName(n),f=this._options.deleteFile.confirmMessage.replace(/\{filename\}/g,u),uuid=this.getUuid(n),r=arguments,t=this,i;i=this._options.showConfirm(f);qq.isGenericPromise(i)?i.then(function(){t._sendDeleteRequest.apply(t,r)}):i!==!1&&t._sendDeleteRequest.apply(t,r)},_addToList:function(n,t,i){var r,u=0,f=this._handler.isProxied(n)&&this._options.scaling.hideScaled;f||(this._options.display.prependFiles&&(this._totalFilesInBatch>1&&this._filesInBatchAddedToUi>0&&(u=this._filesInBatchAddedToUi-1),r={index:u}),i||(this._options.disableCancelForFormUploads&&!qq.supportedFeatures.ajaxUploading&&this._templating.disableCancel(),this._options.multiple||(this._handler.cancelAll(),this._clearList())),this._templating.addFile(n,this._options.formatFileName(t),r),i?this._thumbnailUrls[n]&&this._templating.updateThumbnail(n,this._thumbnailUrls[n],!0):this._templating.generatePreview(n,this.getFile(n)),this._filesInBatchAddedToUi+=1,(i||this._options.display.fileSizeOnSubmit&&qq.supportedFeatures.ajaxUploading)&&this._displayFileSize(n))},_clearList:function(){this._templating.clearFiles();this.clearStoredFiles()},_displayFileSize:function(n,t,i){var r=this.getSize(n),u=this._formatSize(r);r>=0&&(t!==undefined&&i!==undefined&&(u=this._formatProgress(t,i)),this._templating.updateSize(n,u))},_formatProgress:function(n,t){function r(n,t){i=i.replace(n,t)}var i=this._options.text.formatProgress;return r("{percent}",Math.round(n/t*100)),r("{total_size}",this._formatSize(t)),i},_controlFailureTextDisplay:function(n,t){var r,u,f,i,e;r=this._options.failedUploadTextDisplay.mode;u=this._options.failedUploadTextDisplay.maxChars;f=this._options.failedUploadTextDisplay.responseProperty;r==="custom"?(i=t[f],i?i.length>u&&(e=i.substring(0,u)+"..."):i=this._options.text.failUpload,this._templating.setStatusText(n,e||i),this._options.failedUploadTextDisplay.enableTooltip&&this._showTooltip(n,i)):r==="default"?this._templating.setStatusText(n,this._options.text.failUpload):r!=="none"&&this.log("failedUploadTextDisplay.mode value of '"+r+"' is not valid","warn")},_showTooltip:function(n,t){this._templating.getFileContainer(n).title=t},_showCancelLink:function(n){(!this._options.disableCancelForFormUploads||qq.supportedFeatures.ajaxUploading)&&this._templating.showCancel(n)},_itemError:function(){var n=this._parent.prototype._itemError.apply(this,arguments);this._options.showMessage(n)},_batchError:function(n){this._parent.prototype._batchError.apply(this,arguments);this._options.showMessage(n)},_setupPastePrompt:function(){var n=this;this._options.callbacks.onPasteReceived=function(){var t=n._options.paste.namePromptMessage,i=n._options.paste.defaultName;return n._options.showPrompt(t,i)}},_fileOrBlobRejected:function(){this._totalFilesInBatch-=1;this._parent.prototype._fileOrBlobRejected.apply(this,arguments)},_prepareItemsForUpload:function(n){this._totalFilesInBatch=n.length;this._filesInBatchAddedToUi=0;this._parent.prototype._prepareItemsForUpload.apply(this,arguments)},_maybeUpdateThumbnail:function(n){var t=this._thumbnailUrls[n];this._templating.updateThumbnail(n,t)},_addCannedFile:function(){var n=this._parent.prototype._addCannedFile.apply(this,arguments);return this._addToList(n,this.getName(n),!0),this._templating.hideSpinner(n),this._templating.hideCancel(n),this._markFileAsSuccessful(n),n},_setSize:function(n,t){this._parent.prototype._setSize.apply(this,arguments);this._templating.updateSize(n,this._formatSize(t))}}}();qq.FineUploader=function(n,t){"use strict";this._parent=t?qq[t].FineUploaderBasic:qq.FineUploaderBasic;this._parent.apply(this,arguments);qq.extend(this._options,{element:null,button:null,listElement:null,dragAndDrop:{extraDropzones:[],reportDirectoryPaths:!1},text:{formatProgress:"{percent}% of {total_size}",failUpload:"Upload failed",waitingForResponse:"Processing...",paused:"Paused"},template:"qq-template",classes:{retrying:"qq-upload-retrying",retryable:"qq-upload-retryable",success:"qq-upload-success",fail:"qq-upload-fail",editable:"qq-editable",hide:"qq-hide",dropActive:"qq-upload-drop-area-active"},failedUploadTextDisplay:{mode:"default",maxChars:50,responseProperty:"error",enableTooltip:!0},messages:{tooManyFilesError:"You may only drop one file",unsupportedBrowser:"Unrecoverable error - this browser does not permit file uploading of any kind."},retry:{showAutoRetryNote:!0,autoRetryNote:"Retrying {retryNum}/{maxAuto}..."},deleteFile:{forceConfirm:!1,confirmMessage:"Are you sure you want to delete {filename}?",deletingStatusText:"Deleting...",deletingFailedText:"Delete failed"},display:{fileSizeOnSubmit:!1,prependFiles:!1},paste:{promptForName:!1,namePromptMessage:"Please name this image"},thumbnails:{placeholders:{waitUntilResponse:!1,notAvailablePath:null,waitingPath:null}},scaling:{hideScaled:!1},showMessage:function(n){setTimeout(function(){window.alert(n)},0)},showConfirm:function(n){return window.confirm(n)},showPrompt:function(n,t){return window.prompt(n,t)}},!0);qq.extend(this._options,n,!0);this._templating=new qq.Templating({log:qq.bind(this.log,this),templateIdOrEl:this._options.template,containerEl:this._options.element,fileContainerEl:this._options.listElement,button:this._options.button,imageGenerator:this._imageGenerator,classes:{hide:this._options.classes.hide,editable:this._options.classes.editable},placeholders:{waitUntilUpdate:this._options.thumbnails.placeholders.waitUntilResponse,thumbnailNotAvailable:this._options.thumbnails.placeholders.notAvailablePath,waitingForThumbnail:this._options.thumbnails.placeholders.waitingPath},text:this._options.text});qq.supportedFeatures.uploading&&(!this._options.cors.expected||qq.supportedFeatures.uploadCors)?(this._wrapCallbacks(),this._templating.render(),this._classes=this._options.classes,!this._options.button&&this._templating.getButton()&&(this._defaultButtonId=this._createUploadButton({element:this._templating.getButton()}).getButtonId()),this._setupClickAndEditEventHandlers(),qq.DragAndDrop&&qq.supportedFeatures.fileDrop&&(this._dnd=this._setupDragAndDrop()),this._options.paste.targetElement&&this._options.paste.promptForName&&(qq.PasteSupport?this._setupPastePrompt():this.log("Paste support module not found.","error")),this._totalFilesInBatch=0,this._filesInBatchAddedToUi=0):this._templating.renderFailure(this._options.messages.unsupportedBrowser)};qq.extend(qq.FineUploader.prototype,qq.basePublicApi);qq.extend(qq.FineUploader.prototype,qq.basePrivateApi);qq.extend(qq.FineUploader.prototype,qq.uiPublicApi);qq.extend(qq.FineUploader.prototype,qq.uiPrivateApi);qq.Templating=function(n){"use strict";function gt(){var s,f,e,n,v,c,u,r,l;if(o("Parsing template"),i.templateIdOrEl==null)throw new Error("You MUST specify either a template element or ID!");if(qq.isString(i.templateIdOrEl)){if(s=document.getElementById(i.templateIdOrEl),s===null)throw new Error(qq.format("Cannot find template script at ID '{}'!",i.templateIdOrEl));f=s.innerHTML}else{if(i.templateIdOrEl.innerHTML===undefined)throw new Error("You have specified an invalid value for the template option! It must be an ID or an Element.");f=i.templateIdOrEl.innerHTML}if(f=qq.trimStr(f),n=document.createElement("div"),n.appendChild(qq.toElement(f)),i.button&&(c=qq(n).getByClass(t.button)[0],c&&qq(c).remove()),qq.DragAndDrop&&qq.supportedFeatures.fileDrop||(l=qq(n).getByClass(t.dropProcessing)[0],l&&qq(l).remove()),u=qq(n).getByClass(t.drop)[0],u&&!qq.DragAndDrop&&(o("DnD module unavailable.","info"),qq(u).remove()),u&&!qq.supportedFeatures.fileDrop&&qq(u).hasAttribute(dt)&&qq(u).css({display:"none"}),r=qq(n).getByClass(t.thumbnail)[0],a?r&&(h=parseInt(r.getAttribute(bt)),h=h>0?h:null,rt=qq(r).hasAttribute(kt)):r&&qq(r).remove(),a=a&&r,ct=qq(n).getByClass(t.editFilenameInput).length>0,lt=qq(n).getByClass(t.retry).length>0,e=qq(n).getByClass(t.list)[0],e==null)throw new Error("Could not find the file list container in the template!");return v=e.innerHTML,e.innerHTML="",o("Template parsing complete"),{template:qq.trimStr(n.innerHTML),fileTemplate:qq.trimStr(v)}}function f(n){return qq(l).getByClass(ht+n)[0]}function r(n,t){return n&&qq(n).getByClass(t)[0]}function ni(n,t){var i=l,r=i.firstChild;t>0&&(r=qq(i).children()[t].nextSibling);i.insertBefore(n,r)}function at(n){return r(f(n),t.cancel)}function w(n){return r(f(n),t.pause)}function ut(n){return r(f(n),t.continueButton)}function b(n){return n==null?r(s,t.totalProgressBarContainer)||r(s,t.totalProgressBar):r(f(n),t.progressBarContainer)||r(f(n),t.progressBar)}function k(n){return r(f(n),t.spinner)}function vt(n){return r(f(n),t.editNameIcon)}function yt(n){return r(f(n),t.size)}function ft(n){return r(f(n),t.deleteButton)}function et(n){return r(f(n),t.retry)}function d(n){return r(f(n),t.file)}function ot(){return r(s,t.dropProcessing)}function v(n){return a&&r(f(n),t.thumbnail)}function u(n){n&&qq(n).addClass(i.classes.hide)}function e(n){n&&qq(n).removeClass(i.classes.hide)}function pt(n,i){var r=b(n),u=n==null?t.totalProgressBar:t.progressBar;r&&!qq(r).hasClass(u)&&(r=qq(r).getByClass(u)[0]);r&&qq(r).css({width:i+"%"})}function ti(){var n=i.placeholders.thumbnailNotAvailable,t=i.placeholders.waitingForThumbnail,r={maxSize:h,scale:rt};a&&(n?i.imageGenerator.generate(n,new Image,r).then(function(n){y.success(n)},function(){y.failure();o("Problem loading 'not available' placeholder image at "+n,"error")}):y.failure(),t?i.imageGenerator.generate(t,new Image,r).then(function(n){p.success(n)},function(){p.failure();o("Problem loading 'waiting for thumbnail' placeholder image at "+t,"error")}):p.failure())}function st(n){var t=new qq.Promise;return p.then(function(i){wt(i,n);n.src?t.success():(n.src=i.src,n.onload=function(){e(n);t.success()})},function(){u(n);t.success()}),t}function g(n,t){var r=c[n]||(new qq.Promise).failure(),i=new qq.Promise;return y.then(function(n){r.then(function(){i.success()},function(){wt(n,t);t.onload=function(){i.success()};t.src=n.src;e(t)})}),i}function wt(n,t){var i=n.style.maxWidth,r=n.style.maxHeight;r&&i&&!t.style.maxWidth&&!t.style.maxHeight&&qq(t).css({maxWidth:i,maxHeight:r})}function ii(n,t){var r=v(n),u=v(t);o(qq.format("ID {} is the same file as ID {}. Will use generated thumbnail from ID {} instead.",n,t,t));c[t].then(function(){c[n].success();o(qq.format("Now using previously generated thumbnail created for ID {} on ID {}.",t,n));r.src=u.src;e(r)},function(){c[n].failure();i.placeholders.waitUntilUpdate||g(n,r)})}function ri(n,t,r){var u=v(n);return o("Generating new thumbnail for "+n),t.qqThumbnailId=n,i.imageGenerator.generate(t,u,r).then(function(){e(u);c[n].success()},function(){c[n].failure();i.placeholders.waitUntilUpdate||g(n,u)})}var nt="qq-file-id",ht="qq-file-id-",bt="qq-max-size",kt="qq-server-scale",dt="qq-hide-dropzone",tt=!1,h=-1,i={log:null,templateIdOrEl:"qq-template",containerEl:null,fileContainerEl:null,button:null,imageGenerator:null,classes:{hide:"qq-hide",editable:"qq-editable"},placeholders:{waitUntilUpdate:!1,thumbnailNotAvailable:null,waitingForThumbnail:null},text:{paused:"Paused"}},t={button:"qq-upload-button-selector",drop:"qq-upload-drop-area-selector",list:"qq-upload-list-selector",progressBarContainer:"qq-progress-bar-container-selector",progressBar:"qq-progress-bar-selector",totalProgressBarContainer:"qq-total-progress-bar-container-selector",totalProgressBar:"qq-total-progress-bar-selector",file:"qq-upload-file-selector",spinner:"qq-upload-spinner-selector",size:"qq-upload-size-selector",cancel:"qq-upload-cancel-selector",pause:"qq-upload-pause-selector",continueButton:"qq-upload-continue-selector",deleteButton:"qq-upload-delete-selector",retry:"qq-upload-retry-selector",statusText:"qq-upload-status-text-selector",editFilenameInput:"qq-edit-filename-selector",editNameIcon:"qq-edit-filename-icon-selector",dropProcessing:"qq-drop-processing-selector",dropProcessingSpinner:"qq-drop-processing-spinner-selector",thumbnail:"qq-thumbnail-selector"},c={},y=new qq.Promise,p=new qq.Promise,o,ct,lt,it,s,l,a,rt;qq.extend(i,n);o=i.log;s=i.containerEl;a=i.imageGenerator!==undefined;it=gt();ti();qq.extend(this,{render:function(){o("Rendering template in DOM.");s.innerHTML=it.template;u(ot());this.hideTotalProgress();l=i.fileContainerEl||r(s,t.list);o("Template rendering complete")},renderFailure:function(n){var t=qq.toElement(n);s.innerHTML="";s.appendChild(t)},reset:function(){this.render()},clearFiles:function(){l.innerHTML=""},disableCancel:function(){tt=!0},addFile:function(n,i,f){var e=qq.toElement(it.fileTemplate),o=r(e,t.file);qq(e).addClass(ht+n);o&&qq(o).setText(i);e.setAttribute(nt,n);f?ni(e,f.index):l.appendChild(e);u(b(n));u(yt(n));u(ft(n));u(et(n));u(w(n));u(ut(n));tt&&this.hideCancel(n)},removeFile:function(n){qq(f(n)).remove()},getFileId:function(n){var t=n;if(t){while(t.getAttribute(nt)==null)t=t.parentNode;return parseInt(t.getAttribute(nt))}},getFileList:function(){return l},markFilenameEditable:function(n){var t=d(n);t&&qq(t).addClass(i.classes.editable)},updateFilename:function(n,t){var i=d(n);i&&qq(i).setText(t)},hideFilename:function(n){u(d(n))},showFilename:function(n){e(d(n))},isFileName:function(n){return qq(n).hasClass(t.file)},getButton:function(){return i.button||r(s,t.button)},hideDropProcessing:function(){u(ot())},showDropProcessing:function(){e(ot())},getDropZone:function(){return r(s,t.drop)},isEditFilenamePossible:function(){return ct},hideRetry:function(n){u(et(n))},isRetryPossible:function(){return lt},showRetry:function(n){e(et(n))},getFileContainer:function(n){return f(n)},showEditIcon:function(n){var t=vt(n);t&&qq(t).addClass(i.classes.editable)},hideEditIcon:function(n){var t=vt(n);t&&qq(t).removeClass(i.classes.editable)},isEditIcon:function(n){return qq(n).hasClass(t.editNameIcon)},getEditInput:function(n){return r(f(n),t.editFilenameInput)},isEditInput:function(n){return qq(n).hasClass(t.editFilenameInput)},updateProgress:function(n,t,i){var r=b(n),f;r&&(f=Math.round(t/i*100),f===100?u(r):e(r),pt(n,f))},updateTotalProgress:function(n,t){this.updateProgress(null,n,t)},hideProgress:function(n){var t=b(n);t&&u(t)},hideTotalProgress:function(){this.hideProgress()},resetProgress:function(n){pt(n,0)},resetTotalProgress:function(){this.resetProgress()},showCancel:function(n){if(!tt){var t=at(n);t&&qq(t).removeClass(i.classes.hide)}},hideCancel:function(n){u(at(n))},isCancel:function(n){return qq(n).hasClass(t.cancel)},allowPause:function(n){e(w(n));u(ut(n))},uploadPaused:function(n){this.setStatusText(n,i.text.paused);this.allowContinueButton(n);u(k(n))},hidePause:function(n){u(w(n))},isPause:function(n){return qq(n).hasClass(t.pause)},isContinueButton:function(n){return qq(n).hasClass(t.continueButton)},allowContinueButton:function(n){e(ut(n));u(w(n))},uploadContinued:function(n){this.setStatusText(n,"");this.allowPause(n);e(k(n))},showDeleteButton:function(n){e(ft(n))},hideDeleteButton:function(n){u(ft(n))},isDeleteButton:function(n){return qq(n).hasClass(t.deleteButton)},isRetry:function(n){return qq(n).hasClass(t.retry)},updateSize:function(n,t){var i=yt(n);i&&(e(i),qq(i).setText(t))},setStatusText:function(n,i){var u=r(f(n),t.statusText);u&&(i==null?qq(u).clearText():qq(u).setText(i))},hideSpinner:function(n){u(k(n))},showSpinner:function(n){e(k(n))},generatePreview:function(n,t){var r=t&&t.qqThumbnailId,i=v(n),u={maxSize:h,scale:!0,orient:!0};qq.supportedFeatures.imagePreviews?i&&st(i).done(function(){c[n]=new qq.Promise;r!=null?ii(n,r):ri(n,t,u)}):i&&st(i)},updateThumbnail:function(n,t,r){var u=v(n),f={maxSize:h,scale:rt};if(u){if(t)return r&&st(u),i.imageGenerator.generate(t,u,f).then(function(){e(u)},function(){g(n,u)});g(n,u)}}})};qq.traditional=qq.traditional||{};qq.traditional.FormUploadHandler=function(n,t){"use strict";function e(n){var t={};try{t=qq.parseJson(n)}catch(r){i("Error when attempting to parse iframe upload response ("+r.message+")","error")}return t}function o(n,t){var u,f,r;try{f=t.contentDocument||t.contentWindow.document;r=f.body.innerHTML;i("converting iframe's innerHTML to JSON");i("innerHTML = "+r);r&&r.match(/^1&&!t.allowMultipleItems?(t.callbacks.processingDroppedFilesComplete([]),t.callbacks.dropError("tooManyFilesError",""),i.dropDisabled(!1),f.failure()):(r=[],qq.isFolderDropSupported(n)?qq.each(n.items,function(n,t){var i=t.webkitGetAsEntry();i&&(i.isFile?r.push(t.getAsFile()):u.push(o(i).done(function(){u.pop();u.length===0&&f.success()})))}):r=n.files,u.length===0&&f.success()),f}function h(n){var o=new qq.UploadDropZone({HIDE_ZONES_EVENT_NAME:u,element:n,onEnter:function(i){qq(n).addClass(t.classes.dropActive);i.stopPropagation()},onLeaveNotDescendants:function(){qq(n).removeClass(t.classes.dropActive)},onDrop:function(n){l(n.dataTransfer,o).then(function(){c(r,o)},function(){t.callbacks.dropLog("Drop event DataTransfer parsing failed. No files will be uploaded.","error")})}});return i.addDisposer(function(){o.dispose()}),qq(n).hasAttribute(f)&&qq(n).hide(),e.push(o),o}function a(n){var t;return qq.each(n.dataTransfer.types,function(n,i){if(i==="Files")return t=!0,!1}),t}function v(n){return qq.firefox()?!n.relatedTarget:qq.safari()?n.x<0||n.y<0:n.x===0&&n.y===0}function y(){var n=t.dropZoneElements,r=function(){setTimeout(function(){qq.each(n,function(n,i){qq(i).hasAttribute(f)&&qq(i).hide();qq(i).removeClass(t.classes.dropActive)})},10)};qq.each(n,function(t,r){var u=h(r);n.length&&(!qq.ie()||qq.ie10())&&i.attach(document,"dragenter",function(t){!u.dropDisabled()&&a(t)&&qq.each(n,function(n,t){t instanceof HTMLElement&&qq(t).css({display:"block"})})})});i.attach(document,"dragleave",function(n){v(n)&&r()});i.attach(qq(document).children()[0],"mouseenter",function(){r()});i.attach(document,"drop",function(n){n.preventDefault();r()});i.attach(document,u,r)}var t,u="qq-hidezones",f="qq-hide-dropzone",e=[],r=[],i=new qq.DisposeSupport;t={dropZoneElements:[],allowMultipleItems:!0,classes:{dropActive:null},callbacks:new qq.DragAndDrop.callbacks};qq.extend(t,n,!0);y();qq.extend(this,{setupExtraDropzone:function(n){t.dropZoneElements.push(n);h(n)},removeDropzone:function(n){var i,r=t.dropZoneElements;for(i in r)if(r[i]===n)return r.splice(i,1)},dispose:function(){i.dispose();qq.each(e,function(n,t){t.dispose()})}})};qq.DragAndDrop.callbacks=function(){"use strict";return{processingDroppedFiles:function(){},processingDroppedFilesComplete:function(){},dropError:function(n,t){qq.log("Drag & drop error code '"+n+" with these specifics: '"+t+"'","error")},dropLog:function(n,t){qq.log(n,t)}}};qq.UploadDropZone=function(n){"use strict";function s(){return qq.safari()||qq.firefox()&&qq.windows()}function h(){o||(s?i.attach(document,"dragover",function(n){n.preventDefault()}):i.attach(document,"dragover",function(n){n.dataTransfer&&(n.dataTransfer.dropEffect="none",n.preventDefault())}),o=!0)}function u(n){if(qq.ie()&&!qq.ie10())return!1;var i,t=n.dataTransfer,r=qq.safari();return i=qq.ie10()||qq.ie11()?!0:t.effectAllowed!=="none",t&&i&&(t.files||!r&&t.types.contains&&t.types.contains("Files"))}function f(n){return n!==undefined&&(e=n),e}function c(){function i(){n=document.createEvent("Event");n.initEvent(t.HIDE_ZONES_EVENT_NAME,!0,!0)}var n;if(window.CustomEvent)try{n=new CustomEvent(t.HIDE_ZONES_EVENT_NAME)}catch(r){i()}else i();document.dispatchEvent(n)}function l(){i.attach(r,"dragover",function(n){if(u(n)){var t=qq.ie()||qq.ie11()?null:n.dataTransfer.effectAllowed;n.dataTransfer.dropEffect=t==="move"||t==="linkMove"?"move":"copy";n.stopPropagation();n.preventDefault()}});i.attach(r,"dragenter",function(n){if(!f()){if(!u(n))return;t.onEnter(n)}});i.attach(r,"dragleave",function(n){if(u(n)){t.onLeave(n);var i=document.elementFromPoint(n.clientX,n.clientY);if(!qq(this).contains(i))t.onLeaveNotDescendants(n)}});i.attach(r,"drop",function(n){if(!f()){if(!u(n))return;n.preventDefault();n.stopPropagation();t.onDrop(n);c()}})}var i=new qq.DisposeSupport,t,r,e,o;t={element:null,onEnter:function(){},onLeave:function(){},onLeaveNotDescendants:function(){},onDrop:function(){}};qq.extend(t,n);r=t.element;h();l();qq.extend(this,{dropDisabled:function(n){return f(n)},dispose:function(){i.dispose()},getElement:function(){return r}})};qq.DeleteFileAjaxRequester=function(n){"use strict";function r(){return t.method.toUpperCase()==="POST"?{_method:"DELETE"}:{}}var i,t={method:"DELETE",uuidParamName:"qquuid",endpointStore:{},maxConnections:3,customHeaders:function(){return{}},paramsStore:{},demoMode:!1,cors:{expected:!1,sendCredentials:!1},log:function(){},onDelete:function(){},onDeleteComplete:function(){}};qq.extend(t,n);i=qq.extend(this,new qq.AjaxRequester({acceptHeader:"application/json",validMethods:["POST","DELETE"],method:t.method,endpointStore:t.endpointStore,paramsStore:t.paramsStore,mandatedParams:r(),maxConnections:t.maxConnections,customHeaders:function(n){return t.customHeaders.get(n)},demoMode:t.demoMode,log:t.log,onSend:t.onDelete,onComplete:t.onDeleteComplete,cors:t.cors}));qq.extend(this,{sendDelete:function(n,r,u){var f=u||{};t.log("Submitting delete file request for "+n);t.method==="DELETE"?i.initTransport(n).withPath(r).withParams(f).send():(f[t.uuidParamName]=r,i.initTransport(n).withParams(f).send())}})},function(){function i(n){var r=n.naturalWidth,u=n.naturalHeight,t,i;return r*u>1048576?(t=document.createElement("canvas"),t.width=t.height=1,i=t.getContext("2d"),i.drawImage(n,-r+1,0),i.getImageData(0,0,1,1).data[3]===0):!1}function r(n,t,i){var u=document.createElement("canvas"),f,h,o;u.width=1;u.height=i;f=u.getContext("2d");f.drawImage(n,0,0);for(var c=f.getImageData(0,0,1,i).data,e=0,s=i,r=i;r>e;)h=c[(r-1)*4+3],h===0?s=r:e=r,r=s+e>>1;return o=r/i,o===0?1:o}function u(t,i,r){var u=document.createElement("canvas"),f=i.mime||"image/jpeg";return n(t,u,i,r),u.toDataURL(f,i.quality||.8)}function f(n){var t=5241e3;if(!qq.ios())throw new qq.Error("Downsampled dimensions can only be reliably calculated for iOS!");if(n.origHeight*n.origWidth>t)return{newHeight:Math.round(Math.sqrt(t*(n.origHeight/n.origWidth))),newWidth:Math.round(Math.sqrt(t*(n.origWidth/n.origHeight)))}}function n(n,t,u,o){var v=n.naturalWidth,y=n.naturalHeight,h=u.width,c=u.height,p=t.getContext("2d"),l,g,s,a,w,d;if(p.save(),qq.supportedFeatures.unlimitedScaledImageSize||(l=f({origWidth:h,origHeight:c}),l&&(qq.log(qq.format("Had to reduce dimensions due to device limitations from {}w / {}h to {}w / {}h",h,c,l.newWidth,l.newHeight),"warn"),h=l.newWidth,c=l.newHeight)),e(t,h,c,u.orientation),qq.ios()){g=i(n);g&&(v/=2,y/=2);s=1024;a=document.createElement("canvas");a.width=a.height=s;for(var b=a.getContext("2d"),rt=o?r(n,v,y):1,nt=Math.ceil(s*h/v),tt=Math.ceil(s*c/y/rt),k=0,it=0;kh&&(r=h,f=o*r/e<<0);c&&f>c&&(f=c,r=e*f/o<<0);s={width:r,height:f};for(l in i)s[l]=i[l];if(a=t.tagName.toLowerCase(),a==="img"?t.src=u(this.srcImage,s,y):a==="canvas"&&n(this.srcImage,t,s,y),typeof this.onrender=="function")this.onrender(t)};qq.MegaPixImage=t}();qq.ImageGenerator=function(n){"use strict";function i(n){return n.tagName.toLowerCase()==="img"}function r(n){return n.tagName.toLowerCase()==="canvas"}function s(){return(new Image).crossOrigin!==undefined}function h(){var n=document.createElement("canvas");return n.getContext&&n.getContext("2d")}function f(n){var i=n.split("/"),r=i[i.length-1],t=qq.getExtension(r);t=t&&t.toLowerCase();switch(t){case"jpeg":case"jpg":return"image/jpeg";case"png":return"image/png";case"bmp":return"image/bmp";case"gif":return"image/gif";case"tiff":case"tif":return"image/tiff"}}function u(n){var t=document.createElement("a"),i,r,u;return(t.href=n,i=t.protocol,u=t.port,r=t.hostname,i.toLowerCase()!==window.location.protocol.toLowerCase())?!0:r.toLowerCase()!==window.location.hostname.toLowerCase()?!0:u!==window.location.port&&!qq.ie()?!0:!1}function c(t,i){t.onload=function(){t.onload=null;t.onerror=null;i.success(t)};t.onerror=function(){t.onload=null;t.onerror=null;n("Problem drawing thumbnail!","error");i.failure(t,"Problem drawing thumbnail!")}}function l(n,t){n.qqImageRendered=function(){t.success(n)}}function t(t,u){var f=i(t)||r(t);return i(t)?c(t,u):r(t)?l(t,u):(u.failure(t),n(qq.format("Element container of type {} is not supported!",t.tagName),"error")),f}function a(i,r,u){var f=new qq.Promise,o=new qq.Identify(i,n),e=u.maxSize,s=u.orient==null?!0:u.orient,h=function(){r.onerror=null;r.onload=null;n("Could not render preview, file may be too large!","error");f.failure(r,"Browser cannot render image!")};return o.isPreviewable().then(function(u){var c={parse:function(){return(new qq.Promise).success()}},l=s?new qq.Exif(i,n):c,o=new qq.MegaPixImage(i,h);t(r,f)&&l.parse().then(function(n){var t=n&&n.Orientation;o.render(r,{maxWidth:e,maxHeight:e,orientation:t,mime:u})},function(t){n(qq.format("EXIF data could not be parsed ({}). Assuming orientation = 1.",t));o.render(r,{maxWidth:e,maxHeight:e,mime:u})})},function(){n("Not previewable");f.failure(r,"Not previewable")}),f}function e(n,i,r,e){var o=new Image,s=new qq.Promise;t(o,s);u(n)&&(o.crossOrigin="anonymous");o.src=n;s.then(function(){t(i,r);var u=new qq.MegaPixImage(o);u.render(i,{maxWidth:e,maxHeight:e,mime:f(n)})})}function o(n,i,r,u){t(i,r);qq(i).css({maxWidth:u+"px",maxHeight:u+"px"});i.src=n}function v(n,f,c){var l=new qq.Promise,v=c.scale,a=v?c.maxSize:null;return v&&i(f)?h()?u(n)&&!s()?o(n,f,l,a):e(n,f,l,a):o(n,f,l,a):r(f)?e(n,f,l,a):t(f,l)&&(f.src=n),l}qq.extend(this,{generate:function(t,i,r){return qq.isString(t)?(n("Attempting to update thumbnail based on server response."),v(t,i,r||{})):(n("Attempting to draw client-side image preview."),a(t,i,r||{}))}});this._testing={};this._testing.isImg=i;this._testing.isCanvas=r;this._testing.isCrossOrigin=u;this._testing.determineMimeOfFileName=f};qq.Exif=function(n,t){"use strict";function i(n){for(var t=0,i=0;n.length>0;)t+=parseInt(n.substring(0,2),16)*Math.pow(2,i),n=n.substring(2,n.length),i+=8;return t}function u(t,i){var r=t,f=i;return r===undefined&&(r=2,f=new qq.Promise),qq.readBlobToHex(n,r,4).then(function(n){var t=/^ffe([0-9])/.exec(n),i;t?t[1]!=="1"?(i=parseInt(n.slice(4,8),16),u(r+i+2,f)):f.success(r):f.failure("No EXIF header to be found!")}),f}function e(){var t=new qq.Promise;return qq.readBlobToHex(n,0,6).then(function(n){n.indexOf("ffd8")!==0?t.failure("Not a valid JPEG!"):u().then(function(n){t.success(n)},function(n){t.failure(n)})}),t}function o(t){var i=new qq.Promise;return qq.readBlobToHex(n,t+10,2).then(function(n){i.success(n==="4949")}),i}function s(t,r){var u=new qq.Promise;return qq.readBlobToHex(n,t+18,2).then(function(n){if(r)return u.success(i(n));u.success(parseInt(n,16))}),u}function h(t,i){var r=t+20,u=i*12;return qq.readBlobToHex(n,r,u)}function c(n){for(var i=[],t=0;t+24<=n.length;)i.push(n.slice(t,t+24)),t+=24;return i}function l(n,t){var e=16,u=qq.extend([],f),o={};return qq.each(t,function(t,f){var c=f.slice(0,4),s=n?i(c):parseInt(c,16),l=u.indexOf(s),h,a,v;return l>=0&&(a=r[s].name,v=r[s].bytes,h=f.slice(e,e+v*2),o[a]=n?i(h):parseInt(h,16),u.splice(l,1)),u.length===0?!1:void 0}),o}var f=[274],r={274:{name:"Orientation",bytes:2}};qq.extend(this,{parse:function(){var r=new qq.Promise,i=function(n){t(qq.format("EXIF header parse failed: '{}' ",n));r.failure(n)};return e().then(function(u){t(qq.format("Moving forward with EXIF header parsing for '{}'",n.name===undefined?"blob":n.name));o(u).then(function(n){t(qq.format("EXIF Byte order is {} endian",n?"little":"big"));s(u,n).then(function(f){t(qq.format("Found {} APP1 directory entries",f));h(u,f).then(function(i){var u=c(i),f=l(n,u);t("Successfully parsed some EXIF tags");r.success(f)},i)},i)},i)},i),r}});this._testing={};this._testing.parseLittleEndian=i};qq.Identify=function(n,t){"use strict";function i(n,t){var i=!1,r=[].concat(n);return qq.each(r,function(n,r){if(t.indexOf(r)===0)return i=!0,!1}),i}qq.extend(this,{isPreviewable:function(){var e=this,r=new qq.Promise,u=!1,f=n.name===undefined?"blob":n.name;return t(qq.format("Attempting to determine if {} can be rendered in this browser",f)),t("First pass: check type attribute of blob object."),this.isPreviewableSync()?(t("Second pass: check for magic bytes in file header."),qq.readBlobToHex(n,0,4).then(function(n){qq.each(e.PREVIEWABLE_MIME_TYPES,function(t,f){if(i(f,n))return(t!=="image/tiff"||qq.supportedFeatures.tiffPreviews)&&(u=!0,r.success(t)),!1});t(qq.format("'{}' is {} able to be rendered in this browser",f,u?"":"NOT"));u||r.failure()},function(){t("Error reading file w/ name '"+f+"'. Not able to be rendered in this browser.");r.failure()})):r.failure(),r},isPreviewableSync:function(){var r=n.type,u=qq.indexOf(Object.keys(this.PREVIEWABLE_MIME_TYPES),r)>=0,i=!1,f=n.name===undefined?"blob":n.name;return u&&(i=r==="image/tiff"?qq.supportedFeatures.tiffPreviews:!0),i||t(f+" is not previewable in this browser per the blob's type attr"),i}})};qq.Identify.prototype.PREVIEWABLE_MIME_TYPES={"image/jpeg":"ffd8ff","image/gif":"474946","image/png":"89504e","image/bmp":"424d","image/tiff":["49492a00","4d4d002a"]};qq.ImageValidation=function(n,t){"use strict";function i(n){var t=!1;return qq.each(n,function(n,i){if(i>0)return t=!0,!1}),t}function r(){var i=new qq.Promise;return new qq.Identify(n,t).isPreviewable().then(function(){var r=new Image,u=window.URL&&window.URL.createObjectURL?window.URL:window.webkitURL&&window.webkitURL.createObjectURL?window.webkitURL:null;u?(r.onerror=function(){t("Cannot determine dimensions for image. May be too large.","error");i.failure()},r.onload=function(){i.success({width:this.width,height:this.height})},r.src=u.createObjectURL(n)):(t("No createObjectURL function available to generate image URL!","error"),i.failure())},i.failure),i}function u(n,t){var i;return qq.each(n,function(n,r){if(r>0){var u=/(max|min)(Width|Height)/.exec(n),e=u[2].charAt(0).toLowerCase()+u[2].slice(1),f=t[e];switch(u[1]){case"min":if(fr)return i=n,!1}}}),i}this.validate=function(n){var f=new qq.Promise;return t("Attempting to validate image."),i(n)?r().then(function(t){var i=u(n,t);i?f.failure(i):f.success()},f.success):f.success(),f}};qq.Session=function(n){"use strict";function i(n){if(qq.isArray(n))return!0;t.log("Session response is not an array.","error")}function r(n,r,u,f){var e=!1;r=r&&i(n);r&&qq.each(n,function(n,i){if(i.uuid==null)e=!0,t.log(qq.format("Session response item {} did not include a valid UUID - ignoring.",n),"error");else if(i.name==null)e=!0,t.log(qq.format("Session response item {} did not include a valid name - ignoring.",n),"error");else try{return t.addFileRecord(i),!0}catch(r){e=!0;t.log(r.message,"error")}return!1});f[r&&!e?"success":"failure"](n,u)}var t={endpoint:null,params:{},customHeaders:{},cors:{},addFileRecord:function(){},log:function(){}};qq.extend(t,n,!0);this.refresh=function(){var n=new qq.Promise,i=function(t,i,u){r(t,i,u,n)},u=qq.extend({},t),f=new qq.SessionAjaxRequester(qq.extend(u,{onComplete:i}));return f.queryServer(),n}};qq.SessionAjaxRequester=function(n){"use strict";function r(n,i,r){var u=null;if(i.responseText!=null)try{u=qq.parseJson(i.responseText)}catch(f){t.log("Problem parsing session response: "+f.message,"error");r=!0}t.onComplete(u,!r,i)}var i,t={endpoint:null,customHeaders:{},params:{},cors:{expected:!1,sendCredentials:!1},onComplete:function(){},log:function(){}};qq.extend(t,n);i=qq.extend(this,new qq.AjaxRequester({acceptHeader:"application/json",validMethods:["GET"],method:"GET",endpointStore:{get:function(){return t.endpoint}},customHeaders:t.customHeaders,log:t.log,onComplete:r,cors:t.cors}));qq.extend(this,{queryServer:function(){var n=qq.extend({},t.params);t.log("Session query request.");i.initTransport("sessionRefresh").withParams(n).withCacheBuster().send()}})};qq.FormSupport=function(n,t,i){"use strict";function s(n){n.getAttribute("action")&&(u.newEndpoint=n.getAttribute("action"))}function f(n,t){if(n.checkValidity&&!n.checkValidity())i("Form did not pass validation checks - will not upload.","error"),t();else return!0}function h(n){var i=n.submit;qq(n).attach("submit",function(r){r=r||window.event;r.preventDefault?r.preventDefault():r.returnValue=!1;f(n,i)&&t()});n.submit=function(){f(n,i)&&t()}}function c(n){return n&&(qq.isString(n)&&(n=document.getElementById(n)),n&&(i("Attaching to form element."),s(n),e&&h(n))),n}var u=this,e=n.interceptSubmit,r=n.element,o=n.autoUpload;qq.extend(this,{newEndpoint:null,newAutoUpload:o,attachedToForm:!1,getFormInputsAsObject:function(){return r==null?null:u._form2Obj(r)}});r=c(r);this.attachedToForm=!!r};qq.extend(qq.FormSupport.prototype,{_form2Obj:function(n){"use strict";var t={},r=function(n){return qq.indexOf(["button","image","reset","submit"],n.toLowerCase())<0},u=function(n){return qq.indexOf(["checkbox","radio"],n.toLowerCase())>=0},i=function(n){return u(n.type)&&!n.checked?!0:n.disabled&&n.type.toLowerCase()!=="hidden"},f=function(n){var t=null;return qq.each(qq(n).children(),function(n,i){if(i.tagName.toLowerCase()==="option"&&i.selected)return t=i.value,!1}),t};return qq.each(n.elements,function(n,u){if((qq.isInput(u,!0)||u.tagName.toLowerCase()==="textarea")&&r(u.type)&&!i(u))t[u.name]=u.value;else if(u.tagName.toLowerCase()==="select"&&!i(u)){var e=f(u);e!==null&&(t[u.name]=e)}}),t}});qq.Scaler=function(n,t){"use strict";var h=this,r=n.sendOriginal,u=n.orient,f=n.defaultType,e=n.defaultQuality/100,o=n.failureText,s=n.includeExif,i=this._getSortedSizes(n.sizes);qq.extend(this,{enabled:qq.supportedFeatures.scaling&&i.length>0,getFileRecords:function(n,h,c){var a=this,v=[],l=c.blob?c.blob:c,y=new qq.Identify(l,t);return y.isPreviewableSync()?(qq.each(i,function(n,i){var r=a._determineOutputType({defaultType:f,requestedType:i.type,refType:l.type});v.push({uuid:qq.getUniqueId(),name:a._getName(h,{name:i.name,type:r,refType:l.type}),blob:new qq.BlobProxy(l,qq.bind(a._generateScaledImage,a,{maxSize:i.maxSize,orient:u,type:r,quality:e,failedText:o,includeExif:s,log:t}))})}),r&&v.push({uuid:n,name:h,blob:l})):v.push({uuid:n,name:h,blob:l}),v},handleNewFile:function(n,t,i,r,u,f,e,o){var a=this,p=n.qqButtonId||n.blob&&n.blob.qqButtonId,c=[],s=null,v=o.addFileToHandler,h=o.uploadData,l=o.paramsStore,y=qq.getUniqueId();qq.each(a.getFileRecords(i,t,n),function(t,i){var o=n,l=r,f;i.blob instanceof qq.BlobProxy&&(o=i.blob,l=-1);f=h.addFile({uuid:i.uuid,name:i.name,size:l,batchId:e,proxyGroupId:y});i.blob instanceof qq.BlobProxy?c.push(f):s=f;v(f,o);u.push({id:f,file:o})});s!==null&&(qq.each(c,function(n,t){var i={qqparentuuid:h.retrieve({id:s}).uuid,qqparentsize:h.retrieve({id:s}).size};i[f]=h.retrieve({id:t}).uuid;h.setParentId(t,s);l.addReadOnly(t,i)}),c.length&&function(){var n={};n[f]=h.retrieve({id:s}).uuid;l.addReadOnly(s,n)}())}})};qq.extend(qq.Scaler.prototype,{scaleImage:function(n,t,i){"use strict";if(!qq.supportedFeatures.scaling)throw new qq.Error("Scaling is not supported in this browser!");var r=new qq.Promise,f=i.log,e=i.getFile(n),u=i.uploadData.retrieve({id:n}),o=u&&u.name,s=u&&u.uuid,h={sendOriginal:!1,orient:t.orient,defaultType:t.type||null,defaultQuality:t.quality,failedToScaleText:"Unable to scale",sizes:[{name:"",maxSize:t.maxSize}]},c=new qq.Scaler(h,f);return qq.Scaler&&qq.supportedFeatures.imagePreviews&&e?qq.bind(function(){var t=c.getFileRecords(s,o,e)[0];t&&t.blob instanceof qq.BlobProxy?t.blob.create().then(r.success,r.failure):(f(n+" is not a scalable image!","error"),r.failure())},this)():(r.failure(),f("Could not generate requested scaled image for "+n+". Scaling is either not possible in this browser, or the file could not be located.","error")),r},_determineOutputType:function(n){"use strict";var t=n.requestedType,i=n.defaultType,r=n.refType;return!i&&!t?r!=="image/jpeg"?"image/png":r:t?qq.indexOf(Object.keys(qq.Identify.prototype.PREVIEWABLE_MIME_TYPES),t)>=0?t==="image/tiff"?qq.supportedFeatures.tiffPreviews?t:i:t:i:i},_getName:function(n,t){"use strict";var r=n.lastIndexOf("."),u=" ("+t.name+")",f=t.type||"image/png",o=t.refType,i="",e=qq.getExtension(n);return r>=0?(i=n.substr(0,r),o!==f&&(e=f.split("/")[1]),i+=u+"."+e):i=n+u,i},_getSortedSizes:function(n){"use strict";return n=qq.extend([],n),n.sort(function(n,t){return n.maxSize>t.maxSize?1:n.maxSize=0?atob(n.split(",")[1]):decodeURI(n.split(",")[1]),r=n.split(",")[0].split(":")[1].split(";")[0],i=new ArrayBuffer(t.length),u=new Uint8Array(i),qq.each(t,function(n,t){u[n]=t.charCodeAt(0)}),this._createBlob(i,r)},_createBlob:function(n,t){"use strict";var r=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,i=r&&new r;return i?(i.append(n),i.getBlob(t)):new Blob([n],{type:t})}});ExifRestorer=function(){var n={};return n.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n.encode64=function(n){var o="",u,t,i="",s,h,f,r="",e=0;do u=n[e++],t=n[e++],i=n[e++],s=u>>2,h=(u&3)<<4|t>>4,f=(t&15)<<2|i>>6,r=i&63,isNaN(t)?f=r=64:isNaN(i)&&(r=64),o=o+this.KEY_STR.charAt(s)+this.KEY_STR.charAt(h)+this.KEY_STR.charAt(f)+this.KEY_STR.charAt(r),u=t=i="",s=h=f=r="";while(en.length)break}return i},n.decode64=function(n){var e,o,s="",h,r,t,u="",i=0,f=[];if(/[^A-Za-z0-9\+\/\=]/g.exec(n))throw new Error("There were invalid base64 characters in the input text. Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='");n=n.replace(/[^A-Za-z0-9\+\/\=]/g,"");do h=this.KEY_STR.indexOf(n.charAt(i++)),r=this.KEY_STR.indexOf(n.charAt(i++)),t=this.KEY_STR.indexOf(n.charAt(i++)),u=this.KEY_STR.indexOf(n.charAt(i++)),e=h<<2|r>>4,o=(r&15)<<4|t>>2,s=(t&3)<<6|u,f.push(e),t!=64&&f.push(o),u!=64&&f.push(s),e=o=s="",h=r=t=u="";while(i=0)return i=!1,!1}),i},l=function(n){f(n,-1,-1);delete i[n]},a=function(n,t,i){(t.length===0||c(t,i))&&(s(r,r),this.reset())},h=function(n){var r=t(n);r>0&&(f(n,0,r),i[n]={loaded:0,total:r})},f=function(n,t,f){var e=i[n]?i[n].loaded:0,o=i[n]?i[n].total:0;t===-1&&f===-1?(u-=e,r-=o):(t&&(u+=t-e),f&&(r+=f-o));s(u,r)};qq.extend(this,{onAllComplete:a,onStatusChange:function(n,t,i){i===qq.status.CANCELED||i===qq.status.REJECTED?l(n):i===qq.status.SUBMITTING&&h(n)},onIndividualProgress:function(n,t,r){f(n,t,r);i[n]={loaded:t,total:r}},onNewSize:function(n){h(n)},reset:function(){i={};u=0;r=0}})};qq.UiEventHandler=function(n,t){"use strict";function u(n){r.attach(n,i.eventType,function(n){n=n||window.event;var t=n.target||n.srcElement;i.onHandled(t,n)})}var r=new qq.DisposeSupport,i={eventType:"click",attachTo:null,onHandled:function(){}};qq.extend(this,{addHandler:function(n){u(n)},dispose:function(){r.dispose()}});qq.extend(t,{getFileIdFromItem:function(n){return n.qqFileId},getDisposeSupport:function(){return r}});qq.extend(i,n);i.attachTo&&u(i.attachTo)};qq.FileButtonsClickHandler=function(n){"use strict";function r(n,r){qq.each(i,function(i,u){var e=i.charAt(0).toUpperCase()+i.slice(1),f;if(t.templating["is"+e](n))return f=t.templating.getFileId(n),qq.preventDefault(r),t.log(qq.format("Detected valid file button click event on file '{}', ID: {}.",t.onGetName(f),f)),u(f),!1})}var t={templating:null,log:function(){},onDeleteFile:function(){},onCancel:function(){},onRetry:function(){},onPause:function(){},onContinue:function(){},onGetName:function(){}},i={cancel:function(n){t.onCancel(n)},retry:function(n){t.onRetry(n)},deleteButton:function(n){t.onDeleteFile(n)},pause:function(n){t.onPause(n)},continueButton:function(n){t.onContinue(n)}};qq.extend(t,n);t.eventType="click";t.onHandled=r;t.attachTo=t.templating.getFileList();qq.extend(this,new qq.UiEventHandler(t,{}))};qq.FilenameClickHandler=function(n){"use strict";function r(n,r){if(t.templating.isFileName(n)||t.templating.isEditIcon(n)){var u=t.templating.getFileId(n),f=t.onGetUploadStatus(u);f===qq.status.SUBMITTED&&(t.log(qq.format("Detected valid filename click event on file '{}', ID: {}.",t.onGetName(u),u)),qq.preventDefault(r),i.handleFilenameEdit(u,n,!0))}}var i={},t={templating:null,log:function(){},classes:{file:"qq-upload-file",editNameIcon:"qq-edit-filename-icon"},onGetUploadStatus:function(){},onGetName:function(){}};qq.extend(t,n);t.eventType="click";t.onHandled=r;qq.extend(this,new qq.FilenameEditHandler(t,i))};qq.FilenameInputFocusInHandler=function(n,t){"use strict";function r(n){if(i.templating.isEditInput(n)){var r=i.templating.getFileId(n),u=i.onGetUploadStatus(r);u===qq.status.SUBMITTED&&(i.log(qq.format("Detected valid filename input focus event on file '{}', ID: {}.",i.onGetName(r),r)),t.handleFilenameEdit(r,n))}}var i={templating:null,onGetUploadStatus:function(){},log:function(){}};t||(t={});i.eventType="focusin";i.onHandled=r;qq.extend(i,n);qq.extend(this,new qq.FilenameEditHandler(i,t))};qq.FilenameInputFocusHandler=function(n){"use strict";n.eventType="focus";n.attachTo=null;qq.extend(this,new qq.FilenameInputFocusInHandler(n,{}))};qq.FilenameEditHandler=function(n,t){"use strict";function u(n){var t=i.onGetName(n),r=t.lastIndexOf(".");return r>0&&(t=t.substr(0,r)),t}function f(n){var t=i.onGetName(n);return qq.getExtension(t)}function r(n,t){var r=n.value,u;if(r!==undefined&&qq.trimStr(r).length>0){u=f(t);u!==undefined&&(r=r+"."+u);i.onSetName(t,r)}i.onEditingStatusChange(t,!1)}function e(n,i){t.getDisposeSupport().attach(n,"blur",function(){r(n,i)})}function o(n,i){t.getDisposeSupport().attach(n,"keyup",function(t){var u=t.keyCode||t.which;u===13&&r(n,i)})}var i={templating:null,log:function(){},onGetUploadStatus:function(){},onGetName:function(){},onSetName:function(){},onEditingStatusChange:function(){}};qq.extend(i,n);i.attachTo=i.templating.getFileList();qq.extend(this,new qq.UiEventHandler(i,t));qq.extend(t,{handleFilenameEdit:function(n,t,r){var f=i.templating.getEditInput(n);i.onEditingStatusChange(n,!0);f.value=u(n);r&&f.focus();e(f,n);o(f,n)}})},function(n){"use strict";function s(n){var u=r(n||{}),f=h(u);return i(f),c(u,f),t}function h(n){var t=u("uploaderType"),i=u("endpointType");return t?(t=t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),i)?new qq[i]["FineUploader"+t](n):new qq["FineUploader"+t](n):i?new qq[i].FineUploader(n):new qq.FineUploader(n)}function f(n,i){var r=t.data("fineuploader");if(i)r===undefined&&(r={}),r[n]=i,t.data("fineuploader",r);else return r===undefined?null:r[n]}function i(n){return f("uploader",n)}function u(n,t){return f(n,t)}function c(i,r){var u=i.callbacks={};n.each(r._options.callbacks,function(i,r){var f,o;f=/^on(\w+)/.exec(i)[1];f=f.substring(0,1).toLowerCase()+f.substring(1);o=t;u[i]=function(){var i=Array.prototype.slice.call(arguments),u=[],t,s;n.each(i,function(n,t){u.push(e(t))});t=r.apply(this,i);try{s=o.triggerHandler(f,u)}catch(h){qq.log("Caught error in Fine Uploader jQuery event handler: "+h.message,"error")}return t!=null?t:s}});r._options.callbacks=u}function r(i,f){var e,s;return e=f===undefined?i.uploaderType!=="basic"?{element:t[0]}:{}:f,n.each(i,function(t,i){n.inArray(t,o)>=0?u(t,i):i instanceof n?e[t]=i[0]:n.isPlainObject(i)?(e[t]={},r(i,e[t])):n.isArray(i)?(s=[],n.each(i,function(t,i){var u={};i instanceof n?n.merge(s,i):n.isPlainObject(i)?(r(i,u),s.push(u)):s.push(i)}),e[t]=s):e[t]=i}),f===undefined?e:void 0}function l(t){return n.type(t)==="string"&&!t.match(/^_/)&&i()[t]!==undefined}function a(n){var t=[],f=Array.prototype.slice.call(arguments,1),u;return r(f,t),u=i()[n].apply(i(),t),e(u)}function e(t){var i=t;return t!=null&&typeof t=="object"&&(t.nodeType===1||t.nodeType===9)&&t.cloneNode&&(i=n(t)),i}var t,o=["uploaderType","endpointType"];n.fn.fineUploader=function(r){var f=this,e=arguments,u=[];return(this.each(function(o,h){if(t=n(h),i()&&l(r)){if(u.push(a.apply(f,e)),f.length===1)return!1}else typeof r!="object"&&r?n.error("Method "+r+" does not exist on jQuery.fineUploader"):s.apply(f,e)}),u.length===1)?u[0]:u.length>1?u:this}}(jQuery),function(n){"use strict";function f(n){n||(n={});n.dropZoneElements=[t];var u=r(n);return o(u),i(new qq.DragAndDrop(u)),t}function e(n,i){var r=t.data(u);if(i)r===undefined&&(r={}),r[n]=i,t.data(u,r);else return r===undefined?null:r[n]}function i(n){return e("dndInstance",n)}function o(i){var r=i.callbacks={};n.each(new qq.DragAndDrop.callbacks,function(n){var u=n,i;i=t;r[n]=function(){var n=Array.prototype.slice.call(arguments);return i.triggerHandler(u,n)}})}function r(t,i){var u,f;return u=i===undefined?{}:i,n.each(t,function(t,i){i instanceof n?u[t]=i[0]:n.isPlainObject(i)?(u[t]={},r(i,u[t])):n.isArray(i)?(f=[],n.each(i,function(t,i){i instanceof n?n.merge(f,i):f.push(i)}),u[t]=f):u[t]=i}),i===undefined?u:void 0}function s(t){return n.type(t)==="string"&&t==="dispose"&&i()[t]!==undefined}function h(n){var t=[],u=Array.prototype.slice.call(arguments,1);return r(u,t),i()[n].apply(i(),t)}var u="fineUploaderDnd",t;n.fn.fineUploaderDnd=function(r){var e=this,o=arguments,u=[];return(this.each(function(c,l){if(t=n(l),i()&&s(r)){if(u.push(h.apply(e,o)),e.length===1)return!1}else typeof r!="object"&&r?n.error("Method "+r+" does not exist in Fine Uploader's DnD module."):f.apply(e,o)}),u.length===1)?u[0]:u.length>1?u:this}}(jQuery);+function(n){"use strict";function r(i){return this.each(function(){var u=n(this),r=u.data("bs.tooltip"),f=typeof i=="object"&&i;(r||i!="destroy")&&(r||u.data("bs.tooltip",r=new t(this,f)),typeof i=="string"&&r[i]())})}var t=function(n,t){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null;this.init("tooltip",n,t)},i;t.VERSION="3.2.0";t.TRANSITION_DURATION=150;t.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'