diff --git a/resource/web/css/jquery.filer.css b/resource/web/css/jquery.filer.css new file mode 100755 index 00000000..ead852a6 --- /dev/null +++ b/resource/web/css/jquery.filer.css @@ -0,0 +1,438 @@ +/*! + * CSS jQuery.filer + * Copyright (c) 2015 CreativeDream + * Version: 1.0.5 (19-Nov-2015) +*/ +/*@import url('../assets/fonts/jquery.filer-icons/jquery-filer.css');*/ + +/*------------------------- + Basic configurations +-------------------------*/ +.jFiler * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.jFiler { + font-family: sans-serif; + font-size: 14px; + color: #494949; +} + +/* Helpers */ +.jFiler ul.list-inline li { + display: inline-block; + padding-right: 5px; + padding-left: 5px; +} + +.jFiler .pull-left { + float: left; +} + +.jFiler .pull-right { + float: right; +} + +/* File Icons */ +span.jFiler-icon-file { + position: relative; + width: 57px; + height: 70px; + display: inline-block; + line-height: 70px; + text-align: center; + border-radius: 3px; + color: #fff; + font-family: sans-serif; + font-size: 13px; + font-weight: bold; + overflow: hidden; + box-shadow: 42px -55px 0 0 #A4A7AC inset; +} + +span.jFiler-icon-file:after { + position: absolute; + top: -1px; + right: -1px; + display: inline-block; + content: ''; + border-style: solid; + border-width: 16px 0 0 16px; + border-color: transparent transparent transparent #DADDE1; +} + +span.jFiler-icon-file i[class*="icon-jfi-"] { + font-size: 24px; +} + +span.jFiler-icon-file.f-image { + box-shadow: 42px -55px 0 0 #e15955 inset; +} + +span.jFiler-icon-file.f-image:after { + border-left-color: #c6393f; +} + +span.jFiler-icon-file.f-video { + box-shadow: 42px -55px 0 0 #4183d7 inset; +} + +span.jFiler-icon-file.f-video:after { + border-left-color: #446cb3; +} + +span.jFiler-icon-file.f-audio { + box-shadow: 42px -55px 0 0 #5bab6e inset; +} + +span.jFiler-icon-file.f-audio:after { + border-left-color: #448353; +} + + +/* Progress Bar */ +.jFiler-jProgressBar { + height: 8px; + background: #f1f1f1; + margin-top: 3px; + margin-bottom: 0; + overflow: hidden; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.jFiler-jProgressBar .bar { + float: left; + width: 0; + height: 100%; + font-size: 12px; + color: #ffffff; + text-align: center; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); + background-color: #50A1E9; + box-sizing: border-box; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + -webkit-transition: width 0.3s ease; + -moz-transition: width 0.3s ease; + -o-transition: width 0.3s ease; + transition: width 0.3s ease; +} + +.jFiler-jProgressBar .bar.dark { + background-color: #555; +} + +.jFiler-jProgressBar .bar.blue { + background-color: #428bca; +} + +.jFiler-jProgressBar .bar.green { + background-color: #5cb85c; +} + +.jFiler-jProgressBar .bar.orange { + background-color: #f7a923; +} + +.jFiler-jProgressBar .bar.red { + background-color: #d9534f; +} + +/* Thumbs */ +.jFiler-row:after, +.jFiler-item:after { + display: table; + line-height: 0; + content: ""; + clear: both; +} + +.jFiler-items ul { + margin: 0; + padding: 0; + list-style: none; +} + +/*------------------------- + Default Theme +-------------------------*/ +.jFiler-theme-default .jFiler-input { + position: relative; + display: block; + width: 400px; + height: 35px; + margin: 0 0 15px 0; + background: #fefefe; + border: 1px solid #cecece; + font-size: 12px; + font-family: sans-serif; + color: #888; + border-radius: 4px; + cursor: pointer; + overflow: hidden; + -webkit-box-shadow: rgba(0,0,0,.25) 0 4px 5px -5px inset; + -moz-box-shadow: rgba(0,0,0,.25) 0 4px 5px -5px inset; + box-shadow: rgba(0,0,0,.25) 0 4px 5px -5px inset; +} + +.jFiler-theme-default .jFiler-input.focused { + outline: none; + -webkit-box-shadow: 0 0 7px rgba(0,0,0,0.1); + -moz-box-shadow: 0 0 7px rgba(0,0,0,0.1); + box-shadow: 0 0 7px rgba(0,0,0,0.1); +} + +.jFiler-theme-default .jFiler.dragged .jFiler-input { + border: 1px dashed #aaaaaa; + background: #f9f9f9; +} + +.jFiler-theme-default .jFiler.dragged .jFiler-input:hover { + background: #FFF8D0; +} + +.jFiler-theme-default .jFiler.dragged .jFiler-input * { + pointer-events: none; +} + +.jFiler-theme-default .jFiler.dragged .jFiler-input .jFiler-input-caption { + width: 100%; + text-align: center; +} + +.jFiler-theme-default .jFiler.dragged .jFiler-input .jFiler-input-button { + display: none; +} + +.jFiler-theme-default .jFiler-input-caption { + display: block; + float: left; + height: 100%; + padding-top: 8px; + padding-left: 10px; + text-overflow: ellipsis; + overflow: hidden; +} + +.jFiler-theme-default .jFiler-input-button { + display: block; + float: right; + height: 100%; + padding-top: 8px; + padding-left: 15px; + padding-right: 15px; + border-left: 1px solid #ccc; + color: #666666; + text-align: center; + background-color: #fefefe; + background-image: -webkit-gradient(linear,0 0,0 100%,from(#fefefe),to(#f1f1f1)); + background-image: -webkit-linear-gradient(top,#fefefe,#f1f1f1); + background-image: -o-linear-gradient(top,#fefefe,#f1f1f1); + background-image: linear-gradient(to bottom,#fefefe,#f1f1f1); + background-image: -moz-linear-gradient(top,#fefefe,#f1f1f1); + -webkit-transition: all .1s ease-out; + -moz-transition: all .1s ease-out; + -o-transition: all .1s ease-out; + transition: all .1s ease-out; +} + +.jFiler-theme-default .jFiler-input-button:hover { + -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.07); + -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.07); + box-shadow: inset 0 0 10px rgba(0,0,0,0.07); +} + +.jFiler-theme-default .jFiler-input-button:active { + background-image: -webkit-gradient(linear,0 0,0 100%,from(#f1f1f1),to(#fefefe)); + background-image: -webkit-linear-gradient(top,#f1f1f1,#fefefe); + background-image: -o-linear-gradient(top,#f1f1f1,#fefefe); + background-image: linear-gradient(to bottom,#f1f1f1,#fefefe); + background-image: -moz-linear-gradient(top,#f1f1f1,#fefefe); +} + +/*------------------------- + Thumbnails +-------------------------*/ +.jFiler-items-default .jFiler-items { + +} + +.jFiler-items-default .jFiler-item { + position: relative; + padding: 16px; + margin-bottom: 16px; + background: #f7f7f7; + color: #4d4d4c; +} + + +.jFiler-items-default .jFiler-item .jFiler-item-icon { + font-size: 32px; + color: #f5871f; + + margin-right: 15px; + margin-top: -3px; +} + +.jFiler-items-default .jFiler-item .jFiler-item-title { + font-weight: bold; +} + +.jFiler-items-default .jFiler-item .jFiler-item-others { + font-size: 12px; + color: #777; + margin-left: -5px; + margin-right: -5px; +} + +.jFiler-items-default .jFiler-item .jFiler-item-others span { + padding-left: 5px; + padding-right: 5px; +} + +.jFiler-items-default .jFiler-item-assets { + position: absolute; + display: block; + right: 16px; + top: 50%; + margin-top: -10px; +} + +.jFiler-items-default .jFiler-item-assets a { + padding: 8px 9px 8px 12px; + cursor: pointer; + background: #fafafa; + color: #777; + border-radius: 4px; + border: 1px solid #e3e3e3 +} + +.jFiler-items-default .jFiler-item-assets .jFiler-item-trash-action:hover, +.jFiler-items-default .jFiler-item-assets .jFiler-item-trash-action:active { + color: #d9534f; +} + +.jFiler-items-default .jFiler-item-assets .jFiler-item-trash-action:active { + background: transparent; +} + +/* Thumbnails: Grid */ +.jFiler-items-grid .jFiler-item { + float: left; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container { + position: relative; + margin: 0 20px 30px 0; + padding: 10px; + border: 1px solid #e1e1e1; + border-radius: 3px; + background: #fff; + -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.06); + -moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.06); + box-shadow: 0px 0px 3px rgba(0,0,0,0.06); +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-thumb { + position: relative; + width: 160px; + height: 115px; + min-height: 115px; + border: 1px solid #e1e1e1; + overflow: hidden; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-thumb .jFiler-item-thumb-image { + width: 100%; + height: 100%; + text-align: center; +} + +.jFiler-item .jFiler-item-container .jFiler-item-thumb img { + max-width: none; + max-height: 100%; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-thumb span.jFiler-icon-file { + margin-top: 20px; +} + +.jFiler-items-grid .jFiler-item-thum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MPExMSgSSdKmQvBAgIOqwoAgeKkDopBgMiMbOutCgGSLe8IlIeSKbBI1LAKCEAIfkEBQQAHgAsAAAAAAEAAQAABQOgFwIAIfkEBQQAHgAsAAAAAAEAAQAABQOgFwIAIfkECQQAHgAsAAAAACMAIwAABbWgJ45kaZ5oqq5s675wLM90baPBvS6MTgoKgqjxEBEihZuAsRAxHKJHJXk7NAwBB8RzsPRqBYFo4RgkFALKxMhAxAiKBdXtAXgah4Eis2nIBgcLCSgVGxMKNYAoD4MzAgI5KgQHCAhULQUKmgmRJgUaIhwWLwIEBQQDKQEKDxEQCXYxnSUBcjapKAIcHUg+JgkUHRx+YB6zIw4YEMc2QiMBzDB0HgbGvifR19rb3N3e3+Dh4ikhADs=') no-repeat center; + width: 100%; + height: 100%; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-info { + position: absolute; + bottom: -10%; + left: 0; + width: 100%; + color: #fff; + padding: 6px 10px; + background: -moz-linear-gradient(bottom,rgba(0,0,0,1) 0,rgba(0,0,0,0) 100%); + background: -webkit-linear-gradient(bottom,rgba(0,0,0,1) 0,rgba(0,0,0,0) 100%); + background: -o-linear-gradient(bottom,rgba(0,0,0,1) 0,rgba(0,0,0,0) 100%); + background: -ms-linear-gradient(bottom,rgba(0,0,0,1) 0,rgba(0,0,0,0) 100%); + background: linear-gradient(to top,rgba(0,0,0,1) 0,rgba(0,0,0,0) 100%); + z-index: 9; + opacity: 0; + filter: alpha(opacity(0)); + -webkit-transition: all 0.12s; + -moz-transition: all 0.12s; + transition: all 0.12s; +} + +.jFiler-items-grid .jFiler-no-thumbnail.jFiler-item .jFiler-item-container .jFiler-item-info { + background: rgba(0,0,0,0.55); +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-thumb:hover .jFiler-item-info { + bottom: 0; + opacity: 1; + filter: aplpha(opacity(100)); +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-info .jFiler-item-title { + display: block; + font-weight: bold; + word-break: break-all; + line-height: 1; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-info .jFiler-item-others { + display: inline-block; + font-size: 10px; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-assets { + margin-top: 10px; + color: #999; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-assets .text-success { + color: #3C763D +} + +.jFiler-items-grid .jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-assets .text-error { + color: #A94442 +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-assets .jFiler-jProgressBar { + width: 120px; + margin-left: -5px; +} + +.jFiler-items-grid .jFiler-item .jFiler-item-container .jFiler-item-assets .jFiler-item-others { + font-size: 12px; +} + +.jFiler-items-grid .jFiler-item-trash-action:hover { + cursor: pointer; + color: #d9534f; +} \ No newline at end of file diff --git a/resource/web/js/jquery.filer.js b/resource/web/js/jquery.filer.js new file mode 100755 index 00000000..c8a292ef --- /dev/null +++ b/resource/web/js/jquery.filer.js @@ -0,0 +1,991 @@ +/*! + * jQuery.filer + * Copyright (c) 2015 CreativeDream + * Website: https://github.com/CreativeDream/jquery.filer + * Version: 1.0.5 (19-Nov-2015) + * Requires: jQuery v1.7.1 or later + */ +(function($) { + "use strict"; + $.fn.filer = function(q) { + return this.each(function(t, r) { + var s = $(r), + b = '.jFiler', + p = $(), + o = $(), + l = $(), + sl = [], + n_f = $.isFunction(q) ? q(s, $.fn.filer.defaults) : q, + n = n_f && $.isPlainObject(n_f) ? $.extend(true, {}, $.fn.filer.defaults, n_f) : $.fn.filer.defaults, + f = { + init: function() { + s.wrap('
'); + f._set('props'); + s.prop("jFiler").boxEl = p = s.closest(b); + f._changeInput(); + }, + _bindInput: function() { + if(n.changeInput && o.size() > 0) { + o.bind("click", f._clickHandler); + } + s.on({ + "focus": function() { + o.addClass('focused'); + }, + "blur": function() { + o.removeClass('focused'); + }, + "change": function() { + f._onChange(); + } + }); + if(n.dragDrop) { + (o.length > 0 ? o : s) + .bind("drop", f._dragDrop.drop) + .bind("dragover", f._dragDrop.dragEnter) + .bind("dragleave", f._dragDrop.dragLeave); + } + if(n.uploadFile && n.clipBoardPaste) { + $(window) + .on("paste", f._clipboardPaste); + } + }, + _unbindInput: function() { + if(n.changeInput && o.size() > 0) { + o.unbind("click", f._clickHandler); + } + }, + _clickHandler: function() { + s.click() + }, + _applyAttrSettings: function() { + var d = ["name", "limit", "maxSize", "extensions", "changeInput", "showThumbs", "appendTo", "theme", "addMore", "excludeName", "files", "uploadUrl", "uploadData", "options"]; + for(var k in d) { + var j = "data-jfiler-" + d[k]; + if(f._assets.hasAttr(j)) { + switch(d[k]) { + case "changeInput": + case "showThumbs": + case "addMore": + n[d[k]] = (["true", "false"].indexOf(s.attr(j)) > -1 ? s.attr(j) == "true" : s.attr(j)); + break; + case "extensions": + n[d[k]] = s.attr(j) + .replace(/ /g, '') + .split(","); + break; + case "uploadUrl": + if(n.uploadFile) n.uploadFile.url = s.attr(j); + break; + case "uploadData": + if(n.uploadFile) n.uploadFile.data = JSON.parse(s.attr(j)); + break; + case "files": + case "options": + n[d[k]] = JSON.parse(s.attr(j)); + break; + default: + n[d[k]] = s.attr(j); + } + s.removeAttr(j); + } + } + }, + _changeInput: function() { + f._applyAttrSettings(); + n.beforeRender != null && typeof n.beforeRender == "function" ? n.beforeRender(p, s) : null; + if(n.theme) { + p.addClass('jFiler-theme-' + n.theme); + } + if(s.get(0) + .tagName.toLowerCase() != "input" && s.get(0) + .type != "file") { + o = s; + s = $(""); + s.css({ + position: "absolute", + left: "-9999px", + top: "-9999px", + "z-index": "-9999" + }); + p.prepend(s); + f._isGn = s; + } else { + if(n.changeInput) { + switch(typeof n.changeInput) { + case "boolean": + o = $('
' + n.captions.feedback + '
' + n.captions.button + '
"'); + break; + case "string": + case "object": + o = $(n.changeInput); + break; + case "function": + o = $(n.changeInput(p, s, n)); + break; + } + s.after(o); + s.css({ + position: "absolute", + left: "-9999px", + top: "-9999px", + "z-index": "-9999" + }); + } + } + s.prop("jFiler").newInputEl = o; + if(!n.limit || (n.limit && n.limit >= 2)) { + s.attr("multiple", "multiple"); + s.attr("name") + .slice(-2) != "[]" ? s.attr("name", s.attr("name") + "[]") : null; + } + f._bindInput(); + if(n.files) { + f._append(false, { + files: n.files + }); + } + n.afterRender != null && typeof n.afterRender == "function" ? n.afterRender(l, p, o, s) : null; + }, + _clear: function() { + f.files = null; + s.prop("jFiler") + .files = null; + if(!n.uploadFile && !n.addMore) { + f._reset(); + } + f._set('feedback', (f._itFl && f._itFl.length > 0 ? f._itFl.length + ' ' + n.captions.feedback2 : n.captions.feedback)); + n.onEmpty != null && typeof n.onEmpty == "function" ? n.onEmpty(p, o, s) : null + }, + _reset: function(a) { + if(!a) { + if(!n.uploadFile && n.addMore) { + for(var i = 0; i < sl.length; i++) { + sl[i].remove(); + } + sl = []; + f._unbindInput(); + if(f._isGn) { + s = f._isGn; + } else { + s = $(r); + } + f._bindInput(); + } + f._set('input', ''); + } + f._itFl = []; + f._itFc = null; + f._ajFc = 0; + f._set('props'); + s.prop("jFiler") + .files_list = f._itFl; + s.prop("jFiler") + .current_file = f._itFc; + if(!f._prEr) { + f._itFr = []; + p.find("input[name^='jfiler-items-exclude-']:hidden") + .remove(); + } + l.fadeOut("fast", function() { + $(this) + .remove(); + }); + s.prop("jFiler").listEl = l = $(); + }, + _set: function(element, value) { + switch(element) { + case 'input': + s.val(""); + break; + case 'feedback': + if(o.length > 0) { + o.find('.jFiler-input-caption span') + .html(value); + } + break; + case 'props': + if(!s.prop("jFiler")){ + s.prop("jFiler", { + options: n, + listEl: l, + boxEl: p, + newInputEl: o, + inputEl: s, + files: f.files, + files_list: f._itFl, + current_file: f._itFc, + append: function(data) { + return f._append(false, { + files: [data] + }); + }, + remove: function(id) { + f._remove(null, { + binded: true, + data: { + id: id + } + }); + return true; + }, + reset: function() { + f._reset(); + f._clear(); + return true; + }, + retry: function(data) { + return f._retryUpload(data); + } + }) + } + } + }, + _filesCheck: function() { + var s = 0; + if(n.limit && f.files.length + f._itFl.length > n.limit) { + alert(f._assets.textParse(n.captions.errors.filesLimit)); + return false + } + for(var t = 0; t < f.files.length; t++) { + var x = f.files[t].name.split(".") + .pop() + .toLowerCase(), + file = f.files[t], + m = { + name: file.name, + size: file.size, + size2: f._assets.bytesToSize(file.size), + type: file.type, + ext: x + }; + if(n.extensions != null && $.inArray(x, n.extensions) == -1) { + alert(f._assets.textParse(n.captions.errors.filesType, m)); + return false; + break + } + if(n.maxSize != null && f.files[t].size > n.maxSize * 1048576) { + alert(f._assets.textParse(n.captions.errors.filesSize, m)); + return false; + break + } + if(file.size == 4096 && file.type.length == 0) { + return false; + break + } + s += f.files[t].size + } + if(n.maxSize != null && s >= Math.round(n.maxSize * 1048576)) { + alert(f._assets.textParse(n.captions.errors.filesSizeAll)); + return false + } + if((n.addMore || n.uploadFile)) { + var m = f._itFl.filter(function(a, b) { + if(a.file.name == file.name && a.file.size == file.size && a.file.type == file.type && (file.lastModified ? a.file.lastModified == file.lastModified : true)) { + return true; + } + }); + if(m.length > 0) { + return false + } + } + return true; + }, + _thumbCreator: { + create: function(i) { + var file = f.files[i], + id = (f._itFc ? f._itFc.id : i), + name = file.name, + size = file.size, + type = file.type.split("/", 1) + .toString() + .toLowerCase(), + ext = name.indexOf(".") != -1 ? name.split(".") + .pop() + .toLowerCase() : "", + progressBar = n.uploadFile ? '
' + n.templates.progressBar + '
' : '', + opts = { + id: id, + name: name, + size: size, + size2: f._assets.bytesToSize(size), + type: type, + extension: ext, + icon: f._assets.getIcon(ext, type), + icon2: f._thumbCreator.generateIcon({ + type: type, + extension: ext + }), + image: '
', + progressBar: progressBar, + _appended: file._appended + }, + html = ""; + if(file.opts) { + opts = $.extend({}, file.opts, opts); + } + html = $(f._thumbCreator.renderContent(opts)) + .attr("data-jfiler-index", id); + html.get(0) + .jfiler_id = id; + f._thumbCreator.renderFile(file, html, opts); + if(file.forList) { + return html; + } + f._itFc.html = html; + html.hide()[n.templates.itemAppendToEnd ? "appendTo" : "prependTo"](l.find(n.templates._selectors.list)) + .show(); + if(!file._appended) { + f._onSelect(i); + } + }, + renderContent: function(opts) { + return f._assets.textParse((opts._appended ? n.templates.itemAppend : n.templates.item), opts); + }, + renderFile: function(file, html, opts) { + if(html.find('.jFiler-item-thumb-image') + .size() == 0) { + return false; + } + if(file.file && opts.type == "image") { + var g = '', + m = html.find('.jFiler-item-thumb-image.fi-loading'); + $(g) + .error(function() { + g = f._thumbCreator.generateIcon(opts); + html.addClass('jFiler-no-thumbnail'); + m.removeClass('fi-loading') + .html(g); + }) + .load(function() { + m.removeClass('fi-loading') + .html(g); + }); + return true; + } + if(window.File && window.FileList && window.FileReader && opts.type == "image" && opts.size < 6e+6) { + var y = new FileReader; + y.onload = function(e) { + var g = '', + m = html.find('.jFiler-item-thumb-image.fi-loading'); + $(g) + .error(function() { + g = f._thumbCreator.generateIcon(opts); + html.addClass('jFiler-no-thumbnail'); + m.removeClass('fi-loading') + .html(g); + }) + .load(function() { + m.removeClass('fi-loading') + .html(g); + }); + }; + y.readAsDataURL(file); + } else { + var g = f._thumbCreator.generateIcon(opts), + m = html.find('.jFiler-item-thumb-image.fi-loading'); + html.addClass('jFiler-no-thumbnail'); + m.removeClass('fi-loading') + .html(g); + } + }, + generateIcon: function(obj) { + var m = new Array(3); + if(obj && obj.type && obj.extension) { + switch(obj.type) { + case "image": + m[0] = "f-image"; + m[1] = "" + break; + case "video": + m[0] = "f-video"; + m[1] = "" + break; + case "audio": + m[0] = "f-audio"; + m[1] = "" + break; + default: + m[0] = "f-file f-file-ext-" + obj.extension; + m[1] = (obj.extension.length > 0 ? "." + obj.extension : ""); + m[2] = 1 + } + } else { + m[0] = "f-file"; + m[1] = (obj.extension && obj.extension.length > 0 ? "." + obj.extension : ""); + m[2] = 1 + } + var el = '' + m[1] + ''; + if(m[2] == 1) { + var c = f._assets.text2Color(obj.extension); + if(c) { + var j = $(el) + .appendTo("body"), + h = j.css("box-shadow"); + h = c + h.substring(h.replace(/^.*(rgba?\([^)]+\)).*$/, '$1') + .length, h.length); + j.css({ + '-webkit-box-shadow': h, + '-moz-box-shadow': h, + 'box-shadow': h + }) + .attr('style', '-webkit-box-shadow: ' + h + '; -moz-box-shadow: ' + h + '; box-shadow: ' + h + ';'); + el = j.prop('outerHTML'); + j.remove(); + } + } + return el; + }, + _box: function(params) { + if(n.beforeShow != null && typeof n.beforeShow == "function" ? !n.beforeShow(f.files, l, p, o, s) : false) { + return false + } + if(l.length < 1) { + if(n.appendTo) { + var appendTo = $(n.appendTo); + } else { + var appendTo = p; + } + appendTo.find('.jFiler-items') + .remove(); + l = $('
'); + s.prop("jFiler").listEl = l; + l.append(f._assets.textParse(n.templates.box)) + .appendTo(appendTo); + l.on('click', n.templates._selectors.remove, function(e) { + e.preventDefault(); + var cf = n.templates.removeConfirmation ? confirm(n.captions.removeConfirmation) : true; + if(cf) { + f._remove(params ? params.remove.event : e, params ? params.remove.el : $(this) + .closest(n.templates._selectors.item)); + } + }); + } + for(var i = 0; i < f.files.length; i++) { + if(!f.files[i]._appended) f.files[i]._choosed = true; + f._addToMemory(i); + f._thumbCreator.create(i); + } + } + }, + _upload: function(i) { + var el = f._itFc.html, + formData = new FormData(); + formData.append(s.attr('name'), f._itFc.file, (f._itFc.file.name ? f._itFc.file.name : false)); + if(n.uploadFile.data != null && $.isPlainObject(n.uploadFile.data)) { + for(var k in n.uploadFile.data) { + formData.append(k, n.uploadFile.data[k]) + } + } + f._ajax.send(el, formData, f._itFc); + }, + _ajax: { + send: function(el, formData, c) { + c.ajax = $.ajax({ + url: n.uploadFile.url, + data: formData, + type: n.uploadFile.type, + enctype: n.uploadFile.enctype, + xhr: function() { + var myXhr = $.ajaxSettings.xhr(); + if(myXhr.upload) { + myXhr.upload.addEventListener("progress", function(e) { + f._ajax.progressHandling(e, el) + }, false) + } + return myXhr + }, + complete: function(jqXHR, textStatus) { + c.ajax = false; + f._ajFc++; + if(f._ajFc >= f.files.length) { + f._ajFc = 0; + n.uploadFile.onComplete != null && typeof n.uploadFile.onComplete == "function" ? n.uploadFile.onComplete(l, p, o, s, jqXHR, textStatus) : null; + } + }, + beforeSend: function(jqXHR, settings) { + return n.uploadFile.beforeSend != null && typeof n.uploadFile.beforeSend == "function" ? n.uploadFile.beforeSend(el, l, p, o, s, c.id, jqXHR, settings) : true; + }, + success: function(data, textStatus, jqXHR) { + c.uploaded = true; + n.uploadFile.success != null && typeof n.uploadFile.success == "function" ? n.uploadFile.success(data, el, l, p, o, s, c.id, textStatus, jqXHR) : null + }, + error: function(jqXHR, textStatus, errorThrown) { + c.uploaded = false; + n.uploadFile.error != null && typeof n.uploadFile.error == "function" ? n.uploadFile.error(el, l, p, o, s, c.id, jqXHR, textStatus, errorThrown) : null + }, + statusCode: n.uploadFile.statusCode, + cache: false, + contentType: false, + processData: false + }); + return c.ajax; + }, + progressHandling: function(e, el) { + if(e.lengthComputable) { + var t = Math.round(e.loaded * 100 / e.total) + .toString(); + n.uploadFile.onProgress != null && typeof n.uploadFile.onProgress == "function" ? n.uploadFile.onProgress(t, el, l, p, o, s) : null; + el.find('.jFiler-jProgressBar') + .find(n.templates._selectors.progressBar) + .css("width", t + "%") + } + } + }, + _dragDrop: { + dragEnter: function(e) { + e.preventDefault(); + e.stopPropagation(); + p.addClass('dragged'); + f._set('feedback', n.captions.drop); + n.dragDrop.dragEnter != null && typeof n.dragDrop.dragEnter == "function" ? n.dragDrop.dragEnter(e, o, s, p) : null; + }, + dragLeave: function(e) { + e.preventDefault(); + e.stopPropagation(); + if(!f._dragDrop._dragLeaveCheck(e)) { + return false + } + p.removeClass('dragged'); + f._set('feedback', n.captions.feedback); + n.dragDrop.dragLeave != null && typeof n.dragDrop.dragLeave == "function" ? n.dragDrop.dragLeave(e, o, s, p) : null; + }, + drop: function(e) { + e.preventDefault(); + p.removeClass('dragged'); + f._set('feedback', n.captions.feedback); + if(e && e.originalEvent && e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files && e.originalEvent.dataTransfer.files.length > 0) { + f._onChange(e, e.originalEvent.dataTransfer.files); + } + n.dragDrop.drop != null && typeof n.dragDrop.drop == "function" ? n.dragDrop.drop(e.originalEvent.dataTransfer.files, e, o, s, p) : null; + }, + _dragLeaveCheck: function(e) { + var related = e.relatedTarget, + inside = false; + if(related !== o) { + if(related) { + inside = $.contains(o, related); + } + if(inside) { + return false; + } + } + return true; + } + }, + _clipboardPaste: function(e, fromDrop) { + if(!fromDrop && (!e.originalEvent.clipboardData && !e.originalEvent.clipboardData.items)) { + return + } + if(fromDrop && (!e.originalEvent.dataTransfer && !e.originalEvent.dataTransfer.items)) { + return + } + if(f._clPsePre) { + return + } + var items = (fromDrop ? e.originalEvent.dataTransfer.items : e.originalEvent.clipboardData.items), + b64toBlob = function(b64Data, contentType, sliceSize) { + contentType = contentType || ''; + sliceSize = sliceSize || 512; + var byteCharacters = atob(b64Data); + var byteArrays = []; + for(var offset = 0; offset < byteCharacters.length; offset += sliceSize) { + var slice = byteCharacters.slice(offset, offset + sliceSize); + var byteNumbers = new Array(slice.length); + for(var i = 0; i < slice.length; i++) { + byteNumbers[i] = slice.charCodeAt(i); + } + var byteArray = new Uint8Array(byteNumbers); + byteArrays.push(byteArray); + } + var blob = new Blob(byteArrays, { + type: contentType + }); + return blob; + }; + if(items) { + for(var i = 0; i < items.length; i++) { + if(items[i].type.indexOf("image") !== -1 || items[i].type.indexOf("text/uri-list") !== -1) { + if(fromDrop) { + try { + window.atob(e.originalEvent.dataTransfer.getData("text/uri-list") + .toString() + .split(',')[1]); + } catch(e) { + return; + } + } + var blob = (fromDrop ? b64toBlob(e.originalEvent.dataTransfer.getData("text/uri-list") + .toString() + .split(',')[1], "image/png") : items[i].getAsFile()); + blob.name = Math.random() + .toString(36) + .substring(5); + blob.name += blob.type.indexOf("/") != -1 ? "." + blob.type.split("/")[1].toString() + .toLowerCase() : ".png"; + f._onChange(e, [blob]); + f._clPsePre = setTimeout(function() { + delete f._clPsePre + }, 1000); + } + } + } + }, + _onSelect: function(i) { + if(n.uploadFile && !$.isEmptyObject(n.uploadFile)) { + f._upload(i) + } + n.onSelect != null && typeof n.onSelect == "function" ? n.onSelect(f.files[i], f._itFc.html, l, p, o, s) : null; + if(i + 1 >= f.files.length) { + n.afterShow != null && typeof n.afterShow == "function" ? n.afterShow(l, p, o, s) : null + } + }, + _onChange: function(e, d) { + if(!d) { + if(!s.get(0) + .files || typeof s.get(0) + .files == "undefined" || s.get(0) + .files.length == 0) { + if(!n.uploadFile && !n.addMore) { + f._set('input', ''); + f._clear(); + } + return false + } + f.files = s.get(0) + .files; + } else { + if(!d || d.length == 0) { + f._set('input', ''); + f._clear(); + return false + } + f.files = d; + } + if(!n.uploadFile && !n.addMore) { + f._reset(true); + } + s.prop("jFiler") + .files = f.files; + if(!f._filesCheck() || (n.beforeSelect != null && typeof n.beforeSelect == "function" ? !n.beforeSelect(f.files, l, p, o, s) : false)) { + f._set('input', ''); + f._clear(); + return false + } + f._set('feedback', f.files.length + f._itFl.length + ' ' + n.captions.feedback2); + if(n.showThumbs) { + f._thumbCreator._box(); + } else { + for(var i = 0; i < f.files.length; i++) { + f.files[i]._choosed = true; + f._addToMemory(i); + f._onSelect(i); + } + } + if(!n.uploadFile && n.addMore) { + var elem = $(''); + var attributes = s.prop("attributes"); + $.each(attributes, function() { + elem.attr(this.name, this.value); + }); + s.after(elem); + f._unbindInput(); + sl.push(elem); + s = elem; + f._bindInput(); + f._set('props'); + } + }, + _append: function(e, data) { + var files = (!data ? false : data.files); + if(!files || files.length <= 0) { + return; + } + f.files = files; + s.prop("jFiler") + .files = f.files; + if(n.showThumbs) { + for(var i = 0; i < f.files.length; i++) { + f.files[i]._appended = true; + } + f._thumbCreator._box(); + } + }, + _getList: function(e, data) { + var files = (!data ? false : data.files); + if(!files || files.length <= 0) { + return; + } + f.files = files; + s.prop("jFiler") + .files = f.files; + if(n.showThumbs) { + var returnData = []; + for(var i = 0; i < f.files.length; i++) { + f.files[i].forList = true; + returnData.push(f._thumbCreator.create(i)); + } + if(data.callback) { + data.callback(returnData, l, p, o, s); + } + } + }, + _retryUpload: function(e, data) { + var id = parseInt(typeof data == "object" ? data.attr("data-jfiler-index") : data), + obj = f._itFl.filter(function(value, key) { + return value.id == id; + }); + if(obj.length > 0) { + if(n.uploadFile && !$.isEmptyObject(n.uploadFile) && !obj[0].uploaded) { + f._itFc = obj[0]; + s.prop("jFiler") + .current_file = f._itFc; + f._upload(id); + return true; + } + } else { + return false; + } + }, + _remove: function(e, el) { + if(el.binded) { + if(typeof(el.data.id) != "undefined") { + el = l.find(n.templates._selectors.item + "[data-jfiler-index='" + el.data.id + "']"); + if(el.size() == 0) { + return false + } + } + if(el.data.el) { + el = el.data.el; + } + } + var attrId = el.get(0) + .jfiler_id || el.attr('data-jfiler-index'), + id = null, + excl_input = function(id) { + var input = p.find("input[name^='jfiler-items-exclude-']:hidden") + .first(), + item = f._itFl[id], + val = []; + if(input.size() == 0) { + input = $(''); + input.appendTo(p); + } + if(item.file._choosed || item.file._appended || item.uploaded) { + f._prEr = true; + f._itFr.push(item); + if(n.addMore) { + var current_input = item.input, + count_same_input = 0; + f._itFl.filter(function(val, index) { + if(val.file._choosed && val.input.get(0) == current_input.get(0)) count_same_input++; + }); + if(count_same_input == 1) { + f._itFr = f._itFr.filter(function(val, index) { + return val.file._choosed ? val.input.get(0) != current_input.get(0) : true; + }); + current_input.val(""); + f._prEr = false; + } + } + for(var i = 0; i < f._itFr.length; i++) { + val.push(f._itFr[i].file.name); + } + val = JSON.stringify(val); + input.val(val); + } + }, + callback = function(el, id) { + excl_input(id); + f._itFl.splice(id, 1); + if(f._itFl.length < 1) { + f._reset(); + f._clear(); + } else { + f._set('feedback', f._itFl.length + ' ' + n.captions.feedback2); + } + el.fadeOut("fast", function() { + $(this) + .remove(); + }); + }; + for(var key in f._itFl) { + if(key === 'length' || !f._itFl.hasOwnProperty(key)) continue; + if(f._itFl[key].id == attrId) { + id = key; + } + } + if(!f._itFl.hasOwnProperty(id)) { + return false + } + if(f._itFl[id].ajax) { + f._itFl[id].ajax.abort(); + callback(el, id); + return; + } + n.onRemove != null && typeof n.onRemove == "function" ? n.onRemove(el, f._itFl[id].file, id, l, p, o, s) : null; + callback(el, id); + }, + _addToMemory: function(i) { + f._itFl.push({ + id: f._itFl.length, + file: f.files[i], + html: $(), + ajax: false, + uploaded: false, + }); + if(n.addMore && !f.files[i]._appended) f._itFl[f._itFl.length - 1].input = s; + f._itFc = f._itFl[f._itFl.length - 1]; + s.prop("jFiler") + .files_list = f._itFl; + s.prop("jFiler") + .current_file = f._itFc; + }, + _assets: { + bytesToSize: function(bytes) { + if(bytes == 0) return '0 Byte'; + var k = 1000; + var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + var i = Math.floor(Math.log(bytes) / Math.log(k)); + return(bytes / Math.pow(k, i)) + .toPrecision(3) + ' ' + sizes[i]; + }, + hasAttr: function(attr, el) { + var el = (!el ? s : el), + a = el.attr(attr); + if(!a || typeof a == "undefined") { + return false; + } else { + return true; + } + }, + getIcon: function(ext, type) { + var types = ["audio", "image", "text", "video"]; + if($.inArray(type, types) > -1) { + return ''; + } + return ''; + }, + textParse: function(text, opts) { + opts = $.extend({}, { + limit: n.limit, + maxSize: n.maxSize, + extensions: n.extensions ? n.extensions.join(',') : null, + }, (opts && $.isPlainObject(opts) ? opts : {}), n.options); + switch(typeof(text)) { + case "string": + return text.replace(/\{\{fi-(.*?)\}\}/g, function(match, a) { + a = a.replace(/ /g, ''); + if(a.match(/(.*?)\|limitTo\:(\d+)/)) { + return a.replace(/(.*?)\|limitTo\:(\d+)/, function(match, a, b) { + var a = (opts[a] ? opts[a] : ""), + str = a.substring(0, b); + str = (a.length > str.length ? str.substring(0, str.length - 3) + "..." : str); + return str; + }); + } else { + return(opts[a] ? opts[a] : ""); + } + }); + break; + case "function": + return text(opts); + break; + default: + return text; + } + }, + text2Color: function(str) { + if(!str || str.length == 0) { + return false + } + for(var i = 0, hash = 0; i < str.length; hash = str.charCodeAt(i++) + ((hash << 5) - hash)); + for(var i = 0, colour = "#"; i < 3; colour += ("00" + ((hash >> i++ * 2) & 0xFF) + .toString(16)) + .slice(-2)); + return colour; + } + }, + files: null, + _itFl: [], + _itFc: null, + _itFr: [], + _ajFc: 0, + _prEr: false + } + + s.on("filer.append", function(e, data) { + f._append(e, data) + }).on("filer.remove", function(e, data) { + data.binded = true; + f._remove(e, data); + }).on("filer.reset", function(e) { + f._reset(); + f._clear(); + return true; + }).on("filer.generateList", function(e, data) { + return f._getList(e, data) + }).on("filer.retry", function(e, data) { + return f._retryUpload(e, data) + }); + + f.init(); + + return this; + }); + }; + $.fn.filer.defaults = { + limit: null, + maxSize: null, + extensions: null, + changeInput: true, + showThumbs: false, + appendTo: null, + theme: 'default', + templates: { + box: '', + item: '
  • {{fi-icon}}
    {{fi-name | limitTo:30}}
    size: {{fi-size2}}type: {{fi-extension}}{{fi-progressBar}}
  • ', + itemAppend: '
  • {{fi-icon}}
    {{fi-name | limitTo:35}}
    size: {{fi-size2}}type: {{fi-extension}}
  • ', + progressBar: '
    ', + itemAppendToEnd: false, + removeConfirmation: true, + _selectors: { + list: '.jFiler-items-list', + item: '.jFiler-item', + progressBar: '.bar', + remove: '.jFiler-item-trash-action' + } + }, + files: null, + uploadFile: null, + dragDrop: null, + addMore: false, + clipBoardPaste: true, + excludeName: null, + beforeRender: null, + afterRender: null, + beforeShow: null, + beforeSelect: null, + onSelect: null, + afterShow: null, + onRemove: null, + onEmpty: null, + options: null, + captions: { + button: "Choose Files", + feedback: "Choose files To Upload", + feedback2: "files were chosen", + drop: "Drop file here to Upload", + removeConfirmation: "Are you sure you want to remove this file?", + errors: { + filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.", + filesType: "Only Images are allowed to be uploaded.", + filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.", + filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB." + } + } + } +})(jQuery); \ No newline at end of file diff --git a/resource/web/js/jquery.filer.min.js b/resource/web/js/jquery.filer.min.js new file mode 100755 index 00000000..ce233d1e --- /dev/null +++ b/resource/web/js/jquery.filer.min.js @@ -0,0 +1,8 @@ +/*! + * jQuery.filer + * Copyright (c) 2015 CreativeDream + * Website: https://github.com/CreativeDream/jquery.filer + * Version: 1.0.5 (19-Nov-2015) + * Requires: jQuery v1.7.1 or later + */ +!function(e){"use strict";e.fn.filer=function(i){return this.each(function(t,n){var l=e(n),a=".jFiler",r=e(),o=e(),s=e(),d=[],f=e.isFunction(i)?i(l,e.fn.filer.defaults):i,p=f&&e.isPlainObject(f)?e.extend(!0,{},e.fn.filer.defaults,f):e.fn.filer.defaults,u={init:function(){l.wrap('
    '),u._set("props"),l.prop("jFiler").boxEl=r=l.closest(a),u._changeInput()},_bindInput:function(){p.changeInput&&o.size()>0&&o.bind("click",u._clickHandler),l.on({focus:function(){o.addClass("focused")},blur:function(){o.removeClass("focused")},change:function(){u._onChange()}}),p.dragDrop&&(o.length>0?o:l).bind("drop",u._dragDrop.drop).bind("dragover",u._dragDrop.dragEnter).bind("dragleave",u._dragDrop.dragLeave),p.uploadFile&&p.clipBoardPaste&&e(window).on("paste",u._clipboardPaste)},_unbindInput:function(){p.changeInput&&o.size()>0&&o.unbind("click",u._clickHandler)},_clickHandler:function(){l.click()},_applyAttrSettings:function(){var e=["name","limit","maxSize","extensions","changeInput","showThumbs","appendTo","theme","addMore","excludeName","files","uploadUrl","uploadData","options"];for(var i in e){var t="data-jfiler-"+e[i];if(u._assets.hasAttr(t)){switch(e[i]){case"changeInput":case"showThumbs":case"addMore":p[e[i]]=["true","false"].indexOf(l.attr(t))>-1?"true"==l.attr(t):l.attr(t);break;case"extensions":p[e[i]]=l.attr(t).replace(/ /g,"").split(",");break;case"uploadUrl":p.uploadFile&&(p.uploadFile.url=l.attr(t));break;case"uploadData":p.uploadFile&&(p.uploadFile.data=JSON.parse(l.attr(t)));break;case"files":case"options":p[e[i]]=JSON.parse(l.attr(t));break;default:p[e[i]]=l.attr(t)}l.removeAttr(t)}}},_changeInput:function(){if(u._applyAttrSettings(),null!=p.beforeRender&&"function"==typeof p.beforeRender?p.beforeRender(r,l):null,p.theme&&r.addClass("jFiler-theme-"+p.theme),"input"!=l.get(0).tagName.toLowerCase()&&"file"!=l.get(0).type)o=l,l=e(''),l.css({position:"absolute",left:"-9999px",top:"-9999px","z-index":"-9999"}),r.prepend(l),u._isGn=l;else if(p.changeInput){switch(typeof p.changeInput){case"boolean":o=e('
    '+p.captions.feedback+'
    '+p.captions.button+'
    "');break;case"string":case"object":o=e(p.changeInput);break;case"function":o=e(p.changeInput(r,l,p))}l.after(o),l.css({position:"absolute",left:"-9999px",top:"-9999px","z-index":"-9999"})}l.prop("jFiler").newInputEl=o,(!p.limit||p.limit&&p.limit>=2)&&(l.attr("multiple","multiple"),"[]"!=l.attr("name").slice(-2)?l.attr("name",l.attr("name")+"[]"):null),u._bindInput(),p.files&&u._append(!1,{files:p.files}),null!=p.afterRender&&"function"==typeof p.afterRender?p.afterRender(s,r,o,l):null},_clear:function(){u.files=null,l.prop("jFiler").files=null,p.uploadFile||p.addMore||u._reset(),u._set("feedback",u._itFl&&u._itFl.length>0?u._itFl.length+" "+p.captions.feedback2:p.captions.feedback),null!=p.onEmpty&&"function"==typeof p.onEmpty?p.onEmpty(r,o,l):null},_reset:function(i){if(!i){if(!p.uploadFile&&p.addMore){for(var t=0;t0&&o.find(".jFiler-input-caption span").html(i);break;case"props":l.prop("jFiler")||l.prop("jFiler",{options:p,listEl:s,boxEl:r,newInputEl:o,inputEl:l,files:u.files,files_list:u._itFl,current_file:u._itFc,append:function(e){return u._append(!1,{files:[e]})},remove:function(e){return u._remove(null,{binded:!0,data:{id:e}}),!0},reset:function(){return u._reset(),u._clear(),!0},retry:function(e){return u._retryUpload(e)}})}},_filesCheck:function(){var i=0;if(p.limit&&u.files.length+u._itFl.length>p.limit)return alert(u._assets.textParse(p.captions.errors.filesLimit)),!1;for(var t=0;t1048576*p.maxSize)return alert(u._assets.textParse(p.captions.errors.filesSize,a)),!1;if(4096==l.size&&0==l.type.length)return!1;i+=u.files[t].size}if(null!=p.maxSize&&i>=Math.round(1048576*p.maxSize))return alert(u._assets.textParse(p.captions.errors.filesSizeAll)),!1;if(p.addMore||p.uploadFile){var a=u._itFl.filter(function(e,i){return e.file.name!=l.name||e.file.size!=l.size||e.file.type!=l.type||(l.lastModified?e.file.lastModified!=l.lastModified:0)?void 0:!0});if(a.length>0)return!1}return!0},_thumbCreator:{create:function(i){var t=u.files[i],n=u._itFc?u._itFc.id:i,l=t.name,a=t.size,r=t.type.split("/",1).toString().toLowerCase(),o=-1!=l.indexOf(".")?l.split(".").pop().toLowerCase():"",d=p.uploadFile?'
    '+p.templates.progressBar+"
    ":"",f={id:n,name:l,size:a,size2:u._assets.bytesToSize(a),type:r,extension:o,icon:u._assets.getIcon(o,r),icon2:u._thumbCreator.generateIcon({type:r,extension:o}),image:'
    ',progressBar:d,_appended:t._appended},c="";return t.opts&&(f=e.extend({},t.opts,f)),c=e(u._thumbCreator.renderContent(f)).attr("data-jfiler-index",n),c.get(0).jfiler_id=n,u._thumbCreator.renderFile(t,c,f),t.forList?c:(u._itFc.html=c,c.hide()[p.templates.itemAppendToEnd?"appendTo":"prependTo"](s.find(p.templates._selectors.list)).show(),void(t._appended||u._onSelect(i)))},renderContent:function(e){return u._assets.textParse(e._appended?p.templates.itemAppend:p.templates.item,e)},renderFile:function(i,t,n){if(0==t.find(".jFiler-item-thumb-image").size())return!1;if(i.file&&"image"==n.type){var l='',a=t.find(".jFiler-item-thumb-image.fi-loading");return e(l).error(function(){l=u._thumbCreator.generateIcon(n),t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}).load(function(){a.removeClass("fi-loading").html(l)}),!0}if(window.File&&window.FileList&&window.FileReader&&"image"==n.type&&n.size<6e6){var r=new FileReader;r.onload=function(i){var l='',a=t.find(".jFiler-item-thumb-image.fi-loading");e(l).error(function(){l=u._thumbCreator.generateIcon(n),t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}).load(function(){a.removeClass("fi-loading").html(l)})},r.readAsDataURL(i)}else{var l=u._thumbCreator.generateIcon(n),a=t.find(".jFiler-item-thumb-image.fi-loading");t.addClass("jFiler-no-thumbnail"),a.removeClass("fi-loading").html(l)}},generateIcon:function(i){var t=new Array(3);if(i&&i.type&&i.extension)switch(i.type){case"image":t[0]="f-image",t[1]='';break;case"video":t[0]="f-video",t[1]='';break;case"audio":t[0]="f-audio",t[1]='';break;default:t[0]="f-file f-file-ext-"+i.extension,t[1]=i.extension.length>0?"."+i.extension:"",t[2]=1}else t[0]="f-file",t[1]=i.extension&&i.extension.length>0?"."+i.extension:"",t[2]=1;var n=''+t[1]+"";if(1==t[2]){var l=u._assets.text2Color(i.extension);if(l){var a=e(n).appendTo("body"),r=a.css("box-shadow");r=l+r.substring(r.replace(/^.*(rgba?\([^)]+\)).*$/,"$1").length,r.length),a.css({"-webkit-box-shadow":r,"-moz-box-shadow":r,"box-shadow":r}).attr("style","-webkit-box-shadow: "+r+"; -moz-box-shadow: "+r+"; box-shadow: "+r+";"),n=a.prop("outerHTML"),a.remove()}}return n},_box:function(i){if(null!=p.beforeShow&&"function"==typeof p.beforeShow?!p.beforeShow(u.files,s,r,o,l):!1)return!1;if(s.length<1){if(p.appendTo)var t=e(p.appendTo);else var t=r;t.find(".jFiler-items").remove(),s=e('
    '),l.prop("jFiler").listEl=s,s.append(u._assets.textParse(p.templates.box)).appendTo(t),s.on("click",p.templates._selectors.remove,function(t){t.preventDefault();var n=p.templates.removeConfirmation?confirm(p.captions.removeConfirmation):!0;n&&u._remove(i?i.remove.event:t,i?i.remove.el:e(this).closest(p.templates._selectors.item))})}for(var n=0;n=u.files.length&&(u._ajFc=0,null!=p.uploadFile.onComplete&&"function"==typeof p.uploadFile.onComplete?p.uploadFile.onComplete(s,r,o,l,e,i):null)},beforeSend:function(e,t){return null!=p.uploadFile.beforeSend&&"function"==typeof p.uploadFile.beforeSend?p.uploadFile.beforeSend(i,s,r,o,l,n.id,e,t):!0},success:function(e,t,a){n.uploaded=!0,null!=p.uploadFile.success&&"function"==typeof p.uploadFile.success?p.uploadFile.success(e,i,s,r,o,l,n.id,t,a):null},error:function(e,t,a){n.uploaded=!1,null!=p.uploadFile.error&&"function"==typeof p.uploadFile.error?p.uploadFile.error(i,s,r,o,l,n.id,e,t,a):null},statusCode:p.uploadFile.statusCode,cache:!1,contentType:!1,processData:!1}),n.ajax},progressHandling:function(e,i){if(e.lengthComputable){var t=Math.round(100*e.loaded/e.total).toString();null!=p.uploadFile.onProgress&&"function"==typeof p.uploadFile.onProgress?p.uploadFile.onProgress(t,i,s,r,o,l):null,i.find(".jFiler-jProgressBar").find(p.templates._selectors.progressBar).css("width",t+"%")}}},_dragDrop:{dragEnter:function(e){e.preventDefault(),e.stopPropagation(),r.addClass("dragged"),u._set("feedback",p.captions.drop),null!=p.dragDrop.dragEnter&&"function"==typeof p.dragDrop.dragEnter?p.dragDrop.dragEnter(e,o,l,r):null},dragLeave:function(e){return e.preventDefault(),e.stopPropagation(),u._dragDrop._dragLeaveCheck(e)?(r.removeClass("dragged"),u._set("feedback",p.captions.feedback),void(null!=p.dragDrop.dragLeave&&"function"==typeof p.dragDrop.dragLeave?p.dragDrop.dragLeave(e,o,l,r):null)):!1},drop:function(e){e.preventDefault(),r.removeClass("dragged"),u._set("feedback",p.captions.feedback),e&&e.originalEvent&&e.originalEvent.dataTransfer&&e.originalEvent.dataTransfer.files&&e.originalEvent.dataTransfer.files.length>0&&u._onChange(e,e.originalEvent.dataTransfer.files),null!=p.dragDrop.drop&&"function"==typeof p.dragDrop.drop?p.dragDrop.drop(e.originalEvent.dataTransfer.files,e,o,l,r):null},_dragLeaveCheck:function(i){var t=i.relatedTarget,n=!1;return t!==o&&(t&&(n=e.contains(o,t)),n)?!1:!0}},_clipboardPaste:function(e,i){if((i||e.originalEvent.clipboardData||e.originalEvent.clipboardData.items)&&(!i||e.originalEvent.dataTransfer||e.originalEvent.dataTransfer.items)&&!u._clPsePre){var t=i?e.originalEvent.dataTransfer.items:e.originalEvent.clipboardData.items,n=function(e,i,t){i=i||"",t=t||512;for(var n=atob(e),l=[],a=0;a=u.files.length&&(null!=p.afterShow&&"function"==typeof p.afterShow?p.afterShow(s,r,o,l):null)},_onChange:function(i,t){if(t){if(!t||0==t.length)return u._set("input",""),u._clear(),!1;u.files=t}else{if(!l.get(0).files||"undefined"==typeof l.get(0).files||0==l.get(0).files.length)return p.uploadFile||p.addMore||(u._set("input",""),u._clear()),!1;u.files=l.get(0).files}if(p.uploadFile||p.addMore||u._reset(!0),l.prop("jFiler").files=u.files,!u._filesCheck()||(null!=p.beforeSelect&&"function"==typeof p.beforeSelect?!p.beforeSelect(u.files,s,r,o,l):!1))return u._set("input",""),u._clear(),!1;if(u._set("feedback",u.files.length+u._itFl.length+" "+p.captions.feedback2),p.showThumbs)u._thumbCreator._box();else for(var n=0;n'),f=l.prop("attributes");e.each(f,function(){a.attr(this.name,this.value)}),l.after(a),u._unbindInput(),d.push(a),l=a,u._bindInput(),u._set("props")}},_append:function(e,i){var t=i?i.files:!1;if(t&&!(t.length<=0)&&(u.files=t,l.prop("jFiler").files=u.files,p.showThumbs)){for(var n=0;n0?!p.uploadFile||e.isEmptyObject(p.uploadFile)||a[0].uploaded?void 0:(u._itFc=a[0],l.prop("jFiler").current_file=u._itFc,u._upload(n),!0):!1},_remove:function(i,n){if(n.binded){if("undefined"!=typeof n.data.id&&(n=s.find(p.templates._selectors.item+"[data-jfiler-index='"+n.data.id+"']"),0==n.size()))return!1;n.data.el&&(n=n.data.el)}var a=n.get(0).jfiler_id||n.attr("data-jfiler-index"),d=null,f=function(i){var n=r.find("input[name^='jfiler-items-exclude-']:hidden").first(),a=u._itFl[i],o=[];if(0==n.size()&&(n=e(''),n.appendTo(r)),a.file._choosed||a.file._appended||a.uploaded){if(u._prEr=!0,u._itFr.push(a),p.addMore){var s=a.input,d=0;u._itFl.filter(function(e,i){e.file._choosed&&e.input.get(0)==s.get(0)&&d++}),1==d&&(u._itFr=u._itFr.filter(function(e,i){return e.file._choosed?e.input.get(0)!=s.get(0):!0}),s.val(""),u._prEr=!1)}for(var f=0;f-1?'':''},textParse:function(i,t){switch(t=e.extend({},{limit:p.limit,maxSize:p.maxSize,extensions:p.extensions?p.extensions.join(","):null},t&&e.isPlainObject(t)?t:{},p.options),typeof i){case"string":return i.replace(/\{\{fi-(.*?)\}\}/g,function(e,i){return i=i.replace(/ /g,""),i.match(/(.*?)\|limitTo\:(\d+)/)?i.replace(/(.*?)\|limitTo\:(\d+)/,function(e,i,n){var i=t[i]?t[i]:"",l=i.substring(0,n);return l=i.length>l.length?l.substring(0,l.length-3)+"...":l}):t[i]?t[i]:""});case"function":return i(t);default:return i}},text2Color:function(e){if(!e||0==e.length)return!1;for(var i=0,t=0;ii;n+=("00"+(t>>2*i++&255).toString(16)).slice(-2));return n}},files:null,_itFl:[],_itFc:null,_itFr:[],_ajFc:0,_prEr:!1};return l.on("filer.append",function(e,i){u._append(e,i)}).on("filer.remove",function(e,i){i.binded=!0,u._remove(e,i)}).on("filer.reset",function(e){return u._reset(),u._clear(),!0}).on("filer.generateList",function(e,i){return u._getList(e,i)}).on("filer.retry",function(e,i){return u._retryUpload(e,i)}),u.init(),this})},e.fn.filer.defaults={limit:null,maxSize:null,extensions:null,changeInput:!0,showThumbs:!1,appendTo:null,theme:"default",templates:{box:'
      ',item:'
    • {{fi-icon}}
      {{fi-name | limitTo:30}}
      size: {{fi-size2}}type: {{fi-extension}}{{fi-progressBar}}
    • ',itemAppend:'
    • {{fi-icon}}
      {{fi-name | limitTo:35}}
      size: {{fi-size2}}type: {{fi-extension}}
    • ',progressBar:'
      ',itemAppendToEnd:!1,removeConfirmation:!0,_selectors:{list:".jFiler-items-list",item:".jFiler-item",progressBar:".bar",remove:".jFiler-item-trash-action"}},files:null,uploadFile:null,dragDrop:null,addMore:!1,clipBoardPaste:!0,excludeName:null,beforeRender:null,afterRender:null,beforeShow:null,beforeSelect:null,onSelect:null,afterShow:null,onRemove:null,onEmpty:null,options:null,captions:{button:"Choose Files",feedback:"Choose files To Upload",feedback2:"files were chosen",drop:"Drop file here to Upload",removeConfirmation:"Are you sure you want to remove this file?",errors:{filesLimit:"Only {{fi-limit}} files are allowed to be uploaded.",filesType:"Only Images are allowed to be uploaded.",filesSize:"{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.",filesSizeAll:"Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB."}}}}(jQuery); \ No newline at end of file diff --git a/resource/web/map.tmpl b/resource/web/map.tmpl index 73e6b8aa..855d1590 100755 --- a/resource/web/map.tmpl +++ b/resource/web/map.tmpl @@ -1,4 +1,3 @@ -