var DOKU_BASE = '/'; var DOKU_TPL = '/lib/tpl/sprintdoc/'; var DOKU_COOKIE_PARAM = { "path": "\/", "secure": true }; Object.defineProperty(window, 'DOKU_UHN', { get: function () { console.warn('Using DOKU_UHN is deprecated. Please use JSINFO.useHeadingNavigation instead'); return JSINFO.useHeadingNavigation; } }); Object.defineProperty(window, 'DOKU_UHC', { get: function () { console.warn('Using DOKU_UHC is deprecated. Please use JSINFO.useHeadingContent instead'); return JSINFO.useHeadingContent; } }); LANG = { "search_toggle_tools": "Toggle Search Tools", "willexpire": "Your lock for editing this page is about to expire in a minute.\\nTo avoid conflicts use the preview button to reset the locktimer.", "notsavedyet": "Unsaved changes will be lost.", "searchmedia": "Search for files", "keepopen": "Keep window open on selection", "hidedetails": "Hide Details", "mediatitle": "Link settings", "mediadisplay": "Link type", "mediaalign": "Alignment", "mediasize": "Image size", "mediatarget": "Link target", "mediaclose": "Close", "mediainsert": "Insert", "mediadisplayimg": "Show the image.", "mediadisplaylnk": "Show only the link.", "mediasmall": "Small version", "mediamedium": "Medium version", "medialarge": "Large version", "mediaoriginal": "Original version", "medialnk": "Link to detail page", "mediadirect": "Direct link to original", "medianolnk": "No link", "medianolink": "Do not link the image", "medialeft": "Align the image on the left.", "mediaright": "Align the image on the right.", "mediacenter": "Align the image in the middle.", "medianoalign": "Use no align.", "nosmblinks": "Linking to Windows shares only works in Microsoft Internet Explorer.\\nYou still can copy and paste the link.", "linkwiz": "Link Wizard", "linkto": "Link to:", "del_confirm": "Really delete selected item(s)?", "restore_confirm": "Really restore this version?", "media_diff": "View differences:", "media_diff_both": "Side by Side", "media_diff_opacity": "Shine-through", "media_diff_portions": "Swipe", "media_select": "Select files\u2026", "media_upload_btn": "Upload", "media_done_btn": "Done", "media_drop": "Drop files here to upload", "media_cancel": "remove", "media_overwrt": "Overwrite existing files", "data_insecure": "WARNING: It seems your data directory is not properly secured. Please read about Web Access Security in DokuWiki<\/a>.", "plugins": { "edittable": { "toggle_header": "Toggle header state", "align_left": "Left-align cell", "align_center": "Center cell", "align_right": "Right-align cell", "confirmdeleterow": "Really delete row?", "confirmdeletecol": "Really delete column?", "row_above": "Add row above", "remove_row": "Remove row", "row_below": "Add row below", "col_left": "Add column on the left", "remove_col": "Remove column", "col_right": "Add column on the right", "merge_cells": "Merge cells", "unmerge_cells": "Split cells" }, "extension": { "reallydel": "Really uninstall this extension?", "display_viewoptions": "View Options:", "display_enabled": "enabled", "display_disabled": "disabled", "display_updatable": "updatable", "close": "Click to close", "filter": "Show updatable extensions only" }, "logviewer": { "filter": "Filter Loglines:" }, "styling": { "loader": "Preview is loading...
if this does not goes away, your values may be faulty", "popup": "Open as a popup" } } }; var toolbar = [{ "type": "format", "title": "Bold Text", "icon": "bold.png", "key": "b", "open": "**", "close": "**", "block": false }, { "type": "format", "title": "Italic Text", "icon": "italic.png", "key": "i", "open": "\/\/", "close": "\/\/", "block": false }, { "type": "format", "title": "Underlined Text", "icon": "underline.png", "key": "u", "open": "__", "close": "__", "block": false }, { "type": "format", "title": "Monospaced Text", "icon": "mono.png", "key": "m", "open": "''", "close": "''", "block": false }, { "type": "format", "title": "Strike-through Text", "icon": "strike.png", "key": "d", "open": "", "close": "<\/del>", "block": false }, { "type": "autohead", "title": "Same Level Headline", "icon": "hequal.png", "key": "8", "text": "Headline", "mod": 0, "block": true }, { "type": "autohead", "title": "Lower Headline", "icon": "hminus.png", "key": "9", "text": "Headline", "mod": 1, "block": true }, { "type": "autohead", "title": "Higher Headline", "icon": "hplus.png", "key": "0", "text": "Headline", "mod": -1, "block": true }, { "type": "picker", "title": "Select Headline", "icon": "h.png", "class": "pk_hl", "list": [{ "type": "format", "title": "Level 1 Headline", "icon": "h1.png", "key": "1", "open": "====== ", "close": " ======\\n" }, { "type": "format", "title": "Level 2 Headline", "icon": "h2.png", "key": "2", "open": "===== ", "close": " =====\\n" }, { "type": "format", "title": "Level 3 Headline", "icon": "h3.png", "key": "3", "open": "==== ", "close": " ====\\n" }, { "type": "format", "title": "Level 4 Headline", "icon": "h4.png", "key": "4", "open": "=== ", "close": " ===\\n" }, { "type": "format", "title": "Level 5 Headline", "icon": "h5.png", "key": "5", "open": "== ", "close": " ==\\n" }], "block": true }, { "type": "linkwiz", "title": "Internal Link", "icon": "link.png", "key": "l", "open": "[[", "close": "]]", "block": false }, { "type": "format", "title": "External Link", "icon": "linkextern.png", "open": "[[", "close": "]]", "sample": "http:\/\/example.com|External Link", "block": false }, { "type": "formatln", "title": "Ordered List Item", "icon": "ol.png", "open": " - ", "close": "", "key": "-", "block": true }, { "type": "formatln", "title": "Unordered List Item", "icon": "ul.png", "open": " * ", "close": "", "key": ".", "block": true }, { "type": "insert", "title": "Horizontal Rule", "icon": "hr.png", "insert": "\\n----\\n", "block": true }, { "type": "mediapopup", "title": "Add Images and other files (opens in a new window)", "icon": "image.png", "url": "lib\/exe\/mediamanager.php?ns=", "name": "mediaselect", "options": "width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes", "block": false }, { "type": "picker", "title": "Smileys", "icon": "smiley.png", "list": { "8-)": "cool.svg", "8-O": "eek.svg", "8-o": "eek.svg", ":-(": "sad.svg", ":-)": "smile.svg", "=)": "smile2.svg", ":-\/": "doubt.svg", ":-\\": "doubt2.svg", ":-?": "confused.svg", ":-D": "biggrin.svg", ":-P": "razz.svg", ":-o": "surprised.svg", ":-O": "surprised.svg", ":-x": "silenced.svg", ":-X": "silenced.svg", ":-|": "neutral.svg", ";-)": "wink.svg", "m(": "facepalm.svg", "^_^": "fun.svg", ":?:": "question.svg", ":!:": "exclaim.svg", "LOL": "lol.svg", "FIXME": "fixme.svg", "DELETEME": "deleteme.svg" }, "icobase": "smileys", "block": false }, { "type": "picker", "title": "Special Chars", "icon": "chars.png", "list": ["\u00c0", "\u00e0", "\u00c1", "\u00e1", "\u00c2", "\u00e2", "\u00c3", "\u00e3", "\u00c4", "\u00e4", "\u01cd", "\u01ce", "\u0102", "\u0103", "\u00c5", "\u00e5", "\u0100", "\u0101", "\u0104", "\u0105", "\u00c6", "\u00e6", "\u0106", "\u0107", "\u00c7", "\u00e7", "\u010c", "\u010d", "\u0108", "\u0109", "\u010a", "\u010b", "\u00d0", "\u0111", "\u00f0", "\u010e", "\u010f", "\u00c8", "\u00e8", "\u00c9", "\u00e9", "\u00ca", "\u00ea", "\u00cb", "\u00eb", "\u011a", "\u011b", "\u0112", "\u0113", "\u0116", "\u0117", "\u0118", "\u0119", "\u0122", "\u0123", "\u011c", "\u011d", "\u011e", "\u011f", "\u0120", "\u0121", "\u0124", "\u0125", "\u00cc", "\u00ec", "\u00cd", "\u00ed", "\u00ce", "\u00ee", "\u00cf", "\u00ef", "\u01cf", "\u01d0", "\u012a", "\u012b", "\u0130", "\u0131", "\u012e", "\u012f", "\u0134", "\u0135", "\u0136", "\u0137", "\u0139", "\u013a", "\u013b", "\u013c", "\u013d", "\u013e", "\u0141", "\u0142", "\u013f", "\u0140", "\u0143", "\u0144", "\u00d1", "\u00f1", "\u0145", "\u0146", "\u0147", "\u0148", "\u00d2", "\u00f2", "\u00d3", "\u00f3", "\u00d4", "\u00f4", "\u00d5", "\u00f5", "\u00d6", "\u00f6", "\u01d1", "\u01d2", "\u014c", "\u014d", "\u0150", "\u0151", "\u0152", "\u0153", "\u00d8", "\u00f8", "\u0154", "\u0155", "\u0156", "\u0157", "\u0158", "\u0159", "\u015a", "\u015b", "\u015e", "\u015f", "\u0160", "\u0161", "\u015c", "\u015d", "\u0162", "\u0163", "\u0164", "\u0165", "\u00d9", "\u00f9", "\u00da", "\u00fa", "\u00db", "\u00fb", "\u00dc", "\u00fc", "\u01d3", "\u01d4", "\u016c", "\u016d", "\u016a", "\u016b", "\u016e", "\u016f", "\u01d6", "\u01d8", "\u01da", "\u01dc", "\u0172", "\u0173", "\u0170", "\u0171", "\u0174", "\u0175", "\u00dd", "\u00fd", "\u0178", "\u00ff", "\u0176", "\u0177", "\u0179", "\u017a", "\u017d", "\u017e", "\u017b", "\u017c", "\u00de", "\u00fe", "\u00df", "\u0126", "\u0127", "\u00bf", "\u00a1", "\u00a2", "\u00a3", "\u00a4", "\u00a5", "\u20ac", "\u00a6", "\u00a7", "\u00aa", "\u00ac", "\u00af", "\u00b0", "\u00b1", "\u00f7", "\u2030", "\u00bc", "\u00bd", "\u00be", "\u00b9", "\u00b2", "\u00b3", "\u00b5", "\u00b6", "\u2020", "\u2021", "\u00b7", "\u2022", "\u00ba", "\u2200", "\u2202", "\u2203", "\u018f", "\u0259", "\u2205", "\u2207", "\u2208", "\u2209", "\u220b", "\u220f", "\u2211", "\u203e", "\u2212", "\u2217", "\u00d7", "\u2044", "\u221a", "\u221d", "\u221e", "\u2220", "\u2227", "\u2228", "\u2229", "\u222a", "\u222b", "\u2234", "\u223c", "\u2245", "\u2248", "\u2260", "\u2261", "\u2264", "\u2265", "\u2282", "\u2283", "\u2284", "\u2286", "\u2287", "\u2295", "\u2297", "\u22a5", "\u22c5", "\u25ca", "\u2118", "\u2111", "\u211c", "\u2135", "\u2660", "\u2663", "\u2665", "\u2666", "\u03b1", "\u03b2", "\u0393", "\u03b3", "\u0394", "\u03b4", "\u03b5", "\u03b6", "\u03b7", "\u0398", "\u03b8", "\u03b9", "\u03ba", "\u039b", "\u03bb", "\u03bc", "\u039e", "\u03be", "\u03a0", "\u03c0", "\u03c1", "\u03a3", "\u03c3", "\u03a4", "\u03c4", "\u03c5", "\u03a6", "\u03c6", "\u03c7", "\u03a8", "\u03c8", "\u03a9", "\u03c9", "\u2605", "\u2606", "\u260e", "\u261a", "\u261b", "\u261c", "\u261d", "\u261e", "\u261f", "\u2639", "\u263a", "\u2714", "\u2718", "\u201e", "\u201c", "\u201d", "\u201a", "\u2018", "\u2019", "\u00ab", "\u00bb", "\u2039", "\u203a", "\u2014", "\u2013", "\u2026", "\u2190", "\u2191", "\u2192", "\u2193", "\u2194", "\u21d0", "\u21d1", "\u21d2", "\u21d3", "\u21d4", "\u00a9", "\u2122", "\u00ae", "\u2032", "\u2033", "[", "]", "{", "}", "~", "(", ")", "%", "\u00a7", "$", "#", "|", "@"], "block": false }, { "type": "signature", "title": "Insert Signature", "icon": "sig.png", "key": "y", "block": false }, { "title": "Insert a new table", "type": "NewTable", "icon": "..\/..\/plugins\/edittable\/images\/add_table.png", "block": true }, { "type": "picker", "title": "Wrap Plugin", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/picker.png", "list": [{ "type": "format", "title": "columns", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/column.png", "open": "\\n\\n", "close": "\\n<\/WRAP>\\n\\n\\n\\n<\/WRAP>\\n<\/WRAP>\\n" }, { "type": "format", "title": "simple centered box", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/box.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "info box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/info.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "tip box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/tip.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "important box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/important.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "alert box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/alert.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "help box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/help.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "download box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/download.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "format", "title": "todo box", "icon": "..\/..\/plugins\/wrap\/images\/note\/16\/todo.png", "open": "\\n", "close": "\\n<\/WRAP>\\n" }, { "type": "insert", "title": "clear floats", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/clear.png", "insert": "\\n" }, { "type": "format", "title": "especially emphasised", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/em.png", "open": "", "close": "<\/wrap>" }, { "type": "format", "title": "highlighted", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/hi.png", "open": "", "close": "<\/wrap>" }, { "type": "format", "title": "less significant", "icon": "..\/..\/plugins\/wrap\/images\/toolbar\/lo.png", "open": "", "close": "<\/wrap>" }] }]; (function (factory) { if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (typeof exports === 'object') { factory(require('jquery')); } else { factory(jQuery); } }(function ($) { var pluses = /\+/g; function encode(s) { return config.raw ? s : encodeURIComponent(s); } function decode(s) { return config.raw ? s : decodeURIComponent(s); } function stringifyCookieValue(value) { return encode(config.json ? JSON.stringify(value) : String(value)); } function parseCookieValue(s) { if (s.indexOf('"') === 0) { s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try { s = decodeURIComponent(s.replace(pluses, ' ')); return config.json ? JSON.parse(s) : s; } catch (e) { } } function read(s, converter) { var value = config.raw ? s : parseCookieValue(s); return $.isFunction(converter) ? converter(value) : value; } var config = $.cookie = function (key, value, options) { if (value !== undefined && !$.isFunction(value)) { options = $.extend({}, config.defaults, options); if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setTime(+t + days * 864e+5); } return (document.cookie = [encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join('')); } var result = key ? undefined : {}; var cookies = document.cookie ? document.cookie.split('; ') : []; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = parts.join('='); if (key && key === name) { result = read(cookie, value); break; } if (!key && (cookie = read(cookie)) !== undefined) { result[name] = cookie; } } return result; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) === undefined) { return false; } $.cookie(key, '', $.extend({}, options, { expires: -1 })); return !$.cookie(key); }; })); var qq = qq || {}; qq.extend = function (first, second) { for (var prop in second) { first[prop] = second[prop]; } }; 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++) { if (from in arr && arr[from] === elt) { return from; } } return -1; }; qq.getUniqueId = (function () { var id = 0; return function () { return id++; }; })(); qq.attach = function (element, type, fn) { if (element.addEventListener) { element.addEventListener(type, fn, false); } else if (element.attachEvent) { element.attachEvent('on' + type, fn); } }; qq.detach = function (element, type, fn) { if (element.removeEventListener) { element.removeEventListener(type, fn, false); } else if (element.attachEvent) { element.detachEvent('on' + type, fn); } }; qq.preventDefault = function (e) { if (e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; } }; qq.insertBefore = function (a, b) { b.parentNode.insertBefore(a, b); }; qq.remove = function (element) { element.parentNode.removeChild(element); }; qq.contains = function (parent, descendant) { if (parent == descendant) return true; if (parent.contains) { return parent.contains(descendant); } else { return !!(descendant.compareDocumentPosition(parent) & 8); } }; qq.toElement = (function () { var div = document.createElement('div'); return function (html) { div.innerHTML = html; var element = div.firstChild; div.removeChild(element); return element; }; })(); qq.css = function (element, styles) { 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); }; qq.hasClass = function (element, name) { var re = new RegExp('(^| )' + name + '( |$)'); return re.test(element.className); }; qq.addClass = function (element, name) { if (!qq.hasClass(element, name)) { element.className += ' ' + name; } }; qq.removeClass = function (element, name) { var re = new RegExp('(^| )' + name + '( |$)'); element.className = element.className.replace(re, ' ').replace(/^\s+|\s+$/g, ""); }; qq.setText = function (element, text) { element.innerText = text; element.textContent = text; }; qq.children = function (element) { var children = [], child = element.firstChild; while (child) { if (child.nodeType == 1) { children.push(child); } child = child.nextSibling; } return children; }; qq.getByClass = function (element, className) { if (element.querySelectorAll) { return element.querySelectorAll('.' + className); } var result = []; var candidates = element.getElementsByTagName("*"); var len = candidates.length; for (var i = 0; i < len; i++) { if (qq.hasClass(candidates[i], className)) { result.push(candidates[i]); } } return result; }; qq.obj2url = function (obj, temp, prefixDone) { var uristrings = [], prefix = '&', add = function (nextObj, i) { var nextTemp = temp ? (/\[\]$/.test(temp)) ? 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')) { for (var i = 0, len = obj.length; i < len; ++i) { add(obj[i], i); } } else if ((typeof obj != 'undefined') && (obj !== null) && (typeof obj === "object")) { for (var i in obj) { if (obj.hasOwnProperty(i) && typeof obj[i] != 'function') { add(obj[i], i); } } } else { uristrings.push(encodeURIComponent(temp) + '=' + encodeURIComponent(obj)); } return uristrings.join(prefix).replace(/^&/, '').replace(/%20/g, '+'); }; var qq = qq || {}; qq.FileUploaderBasic = function (o) { this._options = { debug: false, action: '/server/upload', params: {}, button: null, multiple: true, maxConnections: 3, allowedExtensions: [], sizeLimit: 0, minSizeLimit: 0, onSubmit: function (id, fileName) { }, onProgress: function (id, fileName, loaded, total) { }, onComplete: function (id, fileName, responseJSON) { }, onCancel: function (id, fileName) { }, messages: { typeError: "{file} has invalid extension. Only {extensions} are allowed.", 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.", onLeave: "The files are being uploaded, if you leave now the upload will be cancelled." }, showMessage: function (message) { alert(message); } }; qq.extend(this._options, o); this._filesInProgress = 0; this._handler = this._createUploadHandler(); if (this._options.button) { this._button = this._createUploadButton(this._options.button); } this._preventLeaveInProgress(); }; qq.FileUploaderBasic.prototype = { setParams: function (params) { this._options.params = params; }, getInProgress: function () { return this._filesInProgress; }, _createUploadButton: function (element) { var self = this; return new qq.UploadButton({ element: element, multiple: this._options.multiple && qq.UploadHandlerXhr.isSupported(), onChange: function (input) { self._onInputChange(input); } }); }, _createUploadHandler: function () { var self = this, handlerClass; if (qq.UploadHandlerXhr.isSupported()) { handlerClass = 'UploadHandlerXhr'; } else { handlerClass = 'UploadHandlerForm'; } var handler = new qq[handlerClass]({ debug: this._options.debug, action: this._options.action, maxConnections: this._options.maxConnections, onProgress: function (id, fileName, loaded, total) { self._onProgress(id, fileName, loaded, total); self._options.onProgress(id, fileName, loaded, total); }, onComplete: function (id, fileName, result) { self._onComplete(id, fileName, result); self._options.onComplete(id, fileName, result); }, onCancel: function (id, fileName) { self._onCancel(id, fileName); self._options.onCancel(id, fileName); } }); return handler; }, _preventLeaveInProgress: function () { var self = this; qq.attach(window, 'beforeunload', function (e) { if (!self._filesInProgress) { return; } var e = e || window.event; e.returnValue = self._options.messages.onLeave; return self._options.messages.onLeave; }); }, _onSubmit: function (id, fileName) { this._filesInProgress++; }, _onProgress: function (id, fileName, loaded, total) { }, _onComplete: function (id, fileName, result) { this._filesInProgress--; if (result.error) { this._options.showMessage(result.error); } }, _onCancel: function (id, fileName) { this._filesInProgress--; }, _onInputChange: function (input) { if (this._handler instanceof qq.UploadHandlerXhr) { this._uploadFileList(input.files); } else { if (this._validateFile(input)) { this._uploadFile(input); } } this._button.reset(); }, _uploadFileList: function (files) { for (var i = 0; i < files.length; i++) { if (!this._validateFile(files[i])) { return; } } for (var i = 0; i < files.length; i++) { this._uploadFile(files[i]); } }, _uploadFile: function (fileContainer) { var id = this._handler.add(fileContainer); var fileName = this._handler.getName(id); if (this._options.onSubmit(id, fileName) !== false) { this._onSubmit(id, fileName); this._handler.upload(id, this._options.params); } }, _validateFile: function (file) { var name, size; if (file.value) { name = file.value.replace(/.*(\/|\\)/, ""); } else { name = file.fileName != null ? file.fileName : file.name; size = file.fileSize != null ? file.fileSize : file.size; } if (!this._isAllowedExtension(name)) { this._error('typeError', name); return false; } else if (size === 0) { this._error('emptyError', name); return false; } else if (size && this._options.sizeLimit && size > this._options.sizeLimit) { this._error('sizeError', name); return false; } else if (size && size < this._options.minSizeLimit) { this._error('minSizeError', name); return false; } return true; }, _error: function (code, fileName) { var message = this._options.messages[code]; function r(name, replacement) { message = message.replace(name, replacement); } r('{file}', this._formatFileName(fileName)); r('{extensions}', this._options.allowedExtensions.join(', ')); r('{sizeLimit}', this._formatSize(this._options.sizeLimit)); r('{minSizeLimit}', this._formatSize(this._options.minSizeLimit)); this._options.showMessage(message); }, _formatFileName: function (name) { if (name.length > 33) { name = name.slice(0, 19) + '...' + name.slice(-13); } return name; }, _isAllowedExtension: function (fileName) { var ext = (-1 !== fileName.indexOf('.')) ? fileName.replace(/.*[.]/, '').toLowerCase() : ''; var allowed = this._options.allowedExtensions; if (!allowed.length) { return true; } for (var i = 0; i < allowed.length; i++) { if (allowed[i].toLowerCase() == ext) { return true; } } return false; }, _formatSize: function (bytes) { var i = -1; do { bytes = bytes / 1024; i++; } while (bytes > 99); return Math.max(bytes, 0.1).toFixed(1) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i]; } }; qq.FileUploader = function (o) { qq.FileUploaderBasic.apply(this, arguments); qq.extend(this._options, { element: null, listElement: null, template: '
' + '
Drop files here to upload
' + '
Upload a file
' + '
    ' + '
    ', fileTemplate: '
  • ' + '' + '' + '' + 'Cancel' + 'Failed' + '
  • ', classes: { button: 'qq-upload-button', drop: 'qq-upload-drop-area', dropActive: 'qq-upload-drop-area-active', list: 'qq-upload-list', file: 'qq-upload-file', spinner: 'qq-upload-spinner', size: 'qq-upload-size', cancel: 'qq-upload-cancel', success: 'qq-upload-success', fail: 'qq-upload-fail' } }); qq.extend(this._options, o); this._element = this._options.element; this._element.innerHTML = this._options.template; this._listElement = this._options.listElement || this._find(this._element, 'list'); this._classes = this._options.classes; this._button = this._createUploadButton(this._find(this._element, 'button')); this._bindCancelEvent(); this._setupDragDrop(); }; qq.extend(qq.FileUploader.prototype, qq.FileUploaderBasic.prototype); qq.extend(qq.FileUploader.prototype, { _find: function (parent, type) { var element = qq.getByClass(parent, this._options.classes[type])[0]; if (!element) { throw new Error('element not found ' + type); } return element; }, _setupDragDrop: function () { var self = this, dropArea = this._find(this._element, 'drop'); var dz = new qq.UploadDropZone({ element: dropArea, onEnter: function (e) { qq.addClass(dropArea, self._classes.dropActive); e.stopPropagation(); }, onLeave: function (e) { e.stopPropagation(); }, onLeaveNotDescendants: function (e) { qq.removeClass(dropArea, self._classes.dropActive); }, onDrop: function (e) { dropArea.style.display = 'none'; qq.removeClass(dropArea, self._classes.dropActive); self._uploadFileList(e.dataTransfer.files); } }); dropArea.style.display = 'none'; qq.attach(document, 'dragenter', function (e) { if (!dz._isValidFileDrag(e)) return; dropArea.style.display = 'block'; }); qq.attach(document, 'dragleave', function (e) { if (!dz._isValidFileDrag(e)) return; var relatedTarget = document.elementFromPoint(e.clientX, e.clientY); if (!relatedTarget || relatedTarget.nodeName == "HTML") { dropArea.style.display = 'none'; } }); }, _onSubmit: function (id, fileName) { qq.FileUploaderBasic.prototype._onSubmit.apply(this, arguments); this._addToList(id, fileName); }, _onProgress: function (id, fileName, loaded, total) { qq.FileUploaderBasic.prototype._onProgress.apply(this, arguments); var item = this._getItemByFileId(id); var size = this._find(item, 'size'); size.style.display = 'inline'; var text; if (loaded != total) { text = Math.round(loaded / total * 100) + '% from ' + this._formatSize(total); } else { text = this._formatSize(total); } qq.setText(size, text); }, _onComplete: function (id, fileName, result) { qq.FileUploaderBasic.prototype._onComplete.apply(this, arguments); var item = this._getItemByFileId(id); qq.remove(this._find(item, 'cancel')); qq.remove(this._find(item, 'spinner')); if (result.success) { qq.addClass(item, this._classes.success); } else { qq.addClass(item, this._classes.fail); } }, _addToList: function (id, fileName) { var item = qq.toElement(this._options.fileTemplate); item.qqFileId = id; var fileElement = this._find(item, 'file'); qq.setText(fileElement, this._formatFileName(fileName)); this._find(item, 'size').style.display = 'none'; this._listElement.appendChild(item); }, _getItemByFileId: function (id) { var item = this._listElement.firstChild; while (item) { if (item.qqFileId == id) return item; item = item.nextSibling; } }, _bindCancelEvent: function () { var self = this, list = this._listElement; qq.attach(list, 'click', function (e) { e = e || window.event; var target = e.target || e.srcElement; if (qq.hasClass(target, self._classes.cancel)) { qq.preventDefault(e); var item = target.parentNode; self._handler.cancel(item.qqFileId); qq.remove(item); } }); } }); qq.UploadDropZone = function (o) { this._options = { element: null, onEnter: function (e) { }, onLeave: function (e) { }, onLeaveNotDescendants: function (e) { }, onDrop: function (e) { } }; qq.extend(this._options, o); this._element = this._options.element; this._disableDropOutside(); this._attachEvents(); }; qq.UploadDropZone.prototype = { _disableDropOutside: function (e) { if (!qq.UploadDropZone.dropOutsideDisabled) { qq.attach(document, 'dragover', function (e) { if (e.dataTransfer) { e.dataTransfer.dropEffect = 'none'; e.preventDefault(); } }); qq.UploadDropZone.dropOutsideDisabled = true; } }, _attachEvents: function () { var self = this; qq.attach(self._element, 'dragover', function (e) { if (!self._isValidFileDrag(e)) return; var effect = e.dataTransfer.effectAllowed; if (effect == 'move' || effect == 'linkMove') { e.dataTransfer.dropEffect = 'move'; } else { e.dataTransfer.dropEffect = 'copy'; } e.stopPropagation(); e.preventDefault(); }); qq.attach(self._element, 'dragenter', function (e) { if (!self._isValidFileDrag(e)) return; self._options.onEnter(e); }); qq.attach(self._element, 'dragleave', function (e) { if (!self._isValidFileDrag(e)) return; self._options.onLeave(e); var relatedTarget = document.elementFromPoint(e.clientX, e.clientY); if (qq.contains(this, relatedTarget)) return; self._options.onLeaveNotDescendants(e); }); qq.attach(self._element, 'drop', function (e) { if (!self._isValidFileDrag(e)) return; e.preventDefault(); self._options.onDrop(e); }); }, _isValidFileDrag: function (e) { var dt = e.dataTransfer, isWebkit = navigator.userAgent.indexOf("AppleWebKit") > -1; return dt && dt.effectAllowed != 'none' && (dt.files || (!isWebkit && dt.types.contains && dt.types.contains('Files'))); } }; qq.UploadButton = function (o) { this._options = { element: null, multiple: false, name: 'file', onChange: function (input) { }, hoverClass: 'qq-upload-button-hover', focusClass: 'qq-upload-button-focus' }; qq.extend(this._options, o); this._element = this._options.element; qq.css(this._element, { position: 'relative', overflow: 'hidden', direction: 'ltr' }); this._input = this._createInput(); }; qq.UploadButton.prototype = { getInput: function () { return this._input; }, reset: function () { if (this._input.parentNode) { qq.remove(this._input); } qq.removeClass(this._element, this._options.focusClass); this._input = this._createInput(); }, _createInput: function () { var input = document.createElement("input"); if (this._options.multiple) { input.setAttribute("multiple", "multiple"); } input.setAttribute("type", "file"); input.setAttribute("name", this._options.name); qq.css(input, { position: 'absolute', right: 0, top: 0, fontFamily: 'Arial', fontSize: '118px', margin: 0, padding: 0, cursor: 'pointer', opacity: 0 }); this._element.appendChild(input); var self = this; qq.attach(input, 'change', function () { self._options.onChange(input); }); qq.attach(input, 'mouseover', function () { qq.addClass(self._element, self._options.hoverClass); }); qq.attach(input, 'mouseout', function () { qq.removeClass(self._element, self._options.hoverClass); }); qq.attach(input, 'focus', function () { qq.addClass(self._element, self._options.focusClass); }); qq.attach(input, 'blur', function () { qq.removeClass(self._element, self._options.focusClass); }); if (window.attachEvent) { input.setAttribute('tabIndex', "-1"); } return input; } }; qq.UploadHandlerAbstract = function (o) { this._options = { debug: false, action: '/upload.php', maxConnections: 999, onProgress: function (id, fileName, loaded, total) { }, onComplete: function (id, fileName, response) { }, onCancel: function (id, fileName) { } }; qq.extend(this._options, o); this._queue = []; this._params = []; }; qq.UploadHandlerAbstract.prototype = { log: function (str) { if (this._options.debug && window.console) console.log('[uploader] ' + str); }, add: function (file) { }, upload: function (id, params) { var len = this._queue.push(id); var copy = {}; qq.extend(copy, params); this._params[id] = copy; if (len <= this._options.maxConnections) { this._upload(id, this._params[id]); } }, cancel: function (id) { this._cancel(id); this._dequeue(id); }, cancelAll: function () { for (var i = 0; i < this._queue.length; i++) { this._cancel(this._queue[i]); } this._queue = []; }, getName: function (id) { }, getSize: function (id) { }, getQueue: function () { return this._queue; }, _upload: function (id) { }, _cancel: function (id) { }, _dequeue: function (id) { var i = qq.indexOf(this._queue, id); this._queue.splice(i, 1); var max = this._options.maxConnections; if (this._queue.length >= max && i < max) { var nextId = this._queue[max - 1]; this._upload(nextId, this._params[nextId]); } } }; qq.UploadHandlerForm = function (o) { qq.UploadHandlerAbstract.apply(this, arguments); this._inputs = {}; }; qq.extend(qq.UploadHandlerForm.prototype, qq.UploadHandlerAbstract.prototype); qq.extend(qq.UploadHandlerForm.prototype, { add: function (fileInput) { fileInput.setAttribute('name', 'qqfile'); var id = 'qq-upload-handler-iframe' + qq.getUniqueId(); this._inputs[id] = fileInput; if (fileInput.parentNode) { qq.remove(fileInput); } return id; }, getName: function (id) { return this._inputs[id].value.replace(/.*(\/|\\)/, ""); }, _cancel: function (id) { this._options.onCancel(id, this.getName(id)); delete this._inputs[id]; var iframe = document.getElementById(id); if (iframe) { iframe.setAttribute('src', 'javascript:false;'); qq.remove(iframe); } }, _upload: function (id, params) { var input = this._inputs[id]; if (!input) { throw new Error('file with passed id was not added, or already uploaded or cancelled'); } var fileName = this.getName(id); var iframe = this._createIframe(id); var form = this._createForm(iframe, params); form.appendChild(input); var self = this; this._attachLoadEvent(iframe, function () { self.log('iframe loaded'); var response = self._getIframeContentJSON(iframe); self._options.onComplete(id, fileName, response); self._dequeue(id); delete self._inputs[id]; setTimeout(function () { qq.remove(iframe); }, 1); }); form.submit(); qq.remove(form); return id; }, _attachLoadEvent: function (iframe, callback) { qq.attach(iframe, 'load', function () { if (!iframe.parentNode) { return; } if (iframe.contentDocument && iframe.contentDocument.body && iframe.contentDocument.body.innerHTML == "false") { return; } callback(); }); }, _getIframeContentJSON: function (iframe) { var doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document, response; this.log("converting iframe's innerHTML to JSON"); this.log("innerHTML = " + doc.body.innerHTML); try { response = eval("(" + doc.body.innerHTML + ")"); } catch (err) { response = {}; } return response; }, _createIframe: function (id) { var iframe = qq.toElement('