Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.69 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. $('.content_box').hide();
  4. $('.sf-menuUP a').click(function(){
  5. $('.content_box').fadeIn('slow');
  6. });
  7.  
  8. var hash = window.location.hash.substr(1);
  9. var href = $('.sf-menuUP li a').each(function(){
  10. var href = $(this).attr('href');
  11. if(hash==href.substr(0,href.length-5)){
  12. var toLoad = hash+'.html #content';
  13. $('#content').load(toLoad)
  14. }
  15. });
  16.  
  17. $('.sf-menuUP li a').click(function(){
  18.  
  19. var toLoad = $(this).attr('href')+' #content';
  20. $('#content').fadeOut('fast',loadContent);
  21. $('#load').remove();
  22. $('#wrapper').append('<span id="load">LOADING...</span>');
  23. $('#load').fadeIn('normal');
  24. window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
  25. function loadContent() {
  26. $('#content').load(toLoad,'',showNewContent())
  27. }
  28. function showNewContent() {
  29. $('#content').fadeIn('normal',hideLoader());
  30. }
  31. function hideLoader() {
  32. $('#load').fadeOut('normal');
  33. }
  34. return false;
  35. });
  36.  
  37. // AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
  38. jQuery(function($) {
  39. $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
  40. return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  41. });
  42. });
  43.  
  44. $("a[rel^='lightbox']").livequery(function(){
  45. $(this).slimbox({/* Put custom options here */}, null, function(el) {
  46. return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  47. }), function() {
  48. //remove slimbox? this is called when elements no longer match
  49. }
  50. });
  51.  
  52. <script type="text/javascript">
  53. $(document).ready(function() {
  54. $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
  55. return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  56. });
  57. });
  58. </script>
  59.  
  60. /*!
  61. Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
  62. (c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
  63. MIT-style license.
  64. */
  65.  
  66. (function($) {
  67.  
  68. // Global variables, accessible to Slimbox only
  69. var win = $(window), options, images, activeImage = -1, activeURL, prevImage, nextImage, compatibleOverlay, middle, centerWidth, centerHeight, ie6 = !window.XMLHttpRequest,
  70. operaFix = window.opera && (document.compatMode == "CSS1Compat") && ($.browser.version >= 9.3), documentElement = document.documentElement,
  71.  
  72. // Preload images
  73. preload = {}, preloadPrev = new Image(), preloadNext = new Image(),
  74.  
  75. // DOM elements
  76. overlay, center, image, sizer, prevLink, nextLink, bottomContainer, bottom, caption, number;
  77.  
  78. /*
  79. Initialization
  80. */
  81.  
  82. $(function() {
  83. // Append the Slimbox HTML code at the bottom of the document
  84. $("body").append(
  85. $([
  86. overlay = $('<div id="lbOverlay" />')[0],
  87. center = $('<div id="lbCenter" />')[0],
  88. bottomContainer = $('<div id="lbBottomContainer" />')[0]
  89. ]).css("display", "none")
  90. );
  91.  
  92. image = $('<div id="lbImage" />').appendTo(center).append(
  93. sizer = $('<div style="position: relative;" />').append([
  94. prevLink = $('<a id="lbPrevLink" href="#" />').click(previous)[0],
  95. nextLink = $('<a id="lbNextLink" href="#" />').click(next)[0]
  96. ])[0]
  97. )[0];
  98.  
  99. bottom = $('<div id="lbBottom" />').appendTo(bottomContainer).append([
  100. $('<a id="lbCloseLink" href="#" />').add(overlay).click(close)[0],
  101. caption = $('<div id="lbCaption" />')[0],
  102. number = $('<div id="lbNumber" />')[0],
  103. $('<div style="clear: both;" />')[0]
  104. ])[0];
  105. });
  106.  
  107.  
  108. /*
  109. API
  110. */
  111.  
  112. // Open Slimbox with the specified parameters
  113. $.slimbox = function(_images, startImage, _options) {
  114. options = $.extend({
  115. loop: false, // Allows to navigate between first and last images
  116. overlayOpacity: 0.8, // 1 is opaque, 0 is completely transparent (change the color in the CSS file)
  117. overlayFadeDuration: 400, // Duration of the overlay fade-in and fade-out animations (in milliseconds)
  118. resizeDuration: 400, // Duration of each of the box resize animations (in milliseconds)
  119. resizeEasing: "swing", // "swing" is jQuery's default easing
  120. initialWidth: 250, // Initial width of the box (in pixels)
  121. initialHeight: 250, // Initial height of the box (in pixels)
  122. imageFadeDuration: 400, // Duration of the image fade-in animation (in milliseconds)
  123. captionAnimationDuration: 400, // Duration of the caption animation (in milliseconds)
  124. counterText: "Image {x} of {y}", // Translate or change as you wish, or set it to false to disable counter text for image groups
  125. closeKeys: [27, 88, 67], // Array of keycodes to close Slimbox, default: Esc (27), 'x' (88), 'c' (67)
  126. previousKeys: [37, 80], // Array of keycodes to navigate to the previous image, default: Left arrow (37), 'p' (80)
  127. nextKeys: [39, 78] // Array of keycodes to navigate to the next image, default: Right arrow (39), 'n' (78)
  128. }, _options);
  129.  
  130. // The function is called for a single image, with URL and Title as first two arguments
  131. if (typeof _images == "string") {
  132. _images = [[_images, startImage]];
  133. startImage = 0;
  134. }
  135.  
  136. middle = win.scrollTop() + ((operaFix ? documentElement.clientHeight : win.height()) / 2);
  137. centerWidth = options.initialWidth;
  138. centerHeight = options.initialHeight;
  139. $(center).css({top: Math.max(0, middle - (centerHeight / 2)), width: centerWidth, height: centerHeight, marginLeft: -centerWidth/2}).show();
  140. compatibleOverlay = ie6 || (overlay.currentStyle && (overlay.currentStyle.position != "fixed"));
  141. if (compatibleOverlay) overlay.style.position = "absolute";
  142. $(overlay).css("opacity", options.overlayOpacity).fadeIn(options.overlayFadeDuration);
  143. position();
  144. setup(1);
  145.  
  146. images = _images;
  147. options.loop = options.loop && (images.length > 1);
  148. return changeImage(startImage);
  149. };
  150.  
  151. /*
  152. options: Optional options object, see jQuery.slimbox()
  153. linkMapper: Optional function taking a link DOM element and an index as arguments and returning an array containing 2 elements:
  154. the image URL and the image caption (may contain HTML)
  155. linksFilter: Optional function taking a link DOM element and an index as arguments and returning true if the element is part of
  156. the image collection that will be shown on click, false if not. "this" refers to the element that was clicked.
  157. This function must always return true when the DOM element argument is "this".
  158. */
  159. $.fn.slimbox = function(_options, linkMapper, linksFilter) {
  160. linkMapper = linkMapper || function(el) {
  161. return [el.href, el.title];
  162. };
  163.  
  164. linksFilter = linksFilter || function() {
  165. return true;
  166. };
  167.  
  168. var links = this;
  169.  
  170. return links.unbind("click").click(function() {
  171. // Build the list of images that will be displayed
  172. var link = this, startIndex = 0, filteredLinks, i = 0, length;
  173. filteredLinks = $.grep(links, function(el, i) {
  174. return linksFilter.call(link, el, i);
  175. });
  176.  
  177. // We cannot use jQuery.map() because it flattens the returned array
  178. for (length = filteredLinks.length; i < length; ++i) {
  179. if (filteredLinks[i] == link) startIndex = i;
  180. filteredLinks[i] = linkMapper(filteredLinks[i], i);
  181. }
  182.  
  183. return $.slimbox(filteredLinks, startIndex, _options);
  184. });
  185. };
  186.  
  187.  
  188. /*
  189. Internal functions
  190. */
  191.  
  192. function position() {
  193. var l = win.scrollLeft(), w = operaFix ? documentElement.clientWidth : win.width();
  194. $([center, bottomContainer]).css("left", l + (w / 2));
  195. if (compatibleOverlay) $(overlay).css({left: l, top: win.scrollTop(), width: w, height: win.height()});
  196. }
  197.  
  198. function setup(open) {
  199. $("object").add(ie6 ? "select" : "embed").each(function(index, el) {
  200. if (open) $.data(el, "slimbox", el.style.visibility);
  201. el.style.visibility = open ? "hidden" : $.data(el, "slimbox");
  202. });
  203. var fn = open ? "bind" : "unbind";
  204. win[fn]("scroll resize", position);
  205. $(document)[fn]("keydown", keyDown);
  206. }
  207.  
  208. function keyDown(event) {
  209. var code = event.keyCode, fn = $.inArray;
  210. // Prevent default keyboard action (like navigating inside the page)
  211. return (fn(code, options.closeKeys) >= 0) ? close()
  212. : (fn(code, options.nextKeys) >= 0) ? next()
  213. : (fn(code, options.previousKeys) >= 0) ? previous()
  214. : false;
  215. }
  216.  
  217. function previous() {
  218. return changeImage(prevImage);
  219. }
  220.  
  221. function next() {
  222. return changeImage(nextImage);
  223. }
  224.  
  225. function changeImage(imageIndex) {
  226. if (imageIndex >= 0) {
  227. activeImage = imageIndex;
  228. activeURL = images[activeImage][0];
  229. prevImage = (activeImage || (options.loop ? images.length : 0)) - 1;
  230. nextImage = ((activeImage + 1) % images.length) || (options.loop ? 0 : -1);
  231.  
  232. stop();
  233. center.className = "lbLoading";
  234.  
  235. preload = new Image();
  236. preload.onload = animateBox;
  237. preload.src = activeURL;
  238. }
  239.  
  240. return false;
  241. }
  242.  
  243. function animateBox() {
  244. center.className = "";
  245. $(image).css({backgroundImage: "url(" + activeURL + ")", visibility: "hidden", display: ""});
  246. $(sizer).width(preload.width);
  247. $([sizer, prevLink, nextLink]).height(preload.height);
  248.  
  249. $(caption).html(images[activeImage][1] || "");
  250. $(number).html((((images.length > 1) && options.counterText) || "").replace(/{x}/, activeImage + 1).replace(/{y}/, images.length));
  251.  
  252. if (prevImage >= 0) preloadPrev.src = images[prevImage][0];
  253. if (nextImage >= 0) preloadNext.src = images[nextImage][0];
  254.  
  255. centerWidth = image.offsetWidth;
  256. centerHeight = image.offsetHeight;
  257. var top = Math.max(0, middle - (centerHeight / 2));
  258. if (center.offsetHeight != centerHeight) {
  259. $(center).animate({height: centerHeight, top: top}, options.resizeDuration, options.resizeEasing);
  260. }
  261. if (center.offsetWidth != centerWidth) {
  262. $(center).animate({width: centerWidth, marginLeft: -centerWidth/2}, options.resizeDuration, options.resizeEasing);
  263. }
  264. $(center).queue(function() {
  265. $(bottomContainer).css({width: centerWidth, top: top + centerHeight, marginLeft: -centerWidth/2, visibility: "hidden", display: ""});
  266. $(image).css({display: "none", visibility: "", opacity: ""}).fadeIn(options.imageFadeDuration, animateCaption);
  267. });
  268. }
  269.  
  270. function animateCaption() {
  271. if (prevImage >= 0) $(prevLink).show();
  272. if (nextImage >= 0) $(nextLink).show();
  273. $(bottom).css("marginTop", -bottom.offsetHeight).animate({marginTop: 0}, options.captionAnimationDuration);
  274. bottomContainer.style.visibility = "";
  275. }
  276.  
  277. function stop() {
  278. preload.onload = null;
  279. preload.src = preloadPrev.src = preloadNext.src = activeURL;
  280. $([center, image, bottom]).stop(true);
  281. $([prevLink, nextLink, image, bottomContainer]).hide();
  282. }
  283.  
  284. function close() {
  285. if (activeImage >= 0) {
  286. stop();
  287. activeImage = prevImage = nextImage = -1;
  288. $(center).hide();
  289. $(overlay).stop().fadeOut(options.overlayFadeDuration, setup);
  290. }
  291.  
  292. return false;
  293. }
  294.  
  295. })(jQuery);
  296.  
  297. function showNewContent() {
  298. // Attach slimbox to new content...
  299. $('#content').find("a[rel^='lightbox']").slimbox({}, null, function(el) {
  300. return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  301. });
  302. // ... and then bring up the new stuff.
  303. $('#content').fadeIn('normal',hideLoader());
  304. }
  305.  
  306. <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
  307. <script src="../slimbox-2.05/slimbox2.js" type="text/javascript"></script>
  308. <script type="text/javascript">
  309. function pageLoad() {
  310. jQuery(function ($) {
  311. $("a[rel^='lightbox']").slimbox({/* Put custom options here */
  312. }, null, function (el) {
  313. return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
  314. });
  315. });
  316. }
  317. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement