diff --git a/addons/photoswipe/PhotoSwipe/LICENSE b/addons/photoswipe/PhotoSwipe/LICENSE new file mode 100644 index 000000000..3391c00e1 --- /dev/null +++ b/addons/photoswipe/PhotoSwipe/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2015 Dmitry Semenov, http://dimsemenov.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/addons/photoswipe/PhotoSwipe/default-skin/default-skin.css b/addons/photoswipe/PhotoSwipe/default-skin/default-skin.css new file mode 100644 index 000000000..f99db1be6 --- /dev/null +++ b/addons/photoswipe/PhotoSwipe/default-skin/default-skin.css @@ -0,0 +1,483 @@ +/*! PhotoSwipe Default UI CSS by Dmitry Semenov | photoswipe.com | MIT license */ +/* + + Contents: + + 1. Buttons + 2. Share modal and links + 3. Index indicator ("1 of X" counter) + 4. Caption + 5. Loading indicator + 6. Additional styles (root element, top bar, idle state, hidden state, etc.) + +*/ +/* + + 1. Buttons + + */ +/* + + + + + + + + + +
+
+
+
+
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + + + + \ No newline at end of file diff --git a/addons/photoswipe/conf/info.xml b/addons/photoswipe/conf/info.xml new file mode 100644 index 000000000..c48bf732f --- /dev/null +++ b/addons/photoswipe/conf/info.xml @@ -0,0 +1,23 @@ + + + 넘겨보는 사진 + PhotoSwipe + + 본문 이미지를 하나의 갤러리 처럼 볼 수 있도록 하는 애드온입니다. + + + Swipe your images of an document on your screens. + + MIT License (codes from http://photoswipe.com/), GPLv2 (other codes by Rhymix contributors) + 1.0.1 + 2016-04-27 + + + misol + misol + + + Rhymix contributors + Rhymix contributors + + \ No newline at end of file diff --git a/addons/photoswipe/photoswipe.addon.php b/addons/photoswipe/photoswipe.addon.php new file mode 100644 index 000000000..288452b79 --- /dev/null +++ b/addons/photoswipe/photoswipe.addon.php @@ -0,0 +1,28 @@ + + * @brief Add-on to highlight an activated image. + */ +if($called_position == 'after_module_proc' && Context::getResponseMethod() == "HTML" && !isCrawler()) +{ + Context::loadFile(array('./addons/photoswipe/PhotoSwipe/photoswipe.css', '', '', null), true); + Context::loadFile(array('./addons/photoswipe/PhotoSwipe/default-skin/default-skin.css', '', '', null), true); + + Context::loadFile(array('./addons/photoswipe/PhotoSwipe/photoswipe.js', 'body', '', null), true); + Context::loadFile(array('./addons/photoswipe/PhotoSwipe/photoswipe-ui-default.js', 'body', '', null), true); + Context::loadFile(array('./addons/photoswipe/rx_photoswipe.js', 'body', '', null), true); + + $footer = FileHandler::readFile('./addons/photoswipe/PhotoSwipe/pswp.html'); + Context::addHtmlFooter($footer); +} + +/* End of file photoswipe.addon.php */ +/* Location: ./addons/photoswipe/photoswipe.addon.php */ diff --git a/addons/photoswipe/rx_photoswipe.js b/addons/photoswipe/rx_photoswipe.js new file mode 100644 index 000000000..62621c673 --- /dev/null +++ b/addons/photoswipe/rx_photoswipe.js @@ -0,0 +1,245 @@ +/* Modified version of a http://photoswipe.com/documentation/getting-started.html example. Modified by misol for rhymix */ +var getPSImageSize = function(src) { + var testImg = new Image(); + testImg.src = src; + + var size = new Array(); + size[0] = testImg.width; + size[1] = testImg.height; + + return size; +} + +var initPhotoSwipeFromDOM = function(gallerySelector) { + + // parse slide data (url, title, size ...) from DOM elements + // (children of gallerySelector) + var parseThumbnailElements = function(el) { + var imgElements = $(el).find("img"), + numNodes = imgElements.length, + items = [], + imgEl, + size, + item; + + for(var i = 0; i < numNodes; i++) { + + imgEl = imgElements.get(i); // element + + // include only element nodes + if(imgEl.nodeType !== 1 || !$(imgEl).attr('data-pswp-pid')) { + continue; + } + + size = getPSImageSize($(imgEl).attr('src')); + + // create slide object + item = { + src: $(imgEl).attr('src'), + w: parseInt( size[0] , 10), + h: parseInt( size[1] , 10), + pid: $(imgEl).attr('data-pswp-pid') + }; + + if(imgEl.alt) { + item.title = imgEl.alt; + } + + if(imgEl.title) { + item.title = imgEl.title; + } + + item.el = imgEl; // save link to element for getThumbBoundsFn + items.push(item); + } + + return items; + }; + + // find nearest parent element + var closest = function closest(el, fn) { + return el && ( fn(el) ? el : closest(el.parentNode, fn) ); + }; + + // triggers when user clicks on thumbnail + var onThumbnailsClick = function(e) { + e = e || window.event; + e.preventDefault ? e.preventDefault() : e.returnValue = false; + + var eTarget = e.target || e.srcElement; + + // find root element of slide + var clickedListItem = closest(eTarget, function(el) { + return (el.tagName && el.tagName.toUpperCase() === 'IMG'); + }); + + if(!clickedListItem) { + return; + } + + // find index of clicked item by looping through all child nodes + // alternatively, you may define index via data- attribute + var clickedGallery = $(clickedListItem).closest(gallerySelector).get(0), + childNodes = $(clickedGallery).find('img'), + numChildNodes = childNodes.length, + nodeIndex = 0, + index; + + /*for (var i = 0; i < numChildNodes; i++) { + if($(childNodes[i]).attr('data-pswp-pid') === $(clickedListItem).attr('data-pswp-pid')) { + index = nodeIndex; + break; + } + nodeIndex++; + }*/ + + for (var i = 0; i < numChildNodes; i++) { + if(childNodes[i].nodeType !== 1 || !$(childNodes[i]).attr('data-pswp-pid')) { + continue; + } + + if(childNodes[i] === clickedListItem) { + index = nodeIndex; + break; + } + nodeIndex++; + } + + if(index >= 0) { + // open PhotoSwipe if valid index found + openPhotoSwipe( index, clickedGallery, false, false); + } + return false; + }; + + // parse picture index and gallery index from URL (#&pid=1&gid=2) + var photoswipeParseHash = function() { + var hash = window.location.hash.substring(1), + params = {}; + + if(hash.length < 5) { + return params; + } + + var vars = hash.split('&'); + for (var i = 0; i < vars.length; i++) { + if(!vars[i]) { + continue; + } + var pair = vars[i].split('='); + if(pair.length < 2) { + continue; + } + params[pair[0]] = pair[1]; + } + + if(params.gid) { + params.gid = parseInt(params.gid, 10); + } + + return params; + }; + + var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) { + var pswpElement = document.querySelectorAll('.pswp')[0], + gallery, + options, + items; + + items = parseThumbnailElements(galleryElement); + + // define options (if needed) + options = { + + // define gallery index (for URL) + galleryUID: galleryElement.getAttribute('data-pswp-uid'), + + getThumbBoundsFn: function(index) { + // See Options -> getThumbBoundsFn section of documentation for more info + var thumbnail = items[index].el, + pageYScroll = window.pageYOffset || document.documentElement.scrollTop, + rect = thumbnail.getBoundingClientRect(); + + return {x:rect.left, y:rect.top + pageYScroll, w:rect.width}; + }, + + addCaptionHTMLFn: function(item, captionEl, isFake) { + if(!item.title) { + captionEl.children[0].innerText = ''; + return false; + } + captionEl.children[0].innerHTML = item.title; + return true; + }, + + }; + + // PhotoSwipe opened from URL + if(fromURL) { + if(options.galleryPIDs) { + // parse real index when custom PIDs are used + // http://photoswipe.com/documentation/faq.html#custom-pid-in-url + for(var j = 0; j < items.length; j++) { + if(items[j].pid == index) { + options.index = j; + break; + } + } + } else { + // in URL indexes start from 1 + options.index = parseInt(index, 10) - 1; + } + } else { + options.index = parseInt(index, 10); + } + + // exit if index not found + if( isNaN(options.index) ) { + return; + } + + if(disableAnimation) { + options.showAnimationDuration = 0; + } + + // Pass data to PhotoSwipe and initialize it + gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); + gallery.init(); + }; + + // loop through all gallery elements and bind events + var galleryElements = document.querySelectorAll( gallerySelector ); + + for(var i = 0, l = galleryElements.length; i < l; i++) { + galleryElements[i].setAttribute('data-pswp-uid', i+1); + galleryElements[i].onclick = onThumbnailsClick; + + // do not activate PhotoSwipe at the editor-component or other module components + var regx_skip = /(?:(modules|addons|classes|common|layouts|libs|widgets|widgetstyles)\/)/i; + var regx_allow_i6pngfix = /(?:common\/tpl\/images\/blank\.gif$)/i; + var galleryImgEls = $(galleryElements[i]).find('img'); + for(var j = 0, jl = galleryImgEls.length; j < jl; j++) { + if(regx_skip.test($(galleryImgEls[j]).attr('src')) && !regx_allow_i6pngfix.test($(galleryImgEls[j]).attr('src'))) continue; + + //$(galleryImgEls[j]).attr('data-pswp-uid', i+1); + $(galleryImgEls[j]).attr('data-pswp-pid', j+1); + + } + } + + // Parse URL and open gallery if it contains #&pid=3&gid=1 + var hashData = photoswipeParseHash(); + if(hashData.pid && hashData.gid) { + openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true ); + } + window.addEventListener("hashchange", function() { + var hashData = photoswipeParseHash(); + if(hashData.pid && hashData.gid) { + openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true ); + } + }, false); +}; + + +// execute above function +initPhotoSwipeFromDOM('.xe_content'); \ No newline at end of file