-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend_body.js
211 lines (189 loc) · 5.74 KB
/
backend_body.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
(function($){
/*
* includeMany 1.2.2
*
* Copyright (c) 2009 Arash Karimzadeh (arashkarimzadeh.com)
* Licensed under the MIT (MIT-LICENSE.txt)
* http://www.opensource.org/licenses/mit-license.php
* http://www.arashkarimzadeh.com/jquery/17-includemany-jquery-include-many.html
*
* Date: Dec 03 2009
*/
$.chainclude = function(urls,finaly){
var onload = function(callback,data){
if(typeof urls.length!='undefined'){
if(urls.length==0)
return $.isFunction(finaly)
?finaly(data)
:null;
urls.shift();
return $.chainclude.load(urls,onload);
}
for(var item in urls){
urls[item](data);
delete urls[item];
var count = 0;
for(var i in urls)
count++;
return (count==0)
?$.isFunction(finaly)?finaly(data):null
:$.chainclude.load(urls,onload);
}
}
$.chainclude.load(urls,onload);
};
$.chainclude.load = function(urls,onload){
if(typeof urls=='object' && typeof urls.length=='undefined')
for(var item in urls)
return $.include.load(item,onload,urls[item].callback);
urls = $.makeArray(urls);
$.include.load(urls[0],onload,null);
};
$.include = function(urls,finaly){
var luid = $.include.luid++;
var onload = function(callback,data){
if($.isFunction(callback))
callback(data);
if(--$.include.counter[luid]==0&&$.isFunction(finaly))
finaly();
}
if(typeof urls=='object' && typeof urls.length=='undefined'){
$.include.counter[luid] = 0;
for(var item in urls)
$.include.counter[luid]++;
return $.each(urls,function(url,callback){$.include.load(url,onload,callback);});
}
urls = $.makeArray(urls);
$.include.counter[luid] = urls.length;
$.each(urls,function(){$.include.load(this,onload,null);});
}
$.extend(
$.include,
{
luid: 0,
counter: [],
load: function(url,onload,callback){
url = url.toString();
if($.include.exist(url))
return onload(callback);
if(/.css$/.test(url))
$.include.loadCSS(url,onload,callback);
else if(/.js$/.test(url))
$.include.loadJS(url,onload,callback);
else
$.get(url,function(data){onload(callback,data)});
},
loadCSS: function(url,onload,callback){
var css=document.createElement('link');
css.setAttribute('type','text/css');
css.setAttribute('rel','stylesheet');
css.setAttribute('href',''+url);
$('head').get(0).appendChild(css);
$.browser.msie
?$.include.IEonload(css,onload,callback)
:onload(callback);//other browsers do not support it
},
loadJS: function(url,onload,callback){
var js=document.createElement('script');
js.setAttribute('type','text/javascript');
js.setAttribute('src',''+url);
$.browser.msie
?$.include.IEonload(js,onload,callback)
:js.onload = function(){onload(callback)};
$('head').get(0).appendChild(js);
},
IEonload: function(elm,onload,callback){
elm.onreadystatechange =
function(){
if(this.readyState=='loaded'||this.readyState=='complete')
onload(callback);
}
},
exist: function(url){
var fresh = false;
$('head script').each(
function(){
if(/.css$/.test(url)&&this.href==url)
return fresh=true;
else if(/.js$/.test(url)&&this.src==url)
return fresh=true;
}
);
return fresh;
}
}
);
//
})(jQuery);
if(!jQuery().sortable){
// load_jQ_UI;
$.include('../../include/jquery/jquery-ui-min.js');
}
$(window).load(function(){
// load jQuery UI if sortable not loaded
if(jQuery().sortable){
/**
Drag&Drop
*/
$(function() {
// This class="dragdrop_bakery" will result in class="dragdrop_bakery dragdrop_handle"
$('.dragdrop_bakery').addClass('dragdrop_handle');
// Remove up/down icons (we have drag&drop therefore we don't need them)
$(".move_up a,.move_down a").fadeOut(1);
$("#dragBakeryTable").sortable({
appendTo: 'body',
handle: '.dragdrop_handle',
opacity: 0.8,
cursor: 'move',
update: function() {
var order = $(this).sortable("serialize") + '&action=updatePosition';
$.post("../../modules/bakery/move_dragdrop.php", order, function(acknowledgement){
//$("#dragBakeryTable tr").removeClass('hilite');
$("#dragBakeryResult").html(acknowledgement).fadeIn("slow");
$("#dragBakeryResult").fadeOut(3500);
});
}
})
});
}//endif
/*
hover effect for item rows
*/
$("tr.irow")
.mouseover(function(){
$(this).addClass("irow_hover");
})
.mouseout(function(){
$(this).removeClass("irow_hover");
});
}); //window.load
/**
Image preview script
written by Alen Grakalic (http://cssglobe.com)
for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
*/
this.imagePreview = function(){
$('div.mod_bakery_thumbnail_b a.internal').addClass('preview');
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='mod_bakery_preview_b'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
$("#mod_bakery_preview_b")
.css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("slow");
},
function(){
this.title = this.t;
$("#mod_bakery_preview_b").remove();
});
$("a.preview").mousemove(function(e){
$("#mod_bakery_preview_b")
.css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
});
};
$(window).load(function(){
// initialize Image preview script
xOffset = 100;
yOffset = 40;
imagePreview();
}); //window.load