parent
a8b7ab3282
commit
0074d64068
44 changed files with 327 additions and 543 deletions
@ -1,94 +0,0 @@ |
|||||||
//replace
|
|
||||||
$(document).ready(function(){ |
|
||||||
//$('#id_city').attr('disabled', true)
|
|
||||||
|
|
||||||
$('select').select2({ |
|
||||||
width: 'element', |
|
||||||
allowClear: true |
|
||||||
|
|
||||||
});//end select
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('#id_city').select2({ |
|
||||||
placeholder: "Search city", |
|
||||||
width: 'element', |
|
||||||
ajax: { |
|
||||||
|
|
||||||
url: "/admin/city/search/", |
|
||||||
dataType: "json", |
|
||||||
quietMillis: 200, |
|
||||||
|
|
||||||
data: function(term, page, country){ |
|
||||||
var country = $('#id_country').val() |
|
||||||
return {term: term, |
|
||||||
page: page, |
|
||||||
country: country}; |
|
||||||
}, |
|
||||||
|
|
||||||
results: function (data) { |
|
||||||
var results = []; |
|
||||||
$.each(data, function(index, item){ |
|
||||||
results.push({ |
|
||||||
id: item.id, |
|
||||||
text: item.label |
|
||||||
}); |
|
||||||
}); |
|
||||||
return {results: results}; |
|
||||||
} |
|
||||||
}, |
|
||||||
initSelection : function(element, callback) { |
|
||||||
var id= $(element).val(); |
|
||||||
var text = $(element).attr('data-init-text'); |
|
||||||
callback({id: id, text:text}); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
//
|
|
||||||
$('#id_tag').select2({ |
|
||||||
placeholder: "Search tag", |
|
||||||
width: '550px', |
|
||||||
multiple: true, |
|
||||||
ajax: { |
|
||||||
|
|
||||||
url: "/admin/theme/tag/search/", |
|
||||||
dataType: "json", |
|
||||||
quietMillis: 200, |
|
||||||
multiple: true, |
|
||||||
|
|
||||||
data: function(term, page, theme){ |
|
||||||
var theme = $('#id_theme').serialize(); |
|
||||||
return {term: term, |
|
||||||
page: page, |
|
||||||
theme: theme}; |
|
||||||
}, |
|
||||||
|
|
||||||
results: function (data) { |
|
||||||
var results = []; |
|
||||||
$.each(data, function(index, item){ |
|
||||||
results.push({ |
|
||||||
id: item.id, |
|
||||||
text: item.label |
|
||||||
}); |
|
||||||
}); |
|
||||||
return {results: results}; |
|
||||||
} |
|
||||||
}, |
|
||||||
initSelection : function(element, callback) { |
|
||||||
var data = []; |
|
||||||
$(element.val().split(",")).each(function(i) { |
|
||||||
var item = this.split(':'); |
|
||||||
data.push({ |
|
||||||
id: item[0], |
|
||||||
text: item[1] |
|
||||||
}); |
|
||||||
}); |
|
||||||
callback(data); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
}); |
|
||||||
|
|
||||||
})//end ready
|
|
||||||
@ -1,195 +1,167 @@ |
|||||||
function init_filer($target) { |
function init_filer($target) { |
||||||
$target.find('.file_uploader').filer({ |
|
||||||
limit: null, |
|
||||||
maxSize: null, |
|
||||||
extensions: null, |
|
||||||
changeInput: '<div class="jFiler-input-dragDrop"><div class="jFiler-input-inner"><div class="jFiler-input-icon"><i class="icon-jfi-cloud-up-o"></i></div><div class="jFiler-input-text"><h3>Drag&Drop files here</h3> <span style="display:inline-block; margin: 15px 0">or</span></div><a class="jFiler-input-choose-btn blue">Browse Files</a></div></div>', |
|
||||||
showThumbs: true, |
|
||||||
theme: "dragdropbox", |
|
||||||
afterRender: function(l, p, o, s){ |
|
||||||
s[0].name = s[0].name.replace('[]', '') |
|
||||||
}, |
|
||||||
templates: { |
|
||||||
box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>', |
|
||||||
item: '<li class="jFiler-item not_loaded">\ |
|
||||||
<div class="jFiler-item-container">\ |
|
||||||
<div class="jFiler-item-inner">\ |
|
||||||
<a href="javascript:void(0);" class="jFiler-item-thumb">\ |
|
||||||
<div class="jFiler-item-status"></div>\ |
|
||||||
<div class="jFiler-item-thumb-overlay">\ |
|
||||||
<div class="jFiler-item-info">\ |
|
||||||
<div style="display:table-cell;vertical-align: middle;">\ |
|
||||||
<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name}}</b></span>\ |
|
||||||
<span class="jFiler-item-others">{{fi-size2}}</span>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
{{fi-image}}\ |
|
||||||
</a>\ |
|
||||||
<div class="jFiler-item-assets jFiler-row">\ |
|
||||||
<ul class="list-inline pull-left">\ |
|
||||||
<li>{{fi-progressBar}}</li>\ |
|
||||||
</ul>\ |
|
||||||
<ul class="list-inline pull-right">\ |
|
||||||
<li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\ |
|
||||||
</ul>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</li>', |
|
||||||
itemAppend: '<li class="jFiler-item">\ |
|
||||||
<div class="jFiler-item-container">\ |
|
||||||
<div class="jFiler-item-inner">\ |
|
||||||
<a href="javascript:void(0);" class="jFiler-item-thumb">\ |
|
||||||
<div class="jFiler-item-status"></div>\ |
|
||||||
<div class="jFiler-item-thumb-overlay">\ |
|
||||||
<div class="jFiler-item-info">\ |
|
||||||
<div style="display:table-cell;vertical-align: middle;">\ |
|
||||||
<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name}}</b></span>\ |
|
||||||
<span class="jFiler-item-others">{{fi-size2}}</span>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
{{fi-image}}\ |
|
||||||
</a>\ |
|
||||||
<div class="jFiler-item-assets jFiler-row">\ |
|
||||||
<ul class="list-inline pull-left">\ |
|
||||||
<li><span class="jFiler-item-others">{{fi-icon}}</span></li>\ |
|
||||||
</ul>\ |
|
||||||
<ul class="list-inline pull-right">\ |
|
||||||
<li><a class="icon-jfi-trash jFiler-item-trash-action"></a>{{fi-remove}}</li>\ |
|
||||||
</ul>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</div>\ |
|
||||||
</li>', |
|
||||||
progressBar: '<div class="bar"></div>', |
|
||||||
itemAppendToEnd: true, |
|
||||||
canvasImage: true, |
|
||||||
removeConfirmation: true, |
|
||||||
_selectors: { |
|
||||||
list: '.jFiler-items-list', |
|
||||||
//item: '.jFiler-item',
|
|
||||||
progressBar: '.bar', |
|
||||||
remove: '.jFiler-item-trash-action' |
|
||||||
} |
|
||||||
}, |
|
||||||
dragDrop: { |
|
||||||
dragEnter: null, |
|
||||||
dragLeave: null, |
|
||||||
drop: null, |
|
||||||
dragContainer: null |
|
||||||
}, |
|
||||||
uploadFile: { |
|
||||||
url: $target.data('upload-url'), |
|
||||||
//data: null,
|
|
||||||
type: 'POST', |
|
||||||
enctype: 'multipart/form-data', |
|
||||||
synchron: true, |
|
||||||
beforeSend: function() {}, |
|
||||||
success: function(data, itemEl, listEl, boxEl, newInputEl, inputEl, id){ |
|
||||||
console.log(data); |
|
||||||
console.log(itemEl); |
|
||||||
console.log(listEl); |
|
||||||
console.log(boxEl); |
|
||||||
console.log(newInputEl); |
|
||||||
console.log(inputEl); |
|
||||||
console.log(id); |
|
||||||
console.log('----------------------------'); |
|
||||||
var parent = itemEl.find(".jFiler-jProgressBar").parent(); |
|
||||||
|
|
||||||
itemEl.find(".jFiler-jProgressBar").fadeOut("slow", function(){ |
$.get($target.data('upload-url'), function(response){ |
||||||
$("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow"); |
var files = []; |
||||||
}); |
if (response['success']) { |
||||||
}, |
files = response['images']; |
||||||
error: function(el){ |
} |
||||||
var parent = el.find(".jFiler-jProgressBar").parent(); |
|
||||||
el.find(".jFiler-jProgressBar").fadeOut("slow", function(){ |
|
||||||
$("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow"); |
|
||||||
}); |
|
||||||
}, |
|
||||||
statusCode: null, |
|
||||||
onProgress: null, |
|
||||||
onComplete: null |
|
||||||
}, |
|
||||||
files: [ |
|
||||||
{ |
|
||||||
name: "appended_file.jpg", |
|
||||||
size: 5453, |
|
||||||
type: "image", |
|
||||||
file: "http://127.0.0.1:8000/media/photologue/photos/cache/am_admin_thumbnail.jpg", // 188x143 crop="center"
|
|
||||||
url: "google.com.ua", |
|
||||||
remove_url: '/remove-url/1/', |
|
||||||
detail_link: '/detail_link/1/' |
|
||||||
}, |
|
||||||
{ |
|
||||||
name: "appended_file_2.jpg", |
|
||||||
size: 9453, |
|
||||||
type: "image", |
|
||||||
file: "http://127.0.0.1:8000/media/photologue/photos/cache/am_admin_thumbnail.jpg", // 188x143 crop="center"
|
|
||||||
url: "/qwerty/qwerty/", |
|
||||||
remove_url: '/remove-url/2/', |
|
||||||
detail_link: '/detail_link/1/' |
|
||||||
}, |
|
||||||
{ |
|
||||||
name: "appended_file_2.jpg", |
|
||||||
size: 9453, |
|
||||||
type: "image", |
|
||||||
file: "http://127.0.0.1:8000/media/photologue/photos/cache/am_admin_thumbnail.jpg", // 188x143 crop="center"
|
|
||||||
url: "/qwerty/qwerty/", |
|
||||||
remove_url: '/remove-url/3/', |
|
||||||
detail_link: '/detail_link/1/' |
|
||||||
} |
|
||||||
], |
|
||||||
addMore: false, |
|
||||||
allowDuplicates: true, |
|
||||||
clipBoardPaste: true, |
|
||||||
excludeName: null, |
|
||||||
beforeRender: null, |
|
||||||
beforeShow: null, |
|
||||||
beforeSelect: null, |
|
||||||
onSelect: null, |
|
||||||
afterShow: null, |
|
||||||
onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){ |
|
||||||
var filerKit = inputEl.prop("jFiler"), |
|
||||||
file_name = filerKit.files_list[id].name; |
|
||||||
|
|
||||||
$.post('./php/ajax_remove_file.php', {file: file_name}); |
$target.find('.file_uploader').filer({ |
||||||
}, |
limit: null, |
||||||
onEmpty: null, |
maxSize: null, |
||||||
options: null, |
extensions: null, |
||||||
dialogs: { |
changeInput: '<div class="jFiler-input-dragDrop"><div class="jFiler-input-inner"><div class="jFiler-input-icon"><i class="icon-jfi-cloud-up-o"></i></div><div class="jFiler-input-text"><h3>Drag&Drop files here</h3> <span style="display:inline-block; margin: 15px 0">or</span></div><a class="jFiler-input-choose-btn blue">Browse Files</a></div></div>', |
||||||
alert: function(text) { |
showThumbs: true, |
||||||
return alert(text); |
theme: "dragdropbox", |
||||||
}, |
afterRender: function(l, p, o, s){ |
||||||
confirm: function (text, callback) { |
s[0].name = s[0].name.replace('[]', '') |
||||||
confirm(text) ? callback() : null; |
}, |
||||||
} |
templates: { |
||||||
}, |
box: '<ul class="jFiler-items-list jFiler-items-grid"></ul>', |
||||||
captions: { |
item: '<li class="jFiler-item">\ |
||||||
button: "Выберите файлы", |
<div class="jFiler-item-container">\ |
||||||
feedback: "Выберите файлы для загрузки", |
<div class="jFiler-item-inner">\ |
||||||
feedback2: "выбранные файлы", |
<a href="javascript:void(0);" class="jFiler-item-thumb">\ |
||||||
drop: "Перетяните файлы для загрузки", |
<div class="jFiler-item-status"></div>\ |
||||||
removeConfirmation: "Вы уверены что хотите удалить этот файл?", |
<div class="jFiler-item-thumb-overlay">\ |
||||||
errors: { |
<div class="jFiler-item-info">\ |
||||||
filesLimit: "Only {{fi-limit}} files are allowed to be uploaded.", |
<div style="display:table-cell;vertical-align: middle;">\ |
||||||
filesType: "Only Images are allowed to be uploaded.", |
<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name}}</b></span>\ |
||||||
filesSize: "{{fi-name}} is too large! Please upload file up to {{fi-maxSize}} MB.", |
<span class="jFiler-item-others">{{fi-size2}}</span>\ |
||||||
filesSizeAll: "Files you've choosed are too large! Please upload files up to {{fi-maxSize}} MB." |
</div>\ |
||||||
} |
</div>\ |
||||||
} |
</div>\ |
||||||
}); |
{{fi-image}}\ |
||||||
|
</a>\ |
||||||
|
<div class="jFiler-item-assets jFiler-row">\ |
||||||
|
<ul class="list-inline pull-left">\ |
||||||
|
<li>{{fi-progressBar}}</li>\ |
||||||
|
</ul>\ |
||||||
|
<ul class="list-inline pull-right">\ |
||||||
|
<li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\ |
||||||
|
</ul>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
</li>', |
||||||
|
itemAppend: '<li class="jFiler-item">\ |
||||||
|
<div class="jFiler-item-container">\ |
||||||
|
<div class="jFiler-item-inner">\ |
||||||
|
<a href="javascript:void(0);" class="jFiler-item-thumb">\ |
||||||
|
<div class="jFiler-item-status"></div>\ |
||||||
|
<div class="jFiler-item-thumb-overlay">\ |
||||||
|
<div class="jFiler-item-info">\ |
||||||
|
<div style="display:table-cell;vertical-align: middle;">\ |
||||||
|
<span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name}}</b></span>\ |
||||||
|
<span class="jFiler-item-others">{{fi-size2}}</span>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
{{fi-image}}\ |
||||||
|
</a>\ |
||||||
|
<div class="jFiler-item-assets jFiler-row">\ |
||||||
|
<ul class="list-inline pull-left">\ |
||||||
|
<li><span class="jFiler-item-others">{{fi-icon}}</span></li>\ |
||||||
|
</ul>\ |
||||||
|
<ul class="list-inline pull-right">\ |
||||||
|
<li><a class="icon-jfi-trash jFiler-item-trash-action"></a>{{fi-remove}}</li>\ |
||||||
|
</ul>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
</div>\ |
||||||
|
</li>', |
||||||
|
progressBar: '<div class="bar"></div>', |
||||||
|
itemAppendToEnd: true, |
||||||
|
canvasImage: true, |
||||||
|
removeConfirmation: true, |
||||||
|
_selectors: { |
||||||
|
list: '.jFiler-items-list', |
||||||
|
//item: '.jFiler-item',
|
||||||
|
progressBar: '.bar', |
||||||
|
remove: '.jFiler-item-trash-action' |
||||||
|
} |
||||||
|
}, |
||||||
|
dragDrop: { |
||||||
|
dragEnter: null, |
||||||
|
dragLeave: null, |
||||||
|
drop: null, |
||||||
|
dragContainer: null |
||||||
|
}, |
||||||
|
uploadFile: { |
||||||
|
url: $target.data('upload-url'), |
||||||
|
//data: null,
|
||||||
|
type: 'POST', |
||||||
|
enctype: 'multipart/form-data', |
||||||
|
synchron: true, |
||||||
|
beforeSend: function() {}, |
||||||
|
success: function(data, itemEl, listEl, boxEl, newInputEl, inputEl, id){ |
||||||
|
var parent = itemEl.find(".jFiler-jProgressBar").parent(); |
||||||
|
|
||||||
|
itemEl.find(".jFiler-jProgressBar").fadeOut("slow", function(){ |
||||||
|
$("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow"); |
||||||
|
}); |
||||||
|
}, |
||||||
|
error: function(el){ |
||||||
|
var parent = el.find(".jFiler-jProgressBar").parent(); |
||||||
|
el.find(".jFiler-jProgressBar").fadeOut("slow", function(){ |
||||||
|
$("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow"); |
||||||
|
}); |
||||||
|
}, |
||||||
|
statusCode: null, |
||||||
|
onProgress: null, |
||||||
|
onComplete: null |
||||||
|
}, |
||||||
|
files: files, |
||||||
|
addMore: false, |
||||||
|
allowDuplicates: true, |
||||||
|
clipBoardPaste: true, |
||||||
|
excludeName: null, |
||||||
|
beforeRender: null, |
||||||
|
beforeShow: null, |
||||||
|
beforeSelect: null, |
||||||
|
onSelect: null, |
||||||
|
afterShow: null, |
||||||
|
onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){ |
||||||
|
var filerKit = inputEl.prop("jFiler"), |
||||||
|
file_name = filerKit.files_list[id].name; |
||||||
|
console.log(itemEl); |
||||||
|
|
||||||
|
$.get(itemEl.find('.jFiler-item-trash-action').attr('href')) |
||||||
|
}, |
||||||
|
onEmpty: null, |
||||||
|
options: null, |
||||||
|
dialogs: { |
||||||
|
alert: function(text) { |
||||||
|
return alert(text); |
||||||
|
}, |
||||||
|
confirm: function (text, callback) { |
||||||
|
confirm(text) ? callback() : null; |
||||||
|
} |
||||||
|
}, |
||||||
|
captions: { |
||||||
|
button: "Выберите файлы", |
||||||
|
feedback: "Выберите файлы для загрузки", |
||||||
|
feedback2: "выбранные файлы", |
||||||
|
drop: "Перетяните файлы для загрузки", |
||||||
|
removeConfirmation: "Вы уверены что хотите удалить этот файл?", |
||||||
|
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." |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
var $uploaders = $('.file_upload_container'); |
var $uploaders = $('.file_upload_container'); |
||||||
|
|
||||||
$uploaders.each(function (i, uploader) { |
$uploaders.each(function (i, uploader) { |
||||||
var $uploader = $(uploader), |
var $uploader = $(uploader), |
||||||
fields = $uploader.data('fields').split('|'), // Массив названий полей для создания фото
|
fields = $uploader.data('fields').split('|'), // Массив названий полей для создания фото
|
||||||
languages = $uploader.data('languages').split('|'); // Массив языков, будет использоватся для генерации инпутов
|
languages = $uploader.data('languages').split('|'); // Массив языков, будет использоватся для генерации инпутов
|
||||||
|
|
||||||
init_filer($uploader); |
init_filer($uploader); |
||||||
}); |
}); |
||||||
Loading…
Reference in new issue