Fixes
This commit is contained in:
parent
75de95acc3
commit
d5c3b25447
4 changed files with 296 additions and 79 deletions
21
ajax_list.js
21
ajax_list.js
|
|
@ -46,21 +46,8 @@ $=jQuery;
|
|||
}
|
||||
|
||||
this.order_field=0;
|
||||
|
||||
if(options.hasOwnProperty("order_field")) {
|
||||
|
||||
this.order_field=options.order_field;
|
||||
|
||||
}
|
||||
|
||||
this.order=0;
|
||||
|
||||
if(options.hasOwnProperty("order")) {
|
||||
|
||||
this.order=options.order;
|
||||
|
||||
}
|
||||
|
||||
arr_icon=['<i class="fa fa-arrow-down asc_icon" aria-hidden="true"></i>', '<i class="fa fa-arrow-up desc_icon" aria-hidden="true"></i>'];
|
||||
|
||||
var func=this;
|
||||
|
|
@ -204,6 +191,14 @@ $=jQuery;
|
|||
|
||||
});
|
||||
|
||||
if(options.hasOwnProperty("after_list")) {
|
||||
|
||||
after_list=options.after_list;
|
||||
|
||||
after_list();
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0%);*/
|
||||
/* position: absolute;
|
||||
top: 50%;
|
||||
position: absolute;
|
||||
/*top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);*/
|
||||
z-index:50005;
|
||||
|
|
@ -45,9 +45,10 @@
|
|||
/*-webkit-box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);
|
||||
-moz-box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);
|
||||
box-shadow: 0px 0px 160px 0px rgba(80,80,80,1);*/
|
||||
/*box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
-webkit-box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
-moz-box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);*/
|
||||
-moz-box-shadow: 0px 0px 5px 5px rgba(0,0,0,0.33);
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
/* Css for animation loading */
|
||||
|
|
|
|||
218
popup.js
218
popup.js
|
|
@ -202,3 +202,221 @@ $=jQuery;
|
|||
}
|
||||
|
||||
})( jQuery );
|
||||
|
||||
$=jQuery;
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.fn.simplePopUp=function (popup, width, pre_callback, post_callback, options) {
|
||||
|
||||
var after_show=false;
|
||||
|
||||
var after_click=false;
|
||||
|
||||
if(options!=undefined)
|
||||
{
|
||||
|
||||
if(options.hasOwnProperty("popup_container"))
|
||||
{
|
||||
|
||||
popup_container=options.popup_container;
|
||||
|
||||
}
|
||||
|
||||
if(options.hasOwnProperty("after_show"))
|
||||
{
|
||||
|
||||
after_show=options.after_show;
|
||||
|
||||
}
|
||||
|
||||
if(options.hasOwnProperty("after_click"))
|
||||
{
|
||||
|
||||
after_click=options.after_click;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$(this).on('click', function (e) {
|
||||
|
||||
//Show layer_popup
|
||||
|
||||
body_height=$("body").height();
|
||||
|
||||
$('#layer_popup').height(body_height);
|
||||
|
||||
$('body').prepend('<div id="layer_popup"></div>');
|
||||
|
||||
//$('body').css('overflow', 'hidden');
|
||||
|
||||
//Show popup
|
||||
|
||||
$(popup).css('position', 'absolute');
|
||||
|
||||
$(popup).css('width', width);
|
||||
|
||||
$(popup).addClass('content_popup');
|
||||
|
||||
/*var position=$(popup).offset();
|
||||
|
||||
var left=position.left;
|
||||
var top=position.top;
|
||||
|
||||
console.log($(popup).css('left'));*/
|
||||
|
||||
scr_width=$(window).width();
|
||||
|
||||
scr_height=$(window).height();
|
||||
|
||||
center_left=parseInt(scr_width/2)-parseInt(width/2);
|
||||
|
||||
center_top=parseInt(scr_height/2)-parseInt($(popup).height()/2);
|
||||
|
||||
$(popup).css('left', center_left);
|
||||
$(popup).css('top', center_top);
|
||||
|
||||
if(!after_show)
|
||||
{
|
||||
|
||||
$(popup).fadeIn();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$(popup).fadeIn({'done': after_show(popup)});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.close_popup').click(function () {
|
||||
|
||||
if(after_click)
|
||||
{
|
||||
|
||||
after_click();
|
||||
|
||||
}
|
||||
|
||||
$('#layer_popup').remove();
|
||||
|
||||
$(popup).hide();
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
|
||||
//From https://www.w3schools.com/howto/howto_js_draggable.asp
|
||||
|
||||
function dragElement(draggable, header) {
|
||||
|
||||
elmnt=document.getElementById(draggable);
|
||||
|
||||
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
||||
if (document.getElementById(header)) {
|
||||
// if present, the header is where you move the DIV from:
|
||||
document.getElementById(header).onmousedown = dragMouseDown;
|
||||
} else {
|
||||
// otherwise, move the DIV from anywhere inside the DIV:
|
||||
elmnt.onmousedown = dragMouseDown;
|
||||
}
|
||||
|
||||
function dragMouseDown(e) {
|
||||
e = e || window.event;
|
||||
e.preventDefault();
|
||||
// get the mouse cursor position at startup:
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
document.onmouseup = closeDragElement;
|
||||
// call a function whenever the cursor moves:
|
||||
document.onmousemove = elementDrag;
|
||||
}
|
||||
|
||||
function elementDrag(e) {
|
||||
e = e || window.event;
|
||||
e.preventDefault();
|
||||
// calculate the new cursor position:
|
||||
pos1 = pos3 - e.clientX;
|
||||
pos2 = pos4 - e.clientY;
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
// set the element's new position:
|
||||
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
|
||||
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
|
||||
}
|
||||
|
||||
function closeDragElement() {
|
||||
// stop moving when mouse button is released:
|
||||
document.onmouseup = null;
|
||||
document.onmousemove = null;
|
||||
}
|
||||
}
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.fn.draggable = function (header) {
|
||||
|
||||
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
||||
|
||||
var popup=this;
|
||||
|
||||
$(header).on('mousedown', function (e) {
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
e.preventDefault();
|
||||
// get the mouse cursor position at startup:
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
|
||||
document.onmouseup = closeDragElement;
|
||||
|
||||
// call a function whenever the cursor moves:
|
||||
document.onmousemove = elementDrag;
|
||||
|
||||
console.log('Moving...');
|
||||
|
||||
});
|
||||
|
||||
function elementDrag(e) {
|
||||
|
||||
console.log('Moving windows...');
|
||||
|
||||
e = e || window.event;
|
||||
e.preventDefault();
|
||||
// calculate the new cursor position:
|
||||
pos1 = pos3 - e.clientX;
|
||||
pos2 = pos4 - e.clientY;
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
// set the element's new position:
|
||||
/*elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
|
||||
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";*/
|
||||
|
||||
offset=$(popup).offset();
|
||||
|
||||
offset_top=parseInt(offset.top);
|
||||
offset_left=parseInt(offset.left);
|
||||
|
||||
$(popup).css('top', (offset_top - pos2) + "px");
|
||||
$(popup).css('left', (offset_left - pos1) + "px");
|
||||
|
||||
}
|
||||
|
||||
function closeDragElement() {
|
||||
// stop moving when mouse button is released:
|
||||
document.onmouseup = null;
|
||||
document.onmousemove = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
115
posting2.js
115
posting2.js
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
/* Add csrf token */
|
||||
|
||||
/* options: url: url to post, loading: dom id, success: func, pre_callback, separated_data:boolean */
|
||||
|
||||
$.fn.options={};
|
||||
/* options: url: url to post, loading: dom id, success: func, error_data: func, pre_callback, separated_data:boolean, upload: {progressbar: '#progressbar', 'total_loader': '#total_loader', 'status': '#status'} */
|
||||
|
||||
$.fn.sendPost = function (options)
|
||||
{
|
||||
|
|
@ -25,58 +23,61 @@
|
|||
|
||||
}
|
||||
|
||||
this.options=options;
|
||||
var xhr=false;
|
||||
|
||||
$(this).on('submit', {url: this.options.url}, function (e) {
|
||||
if(options.hasOwnProperty("upload")) {
|
||||
|
||||
xhr=function() {
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
if(myXhr.upload){
|
||||
|
||||
var progressbar=options.upload.progressbar;
|
||||
var total_loader=options.upload.total_loader;
|
||||
var status=options.upload.status;
|
||||
|
||||
$(total_loader).html('');
|
||||
$(progressbar).attr('value', 0);
|
||||
$(status).html('');
|
||||
|
||||
myXhr.upload.addEventListener('progress',function (event) {
|
||||
|
||||
$(total_loader).html("Uploaded "+event.loaded+" bytes of "+event.total);
|
||||
var percent = (event.loaded / event.total) * 100;
|
||||
$(progressbar).attr('value', (Math.round(percent)));
|
||||
$(status).html(Math.round(percent)+"% uploaded... please wait");
|
||||
|
||||
}, false);
|
||||
|
||||
myXhr.addEventListener("load", function(event) {
|
||||
|
||||
$(status).html("File loaded successfully!!");
|
||||
|
||||
}, false);
|
||||
}
|
||||
return myXhr;
|
||||
}
|
||||
}
|
||||
|
||||
$(this).on('submit', function (e) {
|
||||
|
||||
//Get data of form
|
||||
|
||||
form=this;
|
||||
|
||||
/*if($(this).attr('enctype'))
|
||||
{*/
|
||||
if(options.separated_data)
|
||||
{
|
||||
|
||||
data[options.separated_data]=new FormData($(this)[0]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
data=new FormData($(this)[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
xhrFields={
|
||||
withCredentials: true
|
||||
};
|
||||
|
||||
/*}
|
||||
if(options.separated_data)
|
||||
{
|
||||
data[options.separated_data]=new FormData($(this)[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
data=new FormData($(this)[0]);
|
||||
}
|
||||
|
||||
if(options.separated_data)
|
||||
{
|
||||
|
||||
data[options.separated_data]=$(this).serializeArray();
|
||||
xhrFields={
|
||||
withCredentials: true
|
||||
};
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
data=$(this).serializeArray().reduce(function(obj, item) {
|
||||
obj[item.name] = item.value;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
}
|
||||
|
||||
xhrFields={
|
||||
};
|
||||
|
||||
}*/
|
||||
|
||||
if(!data.hasOwnProperty("csrf_token")) {
|
||||
|
||||
|
|
@ -87,11 +88,8 @@
|
|||
//Hide form and show the time icon
|
||||
|
||||
$(this).find('.error').hide();
|
||||
//$(this).hide();
|
||||
$(options.loading).show();
|
||||
|
||||
/*$(this).find('input').prop("disabled", true);
|
||||
$(this).find('select').prop("disabled", true);*/
|
||||
$(options.loading).show();
|
||||
|
||||
if(options.hasOwnProperty("pre_callback")) {
|
||||
|
||||
|
|
@ -101,20 +99,19 @@
|
|||
|
||||
//Ajax
|
||||
|
||||
$.ajax({
|
||||
ajax_post={
|
||||
type: "POST",
|
||||
url: options.url,
|
||||
data: data,
|
||||
encoding: "UTF-8",
|
||||
xhrFields: xhrFields,
|
||||
cache:false,
|
||||
contentType: false,
|
||||
contentType:false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
|
||||
$(options.loading).hide();
|
||||
|
||||
|
||||
if(data.error) {
|
||||
|
||||
if(!data.hasOwnProperty("error_csrf"))
|
||||
|
|
@ -172,8 +169,6 @@
|
|||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
// If ok then post successful task.
|
||||
|
||||
if(options.hasOwnProperty("success")) {
|
||||
|
|
@ -200,14 +195,22 @@
|
|||
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
};
|
||||
|
||||
//console.log(xhr);
|
||||
|
||||
if(xhr!=false) {
|
||||
|
||||
ajax_post.xhr=xhr;
|
||||
|
||||
}
|
||||
|
||||
$.ajax(ajax_post);
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
})( jQuery );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue