PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/slidedeck2-personal/views/preview-iframe.php

https://gitlab.com/iamgraeme/royalmile
PHP | 370 lines | 278 code | 33 blank | 59 comment | 28 complexity | d0e5d7977671bf2390b55070bcfcd196 MD5 | raw file
  1. <?php
  2. /**
  3. * Preview SlideDeck iframe template
  4. *
  5. * More information on this project:
  6. * http://www.slidedeck.com/
  7. *
  8. * Full Usage Documentation: http://www.slidedeck.com/usage-documentation
  9. *
  10. * @package SlideDeck
  11. * @subpackage SlideDeck 2 Pro for WordPress
  12. * @author dtelepathy
  13. */
  14. /*
  15. Copyright 2012 digital-telepathy (email : support@digital-telepathy.com)
  16. This file is part of SlideDeck.
  17. SlideDeck is free software: you can redistribute it and/or modify
  18. it under the terms of the GNU General Public License as published by
  19. the Free Software Foundation, either version 3 of the License, or
  20. (at your option) any later version.
  21. SlideDeck is distributed in the hope that it will be useful,
  22. but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. GNU General Public License for more details.
  25. You should have received a copy of the GNU General Public License
  26. along with SlideDeck. If not, see <http://www.gnu.org/licenses/>.
  27. */
  28. ?>
  29. <!doctype html>
  30. <head>
  31. <meta charset="utf-8">
  32. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  33. <title><?php echo $slidedeck['title']; ?></title>
  34. <script type="text/javascript">
  35. var SlideDeckLens={};
  36. var slideDeck2Version = '<?php echo SLIDEDECK2_VERSION; ?>';
  37. var slideDeck2Distribution = '<?php echo strtolower( SLIDEDECK2_LICENSE ); ?>';
  38. var slideDeck2CurrentSlide = null;
  39. </script>
  40. <?php
  41. foreach( $scripts as $script ) {
  42. if( $script == 'jquery' && !$wp_scripts->registered[$script]->src ) $script = 'jquery-core';
  43. $src = $wp_scripts->registered[$script]->src;
  44. if ( !preg_match( '|^(https?:)?//|', $src ) && !( $content_url && 0 === strpos( $src, $content_url ) ) ) {
  45. $src = $base_url . $src;
  46. }
  47. if( $preview && $script == "slidedeck-library-js" ) {
  48. $src.= "?noping";
  49. }
  50. /**
  51. * This is an effort to reduce the number of requests that this iFrame needs to make.
  52. */
  53. if( preg_match( '#/slidedeck([^/]+/js/)#', $wp_scripts->registered[$script]->src ) ){
  54. // If the script is in our JS folder, echo it instead of adding a script tag with a src.
  55. $parts = explode( '/js/', $wp_scripts->registered[$script]->src );
  56. echo "\n" . '<script type="text/javascript">' . "\n";
  57. echo "// {$wp_scripts->registered[$script]->src}" . "\n";
  58. include( SLIDEDECK2_DIRNAME . '/js/' . end( $parts ) );
  59. echo "\n" . '</script>' . "\n";
  60. }else{
  61. // If the script is not in our plugin folder, then include it regularly.
  62. echo '<script type="text/javascript" src="' . $src . ( strpos( $src, "?" ) !== false ? "&" : "?" ) . "v=" . $wp_scripts->registered[$script]->ver . '"></script>';
  63. }
  64. }
  65. ?>
  66. <link rel="stylesheet" type="text/css" href="<?php echo $wp_styles->registered['slidedeck']->src . ( strpos( $wp_styles->registered['slidedeck']->src, "?" ) !== false ? "&" : "?" ) . "v=" . $wp_styles->registered['slidedeck']->ver; ?>" />
  67. <link rel="stylesheet" type="text/css" href="<?php echo $lens['url']; ?>?v=<?php echo isset( $lens['meta']['version'] ) && !empty( $lens['meta']['version'] ) ? $lens['meta']['version'] : SLIDEDECK2_VERSION; ?>" />
  68. <?php echo $this->Lens->get_css( $lens ); ?>
  69. <style type="text/css">
  70. body, html {
  71. margin: 0;
  72. padding: 0;
  73. overflow: hidden;
  74. width: 100%;
  75. height: 100%;
  76. }
  77. #mask {
  78. position: absolute;
  79. z-index: 1;
  80. top: 0;
  81. right: 0;
  82. bottom: 0;
  83. left: 0;
  84. background: #f2f2f2;
  85. -webkit-opacity: 0;
  86. -moz-opacity: 0;
  87. -o-opacity: 0;
  88. opacity: 0;
  89. filter: Alpha(opacity=0);
  90. -ms-filter: "Alpha(opacity=0)";
  91. -webkit-transition: opacity 0.35s;
  92. -moz-transition: opacity 0.35s;
  93. -o-transition: opacity 0.35s;
  94. transition: opacity 0.35s;
  95. font-size: 10px;
  96. }
  97. #mask.visible {
  98. z-index: 99999;
  99. left: 0;
  100. -webkit-opacity: 1;
  101. -moz-opacity: 1;
  102. -o-opacity: 1;
  103. opacity: 1;
  104. filter: Alpha(opacity=100);
  105. -ms-filter: "Alpha(opacity=100)";
  106. }
  107. #mask .mask-loading-wrapper {
  108. position: absolute;
  109. top: 0;
  110. right: 0;
  111. bottom: 0;
  112. left: 0;
  113. width: 100%;
  114. height: 100%;
  115. }
  116. #mask .mask-loading-title {
  117. position: absolute;
  118. display: block;
  119. top: 50%;
  120. left: 0;
  121. right: 0;
  122. margin: -7.9em 0 0 0;
  123. text-indent: -999em;
  124. width: 100%;
  125. line-height: 5.3em;
  126. max-height: 53px;
  127. font-size: 1em;
  128. background: url('<?php echo SLIDEDECK2_URLPATH; ?>/images/loading-title.png') center center no-repeat;
  129. background-size: contain;
  130. }
  131. #mask .mask-loading-copy {
  132. position: absolute;
  133. top: 50%;
  134. left: 50%;
  135. text-align: center;
  136. margin: 0 0 0 -8.675em;
  137. text-align: center;
  138. width: 17.35em;
  139. background: url('<?php echo SLIDEDECK2_URLPATH; ?>/images/border-loading.png') center 0 no-repeat;
  140. background-size: contain;
  141. padding: 1em 0 0;
  142. font: italic 2em/1.6em Georigia, serif;
  143. color: #aeaeae;
  144. text-shadow: 0 1px 1px #fff;
  145. }
  146. #mask .mask-loading-wrapper img {
  147. position: absolute;
  148. top: 50%;
  149. left: 50%;
  150. width: 3.1em;
  151. height: 3.1em;
  152. margin: 0;
  153. max-width: 31px;
  154. max-height: 31px;
  155. margin: -1.55em 0 0 -1.55em;
  156. }
  157. .slidedeck-frame { z-index: 2; }
  158. #status {
  159. position: fixed;
  160. top: 0;
  161. right: 0;
  162. padding: 5px;
  163. background: #fff;
  164. font-size: 11px;
  165. color: #333;
  166. z-index: 999999;
  167. font-family: sans-serif;
  168. -webkit-border-bottom-left-radius: 5px;
  169. -moz-border-radius-bottomleft: 5px;
  170. border-bottom-left-radius: 5px;
  171. -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.75);
  172. -moz-box-shadow: 0 0 10px rgba(0,0,0,0.75);
  173. box-shadow: 0 0 10px rgba(0,0,0,0.75);
  174. border: 1px solid #ccc;
  175. -webkit-opacity: 0.25;
  176. -moz-opacity: 0.25;
  177. opacity: 0.25;
  178. -webkit-transition: opacity 0.25s;
  179. -moz-transition: opacity 0.25s;
  180. transition: opacity 0.25s;
  181. }
  182. body:hover #status {
  183. -webkit-opacity: 1;
  184. -moz-opacity: 1;
  185. opacity: 1;
  186. }
  187. .button {
  188. text-decoration: none;
  189. font-size: 12px !important;
  190. line-height: 13px;
  191. padding: 3px 8px;
  192. cursor: pointer;
  193. border-width: 1px;
  194. border-style: solid;
  195. -webkit-border-radius: 11px;
  196. border-radius: 11px;
  197. -moz-box-sizing: content-box;
  198. -webkit-box-sizing: content-box;
  199. box-sizing: content-box;
  200. border-color: #bbb;
  201. color: #464646;
  202. background: #f2f2f2;
  203. text-shadow: rgba(255,255,255,1) 0 1px 0;
  204. margin-right: 5px;
  205. }
  206. .button:hover {
  207. color: #000;
  208. border-color: #666;
  209. }
  210. .button:active {
  211. background: #eee;
  212. }
  213. </style>
  214. <script type="text/javascript">
  215. (function($){
  216. $(document).ready(function(){
  217. var $mask = $('#mask'),
  218. $window = $(window);
  219. var $wrapper = $mask.find('.mask-loading-wrapper');
  220. $window.resize(function(){
  221. var width = $window.width(),
  222. height = $window.height();
  223. $wrapper.css('font-size', (Math.round(Math.min((width/347)*1000, 1139))/1000) + "em");
  224. });
  225. $mask.removeClass('visible');
  226. });
  227. })(jQuery);
  228. </script>
  229. <?php do_action( "{$namespace}_iframe_header", $slidedeck, $preview ); ?>
  230. </head>
  231. <body>
  232. <?php if( SLIDEDECK2_ENVIRONMENT != "production" && $preview ): ?>
  233. <span id="status">
  234. <button class="button" onclick="parent.SlideDeckPreview.ajaxUpdate();">Refresh</button>
  235. <strong>Refreshed:</strong> <?php echo date( "Y-m-d H:i:s"); ?>
  236. </span>
  237. <?php endif; ?>
  238. <div id="mask" class="visible">
  239. <div class="mask-loading-wrapper" style="<?php if( isset( $preview_font_size ) ) echo 'font-size: ' . $preview_font_size . 'em'; ?>">
  240. <img src="<?php echo SLIDEDECK2_URLPATH; ?>/images/loading.gif" alt="<?php _e( "Loading", $namespace ); ?>">
  241. <div class="mask-loading-title">Loading</div>
  242. <div class="mask-loading-copy"><?php _e( "We&rsquo;re decking out your content!", $namespace ); ?></div>
  243. </div>
  244. </div>
  245. <?php
  246. $shortcode = "[SlideDeck2 id={$slidedeck['id']} echo_js=1";
  247. if( isset( $width ) )
  248. $shortcode .= " width={$width}";
  249. if( isset( $height ) )
  250. $shortcode .= " height={$height}";
  251. if( $start_slide !== false )
  252. $shortcode .= " start={$start_slide}";
  253. $shortcode .= ( $preview ? ' preview=1' : '' ) . "]";
  254. echo do_shortcode( $shortcode );
  255. ?>
  256. <?php
  257. if( slidedeck2_load_video_scripts() ) {
  258. foreach( array( 'froogaloop', 'youtube-api', 'dailymotion-api' ) as $script ) {
  259. $src = $wp_scripts->registered[$script]->src;
  260. if ( !preg_match( '|^https?://|', $src ) && !( $content_url && 0 === strpos( $src, $content_url ) ) ) {
  261. $src = $base_url . $src;
  262. }
  263. echo '<script type="text/javascript" src="' . $src . ( strpos( $src, "?" ) !== false ? "&" : "?" ) . "v=" . $wp_scripts->registered[$script]->ver . '"></script>';
  264. }
  265. }
  266. ?>
  267. <?php $this->print_footer_scripts(); ?>
  268. <?php if( $ress ): ?>
  269. <!-- child iFrame code -->
  270. <script type="text/javascript">
  271. (function($){
  272. var deckWrapper = $('#SlideDeck-<?php echo $slidedeck['id']; ?>-frame');
  273. var deck = deckWrapper.find('.slidedeck').slidedeck();
  274. /**
  275. * Check for the old before/complete in a
  276. * document ready so there's time for others to
  277. * bind to it first.
  278. */
  279. $(document).ready(function(){
  280. var oldBefore = deck.options.before;
  281. slideDeck2CurrentSlide = deck.current;
  282. deck.options.before = function(deck){
  283. // If the old before option was a function, run it
  284. if(typeof(oldBefore) == 'function') oldBefore(deck);
  285. // Make this iFrame's current slide accessible within this window.
  286. slideDeck2CurrentSlide = deck.current;
  287. };
  288. });
  289. var messageParent = function(deckWrapper){
  290. // SlideDeck Unique ID plus the height plus currentSlide
  291. message = "<?php echo $_REQUEST['slidedeck_unique_id']; ?>__" + parseInt( deckWrapper.outerHeight(true) ) + "__" + slideDeck2CurrentSlide;
  292. if(top.postMessage){
  293. // If the browser we're in is non-crappy enough to post a message... DO IT!
  294. top.postMessage( message , '*');
  295. } else {
  296. // If the browser is likely crapp-a-crap-tastic IE, then try hash-ifying the URL...
  297. window.location.hash = 'message'+message;
  298. }
  299. }
  300. messageParent(deckWrapper);
  301. window.onresize = function() {
  302. messageParent(deckWrapper);
  303. }
  304. })(jQuery);
  305. </script>
  306. <!-- end child iFrame code -->
  307. <?php endif; ?>
  308. <?php if( $preview ): ?>
  309. <script type="text/javascript">
  310. // Force all links to be target _blank in preview
  311. (function($){
  312. $(document).ready(function(){
  313. $('a').attr('target', '_blank');
  314. });
  315. })(jQuery);
  316. </script>
  317. <?php endif; ?>
  318. <script type="text/javascript">
  319. /**
  320. * If a link is NOT set to open in a new window, then
  321. * make sure it tries to open in the top frame.
  322. *
  323. * This only applies for the caption area.
  324. */
  325. (function($){
  326. $(document).ready(function(){
  327. $('.slidedeck-frame dl dd .sd2-node-caption a[target!="_blank"]').attr('target', '_top');
  328. });
  329. })(jQuery);
  330. </script>
  331. <?php do_action( "{$namespace}_iframe_footer", $slidedeck, $preview ); ?>
  332. </body>
  333. </html>