/** * Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui) * Copyright 2016 Telerik AD. All rights reserved. * * Kendo UI commercial licenses may be obtained at * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete * If you do not own a commercial license, this file shall be governed by the trial license terms. */ (function (f, define) { define('kendo.filebrowser', [ 'kendo.listview', 'kendo.dropdownlist', 'kendo.upload' ], f); }(function () { var __meta__ = { id: 'filebrowser', name: 'FileBrowser', category: 'web', description: '', hidden: true, depends: [ 'selectable', 'listview', 'dropdownlist', 'upload' ] }; (function ($, undefined) { var kendo = window.kendo, Widget = kendo.ui.Widget, isPlainObject = $.isPlainObject, proxy = $.proxy, extend = $.extend, placeholderSupported = kendo.support.placeholder, browser = kendo.support.browser, isFunction = kendo.isFunction, trimSlashesRegExp = /(^\/|\/$)/g, CHANGE = 'change', APPLY = 'apply', ERROR = 'error', CLICK = 'click', NS = '.kendoFileBrowser', BREADCRUBMSNS = '.kendoBreadcrumbs', SEARCHBOXNS = '.kendoSearchBox', NAMEFIELD = 'name', SIZEFIELD = 'size', TYPEFIELD = 'type', DEFAULTSORTORDER = { field: TYPEFIELD, dir: 'asc' }, EMPTYTILE = kendo.template('
  • ${text}
  • '), TOOLBARTMPL = '
    ' + '
    ' + '# if (showUpload) { # ' + '
    ' + '#=messages.uploadFile#
    ' + '# } #' + '# if (showCreate) { #' + '' + '# } #' + '# if (showDelete) { #' + ' ' + '# } #' + '
    ' + '
    ' + '
    ').appendTo(this.element); that.breadcrumbs = navigation.find('input:first').kendoBreadcrumbs({ value: that.options.path, change: function () { that.path(this.value()); } }).data('kendoBreadcrumbs'); that.searchBox = navigation.parent().find('input:last').kendoSearchBox({ label: that.options.messages.search, change: function () { that.search(this.value()); } }).data('kendoSearchBox'); }, _error: function (e) { var that = this, status; if (!that.trigger(ERROR, e)) { status = e.xhr.status; if (e.status == 'error') { if (status == '404') { that._showMessage(that.options.messages.directoryNotFound); } else if (status != '0') { that._showMessage('Error! The requested URL returned ' + status + ' - ' + e.xhr.statusText); } } else if (status == 'timeout') { that._showMessage('Error! Server timeout.'); } } }, _showMessage: function (message, type) { return window[type || 'alert'](message); }, refresh: function () { var that = this; that._navigation(); that._toolbar(); that._content(); }, _editTmpl: function () { var html = '
  • '; html += '#if(' + TYPEFIELD + ' == "d") { #'; html += '
    '; html += '#}else{#'; html += '
    '; html += '#}#'; html += '#if(' + TYPEFIELD + ' == "d") { #'; html += ''; html += '#}#'; html += '
  • '; return proxy(kendo.template(html), { sizeFormatter: sizeFormatter }); }, _itemTmpl: function () { var html = '
  • '; html += '#if(' + TYPEFIELD + ' == "d") { #'; html += '
    '; html += '#}else{#'; html += '
    '; html += '#}#'; html += '${' + NAMEFIELD + '}'; html += '#if(' + TYPEFIELD + ' == "f") { # ${this.sizeFormatter(' + SIZEFIELD + ')} #}#'; html += '
  • '; return proxy(kendo.template(html), { sizeFormatter: sizeFormatter }); }, path: function (value) { var that = this, path = that._path || ''; if (value !== undefined) { that._path = value.replace(trimSlashesRegExp, '') + '/'; that.dataSource.read({ path: that._path }); return; } if (path) { path = path.replace(trimSlashesRegExp, ''); } return path === '/' || path === '' ? '' : path + '/'; } }); var SearchBox = Widget.extend({ init: function (element, options) { var that = this; options = options || {}; Widget.fn.init.call(that, element, options); if (placeholderSupported) { that.element.attr('placeholder', that.options.label); } that._wrapper(); that.element.on('keydown' + SEARCHBOXNS, proxy(that._keydown, that)).on('change' + SEARCHBOXNS, proxy(that._updateValue, that)); that.wrapper.on(CLICK + SEARCHBOXNS, 'a', proxy(that._click, that)); if (!placeholderSupported) { that.element.on('focus' + SEARCHBOXNS, proxy(that._focus, that)).on('blur' + SEARCHBOXNS, proxy(that._blur, that)); } }, options: { name: 'SearchBox', label: 'Search', value: '' }, events: [CHANGE], destroy: function () { var that = this; that.wrapper.add(that.element).add(that.label).off(SEARCHBOXNS); Widget.fn.destroy.call(that); }, _keydown: function (e) { if (e.keyCode === 13) { this._updateValue(); } }, _click: function (e) { e.preventDefault(); this._updateValue(); }, _updateValue: function () { var that = this, value = that.element.val(); if (value !== that.value()) { that.value(value); that.trigger(CHANGE); } }, _blur: function () { this._updateValue(); this._toggleLabel(); }, _toggleLabel: function () { if (!placeholderSupported) { this.label.toggle(!this.element.val()); } }, _focus: function () { this.label.hide(); }, _wrapper: function () { var element = this.element, wrapper = element.parents('.k-search-wrap'); element[0].style.width = ''; element.addClass('k-input'); if (!wrapper.length) { wrapper = element.wrap($('
    ')).parent(); if (!placeholderSupported) { $('').insertBefore(element); } $('').appendTo(wrapper); } this.wrapper = wrapper; this.label = wrapper.find('>label'); }, value: function (value) { var that = this; if (value !== undefined) { that.options.value = value; that.element.val(value); that._toggleLabel(); return; } return that.options.value; } }); var Breadcrumbs = Widget.extend({ init: function (element, options) { var that = this; options = options || {}; Widget.fn.init.call(that, element, options); that._wrapper(); that.wrapper.on('focus' + BREADCRUBMSNS, 'input', proxy(that._focus, that)).on('blur' + BREADCRUBMSNS, 'input', proxy(that._blur, that)).on('keydown' + BREADCRUBMSNS, 'input', proxy(that._keydown, that)).on(CLICK + BREADCRUBMSNS, 'a.k-i-arrow-n:first', proxy(that._rootClick, that)).on(CLICK + BREADCRUBMSNS, 'a:not(.k-i-arrow-n)', proxy(that._click, that)); that.value(that.options.value); }, options: { name: 'Breadcrumbs', gap: 50 }, events: [CHANGE], destroy: function () { var that = this; Widget.fn.destroy.call(that); that.wrapper.add(that.wrapper.find('input')).add(that.wrapper.find('a')).off(BREADCRUBMSNS); }, _update: function (val) { val = (val || '').charAt(0) === '/' ? val : '/' + (val || ''); if (val !== this.value()) { this.value(val); this.trigger(CHANGE); } }, _click: function (e) { e.preventDefault(); this._update(this._path($(e.target).prevAll('a:not(.k-i-arrow-n)').addBack())); }, _rootClick: function (e) { e.preventDefault(); this._update(''); }, _focus: function () { var that = this, element = that.element; that.overlay.hide(); that.element.val(that.value()); setTimeout(function () { element.select(); }); }, _blur: function () { if (this.overlay.is(':visible')) { return; } var that = this, element = that.element, val = element.val().replace(/\/{2,}/g, '/'); that.overlay.show(); element.val(''); that._update(val); }, _keydown: function (e) { var that = this; if (e.keyCode === 13) { that._blur(); setTimeout(function () { that.overlay.find('a:first').focus(); }); } }, _wrapper: function () { var element = this.element, wrapper = element.parents('.k-breadcrumbs'), overlay; element[0].style.width = ''; element.addClass('k-input'); if (!wrapper.length) { wrapper = element.wrap($('
    ')).parent(); } overlay = wrapper.find('.k-breadcrumbs-wrap'); if (!overlay.length) { overlay = $('
    ').appendTo(wrapper); } this.wrapper = wrapper; this.overlay = overlay; }, refresh: function () { var html = '', value = this.value(), segments, segment, idx, length; if (value === undefined || !value.match(/^\//)) { value = '/' + (value || ''); } segments = value.split('/'); for (idx = 0, length = segments.length; idx < length; idx++) { segment = segments[idx]; if (segment) { if (!html) { html += 'root'; } html += '' + segments[idx] + ''; html += '>'; } } this.overlay.empty().append($(html)); this._adjustSectionWidth(); }, _adjustSectionWidth: function () { var that = this, wrapper = that.wrapper, width = wrapper.width() - that.options.gap, links = that.overlay.find('a'), a; links.each(function (index) { a = $(this); if (a.parent().width() > width) { if (index == links.length - 1) { a.width(width); } else { a.prev().addBack().hide(); } } }); }, value: function (val) { if (val !== undefined) { this._value = val.replace(/\/{2,}/g, '/'); this.refresh(); return; } return this._value; }, _path: function (trail) { return '/' + $.map(trail, function (b) { return $(b).text(); }).join('/'); } }); kendo.ui.plugin(FileBrowser); kendo.ui.plugin(Breadcrumbs); kendo.ui.plugin(SearchBox); }(window.kendo.jQuery)); return window.kendo; }, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) { (a3 || a2)(); }));