public.component.assets.js.ace-elements.js Maven / Gradle / Ivy
/*!
* Ace v1.3.2
*/
if (typeof jQuery === 'undefined') { throw new Error('Ace\'s JavaScript requires jQuery') }
/**
Ace custom scroller. It is not as feature-rich as plugins such as NiceScroll but it's good enough for most cases.
*/
(function($ , undefined) {
var Ace_Scroll = function(element , _settings) {
var self = this;
var settings = $.extend({}, $.fn.ace_scroll.defaults, _settings);
this.size = 0;
this.lock = false;
this.lock_anyway = false;
this.$element = $(element);
this.element = element;
var vertical = true;
var disabled = false;
var active = false;
var created = false;
var $content_wrap = null, content_wrap = null;
var $track = null, $bar = null, track = null, bar = null;
var bar_style = null;
var bar_size = 0, bar_pos = 0, bar_max_pos = 0, bar_size_2 = 0, move_bar = true;
var reset_once = false;
var styleClass = '';
var trackFlip = false;//vertical on left or horizontal on top
var trackSize = 0;
var css_pos,
css_size,
max_css_size,
client_size,
scroll_direction,
scroll_size;
var ratio = 1;
var inline_style = false;
var mouse_track = false;
var mouse_release_target = 'onmouseup' in window ? window : 'html';
var dragEvent = settings.dragEvent || false;
var trigger_scroll = _settings.scrollEvent || false;
var detached = settings.detached || false;//when detached, hideOnIdle as well?
var updatePos = settings.updatePos || false;//default is true
var hideOnIdle = settings.hideOnIdle || false;
var hideDelay = settings.hideDelay || 1500;
var insideTrack = false;//used to hide scroll track when mouse is up and outside of track
var observeContent = settings.observeContent || false;
var prevContentSize = 0;
var is_dirty = true;//to prevent consecutive 'reset' calls
this.create = function(_settings) {
if(created) return;
//if(disabled) return;
if(_settings) settings = $.extend({}, $.fn.ace_scroll.defaults, _settings);
this.size = parseInt(this.$element.attr('data-size')) || settings.size || 200;
vertical = !settings['horizontal'];
css_pos = vertical ? 'top' : 'left';//'left' for horizontal
css_size = vertical ? 'height' : 'width';//'width' for horizontal
max_css_size = vertical ? 'maxHeight' : 'maxWidth';
client_size = vertical ? 'clientHeight' : 'clientWidth';
scroll_direction = vertical ? 'scrollTop' : 'scrollLeft';
scroll_size = vertical ? 'scrollHeight' : 'scrollWidth';
this.$element.addClass('ace-scroll');
if(this.$element.css('position') == 'static') {
inline_style = this.element.style.position;
this.element.style.position = 'relative';
} else inline_style = false;
var scroll_bar = null;
if(!detached) {
this.$element.wrapInner('');
this.$element.prepend('');
}
else {
scroll_bar = $('').appendTo('body');
}
$content_wrap = this.$element;
if(!detached) $content_wrap = this.$element.find('.scroll-content').eq(0);
if(!vertical) $content_wrap.wrapInner('');
content_wrap = $content_wrap.get(0);
if(detached) {
//set position for detached scrollbar
$track = scroll_bar;
setTrackPos();
}
else $track = this.$element.find('.scroll-track').eq(0);
$bar = $track.find('.scroll-bar').eq(0);
track = $track.get(0);
bar = $bar.get(0);
bar_style = bar.style;
//add styling classes and horizontalness
if(!vertical) $track.addClass('scroll-hz');
if(settings.styleClass) {
styleClass = settings.styleClass;
$track.addClass(styleClass);
trackFlip = !!styleClass.match(/scroll\-left|scroll\-top/);
}
//calculate size of track!
if(trackSize == 0) {
$track.show();
getTrackSize();
}
$track.hide();
//if(!touchDrag) {
$track.on('mousedown', mouse_down_track);
$bar.on('mousedown', mouse_down_bar);
//}
$content_wrap.on('scroll', function() {
if(move_bar) {
bar_pos = parseInt(Math.round(this[scroll_direction] * ratio));
bar_style[css_pos] = bar_pos + 'px';
}
move_bar = false;
if(trigger_scroll) this.$element.trigger('scroll', [content_wrap]);
})
if(settings.mouseWheel) {
this.lock = settings.mouseWheelLock;
this.lock_anyway = settings.lockAnyway;
//mousewheel library available?
this.$element.on(!!$.event.special.mousewheel ? 'mousewheel.ace_scroll' : 'mousewheel.ace_scroll DOMMouseScroll.ace_scroll', function(event) {
if(disabled) return;
checkContentChanges(true);
if(!active) return !self.lock_anyway;
if(mouse_track) {
mouse_track = false;
$('html').off('.ace_scroll')
$(mouse_release_target).off('.ace_scroll');
if(dragEvent) self.$element.trigger('drag.end');
}
event.deltaY = event.deltaY || 0;
var delta = (event.deltaY > 0 || event.originalEvent.detail < 0 || event.originalEvent.wheelDelta > 0) ? 1 : -1
var scrollEnd = false//have we reached the end of scrolling?
var clientSize = content_wrap[client_size], scrollAmount = content_wrap[scroll_direction];
if( !self.lock ) {
if(delta == -1) scrollEnd = (content_wrap[scroll_size] <= scrollAmount + clientSize);
else scrollEnd = (scrollAmount == 0);
}
self.move_bar(true);
//var step = parseInt( Math.min(Math.max(parseInt(clientSize / 8) , 80) , self.size) ) + 1;
var step = parseInt(clientSize / 8);
if(step < 80) step = 80;
if(step > self.size) step = self.size;
step += 1;
content_wrap[scroll_direction] = scrollAmount - (delta * step);
return scrollEnd && !self.lock_anyway;
})
}
//swipe not available yet
var touchDrag = ace.vars['touch'] && 'ace_drag' in $.event.special && settings.touchDrag //&& !settings.touchSwipe;
//add drag event for touch devices to scroll
if(touchDrag/** || ($.fn.swipe && settings.touchSwipe)*/) {
var dir = '', event_name = touchDrag ? 'ace_drag' : 'swipe';
this.$element.on(event_name + '.ace_scroll', function(event) {
if(disabled) {
event.retval.cancel = true;
return;
}
checkContentChanges(true);
if(!active) {
event.retval.cancel = this.lock_anyway;
return;
}
dir = event.direction;
if( (vertical && (dir == 'up' || dir == 'down'))
||
(!vertical && (dir == 'left' || dir == 'right'))
)
{
var distance = vertical ? event.dy : event.dx;
if(distance != 0) {
if(Math.abs(distance) > 20 && touchDrag) distance = distance * 2;
self.move_bar(true);
content_wrap[scroll_direction] = content_wrap[scroll_direction] + distance;
}
}
})
}
/////////////////////////////////
if(hideOnIdle) {
$track.addClass('idle-hide');
}
if(observeContent) {
$track.on('mouseenter.ace_scroll', function() {
insideTrack = true;
checkContentChanges(false);
}).on('mouseleave.ace_scroll', function() {
insideTrack = false;
if(mouse_track == false) hideScrollbars();
});
}
//some mobile browsers don't have mouseenter
this.$element.on('mouseenter.ace_scroll touchstart.ace_scroll', function(e) {
//if(ace.vars['old_ie']) return;//IE8 has a problem triggering event two times and strangely wrong values for this.size especially in fullscreen widget!
is_dirty = true;
if(observeContent) checkContentChanges(true);
else if(settings.hoverReset) self.reset(true);
$track.addClass('scroll-hover');
}).on('mouseleave.ace_scroll touchend.ace_scroll', function() {
$track.removeClass('scroll-hover');
});
//
if(!vertical) $content_wrap.children(0).css(css_size, this.size);//the extra wrapper
$content_wrap.css(max_css_size , this.size);
disabled = false;
created = true;
}
this.is_active = function() {
return active;
}
this.is_enabled = function() {
return !disabled;
}
this.move_bar = function($move) {
move_bar = $move;
}
this.get_track = function() {
return track;
}
this.reset = function(innert_call) {
if(disabled) return;// this;
if(!created) this.create();
/////////////////////
var size = this.size;
if(innert_call && !is_dirty) {
return;
}
is_dirty = false;
if(detached) {
var border_size = parseInt(Math.round( (parseInt($content_wrap.css('border-top-width')) + parseInt($content_wrap.css('border-bottom-width'))) / 2.5 ));//(2.5 from trial?!)
size -= border_size;//only if detached
}
var content_size = vertical ? content_wrap[scroll_size] : size;
if( (vertical && content_size == 0) || (!vertical && this.element.scrollWidth == 0) ) {
//element is hidden
//this.$element.addClass('scroll-hidden');
$track.removeClass('scroll-active')
return;// this;
}
var available_space = vertical ? size : content_wrap.clientWidth;
if(!vertical) $content_wrap.children(0).css(css_size, size);//the extra wrapper
$content_wrap.css(max_css_size , this.size);
if(content_size > available_space) {
active = true;
$track.css(css_size, available_space).show();
ratio = parseFloat((available_space / content_size).toFixed(5))
bar_size = parseInt(Math.round(available_space * ratio));
bar_size_2 = parseInt(Math.round(bar_size / 2));
bar_max_pos = available_space - bar_size;
bar_pos = parseInt(Math.round(content_wrap[scroll_direction] * ratio));
bar_style[css_size] = bar_size + 'px';
bar_style[css_pos] = bar_pos + 'px';
$track.addClass('scroll-active');
if(trackSize == 0) {
getTrackSize();
}
if(!reset_once) {
//this.$element.removeClass('scroll-hidden');
if(settings.reset) {
//reset scrollbar to zero position at first
content_wrap[scroll_direction] = 0;
bar_style[css_pos] = 0;
}
reset_once = true;
}
if(detached) setTrackPos();
} else {
active = false;
$track.hide();
$track.removeClass('scroll-active');
$content_wrap.css(max_css_size , '');
}
return;// this;
}
this.disable = function() {
content_wrap[scroll_direction] = 0;
bar_style[css_pos] = 0;
disabled = true;
active = false;
$track.hide();
this.$element.addClass('scroll-disabled');
$track.removeClass('scroll-active');
$content_wrap.css(max_css_size , '');
}
this.enable = function() {
disabled = false;
this.$element.removeClass('scroll-disabled');
}
this.destroy = function() {
active = false;
disabled = false;
created = false;
this.$element.removeClass('ace-scroll scroll-disabled scroll-active');
this.$element.off('.ace_scroll')
if(!detached) {
if(!vertical) {
//remove the extra wrapping div
$content_wrap.find('> div').children().unwrap();
}
$content_wrap.children().unwrap();
$content_wrap.remove();
}
$track.remove();
if(inline_style !== false) this.element.style.position = inline_style;
if(idleTimer != null) {
clearTimeout(idleTimer);
idleTimer = null;
}
}
this.modify = function(_settings) {
if(_settings) settings = $.extend({}, settings, _settings);
this.destroy();
this.create();
is_dirty = true;
this.reset(true);
}
this.update = function(_settings) {
if(_settings) settings = $.extend({}, settings, _settings);
this.size = _settings.size || this.size;
this.lock = _settings.mouseWheelLock || this.lock;
this.lock_anyway = _settings.lockAnyway || this.lock_anyway;
if(_settings.styleClass != undefined) {
if(styleClass) $track.removeClass(styleClass);
styleClass = _settings.styleClass;
if(styleClass) $track.addClass(styleClass);
trackFlip = !!styleClass.match(/scroll\-left|scroll\-top/);
}
}
this.start = function() {
content_wrap[scroll_direction] = 0;
}
this.end = function() {
content_wrap[scroll_direction] = content_wrap[scroll_size];
}
this.hide = function() {
$track.hide();
}
this.show = function() {
$track.show();
}
this.update_scroll = function() {
move_bar = false;
bar_style[css_pos] = bar_pos + 'px';
content_wrap[scroll_direction] = parseInt(Math.round(bar_pos / ratio));
}
function mouse_down_track(e) {
e.preventDefault();
e.stopPropagation();
var track_offset = $track.offset();
var track_pos = track_offset[css_pos];//top for vertical, left for horizontal
var mouse_pos = vertical ? e.pageY : e.pageX;
if(mouse_pos > track_pos + bar_pos) {
bar_pos = mouse_pos - track_pos - bar_size + bar_size_2;
if(bar_pos > bar_max_pos) {
bar_pos = bar_max_pos;
}
}
else {
bar_pos = mouse_pos - track_pos - bar_size_2;
if(bar_pos < 0) bar_pos = 0;
}
self.update_scroll()
}
var mouse_pos1 = -1, mouse_pos2 = -1;
function mouse_down_bar(e) {
e.preventDefault();
e.stopPropagation();
if(vertical) {
mouse_pos2 = mouse_pos1 = e.pageY;
} else {
mouse_pos2 = mouse_pos1 = e.pageX;
}
mouse_track = true;
$('html').off('mousemove.ace_scroll').on('mousemove.ace_scroll', mouse_move_bar)
$(mouse_release_target).off('mouseup.ace_scroll').on('mouseup.ace_scroll', mouse_up_bar);
$track.addClass('active');
if(dragEvent) self.$element.trigger('drag.start');
}
function mouse_move_bar(e) {
e.preventDefault();
e.stopPropagation();
if(vertical) {
mouse_pos2 = e.pageY;
} else {
mouse_pos2 = e.pageX;
}
if(mouse_pos2 - mouse_pos1 + bar_pos > bar_max_pos) {
mouse_pos2 = mouse_pos1 + bar_max_pos - bar_pos;
} else if(mouse_pos2 - mouse_pos1 + bar_pos < 0) {
mouse_pos2 = mouse_pos1 - bar_pos;
}
bar_pos = bar_pos + (mouse_pos2 - mouse_pos1);
mouse_pos1 = mouse_pos2;
if(bar_pos < 0) {
bar_pos = 0;
}
else if(bar_pos > bar_max_pos) {
bar_pos = bar_max_pos;
}
self.update_scroll()
}
function mouse_up_bar(e) {
e.preventDefault();
e.stopPropagation();
mouse_track = false;
$('html').off('.ace_scroll')
$(mouse_release_target).off('.ace_scroll');
$track.removeClass('active');
if(dragEvent) self.$element.trigger('drag.end');
if(active && hideOnIdle && !insideTrack) hideScrollbars();
}
var idleTimer = null;
var prevCheckTime = 0;
function checkContentChanges(hideSoon) {
//check if content size has been modified since last time?
//and with at least 1s delay
var newCheck = +new Date();
if(observeContent && newCheck - prevCheckTime > 1000) {
var newSize = content_wrap[scroll_size];
if(prevContentSize != newSize) {
prevContentSize = newSize;
is_dirty = true;
self.reset(true);
}
prevCheckTime = newCheck;
}
//show scrollbars when not idle anymore i.e. triggered by mousewheel, dragging, etc
if(active && hideOnIdle) {
if(idleTimer != null) {
clearTimeout(idleTimer);
idleTimer = null;
}
$track.addClass('not-idle');
if(!insideTrack && hideSoon == true) {
//hideSoon is false when mouse enters track
hideScrollbars();
}
}
}
function hideScrollbars() {
if(idleTimer != null) {
clearTimeout(idleTimer);
idleTimer = null;
}
idleTimer = setTimeout(function() {
idleTimer = null;
$track.removeClass('not-idle');
} , hideDelay);
}
//for detached scrollbars
function getTrackSize() {
$track.css('visibility', 'hidden').addClass('scroll-hover');
if(vertical) trackSize = parseInt($track.outerWidth()) || 0;
else trackSize = parseInt($track.outerHeight()) || 0;
$track.css('visibility', '').removeClass('scroll-hover');
}
this.track_size = function() {
if(trackSize == 0) getTrackSize();
return trackSize;
}
//for detached scrollbars
function setTrackPos() {
if(updatePos === false) return;
var off = $content_wrap.offset();//because we want it relative to parent not document
var left = off.left;
var top = off.top;
if(vertical) {
if(!trackFlip) {
left += ($content_wrap.outerWidth() - trackSize)
}
}
else {
if(!trackFlip) {
top += ($content_wrap.outerHeight() - trackSize)
}
}
if(updatePos === true) $track.css({top: parseInt(top), left: parseInt(left)});
else if(updatePos === 'left') $track.css('left', parseInt(left));
else if(updatePos === 'top') $track.css('top', parseInt(top));
}
this.create();
is_dirty = true;
this.reset(true);
prevContentSize = content_wrap[scroll_size];
return this;
}
$.fn.ace_scroll = function (option,value) {
var retval;
var $set = this.each(function () {
var $this = $(this);
var data = $this.data('ace_scroll');
var options = typeof option === 'object' && option;
if (!data) $this.data('ace_scroll', (data = new Ace_Scroll(this, options)));
//else if(typeof options == 'object') data['modify'](options);
if (typeof option === 'string') retval = data[option](value);
});
return (retval === undefined) ? $set : retval;
};
$.fn.ace_scroll.defaults = {
'size' : 200,
'horizontal': false,
'mouseWheel': true,
'mouseWheelLock': false,
'lockAnyway': false,
'styleClass' : false,
'observeContent': false,
'hideOnIdle': false,
'hideDelay': 1500,
'hoverReset': true //reset scrollbar sizes on mouse hover because of possible sizing changes
,
'reset': false //true= set scrollTop = 0
,
'dragEvent': false
,
'touchDrag': true
,
'touchSwipe': false
,
'scrollEvent': false //trigger scroll event
,
'detached': false
,
'updatePos': true
/**
,
'track' : true,
'show' : false,
'dark': false,
'alwaysVisible': false,
'margin': false,
'thin': false,
'position': 'right'
*/
}
/**
$(document).on('ace.settings.ace_scroll', function(e, name) {
if(name == 'sidebar_collapsed') $('.ace-scroll').scroller('reset');
});
$(window).on('resize.ace_scroll', function() {
$('.ace-scroll').scroller('reset');
});
*/
})(window.jQuery);;/**
Custom color picker element. Converts html select elements to a dropdown color picker.
*/
(function($ , undefined) {
var Ace_Colorpicker = function(element, option) {
var options = $.extend({}, $.fn.ace_colorpicker.defaults, option);
var $element = $(element);
var color_list = '';
var color_selected = '';
var selection = null;
var color_array = [];
$element.addClass('hide').find('option').each(function() {
var $class = 'colorpick-btn';
var color = this.value.replace(/[^\w\s,#\(\)\.]/g, '');
if(this.value != color) this.value = color;
if(this.selected) {
$class += ' selected';
color_selected = color;
}
color_array.push(color)
color_list += ' ';
}).
end()
.on('change.color', function(){
$element.next().find('.btn-colorpicker').css('background-color', this.value);
})
.after('')
var dropdown = $element.next().find('.dropdown-menu')
dropdown.on(ace.click_event, function(e) {
var a = $(e.target);
if(!a.is('.colorpick-btn')) return false;
if(selection) selection.removeClass('selected');
selection = a;
selection.addClass('selected');
var color = selection.data('color');
$element.val(color).trigger('change');
e.preventDefault();
return true;//to hide dropdown
})
selection = $element.next().find('a.selected');
this.pick = function(index, insert) {
if(typeof index === 'number') {
if(index >= color_array.length) return;
element.selectedIndex = index;
dropdown.find('a:eq('+index+')').trigger(ace.click_event);
}
else if(typeof index === 'string') {
var color = index.replace(/[^\w\s,#\(\)\.]/g, '');
index = color_array.indexOf(color);
//add this color if it doesn't exist
if(index == -1 && insert === true) {
color_array.push(color);
$('')
.appendTo($element)
.val(color);
$(' ')
.appendTo(dropdown)
.find('a')
.css('background-color', color)
.data('color', color);
index = color_array.length - 1;
}
if(index == -1) return;
dropdown.find('a:eq('+index+')').trigger(ace.click_event);
}
}
this.destroy = function() {
$element.removeClass('hide').off('change.color')
.next().remove();
color_array = [];
}
}
$.fn.ace_colorpicker = function(option, value) {
var retval;
var $set = this.each(function () {
var $this = $(this);
var data = $this.data('ace_colorpicker');
var options = typeof option === 'object' && option;
if (!data) $this.data('ace_colorpicker', (data = new Ace_Colorpicker(this, options)));
if (typeof option === 'string') retval = data[option](value);
});
return (retval === undefined) ? $set : retval;
}
$.fn.ace_colorpicker.defaults = {
'pull_right' : false,
'caret': true,
'auto_pos': true
}
})(window.jQuery);;/**
Ace file input element. Custom, simple file input element to style browser's default file input.
*/
(function($ , undefined) {
var multiplible = 'multiple' in document.createElement('INPUT');
var hasFileList = 'FileList' in window;//file list enabled in modern browsers
var hasFileReader = 'FileReader' in window;
var hasFile = 'File' in window;
var Ace_File_Input = function(element , settings) {
var self = this;
this.settings = $.extend({}, $.fn.ace_file_input.defaults, settings);
this.$element = $(element);
this.element = element;
this.disabled = false;
this.can_reset = true;
this.$element
.off('change.ace_inner_call')
.on('change.ace_inner_call', function(e , ace_inner_call){
if(self.disabled) return;
if(ace_inner_call === true) return;//this change event is called from above drop event and extra checkings are taken care of there
return handle_on_change.call(self);
//if(ret === false) e.preventDefault();
});
var parent_label = this.$element.closest('label').css({'display':'block'})
var tagName = parent_label.length == 0 ? 'label' : 'span';//if not inside a "LABEL" tag, use "LABEL" tag, otherwise use "SPAN"
this.$element.wrap('<'+tagName+' class="ace-file-input" />');
this.apply_settings();
this.reset_input_field();//for firefox as it keeps selected file after refresh
}
Ace_File_Input.error = {
'FILE_LOAD_FAILED' : 1,
'IMAGE_LOAD_FAILED' : 2,
'THUMBNAIL_FAILED' : 3
};
Ace_File_Input.prototype.apply_settings = function() {
var self = this;
this.multi = this.$element.attr('multiple') && multiplible;
this.well_style = this.settings.style == 'well';
if(this.well_style) this.$element.parent().addClass('ace-file-multiple');
else this.$element.parent().removeClass('ace-file-multiple');
this.$element.parent().find(':not(input[type=file])').remove();//remove all except our input, good for when changing settings
this.$element.after(''+(this.settings.no_icon ? '' : '')+'');
this.$label = this.$element.next();
this.$container = this.$element.closest('.ace-file-input');
var remove_btn = !!this.settings.icon_remove;
if(remove_btn) {
var btn =
$('')
.appendTo(this.$element.parent());
btn.on(ace.click_event, function(e){
e.preventDefault();
if( !self.can_reset ) return false;
var ret = true;
if(self.settings.before_remove) ret = self.settings.before_remove.call(self.element);
if(!ret) return false;
var r = self.reset_input();
return false;
});
}
if(this.settings.droppable && hasFileList) {
enable_drop_functionality.call(this);
}
}
Ace_File_Input.prototype.show_file_list = function($files , inner_call) {
var files = typeof $files === "undefined" ? this.$element.data('ace_input_files') : $files;
if(!files || files.length == 0) return;
//////////////////////////////////////////////////////////////////
if(this.well_style) {
this.$label.find('.ace-file-name').remove();
if(!this.settings.btn_change) this.$label.addClass('hide-placeholder');
}
this.$label.attr('data-title', this.settings.btn_change).addClass('selected');
for (var i = 0; i < files.length; i++) {
var filename = '', format = false;
if(typeof files[i] === "string") filename = files[i];
else if(hasFile && files[i] instanceof File) filename = $.trim( files[i].name );
else if(files[i] instanceof Object && files[i].hasOwnProperty('name')) {
//format & name specified by user (pre-displaying name, etc)
filename = files[i].name;
if(files[i].hasOwnProperty('type')) format = files[i].type;
if(!files[i].hasOwnProperty('path')) files[i].path = files[i].name;
}
else continue;
var index = filename.lastIndexOf("\\") + 1;
if(index == 0)index = filename.lastIndexOf("/") + 1;
filename = filename.substr(index);
if(format == false) {
if((/\.(jpe?g|png|gif|svg|bmp|tiff?)$/i).test(filename)) {
format = 'image';
}
else if((/\.(mpe?g|flv|mov|avi|swf|mp4|mkv|webm|wmv|3gp)$/i).test(filename)) {
format = 'video';
}
else if((/\.(mp3|ogg|wav|wma|amr|aac)$/i).test(filename)) {
format = 'audio';
}
else format = 'file';
}
var fileIcons = {
'file' : 'fa fa-file',
'image' : 'fa fa-picture-o file-image',
'video' : 'fa fa-film file-video',
'audio' : 'fa fa-music file-audio'
};
var fileIcon = fileIcons[format];
if(!this.well_style) this.$label.find('.ace-file-name').attr({'data-title':filename}).find(ace.vars['.icon']).attr('class', ace.vars['icon'] + fileIcon);
else {
this.$label.append('');
var type = (inner_call === true && hasFile && files[i] instanceof File) ? $.trim(files[i].type) : '';
var can_preview = hasFileReader && this.settings.thumbnail
&&
( (type.length > 0 && type.match('image')) || (type.length == 0 && format == 'image') )//the second one is for older Android's default browser which gives an empty text for file.type
if(can_preview) {
var self = this;
$.when(preview_image.call(this, files[i])).fail(function(result){
//called on failure to load preview
if(self.settings.preview_error) self.settings.preview_error.call(self, filename, result.code);
})
}
}
}
return true;
}
Ace_File_Input.prototype.reset_input = function() {
this.reset_input_ui();
this.reset_input_field();
}
Ace_File_Input.prototype.reset_input_ui = function() {
this.$label.attr({'data-title':this.settings.btn_choose, 'class':'ace-file-container'})
.find('.ace-file-name:first').attr({'data-title':this.settings.no_file , 'class':'ace-file-name'})
.find(ace.vars['.icon']).attr('class', ace.vars['icon'] + this.settings.no_icon)
.prev('img').remove();
if(!this.settings.no_icon) this.$label.find(ace.vars['.icon']).remove();
this.$label.find('.ace-file-name').not(':first').remove();
this.reset_input_data();
//if(ace.vars['old_ie']) ace.helper.redraw(this.$container[0]);
}
Ace_File_Input.prototype.reset_input_field = function() {
//http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery/13351234#13351234
this.$element.wrap('
© 2015 - 2025 Weber Informatics LLC | Privacy Policy