/
global-mod.js
executable file
·444 lines (408 loc) · 14.5 KB
/
global-mod.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
// HTML5 placeholder plugin version 0.3
// Enables cross-browser* html5 placeholder for inputs, by first testing
// for a native implementation before building one.
//
// USAGE:
//$('input[placeholder]').placeholder();
(function($){
$.fn.placeholder = function(options) {
return this.each(function() {
if ( !("placeholder" in document.createElement(this.tagName.toLowerCase()))) {
var $this = $(this);
var placeholder = $this.attr('placeholder');
$this.val(placeholder).data('color', $this.css('color')).css('color', '#aaa');
$this
.focus(function(){ if ($.trim($this.val())===placeholder){ $this.val('').css('color', $this.data('color')); } })
.blur(function(){ if (!$.trim($this.val())){ $this.val(placeholder).data('color', $this.css('color')).css('color', '#aaa'); } });
}
});
};
}(jQuery));
var menuYloc = null;
var sortableCookieExpiry = 365;
var sortableCookie = "sortable-order"
var sortableName = ".sortable";
// perform JavaScript after the document is scriptable.
$(document).ready(function() {
/**
* Main Menu Shortcuts Toggle
*/
// $('.chevron').click(function(){
// if ($(this).hasClass('toggle-up')) {
// if (!$.browser.msie) {
// $('.shortcuts').slideUp();
// } else {
// $('.shortcuts').hide();
// }
// } else {
// if (!$.browser.msie) {
// $('.shortcuts').slideDown();
// } else {
// $('.shortcuts').show();
// }
// }
// $(this).toggleClass('toggle-up');
// });
/**
* Skin select elements
*/
// $('select:not([multiple])').each(function(){
// var select = this;
// $(this).wrap('<span class="ui-select" />')
// .before('<span class="ui-select-value" />')
// .bind('change, click', function(){
// $(this).prev().html($(this).find('option:selected').text());
// })
// .after('<a class="ui-select-button button button-gray"><span></span></a>')
// .prev().html($(this).find('option:selected').text());
// $(this).mousedown(function(){
// $(this).next().addClass("active");
// }).mouseup(function(){
// $(this).next().removeClass("active");
// }).hover(function(){
// $(this).next().addClass("hover");
// }, function(){
// $(this).next().removeClass("hover");
// }).parent().disableSelection();
// });
/**
* Skin file input elements
*/
// $(':file').each(function(){
// var file = this;
// $(this).attr('size', 25).wrap('<span class="ui-file" />')
// .before('<span class="ui-file-value">No file chosen</span><button class="ui-file-button button button-gray">Browse...</button>')
// .change(function(){
// $(file).parent().find('.ui-file-value').html($(this).val()? $(this).val() : 'No file chosen');
// })
// .hover(
// function(){ $(file).prev().addClass('hover');},
// function(){ $(file).prev().removeClass('hover');}
// ).mousedown(function(){$(file).prev().addClass('active');})
// .bind('mouseup mouseleave', function(){$(file).prev().removeClass('active');})
// .parent().disableSelection();
// });
/**
* Setup tooltips
*/
// $('[title]').tooltip({
// effect: 'slide', offset: [-14, 0], position: 'top center', layout: '<div><em/></div>',
// onBeforeShow: function() {
// this.getTip().each(function(){
// if ($.browser.msie) {
// PIE.attach(this);
// }
// });
// },
// onHide: function() {
// this.getTip().each(function(){
// if ($.browser.msie) {
// PIE.detach(this);
// }
// });
// }
// }).dynamic({
// bottom: { direction: 'down', bounce: true }
// });
/**
* Setup the Accordions
*/
// $(".accordion").tabs(".accordion section", {tabs: 'header', effect: 'slide', initialIndex: null});
/**
* Setup the Tabs
*/
$("ul.tabs").tabs("div.panes > section");
/**
* Setup the Sidebar tabs
*/
// $("ul.sidebar-tabs").tabs("div.panes > section");
/**
* Textbox Placeholder
*/
// $('input[placeholder]').placeholder();
/**
* attach calendar to date inputs
*/
// $(":date")
// .wrap('<span class="ui-date" />')
// .dateinput({trigger: true, format: 'mm/dd/yyyy', selectors: true})
// .focus(function(){$(this).parent().addClass('ui-focused'); return false;})
// .blur(function(){$(this).parent().removeClass('ui-focused'); return false;});
/**
* add close buttons to closeable message boxes
*/
// $(".message.closeable").prepend('<span class="message-close"></span>')
// .find('.message-close')
// .click(function(){
// $(this).parent().fadeOut(function(){$(this).remove();});
// });
/**
* setup popup balloons (add contact / add task)
*/
// $('.has-popupballoon').click(function(){
// // close all open popup balloons
// $('.popupballoon').fadeOut();
// $(this).next().fadeIn();
// return false;
// });
//
// $('.popupballoon .close').click(function(){
// $(this).parents('.popupballoon').fadeOut();
// });
/**
* floating menu
*/
// if ($('#wrapper > header').length>0) { menuYloc = parseInt($('#wrapper > header').css("top").substring(0,$('#wrapper > header').css("top").indexOf("px")), 10); }
// $(window).scroll(function () {
// var offset = 0;
// if ($('#wrapper > header').length>0) {
// offset = menuYloc+$(document).scrollTop();
// if (!$.browser.msie) { $('#wrapper > header').animate({opacity: ($(document).scrollTop()<=10? 1 : 0.8)}); }
// }
// });
//
// if (!$.browser.msie) {
// $('#wrapper > header').hover(
// function(){$(this).animate({opacity: 1});},
// function(){$(this).animate({opacity: ($(document).scrollTop()<=10? 1 : 0.8)});}
// );
// }
/**
* html element for the help popup
*/
// $('body').append('<div class="apple_overlay black" id="overlay"><iframe class="contentWrap" style="width: 100%; height: 500px"></iframe></div>');
/**
* this is the help popup
*/
// $("a.help[rel]").overlay({
//
// effect: 'apple',
//
// onBeforeLoad: function() {
//
// // grab wrapper element inside content
// var wrap = this.getOverlay().find(".contentWrap");
//
// // load the page specified in the trigger
// wrap.attr('src', this.getTrigger().attr("href"));
// }
//
// });
/**
* Form Validators
*/
// Regular Expression to test whether the value is valid
// $.tools.validator.fn("[type=time]", "Please supply a valid time", function(input, value) {
// return (/^\d\d:\d\d$/).test(value);
// });
//
// $.tools.validator.fn("[data-equals]", "Value not equal with the $1 field", function(input) {
// var name = input.attr("data-equals"),
// field = this.getInputs().filter("[name=" + name + "]");
// return input.val() === field.val() ? true : [name];
// });
//
// $.tools.validator.fn("[minlength]", function(input, value) {
// var min = input.attr("minlength");
//
// return value.length >= min ? true : {
// en: "Please provide at least " +min+ " character" + (min > 1 ? "s" : "")
// };
// });
//
// $.tools.validator.localizeFn("[type=time]", {
// en: 'Please supply a valid time'
// });
/**
* setup the validators
*/
// $(".form").validator({
// position: 'bottom left',
// offset: [5, 0],
// messageClass:'form-error',
// message: '<div><em/></div>' // em element is the arrow
// }).attr('novalidate', 'novalidate');
//
// if ($(sortableName).sortable) {
// $(sortableName).sortable({
// cursor: 'move',
// revert: 500,
// opacity: 0.7,
// appendTo: 'body',
// handle: 'header',
// items: '.widget-container[draggable=true]',
// placeholder: 'widget-placeholder grid_2',
// forcePlaceholderSize: true,
// start: function(event, ui) {
// ui.item.addClass('start-drag');
// },
// stop: function(event, ui) {
// ui.item.removeClass('start-drag');
// },
// update: function(event, ui) {
// if ($.cookie) {
// $.cookie(sortableCookie, $(this).sortable("toArray"), { expires: sortableCookieExpiry, path: "/" });
// }
// }
// }).disableSelection();
// }
/**
* restore the order of sortable widgets
*/
if ($.cookie) {
restoreOrder(sortableName, sortableCookie);
}
/**
* Widget Drag and Drop
*/
$('.widget-container .widget')
.hover(
function(){
if (!$(this).parent().hasClass('start-drag')) {
$(this).find('header').animate({height : 30}).parents('.widget-container').siblings(':not(.start-drag)').find('header').animate({height: 4});
}
return false;
},
function() {
if (!$(this).parent().hasClass('start-drag')) {
$(this).find('header').animate({height : 4})
}
return false;
}
)
.find('.widget-close').click(function(){
$(this).parents('.widget-container').fadeOut(function(){$(this).remove();});
// perhaps call an ajax function to remember the widget is closed
// $.ajax({url: "somescript.php", data: {widgetId: $(this).parents('.widget-container').attr('id')});
return false;
})
.parents('.widget-container').each(function(){
$(this).css({height: $(this).find('.widget').height()+30}, "slow");
});
/**
* Widget overlays
*/
$(".widget.has-details > section").each(function(){
var section = this;
$(section).append('<a class="rollover" />')
.find('.rollover')
.attr('rel', $(section).prev().find('h2 > a').attr('rel'))
.hover(
function(){$(this).animate({opacity: 0.6});},
function(){$(this).animate({opacity: 0});}
).parents('.widget').find('.rollover[rel]').overlay({
effect: $.browser.msie? 'default' : 'drop',
top: 'center',
mask: {
color: '#000',
loadSpeed: 200,
opacity: 0.5
}
});
});
/**
* Table Sorting, Row Selection and Pagination
*/
if ($.paginate) {
$("table.paginate").paginate({rows: 10, buttonClass: 'button-blue'});
}
if ($.tablesort) {
$("table.tablesort").tablesort();
}
if ($.selectable) {
$("table.selectable").selectable({
onSelect: function(row) {
// do something
},
onDeselect: function(row) {
// do something
}
});
}
/**
* Setup details viewing for table
*/
$('table tr a.view-details').each(function(){
var a = $(this);
$(this).next().overlay({
effect: $.browser.msie? 'default' : 'drop',
top: 'center',
mask: {
color: '#000',
loadSpeed: 200,
opacity: 0.5
},
onClose: function() {
this.getOverlay().appendTo(a.parent());
}
});
}).click(function(){
$(this).next().appendTo('body').overlay().load();
return false;
});
});
/**
* Restores the sortable order from a cookie
*/
function restoreOrder(sortable, cookieName) {
var list = $(sortable);
if (!list) return;
// fetch the saved cookie
var cookie = $.cookie(cookieName);
if (!cookie) return;
// create array from cookie
var IDs = cookie.split(",");
// fetch current order
var items = list.sortable("toArray");
// create associative array from current order
var current = [];
for ( var v=0; v < items.length; v++ ){
current[items[v]] = items[v];
}
for (var i = 0, n = IDs.length; i < n; i++) {
// item id from saved order
var itemID = IDs[i];
if (itemID in current) {
// select the item according to the saved order and reappend it to the list
$(sortable).append($(sortable).children("#" + itemID));
}
}
}
/**
* Custom jQuery Tools Overlay Effect, thanks to the great guys at flowplayer.org :)
*/
// create custom animation algorithm for jQuery called "drop"
// $.easing.drop = function (x, t, b, c, d) {
// return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
// };
//
// // loading animation
// $.tools.overlay.addEffect("drop", function(css, done) {
//
// // use Overlay API to gain access to crucial elements
// var conf = this.getConf(),
// overlay = this.getOverlay();
//
// // determine initial position for the overlay
// if (conf.fixed) {
// css.position = 'fixed';
// } else {
// css.top += $(window).scrollTop();
// css.left += $(window).scrollLeft();
// css.position = 'absolute';
// }
//
// // position the overlay and show it
// overlay.css(css).show();
//
// // begin animating with our custom easing
// overlay.animate({ top: '+=55', opacity: 1, width: '+=20'}, 400, 'drop', done);
//
// /* closing animation */
// }, function(done) {
// this.getOverlay().animate({top:'-=55', opacity:0, width:'-=20'}, 300, 'drop', function() {
// $(this).hide();
// done.call();
// });
// }
// );