| 1 |
|
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
(function($) |
| 6 |
{ |
| 7 |
|
| 8 |
/** |
| 9 |
* put your comment there... |
| 10 |
* |
| 11 |
*/ |
| 12 |
window.CJTResponsiveHelper = new function() |
| 13 |
{ |
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @type Object |
| 18 |
*/ |
| 19 |
var widthsMap = {}; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
*/ |
| 25 |
var cssMarker = function() |
| 26 |
{ |
| 27 |
|
| 28 |
var body = $('body'); |
| 29 |
|
| 30 |
$.each(widthsMap, |
| 31 |
|
| 32 |
function(index, width) |
| 33 |
{ |
| 34 |
|
| 35 |
var widthBodyClass = 'cjt-responsive-wm-' + width; |
| 36 |
|
| 37 |
if ((screen.width <= width)) |
| 38 |
{ |
| 39 |
|
| 40 |
if (!body.hasClass(widthBodyClass)) |
| 41 |
{ |
| 42 |
body.addClass(widthBodyClass); |
| 43 |
} |
| 44 |
|
| 45 |
} |
| 46 |
else |
| 47 |
{ |
| 48 |
|
| 49 |
if (body.hasClass(widthBodyClass)) |
| 50 |
{ |
| 51 |
body.removeClass(widthBodyClass); |
| 52 |
} |
| 53 |
|
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
); |
| 58 |
}; |
| 59 |
|
| 60 |
/** |
| 61 |
* |
| 62 |
*/ |
| 63 |
this.defWidths = function(map) |
| 64 |
{ |
| 65 |
|
| 66 |
widthsMap = map; |
| 67 |
|
| 68 |
return this; |
| 69 |
}; |
| 70 |
|
| 71 |
// Init when ready |
| 72 |
$($.proxy( |
| 73 |
|
| 74 |
function() |
| 75 |
{ |
| 76 |
// Set Default widths map |
| 77 |
this.defWidths([786]); |
| 78 |
|
| 79 |
// Init for first time |
| 80 |
cssMarker(); |
| 81 |
|
| 82 |
// Set responsive class names when window resized |
| 83 |
$(window).resize($.proxy(cssMarker)); |
| 84 |
} |
| 85 |
|
| 86 |
, this)); |
| 87 |
|
| 88 |
/** |
| 89 |
* |
| 90 |
*/ |
| 91 |
this.getThickBoxSize = function(params, recusriveLevel) |
| 92 |
{ |
| 93 |
|
| 94 |
var wnd = $(window); |
| 95 |
|
| 96 |
if (recusriveLevel === undefined) |
| 97 |
{ |
| 98 |
recusriveLevel = 0; |
| 99 |
} |
| 100 |
|
| 101 |
var stopOffset = |
| 102 |
{ |
| 103 |
width : params.width + 30, |
| 104 |
height : params.height + 60 + (recusriveLevel * 20) |
| 105 |
}; |
| 106 |
|
| 107 |
// Landscape on low screen height need less height dialogs |
| 108 |
if (wnd.height() < wnd.width()) |
| 109 |
{ |
| 110 |
stopOffset.height += 50 |
| 111 |
} |
| 112 |
|
| 113 |
// Calculate width and height based on window size |
| 114 |
// Get smaller when window is smaller and vise versa |
| 115 |
|
| 116 |
params.width += ((wnd.width() < stopOffset.width) ? (wnd.width() - stopOffset.width) : 0); |
| 117 |
params.height += ((wnd.height() < stopOffset.height) ? (wnd.height() - stopOffset.height) : 0); |
| 118 |
|
| 119 |
return params; |
| 120 |
}; |
| 121 |
|
| 122 |
}; |
| 123 |
|
| 124 |
})(jQuery); |