{"version":3,"sources":["kendo.imagebrowser.js"],"names":["f","define","$","undefined","concatPaths","path","name","match","sizeFormatter","value","suffix","Math","round","offsetTop","ImageBrowser","kendo","window","FileBrowser","ui","isPlainObject","proxy","extend","browser","support","isFunction","trimSlashesRegExp","ERROR","NS","NAMEFIELD","SIZEFIELD","TYPEFIELD","DEFAULTSORTORDER","field","dir","EMPTYTILE","template","data","schemas","imagebrowser","items","model","id","fields","size","type","transports","RemoteTransport","init","options","fn","call","this","_call","read","create","destroy","update","msie","version","element","height","that","addClass","fileTypes","selected","_selectedItem","imageUrl","transport","get","replace","format","encodeURIComponent","_fileUpload","e","file","filterRegExp","RegExp","split","join","fileName","files","fileNameField","sizeField","test","_createFile","_uploading","upload","one","_insertFileToList","set","response","_getFieldName","_tiles","listView","filter","attr","_scroll","preventDefault","_showMessage","messages","invalidFileType","_content","list","appendTo","on","_dblClick","ListView","dataSource","_itemTmpl","editTemplate","_editTmpl","selectable","autoBind","dataBinding","toolbar","find","parent","action","dataBound","view","length","wrapper","append","text","emptyFolder","change","_listViewChange","_dataSource","schema","typeSortOrder","nameSortOrder","sort","_errorHandler","unbind","_error","DataSource","bind","_loadImage","li","dataItem","getByUid","thumbnailUrl","img","alt","urlJoin","hide","prev","remove","end","fadeIn","after","indexOf","_override","Date","getTime","loaded","clearTimeout","_timeout","setTimeout","_outerHeight","viewTop","scrollTop","viewBottom","each","top","bottom","offsetHeight","html","plugin","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,sBAAuB,qBAAsBD,IACtD,WAoQE,MA3PC,UAAUE,EAAGC,GAkEV,QAASC,GAAYC,EAAMC,GAIvB,MAHID,KAASF,GAAcE,EAAKE,MAAM,SAClCF,GAAQA,GAAQ,IAAM,KAEnBA,EAAOC,EAElB,QAASE,GAAcC,GACnB,IAAKA,EACD,MAAO,EAEX,IAAIC,GAAS,QAWb,OAVID,IAAS,YACTC,EAAS,M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["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.imagebrowser', ['kendo.filebrowser'], f);\n}(function () {\n var __meta__ = {\n id: 'imagebrowser',\n name: 'ImageBrowser',\n category: 'web',\n description: '',\n hidden: true,\n depends: ['filebrowser']\n };\n (function ($, undefined) {\n var kendo = window.kendo, FileBrowser = kendo.ui.FileBrowser, isPlainObject = $.isPlainObject, proxy = $.proxy, extend = $.extend, browser = kendo.support.browser, isFunction = kendo.isFunction, trimSlashesRegExp = /(^\\/|\\/$)/g, ERROR = 'error', NS = '.kendoImageBrowser', NAMEFIELD = 'name', SIZEFIELD = 'size', TYPEFIELD = 'type', DEFAULTSORTORDER = {\n field: TYPEFIELD,\n dir: 'asc'\n }, EMPTYTILE = kendo.template('
  • ${text}
  • ');\n extend(true, kendo.data, {\n schemas: {\n 'imagebrowser': {\n data: function (data) {\n return data.items || data || [];\n },\n model: {\n id: 'name',\n fields: {\n name: 'name',\n size: 'size',\n type: 'type'\n }\n }\n }\n }\n });\n extend(true, kendo.data, {\n transports: {\n 'imagebrowser': kendo.data.RemoteTransport.extend({\n init: function (options) {\n kendo.data.RemoteTransport.fn.init.call(this, $.extend(true, {}, this.options, options));\n },\n _call: function (type, options) {\n options.data = $.extend({}, options.data, { path: this.options.path() });\n if (isFunction(this.options[type])) {\n this.options[type].call(this, options);\n } else {\n kendo.data.RemoteTransport.fn[type].call(this, options);\n }\n },\n read: function (options) {\n this._call('read', options);\n },\n create: function (options) {\n this._call('create', options);\n },\n destroy: function (options) {\n this._call('destroy', options);\n },\n update: function () {\n },\n options: {\n read: { type: 'POST' },\n update: { type: 'POST' },\n create: { type: 'POST' },\n destroy: { type: 'POST' }\n }\n })\n }\n });\n var offsetTop;\n if (browser.msie && browser.version < 8) {\n offsetTop = function (element) {\n return element.offsetTop;\n };\n } else {\n offsetTop = function (element) {\n return element.offsetTop - $(element).height();\n };\n }\n function concatPaths(path, name) {\n if (path === undefined || !path.match(/\\/$/)) {\n path = (path || '') + '/';\n }\n return path + name;\n }\n function sizeFormatter(value) {\n if (!value) {\n return '';\n }\n var suffix = ' bytes';\n if (value >= 1073741824) {\n suffix = ' GB';\n value /= 1073741824;\n } else if (value >= 1048576) {\n suffix = ' MB';\n value /= 1048576;\n } else if (value >= 1024) {\n suffix = ' KB';\n value /= 1024;\n }\n return Math.round(value * 100) / 100 + suffix;\n }\n var ImageBrowser = FileBrowser.extend({\n init: function (element, options) {\n var that = this;\n options = options || {};\n FileBrowser.fn.init.call(that, element, options);\n that.element.addClass('k-imagebrowser');\n },\n options: {\n name: 'ImageBrowser',\n fileTypes: '*.png,*.gif,*.jpg,*.jpeg'\n },\n value: function () {\n var that = this, selected = that._selectedItem(), path, imageUrl = that.options.transport.imageUrl;\n if (selected && selected.get(TYPEFIELD) === 'f') {\n path = concatPaths(that.path(), selected.get(NAMEFIELD)).replace(trimSlashesRegExp, '');\n if (imageUrl) {\n path = isFunction(imageUrl) ? imageUrl(path) : kendo.format(imageUrl, encodeURIComponent(path));\n }\n return path;\n }\n },\n _fileUpload: function (e) {\n var that = this, options = that.options, fileTypes = options.fileTypes, filterRegExp = new RegExp(('(' + fileTypes.split(',').join(')|(') + ')').replace(/\\*\\./g, '.*.'), 'i'), fileName = e.files[0].name, fileNameField = NAMEFIELD, sizeField = SIZEFIELD, file;\n if (filterRegExp.test(fileName)) {\n e.data = { path: that.path() };\n file = that._createFile(fileName);\n if (!file) {\n e.preventDefault();\n } else {\n file._uploading = true;\n that.upload.one('success', function (e) {\n delete file._uploading;\n var model = that._insertFileToList(file);\n model.set(fileNameField, e.response[that._getFieldName(fileNameField)]);\n model.set(sizeField, e.response[that._getFieldName(sizeField)]);\n that._tiles = that.listView.items().filter('[' + kendo.attr('type') + '=f]');\n that._scroll();\n });\n }\n } else {\n e.preventDefault();\n that._showMessage(kendo.format(options.messages.invalidFileType, fileName, fileTypes));\n }\n },\n _content: function () {\n var that = this;\n that.list = $('