diff options
author | Theo Chatzimichos <tampakrap@gentoo.org> | 2013-03-10 12:10:26 +0100 |
---|---|---|
committer | Theo Chatzimichos <tampakrap@gentoo.org> | 2013-03-10 12:10:26 +0100 |
commit | 7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7 (patch) | |
tree | 68c852c654cef340592f1001b6310e33827b130c /plugins/jetpack/_inc | |
parent | Make the script more silent (diff) | |
download | blogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.tar.gz blogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.tar.bz2 blogs-gentoo-7aea9fc04bd42e2ac02a1925d3a02a76d391c3e7.zip |
update plugins
Diffstat (limited to 'plugins/jetpack/_inc')
20 files changed, 1397 insertions, 170 deletions
diff --git a/plugins/jetpack/_inc/gallery-settings.js b/plugins/jetpack/_inc/gallery-settings.js new file mode 100644 index 00000000..0ce38f0b --- /dev/null +++ b/plugins/jetpack/_inc/gallery-settings.js @@ -0,0 +1,19 @@ +/** + * Jetpack Gallery Settings + */ +(function($) { + var media = wp.media; + + // Wrap the render() function to append controls. + media.view.Settings.Gallery = media.view.Settings.Gallery.extend({ + render: function() { + media.view.Settings.prototype.render.apply( this, arguments ); + + // Append the type template and update the settings. + this.$el.append( media.template( 'jetpack-gallery-settings' ) ); + media.gallery.defaults.type = 'default'; // lil hack that lets media know there's a type attribute. + this.update.apply( this, ['type'] ); + return this; + } + }); +})(jQuery);
\ No newline at end of file diff --git a/plugins/jetpack/_inc/images/module-icons-sprite-2x.png b/plugins/jetpack/_inc/images/module-icons-sprite-2x.png Binary files differindex db87b2d5..11f42042 100644 --- a/plugins/jetpack/_inc/images/module-icons-sprite-2x.png +++ b/plugins/jetpack/_inc/images/module-icons-sprite-2x.png diff --git a/plugins/jetpack/_inc/images/module-icons-sprite.png b/plugins/jetpack/_inc/images/module-icons-sprite.png Binary files differindex 44de3b9e..c6979f67 100644 --- a/plugins/jetpack/_inc/images/module-icons-sprite.png +++ b/plugins/jetpack/_inc/images/module-icons-sprite.png diff --git a/plugins/jetpack/_inc/images/publicize.png b/plugins/jetpack/_inc/images/publicize.png Binary files differnew file mode 100644 index 00000000..428b886c --- /dev/null +++ b/plugins/jetpack/_inc/images/publicize.png diff --git a/plugins/jetpack/_inc/images/screenshots/carousel.png b/plugins/jetpack/_inc/images/screenshots/carousel.png Binary files differnew file mode 100644 index 00000000..5bcc94cd --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/carousel.png diff --git a/plugins/jetpack/_inc/images/screenshots/custom-css.png b/plugins/jetpack/_inc/images/screenshots/custom-css.png Binary files differnew file mode 100644 index 00000000..4be5cb22 --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/custom-css.png diff --git a/plugins/jetpack/_inc/images/screenshots/likes.png b/plugins/jetpack/_inc/images/screenshots/likes.png Binary files differnew file mode 100644 index 00000000..1c7670a3 --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/likes.png diff --git a/plugins/jetpack/_inc/images/screenshots/mobile-push-notifications.jpg b/plugins/jetpack/_inc/images/screenshots/mobile-push-notifications.jpg Binary files differnew file mode 100644 index 00000000..94ca6dd6 --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/mobile-push-notifications.jpg diff --git a/plugins/jetpack/_inc/images/screenshots/mobile-theme.png b/plugins/jetpack/_inc/images/screenshots/mobile-theme.png Binary files differnew file mode 100644 index 00000000..88bad2d6 --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/mobile-theme.png diff --git a/plugins/jetpack/_inc/images/screenshots/notes.png b/plugins/jetpack/_inc/images/screenshots/notes.png Binary files differnew file mode 100644 index 00000000..4506db17 --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/notes.png diff --git a/plugins/jetpack/_inc/images/screenshots/post-by-email.png b/plugins/jetpack/_inc/images/screenshots/post-by-email.png Binary files differnew file mode 100644 index 00000000..b114088c --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/post-by-email.png diff --git a/plugins/jetpack/_inc/images/screenshots/publicize.png b/plugins/jetpack/_inc/images/screenshots/publicize.png Binary files differnew file mode 100644 index 00000000..428b886c --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/publicize.png diff --git a/plugins/jetpack/_inc/images/screenshots/tiled-gallery.png b/plugins/jetpack/_inc/images/screenshots/tiled-gallery.png Binary files differnew file mode 100644 index 00000000..8168590d --- /dev/null +++ b/plugins/jetpack/_inc/images/screenshots/tiled-gallery.png diff --git a/plugins/jetpack/_inc/jetpack.css b/plugins/jetpack/_inc/jetpack.css index 0b6c340e..b684f7c7 100644 --- a/plugins/jetpack/_inc/jetpack.css +++ b/plugins/jetpack/_inc/jetpack.css @@ -21,20 +21,27 @@ height: 70px; } - #jp-header #jp-clouds #jp-disconnect { + + #jp-header #jp-clouds #jp-disconnectors { font-size: 12px; color: #fff; float: right; - margin: -35px 25px 0 0; - text-align: right; + margin-top: -35px; + text-align: left; + position: relative; + left: -45px; } - #jp-header #jp-clouds #jp-disconnect a { + #jp-header #jp-clouds .jp-disconnect a { background: #8caa46 url( images/status-light.png ) 3px 85% no-repeat; display: inline-block; - padding: 4px 10px 3px 30px; + position: relative; + width: 100%; + height: 1.7em; + overflow: hidden; + padding: 4px 0 3px 30px; + margin: 0 -20px 3px 0; color: #fff; - text-align: center; text-decoration: none; border: 1px solid #7a943d; -moz-border-radius: 5px; @@ -45,14 +52,23 @@ box-shadow: inset 0 0 2px rgba( 255, 255, 255, 0.4 ); text-shadow: 0px -1px 0px rgba( 0,0,0,0.3 ); } - #jp-header #jp-clouds #jp-disconnect a:hover { - background: #8caa46 url( images/status-light.png ) 3px 5% no-repeat; + #jp-header #jp-clouds .jp-disconnect a:hover { + background: #8caa46 url( images/status-light.png ) 3px -2% no-repeat; background-color: #839f40; border-color: #6a8037; } - #jp-header #jp-clouds #jp-disconnect span { display: none; } - + #jp-header #jp-clouds .jp-disconnect div { + position: relative; + line-height: 1.7em; + height: 1.7em; + } + + #jp-header #jp-clouds .jp-disconnect a:hover div, + #jp-header #jp-clouds .jp-disconnect a.clicked div { + top: -1.7em; + } + /* Retina Header Clouds & Status Light */ @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { #jp-header #jp-clouds { @@ -63,18 +79,18 @@ background: transparent url( images/header-clouds-small-2x.png ) -120px 100% repeat-x; background-size:980px 140px; } - - #jp-header #jp-clouds #jp-disconnect a { + + #jp-header #jp-clouds .jp-disconnect a { background: #8caa46 url( images/status-light-2x.png ) 3px 85% no-repeat; background-size:25px 57px; } - #jp-header #jp-clouds #jp-disconnect a:hover { - background: #8caa46 url( images/status-light-2x.png ) 3px 5% no-repeat; + #jp-header #jp-clouds .jp-disconnect a:hover { + background: #8caa46 url( images/status-light-2x.png ) 3px -2% no-repeat; background-size:25px 57px; } } - - + + #jp-header h3 { position: relative; background: transparent url( images/logo.png ) top left no-repeat; @@ -93,7 +109,7 @@ height: 120px; top: -35px; } - + /* Retina Logo */ @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { #jp-header h3 { @@ -105,9 +121,9 @@ background-size:150px 120px; } } - - - + + + #jp-header p { position: absolute; left: 390px; @@ -237,11 +253,11 @@ color: #fff; text-decoration: underline; } - + .jetpack-message .squeezer a:hover { color: #f0a000; } - + .jetpack-message code, .jetpack-err p { background: rgba( 0,0,0,0.2 ); font-size: 14px; @@ -309,7 +325,7 @@ -moz-box-shadow: inset 0 0 20px rgba(0,0,0,0.05), 0 1px 2px rgba( 0,0,0,0.1 ); box-shadow: inset 0 0 20px rgba(0,0,0,0.05), 0 1px 2px rgba( 0,0,0,0.1 ); } - + /* Retina moreinfo bg clouds */ @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { .more-info { @@ -317,8 +333,8 @@ background-size:980px 140px; } } - - + + .more-info h4 { padding: 0; background: none; @@ -340,7 +356,7 @@ left: 0; background: url( images/arrow.png ) top left no-repeat; } - + /* Retina module more info arrow */ @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { .more-info .arrow { @@ -534,13 +550,13 @@ p.jp-help { border-bottom-left-radius: 3px; background-repeat: no-repeat; background-image: url( images/module-icons-sprite.png ); + background-size: 2555px 50px; /* remember to update this every time a new module is added! */ } @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { .jetpack-module div.module-image { background-image: url( images/module-icons-sprite-2x.png ); - background-size: 1450px 50px; } } @@ -586,6 +602,40 @@ p.jp-help { #carousel.jetpack-module div.module-image { background-position: -1325px 5px; } + #custom-css.jetpack-module div.module-image { + background-position: -1459px 5px; + } + #minileven.jetpack-module div.module-image { + background-position: -1570px 5px; + } + #notes.jetpack-module div.module-image { + background-position: -1806px 5px; + } + #json-api.jetpack-module div.module-image { + background-position: -1689px 5px; + } + #mobile-push.jetpack-module div.module-image { + background-position: -1925px 5px; + } + #publicize.jetpack-module div.module-image { + background-position: -2136px 5px; + } + #post-by-email.jetpack-module div.module-image { + background-position: -2025px 5px; + } + #infinite-scroll.jetpack-module div.module-image { + background-position: -2230px 5px; + } + #photon.jetpack-module div.module-image { + background-position: -2320px 5px; + } + #tiled-gallery.jetpack-module div.module-image { + background-position: -2400px 5px; + } + + #likes.jetpack-module div.module-image { + background-position: -2471px 5px; + } .jetpack-module div.module-image p { background-color: #b4d278; @@ -725,7 +775,7 @@ p.jp-help { margin-right: 15px; box-shadow: none; } - + @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { .placeholder h3 { background: transparent url(images/icon-comingsoon-2x.png) top center no-repeat; @@ -822,34 +872,10 @@ p#news-sub { margin-top: 15px; } -#jetpack-settings .button, #jetpack-settings .button-primary { - -moz-border-radius: 5px !important; - -webkit-border-radius: 5px !important; - border-radius: 5px !important; - padding: 5px 10px !important; - -moz-box-shadow: inset 0 0 2px #fff, 0 0 3px rgba(0,0,0,0.1); - -webkit-box-shadow: inset 0 0 2px #fff, 0 0 3px rgba(0,0,0,0.1); - box-shadow: inset 0 0 2px #fff, 0 0 3px rgba(0,0,0,0.1); -} - #jetpack-settings .button-primary { - color: #bceaff !important; -} - -#jetpack-settings .button-primary:hover { color: #fff !important; } -#jetpack-settings .button:hover { - color: #298cba !important; - border-color: #69acce !important; - -moz-box-shadow: 0 0 2px rgba(105,172,206,1); - -webkit-box-shadow: 0 0 2px rgba(105,172,206,1); - box-shadow: 0 0 2px rgba(105,172,206,1); - -webkit-transition-duration: .3s; - -moz-transition-duration: .3s; -} - .jp-survey { position: relative; z-index: 100; @@ -889,91 +915,6 @@ p#news-sub { display: block; } -.jp-survey a { - color: #000; - text-decoration: underline; - -webkit-transition-duration: .3s; - -moz-transition-duration: .3s; - -o-transition-duration: .3s; - -ms-transition-duration: .3s; - transition-duration: .3s; -} - -.jp-survey a:hover { - color: #555; - text-decoration: none; -} - -#jetpack-settings .jp-survey p a.button-primary { - font-size: 16px !important; - display: inline-block; - padding: 8px 15px; - color: #fff!important; - text-align: center; - font-size: 20px; - text-decoration: none; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - border: 1px solid #2A8CBA; - background: #6AAFCF; - -moz-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - -webkit-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - text-shadow: 0px -1px 0px rgba( 0,0,0,0.3); - -webkit-transition-duration: .3s; - -moz-transition-duration: .3s; - -o-transition-duration: .3s; - -ms-transition-duration: .3s; - transition-duration: .3s; - cursor: pointer; - font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif; -} - -#jetpack-settings .jp-survey p a.button-primary:hover, #jetpack-settings .jp-survey p a.button-primary:active { - background-color: #f0a000; - border-color: #c87800; - -webkit-transition-duration: .3s; - outline: none; -} - -.jp-survey p a.button-secondary { - font-size: 16px !important; - display: inline-block; - padding: 8px 15px; - color: #fff; - text-align: center; - font-size: 20px; - text-decoration: none; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - border: 1px solid #8caa46; - background: #b4d278; - -moz-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - -webkit-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 ); - text-shadow: 0px -1px 0px rgba( 0,0,0,0.3); - -webkit-transition-duration: .3s; - -moz-transition-duration: .3s; - -o-transition-duration: .3s; - -ms-transition-duration: .3s; - transition-duration: .3s; - cursor: pointer; - font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif; -} - -.jp-survey p a.button-secondary:hover, .jp-survey p a.button-secondary:active { - background-color: #f0a000; - border-color: #c87800; - -webkit-transition-duration: .3s; - -moz-transition-duration: .3s; - -o-transition-duration: .3s; - -ms-transition-duration: .3s; - transition-duration: .3s; - outline: none; -} - .jp-survey-container { overflow: hidden; padding: 0 20px 8px 0; @@ -1095,3 +1036,35 @@ p#news-sub { box-shadow: inset 0 0 2px #fff, 0 1px 7spx rgba(240,160,0,0.5); } +.jetpack-inline-error, .jetpack-inline-message { + padding: .5em 1em .5em 1em; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + border-width: 1px; + border-style: solid; + color: #333; +} + +.jetpack-inline-error { + background-color: #ffebe8; + border-color: #c00; +} + +.jetpack-inline-message { + background-color: #ffffe0; + border-color: #e6db55; +} + +.jetpack-targetable { + border-top: 28px solid transparent; + margin-top: -28px; +} + +.jetpack-targetable:target { + background-color: #ffffe0; + background-clip: padding-box; + padding: 0 10px; + margin-left: -10px; + margin-right: -10px; +} diff --git a/plugins/jetpack/_inc/jetpack.js b/plugins/jetpack/_inc/jetpack.js index 69a86c13..6ef9de8d 100644 --- a/plugins/jetpack/_inc/jetpack.js +++ b/plugins/jetpack/_inc/jetpack.js @@ -57,36 +57,23 @@ jetpack = { }); var widerWidth = 0; - jQuery( '#jp-disconnect' ).hover( function() { - var t = jQuery( this ), - a = t.find( 'a' ), - width = t.width(), - changeWidth = widerWidth == 0; - - if ( changeWidth && widerWidth < width ) { - widerWidth = width; - } - jetpack.statusText = a.html(); - a.html( jQuery( '#jp-disconnect span' ).html() ); - width = t.width(); - if ( changeWidth && widerWidth < width ) { - widerWidth = width + 15; - } - if ( changeWidth ) { - t.width( widerWidth ); - } - a.hide().fadeIn(100); - }, function() { - var a = jQuery( 'a', this ); - a.html( jetpack.statusText ); - a.hide().fadeIn(100); - jetpack.statusText = null; - } ).find( 'a' ).click( function() { + jQuery( '#jp-disconnect a' ).click( function() { if ( confirm( jetpackL10n.ays_disconnect ) ) { - jQuery( '#jp-disconnect' ).unbind( 'mouseenter mouseleave' ); + jQuery( this ).addClass( 'clicked' ).css( { + "background-image": 'url( ' + userSettings.url + 'wp-admin/images/wpspin_light.gif )', + "background-position": '9px 5px', + "background-size": '16px 16px' + } ).unbind( 'click' ).click( function() { return false; } ); + } else { + return false; + } + } ); + jQuery( '#jp-unlink a' ).click( function() { + if ( confirm( jetpackL10n.ays_unlink ) ) { jQuery( this ).css( { - "background-image": 'url( ' + userSettings.url + 'wp-admin/images/wpspin_dark.gif )', + "background-image": 'url( ' + userSettings.url + 'wp-admin/images/wpspin_light.gif )', "background-position": '9px 5px', + "background-size": '16px 16px' } ).unbind( 'click' ).click( function() { return false; } ); } else { return false; @@ -108,7 +95,7 @@ jetpack = { jQuery( 'div.placeholder' ).show(); var containerWidth = jetpack.container.width(), - needed = 4 * parseInt( containerWidth / 242, 10 ) - jetpack.numModules + needed = 5 * parseInt( containerWidth / 242, 10 ) - jetpack.numModules if ( jetpack.numModules * 242 > containerWidth ) jQuery( 'div.placeholder' ).slice( needed ).hide(); @@ -155,12 +142,15 @@ jetpack = { jQuery( window ).scrollTo( ( jQuery( 'div.more-info' ).prev().offset().top ) - 70, 600, function() { if ( typeof callback == 'function' ) callback.call( this ); } ); } else { jQuery( 'div.more-info div.jp-content' ).hide(); - jQuery( 'div.more-info' ).slideUp( 200, function() { - jQuery(this).detach().insertAfter( el ); + jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } ).slideUp( 200, function() { + var $this = jQuery(this); + $this.detach().insertAfter( el ); jQuery( 'div.more-info div.jp-content' ).hide(); jetpack.learn_more_content( jQuery(card).attr( 'id' ) ); - jQuery( 'div.more-info' ).slideDown( 300 ); - jQuery( window ).scrollTo( ( jQuery( 'div.more-info' ).prev().offset().top ) - 70, 600, function() { if ( typeof callback == 'function' ) callback.call( this ); } ); + $this.css( { height: '230px', minHeight: 0 } ).slideDown( 300, function() { + $this.css( { height: 'auto', minHeight: '230px' } ); + } ); + jQuery( window ).scrollTo( ( $this.prev().offset().top ) - 70, 600, function() { if ( typeof callback == 'function' ) callback.call( this ); } ); } ); } @@ -170,7 +160,9 @@ jetpack = { jQuery( el ).after( '<div id="message" class="more-info jetpack-message"><div class="arrow"></div><div class="jp-content"></div><div class="jp-close">×</div><div class="clear"></div></div>' ); // Show the box + jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } ); jQuery( 'div.more-info', 'div.module-container' ).hide().slideDown( 400, function() { + jQuery( 'div.more-info' ).css( { height: 'auto', minHeight: '230px' } ); // Load the content and scroll to it jetpack.learn_more_content( jQuery(card).attr( 'id' ) ); jQuery( window ).scrollTo( ( jQuery( 'div.more-info' ).prev().offset().top ) - 70, 600 ); @@ -226,7 +218,7 @@ jetpack = { close_learn_more: function( callback ) { jQuery( 'div.more-info div.jp-content' ).hide(); - jQuery( 'div.more-info' ).slideUp( 200, function() { + jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } ).slideUp( 200, function() { jQuery( this ).remove(); jQuery( 'a.jetpack-deactivate-button' ).hide(); jetpack.linkClicked.parents( 'div.jetpack-module' ).children( '.jetpack-module-actions' ).children( 'a.jetpack-configure-button' ).show(); diff --git a/plugins/jetpack/_inc/jquery.inview.js b/plugins/jetpack/_inc/jquery.inview.js new file mode 100644 index 00000000..45f71c4c --- /dev/null +++ b/plugins/jetpack/_inc/jquery.inview.js @@ -0,0 +1,143 @@ +/** + * author Christopher Blum + * - based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/ + * - forked from http://github.com/zuk/jquery.inview/ + */ +(function ($) { + var inviewObjects = {}, viewportSize, viewportOffset, + d = document, w = window, documentElement = d.documentElement, expando = $.expando; + + $.event.special.inview = { + add: function(data) { + inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) }; + }, + + remove: function(data) { + try { delete inviewObjects[data.guid + "-" + this[expando]]; } catch(e) {} + } + }; + + function getViewportSize() { + var mode, domObject, size = { height: w.innerHeight, width: w.innerWidth }; + + // if this is correct then return it. iPad has compat Mode, so will + // go into check clientHeight/clientWidth (which has the wrong value). + if (!size.height) { + mode = d.compatMode; + if (mode || !$.support.boxModel) { // IE, Gecko + domObject = mode === 'CSS1Compat' ? + documentElement : // Standards + d.body; // Quirks + size = { + height: domObject.clientHeight, + width: domObject.clientWidth + }; + } + } + + return size; + } + + function getViewportOffset() { + return { + top: w.pageYOffset || documentElement.scrollTop || d.body.scrollTop, + left: w.pageXOffset || documentElement.scrollLeft || d.body.scrollLeft + }; + } + + function checkInView() { + var $elements = $(), elementsLength, i = 0; + + $.each(inviewObjects, function(i, inviewObject) { + var selector = inviewObject.data.selector, + $element = inviewObject.$element; + $elements = $elements.add(selector ? $element.find(selector) : $element); + }); + + elementsLength = $elements.length; + if (elementsLength) { + viewportSize = viewportSize || getViewportSize(); + viewportOffset = viewportOffset || getViewportOffset(); + + for (; i<elementsLength; i++) { + // Ignore elements that are not in the DOM tree + if (!$.contains(documentElement, $elements[i])) { + continue; + } + + var element = $elements[i], + $element = $(element), + elementSize = {}, + elementOffset = {}, + inView = $element.data('inview'), + visiblePartX, + visiblePartY, + visiblePartsMerged; + + // for the case where 'display:none' is used in place of 'visibility:hidden' + // count and sum the above items to get and move closer to the correct values + // IMPORTANT :: insert element into container empty + if($element.css('display') == 'none') + { + var parentElement = $element.parent(); + + elementOffset.top = parentElement.offset().top; + elementOffset.left = parentElement.offset().left; + elementSize.height = parentElement.height(); + elementSize.width = parentElement.width(); + } else { + elementSize = { height: $element.height(), width: $element.width() } + elementOffset = $element.offset(); + } + + // Don't ask me why because I haven't figured out yet: + // viewportOffset and viewportSize are sometimes suddenly null in Firefox 5. + // Even though it sounds weird: + // It seems that the execution of this function is interferred by the onresize/onscroll event + // where viewportOffset and viewportSize are unset + if (!viewportOffset || !viewportSize) { + return; + } + + if (element.offsetWidth >= 0 && element.offsetHeight >= 0 && element.style.display != "none" && + elementOffset.top + elementSize.height > viewportOffset.top && + elementOffset.top < viewportOffset.top + viewportSize.height && + elementOffset.left + elementSize.width > viewportOffset.left && + elementOffset.left < viewportOffset.left + viewportSize.width) { + visiblePartX = (viewportOffset.left > elementOffset.left ? + 'right' : (viewportOffset.left + viewportSize.width) < (elementOffset.left + elementSize.width) ? + 'left' : 'both'); + visiblePartY = (viewportOffset.top > elementOffset.top ? + 'bottom' : (viewportOffset.top + viewportSize.height) < (elementOffset.top + elementSize.height) ? + 'top' : 'both'); + visiblePartsMerged = visiblePartX + "-" + visiblePartY; + if (!inView || inView !== visiblePartsMerged) { + $element.data('inview', visiblePartsMerged).trigger('inview', [true, visiblePartX, visiblePartY]); + } + } else if (inView) { + $element.data('inview', false).trigger('inview', [false]); + } + } + } + } + + $(w).bind("scroll resize", function() { + viewportSize = viewportOffset = null; + }); + + // IE < 9 scrolls to focused elements without firing the "scroll" event + if (!documentElement.addEventListener && documentElement.attachEvent) { + documentElement.attachEvent("onfocusin", function() { + viewportOffset = null; + }); + } + + // Use setInterval in order to also make sure this captures elements within + // "overflow:scroll" elements or elements that appeared in the dom tree due to + // dom manipulation and reflow + // old: $(window).scroll(checkInView); + // + // By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays + // intervals while the user scrolls. Therefore the inview event might fire a bit late there + setInterval(checkInView, 250); +})(jQuery);
\ No newline at end of file diff --git a/plugins/jetpack/_inc/jquery.jetpack-resize.js b/plugins/jetpack/_inc/jquery.jetpack-resize.js new file mode 100644 index 00000000..e1adb22d --- /dev/null +++ b/plugins/jetpack/_inc/jquery.jetpack-resize.js @@ -0,0 +1,275 @@ +/** + * Resizeable Iframes. + * + * Start listening to resize postMessage events for selected iframes: + * $( selector ).Jetpack( 'resizeable' ); + * - OR - + * Jetpack.resizeable( 'on', context ); + * + * Resize selected iframes: + * $( selector ).Jetpack( 'resizeable', 'resize', { width: 100, height: 200 } ); + * - OR - + * Jetpack.resizeable( 'resize', { width: 100, height: 200 }, context ); + * + * Stop listening to resize postMessage events for selected iframes: + * $( selector ).Jetpack( 'resizeable', 'off' ); + * - OR - + * Jetpack.resizeable( 'off', context ); + * + * Stop listening to all resize postMessage events: + * Jetpack.resizeable( 'off' ); + */ +(function($) { + var listening = false, // Are we listening for resize postMessage events + sourceOrigins = [], // What origins are allowed to send resize postMessage events + $sources = false, // What iframe elements are we tracking resize postMessage events from + + URLtoOrigin, // Utility to convert URLs into origins + setupListener, // Binds global resize postMessage event handler + destroyListener, // Unbinds global resize postMessage event handler + + methods; // Jetpack.resizeable methods + + // Setup the Jetpack global + if ( 'undefined' === typeof window.Jetpack ) { + window.Jetpack = { + /** + * Handles the two different calling methods: + * $( selector ).Jetpack( 'namespace', 'method', context ) // here, context is optional and is used to filter the collection + * - vs. - + * Jetpack.namespace( 'method', context ) // here context defines the collection + * + * @internal + * + * Call as: Jetpack.getTarget.call( this, context ) + * + * @param string context: jQuery selector + * @return jQuery|undefined object on which to perform operations or undefined when context cannot be determined + */ + getTarget: function( context ) { + if ( this instanceof jQuery ) { + return context ? this.filter( context ) : this; + } + + return context ? $( context ) : context; + } + }; + } + + // Setup the Jetpack jQuery method + if ( 'undefined' === typeof $.fn.Jetpack ) { + /** + * Dispatches calls to the correct namespace + * + * @param string namespace + * @param ... + * @return mixed|jQuery (chainable) + */ + $.fn.Jetpack = function( namespace ) { + if ( 'function' === typeof Jetpack[namespace] ) { + // Send the call to the correct Jetpack.namespace + return Jetpack[namespace].apply( this, Array.prototype.slice.call( arguments, 1 ) ); + } else { + $.error( 'Namespace "' + namespace + '" does not exist on jQuery.Jetpack' ); + } + }; + } + + // Define Jetpack.resizeable() namespace to just always bail if no postMessage + if ( 'function' !== typeof window.postMessage ) { + $.extend( window.Jetpack, { + /** + * Defines the Jetpack.resizeable() namespace. + * See below for non-trivial definition for browsers with postMessage. + */ + resizeable: function() { + $.error( 'Browser does not support window.postMessage' ); + } + } ); + + return; + } + + /** + * Utility to convert URLs into origins + * + * http://example.com:port/path?query#fragment -> http://example.com:port + * + * @param string URL + * @return string origin + */ + URLtoOrigin = function( URL ) { + if ( ! URL.match( /^https?:\/\// ) ) { + URL = document.location.href; + } + return URL.split( '/' ).slice( 0, 3 ).join( '/' ); + }; + + /** + * Binds global resize postMessage event handler + */ + setupListener = function() { + listening = true; + + $( window ).on( 'message.JetpackResizeableIframe', function( e ) { + var event = e.originalEvent, + data; + + // Ensure origin is allowed + if ( -1 === $.inArray( event.origin, sourceOrigins ) ) { + return; + } + + // Some browsers send structured data, some send JSON strings + if ( 'object' === typeof event.data ) { + data = event.data; + } else { + try { + data = JSON.parse( event.data ); + } catch ( err ) { + data = false; + } + } + + if ( !data ) { + return; + } + + // Is it a resize event? + if ( 'undefined' === typeof data.action || 'resize' !== data.action ) { + return; + } + + // Find the correct iframe and resize it + $sources.filter( function() { + if ( 'undefined' !== typeof data.name ) + return this.name === data.name; + else + return event.source === this.contentWindow; + } ).first().Jetpack( 'resizeable', 'resize', data ); + } ); + }; + + /** + * Unbinds global resize postMessage event handler + */ + destroyListener = function() { + listening = false; + $( window ).off( 'message.JetpackResizeableIframe' ); + + sourceOrigins = []; + $( '.jetpack-resizeable' ).removeClass( 'jetpack-resizeable' ); + $sources = false; + }; + + // Methods for Jetpack.resizeable() namespace + methods = { + /** + * Start listening for resize postMessage events on the given iframes + * + * Call statically as: Jetpack.resizeable( 'on', context ) + * Call as: $( selector ).Jetpack( 'resizeable', 'on', context ) // context optional: used to filter the collectino + * + * @param string context jQuery selector. + * @return jQuery (chainable) + */ + on: function( context ) { + var target = Jetpack.getTarget.call( this, context ); + + if ( ! listening ) { + setupListener(); + } + + target.each( function() { + sourceOrigins.push( URLtoOrigin( $( this ).attr( 'src' ) ) ); + } ).addClass( 'jetpack-resizeable' ); + + $sources = $( '.jetpack-resizeable' ); + + return target; + }, + + /** + * Stop listening for resize postMessage events on the given iframes + * + * Call statically as: Jetpack.resizeable( 'off', context ) + * Call as: $( selector ).Jetpack( 'resizeable', 'off', context ) // context optional: used to filter the collectino + * + * @param string context jQuery selector + * @return jQuery (chainable) + */ + off: function( context ) { + var target = Jetpack.getTarget.call( this, context ); + + if ( 'undefined' === typeof target ) { + destroyListener(); + + return target; + } + + target.each( function() { + var origin = URLtoOrigin( $( this ).attr( 'src' ) ), + pos = $.inArray( origin, sourceOrigins ); + + if ( -1 !== pos ) { + sourceOrigins.splice( pos, 1 ); + } + } ).removeClass( 'jetpack-resizeable' ); + + $sources = $( '.jetpack-resizeable' ); + + return target; + }, + + /** + * Resize the given iframes + * + * Call statically as: Jetpack.resizeable( 'resize', dimensions, context ) + * Call as: $( selector ).Jetpack( 'resizeable', 'resize', dimensions, context ) // context optional: used to filter the collectino + * + * @param object dimensions in pixels: { width: (int), height: (int) } + * @param string context jQuery selector + * @return jQuery (chainable) + */ + resize: function( dimensions, context ) { + var target = Jetpack.getTarget.call( this, context ); + + $.each( [ 'width', 'height' ], function( i, variable ) { + var value = 0; + if ( 'undefined' !== typeof dimensions[variable] ) { + value = parseInt( dimensions[variable], 10 ); + } + + if ( 0 !== value ) { + target[variable]( value ); + } + } ); + + return target; + } + }; + + // Define Jetpack.resizeable() namespace + $.extend( window.Jetpack, { + /** + * Defines the Jetpack.resizeable() namespace. + * See above for trivial definition for browsers with no postMessage. + * + * @param string method + * @param ... + * @return mixed|jQuery (chainable) + */ + resizeable: function( method ) { + if ( methods[method] ) { + // Send the call to the correct Jetpack.resizeable() method + return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ) ); + } else if ( ! method ) { + // By default, send to Jetpack.resizeable( 'on' ), which isn't useful in that form but is when called as + // jQuery( selector ).Jetpack( 'resizeable' ) + return methods.on.apply( this ); + } else { + $.error( 'Method ' + method + ' does not exist on Jetpack.resizeable' ); + } + } + } ); +})(jQuery); diff --git a/plugins/jetpack/_inc/jquery.spin.js b/plugins/jetpack/_inc/jquery.spin.js new file mode 100644 index 00000000..4642af13 --- /dev/null +++ b/plugins/jetpack/_inc/jquery.spin.js @@ -0,0 +1,86 @@ +/* + * Matt Husby https://github.com/matthusby/spin.js + * Based on the jquery plugin by Bradley Smith + * https://gist.github.com/1290439 + */ + +/* +Add spin to the jQuery object +If color is not passed the spinner will be black +You can now create a spinner using any of the variants below: +$("#el").spin(); // Produces default Spinner +$("#el").spin("small"); // Produces a 'small' Spinner +$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color). +$("#el").spin({ ... }); // Produces a Spinner using your custom settings. +$("#el").spin("small-right"); // Pin the small spinner to the right edge +$("#el").spin("{small, medium, large}-{left, right, top, bottom}"); // All options for where to pin +$("#el").spin(false); // Kills the spinner. +*/ + +( function( $ ) { + $.fn.spin = function( opts, color ) { + var presets = { + "small": { lines: 8, length: 2, width: 2, radius: 3, trail: 60, speed: 1.3 }, + "medium": { lines: 8, length: 4, width: 3, radius: 5, trail: 60, speed: 1.3 }, + "large": { lines: 10, length: 6, width: 4, radius: 7, trail: 60, speed: 1.3 } + }; + if ( Spinner ) { + return this.each( function() { + var $this = $( this ), + data = $this.data(); + + if ( data.spinner ) { + data.spinner.stop(); + delete data.spinner; + } + if ( opts !== false ) { + var spinner_options; + if ( typeof opts === "string" ) { + var spinner_base = opts.indexOf( '-' ); + if( spinner_base == -1 ) { + spinner_base = opts; + } else { + spinner_base = opts.substring( 0, spinner_base ); + } + if ( spinner_base in presets ) { + spinner_options = presets[spinner_base]; + } else { + spinner_options = {}; + } + var padding; + if ( opts.indexOf( "-right" ) != -1 ) { + padding = jQuery( this ).css( 'padding-left' ); + if( typeof padding === "undefined" ) { + padding = 0; + } else { + padding = padding.replace( 'px', '' ); + } + spinner_options.left = jQuery( this ).outerWidth() - ( 2 * ( spinner_options.length + spinner_options.width + spinner_options.radius ) ) - padding - 5; + } + if ( opts.indexOf( '-left' ) != -1 ) { + spinner_options.left = 5; + } + if ( opts.indexOf( '-top' ) != -1 ) { + spinner_options.top = 5; + } + if ( opts.indexOf( '-bottom' ) != -1 ) { + padding = jQuery( this ).css( 'padding-top' ); + if( typeof padding === "undefined" ) { + padding = 0; + } else { + padding = padding.replace( 'px', '' ); + } + spinner_options.top = jQuery( this ).outerHeight() - ( 2 * ( spinner_options.length + spinner_options.width + spinner_options.radius ) ) - padding - 5; + } + } + if( color ){ + spinner_options.color = color; + } + data.spinner = new Spinner( spinner_options ).spin( this ); + } + }); + } else { + throw "Spinner class not available."; + } + }; +})( jQuery );
\ No newline at end of file diff --git a/plugins/jetpack/_inc/postmessage.js b/plugins/jetpack/_inc/postmessage.js new file mode 100644 index 00000000..e8933bca --- /dev/null +++ b/plugins/jetpack/_inc/postmessage.js @@ -0,0 +1,438 @@ +/** + The MIT License + + Copyright (c) 2010 Daniel Park (http://metaweb.com, http://postmessage.freebaseapps.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. + **/ +var NO_JQUERY = {}; +(function(window, $, undefined) { + + if (!("console" in window)) { + var c = window.console = {}; + c.log = c.warn = c.error = c.debug = function(){}; + } + + if ($ === NO_JQUERY) { + // jQuery is optional + $ = { + fn: {}, + extend: function() { + var a = arguments[0]; + for (var i=1,len=arguments.length; i<len; i++) { + var b = arguments[i]; + for (var prop in b) { + a[prop] = b[prop]; + } + } + return a; + } + }; + } + + $.fn.pm = function() { + console.log("usage: \nto send: $.pm(options)\nto receive: $.pm.bind(type, fn, [origin])"); + return this; + }; + + // send postmessage + $.pm = window.pm = function(options) { + pm.send(options); + }; + + // bind postmessage handler + $.pm.bind = window.pm.bind = function(type, fn, origin, hash, async_reply) { + pm.bind(type, fn, origin, hash, async_reply === true); + }; + + // unbind postmessage handler + $.pm.unbind = window.pm.unbind = function(type, fn) { + pm.unbind(type, fn); + }; + + // default postmessage origin on bind + $.pm.origin = window.pm.origin = null; + + // default postmessage polling if using location hash to pass postmessages + $.pm.poll = window.pm.poll = 200; + + var pm = { + + send: function(options) { + var o = $.extend({}, pm.defaults, options), + target = o.target; + if (!o.target) { + console.warn("postmessage target window required"); + return; + } + if (!o.type) { + console.warn("postmessage type required"); + return; + } + var msg = {data:o.data, type:o.type}; + if (o.success) { + msg.callback = pm._callback(o.success); + } + if (o.error) { + msg.errback = pm._callback(o.error); + } + if (("postMessage" in target) && !o.hash) { + pm._bind(); + target.postMessage(JSON.stringify(msg), o.origin || '*'); + } + else { + pm.hash._bind(); + pm.hash.send(o, msg); + } + }, + + bind: function(type, fn, origin, hash, async_reply) { + pm._replyBind ( type, fn, origin, hash, async_reply ); + }, + + _replyBind: function(type, fn, origin, hash, isCallback) { + if (("postMessage" in window) && !hash) { + pm._bind(); + } + else { + pm.hash._bind(); + } + var l = pm.data("listeners.postmessage"); + if (!l) { + l = {}; + pm.data("listeners.postmessage", l); + } + var fns = l[type]; + if (!fns) { + fns = []; + l[type] = fns; + } + fns.push({fn:fn, callback: isCallback, origin:origin || $.pm.origin}); + }, + + unbind: function(type, fn) { + var l = pm.data("listeners.postmessage"); + if (l) { + if (type) { + if (fn) { + // remove specific listener + var fns = l[type]; + if (fns) { + var m = []; + for (var i=0,len=fns.length; i<len; i++) { + var o = fns[i]; + if (o.fn !== fn) { + m.push(o); + } + } + l[type] = m; + } + } + else { + // remove all listeners by type + delete l[type]; + } + } + else { + // unbind all listeners of all type + for (var i in l) { + delete l[i]; + } + } + } + }, + + data: function(k, v) { + if (v === undefined) { + return pm._data[k]; + } + pm._data[k] = v; + return v; + }, + + _data: {}, + + _CHARS: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''), + + _random: function() { + var r = []; + for (var i=0; i<32; i++) { + r[i] = pm._CHARS[0 | Math.random() * 32]; + }; + return r.join(""); + }, + + _callback: function(fn) { + var cbs = pm.data("callbacks.postmessage"); + if (!cbs) { + cbs = {}; + pm.data("callbacks.postmessage", cbs); + } + var r = pm._random(); + cbs[r] = fn; + return r; + }, + + _bind: function() { + // are we already listening to message events on this w? + if (!pm.data("listening.postmessage")) { + if (window.addEventListener) { + window.addEventListener("message", pm._dispatch, false); + } + else if (window.attachEvent) { + window.attachEvent("onmessage", pm._dispatch); + } + pm.data("listening.postmessage", 1); + } + }, + + _dispatch: function(e) { + //console.log("$.pm.dispatch", e, this); + try { + var msg = JSON.parse(e.data); + } + catch (ex) { + //console.warn("postmessage data invalid json: ", ex); //message wasn't meant for pm + return; + } + if (!msg.type) { + //console.warn("postmessage message type required"); //message wasn't meant for pm + return; + } + var cbs = pm.data("callbacks.postmessage") || {}, + cb = cbs[msg.type]; + if (cb) { + cb(msg.data); + } + else { + var l = pm.data("listeners.postmessage") || {}; + var fns = l[msg.type] || []; + for (var i=0,len=fns.length; i<len; i++) { + var o = fns[i]; + if (o.origin && o.origin !== '*' && e.origin !== o.origin) { + console.warn("postmessage message origin mismatch", e.origin, o.origin); + if (msg.errback) { + // notify post message errback + var error = { + message: "postmessage origin mismatch", + origin: [e.origin, o.origin] + }; + pm.send({target:e.source, data:error, type:msg.errback}); + } + continue; + } + + function sendReply ( data ) { + if (msg.callback) { + pm.send({target:e.source, data:data, type:msg.callback}); + } + } + + try { + if ( o.callback ) { + o.fn(msg.data, sendReply, e); + } else { + sendReply ( o.fn(msg.data, e) ); + } + } + catch (ex) { + if (msg.errback) { + // notify post message errback + pm.send({target:e.source, data:ex, type:msg.errback}); + } else { + throw ex; + } + } + }; + } + } + }; + + // location hash polling + pm.hash = { + + send: function(options, msg) { + //console.log("hash.send", target_window, options, msg); + var target_window = options.target, + target_url = options.url; + if (!target_url) { + console.warn("postmessage target window url is required"); + return; + } + target_url = pm.hash._url(target_url); + var source_window, + source_url = pm.hash._url(window.location.href); + if (window == target_window.parent) { + source_window = "parent"; + } + else { + try { + for (var i=0,len=parent.frames.length; i<len; i++) { + var f = parent.frames[i]; + if (f == window) { + source_window = i; + break; + } + }; + } + catch(ex) { + // Opera: security error trying to access parent.frames x-origin + // juse use window.name + source_window = window.name; + } + } + if (source_window == null) { + console.warn("postmessage windows must be direct parent/child windows and the child must be available through the parent window.frames list"); + return; + } + var hashmessage = { + "x-requested-with": "postmessage", + source: { + name: source_window, + url: source_url + }, + postmessage: msg + }; + var hash_id = "#x-postmessage-id=" + pm._random(); + target_window.location = target_url + hash_id + encodeURIComponent(JSON.stringify(hashmessage)); + }, + + _regex: /^\#x\-postmessage\-id\=(\w{32})/, + + _regex_len: "#x-postmessage-id=".length + 32, + + _bind: function() { + // are we already listening to message events on this w? + if (!pm.data("polling.postmessage")) { + setInterval(function() { + var hash = "" + window.location.hash, + m = pm.hash._regex.exec(hash); + if (m) { + var id = m[1]; + if (pm.hash._last !== id) { + pm.hash._last = id; + pm.hash._dispatch(hash.substring(pm.hash._regex_len)); + } + } + }, $.pm.poll || 200); + pm.data("polling.postmessage", 1); + } + }, + + _dispatch: function(hash) { + if (!hash) { + return; + } + try { + hash = JSON.parse(decodeURIComponent(hash)); + if (!(hash['x-requested-with'] === 'postmessage' && + hash.source && hash.source.name != null && hash.source.url && hash.postmessage)) { + // ignore since hash could've come from somewhere else + return; + } + } + catch (ex) { + // ignore since hash could've come from somewhere else + return; + } + var msg = hash.postmessage, + cbs = pm.data("callbacks.postmessage") || {}, + cb = cbs[msg.type]; + if (cb) { + cb(msg.data); + } + else { + var source_window; + if (hash.source.name === "parent") { + source_window = window.parent; + } + else { + source_window = window.frames[hash.source.name]; + } + var l = pm.data("listeners.postmessage") || {}; + var fns = l[msg.type] || []; + for (var i=0,len=fns.length; i<len; i++) { + var o = fns[i]; + if (o.origin) { + var origin = /https?\:\/\/[^\/]*/.exec(hash.source.url)[0]; + if (o.origin !== '*' && origin !== o.origin) { + console.warn("postmessage message origin mismatch", origin, o.origin); + if (msg.errback) { + // notify post message errback + var error = { + message: "postmessage origin mismatch", + origin: [origin, o.origin] + }; + pm.send({target:source_window, data:error, type:msg.errback, hash:true, url:hash.source.url}); + } + continue; + } + } + + function sendReply ( data ) { + if (msg.callback) { + pm.send({target:source_window, data:data, type:msg.callback, hash:true, url:hash.source.url}); + } + } + + try { + if ( o.callback ) { + o.fn(msg.data, sendReply); + } else { + sendReply ( o.fn(msg.data) ); + } + } + catch (ex) { + if (msg.errback) { + // notify post message errback + pm.send({target:source_window, data:ex, type:msg.errback, hash:true, url:hash.source.url}); + } else { + throw ex; + } + } + }; + } + }, + + _url: function(url) { + // url minus hash part + return (""+url).replace(/#.*$/, ""); + } + + }; + + $.extend(pm, { + defaults: { + target: null, /* target window (required) */ + url: null, /* target window url (required if no window.postMessage or hash == true) */ + type: null, /* message type (required) */ + data: null, /* message data (required) */ + success: null, /* success callback (optional) */ + error: null, /* error callback (optional) */ + origin: "*", /* postmessage origin (optional) */ + hash: false /* use location hash for message passing (optional) */ + } + }); + + })(this, typeof jQuery === "undefined" ? NO_JQUERY : jQuery); + +/** + * http://www.JSON.org/json2.js + **/ +if (! ("JSON" in window && window.JSON)){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}()); diff --git a/plugins/jetpack/_inc/spin.js b/plugins/jetpack/_inc/spin.js new file mode 100644 index 00000000..f506cd2b --- /dev/null +++ b/plugins/jetpack/_inc/spin.js @@ -0,0 +1,301 @@ +//fgnass.github.com/spin.js#v1.2.4 +(function(window, document, undefined) { + +/** + * Copyright (c) 2011 Felix Gnass [fgnass at neteye dot de] + * Licensed under the MIT license + */ + + var prefixes = ['webkit', 'Moz', 'ms', 'O']; /* Vendor prefixes */ + var animations = {}; /* Animation rules keyed by their name */ + var useCssAnimations; + + /** + * Utility function to create elements. If no tag name is given, + * a DIV is created. Optionally properties can be passed. + */ + function createEl(tag, prop) { + var el = document.createElement(tag || 'div'); + var n; + + for(n in prop) { + el[n] = prop[n]; + } + return el; + } + + /** + * Appends children and returns the parent. + */ + function ins(parent /* child1, child2, ...*/) { + for (var i=1, n=arguments.length; i<n; i++) { + parent.appendChild(arguments[i]); + } + return parent; + } + + /** + * Insert a new stylesheet to hold the @keyframe or VML rules. + */ + var sheet = function() { + var el = createEl('style'); + ins(document.getElementsByTagName('head')[0], el); + return el.sheet || el.styleSheet; + }(); + + /** + * Creates an opacity keyframe animation rule and returns its name. + * Since most mobile Webkits have timing issues with animation-delay, + * we create separate rules for each line/segment. + */ + function addAnimation(alpha, trail, i, lines) { + var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-'); + var start = 0.01 + i/lines*100; + var z = Math.max(1-(1-alpha)/trail*(100-start) , alpha); + var prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase(); + var pre = prefix && '-'+prefix+'-' || ''; + + if (!animations[name]) { + sheet.insertRule( + '@' + pre + 'keyframes ' + name + '{' + + '0%{opacity:'+z+'}' + + start + '%{opacity:'+ alpha + '}' + + (start+0.01) + '%{opacity:1}' + + (start+trail)%100 + '%{opacity:'+ alpha + '}' + + '100%{opacity:'+ z + '}' + + '}', 0); + animations[name] = 1; + } + return name; + } + + /** + * Tries various vendor prefixes and returns the first supported property. + **/ + function vendor(el, prop) { + var s = el.style; + var pp; + var i; + + if(s[prop] !== undefined) return prop; + prop = prop.charAt(0).toUpperCase() + prop.slice(1); + for(i=0; i<prefixes.length; i++) { + pp = prefixes[i]+prop; + if(s[pp] !== undefined) return pp; + } + } + + /** + * Sets multiple style properties at once. + */ + function css(el, prop) { + for (var n in prop) { + el.style[vendor(el, n)||n] = prop[n]; + } + return el; + } + + /** + * Fills in default values. + */ + function merge(obj) { + for (var i=1; i < arguments.length; i++) { + var def = arguments[i]; + for (var n in def) { + if (obj[n] === undefined) obj[n] = def[n]; + } + } + return obj; + } + + /** + * Returns the absolute page-offset of the given element. + */ + function pos(el) { + var o = {x:el.offsetLeft, y:el.offsetTop}; + while((el = el.offsetParent)) { + o.x+=el.offsetLeft; + o.y+=el.offsetTop; + } + return o; + } + + var defaults = { + lines: 12, // The number of lines to draw + length: 7, // The length of each line + width: 5, // The line thickness + radius: 10, // The radius of the inner circle + color: '#000', // #rgb or #rrggbb + speed: 1, // Rounds per second + trail: 100, // Afterglow percentage + opacity: 1/4, // Opacity of the lines + fps: 20, // Frames per second when using setTimeout() + zIndex: 2e9, // Use a high z-index by default + className: 'spinner', // CSS class to assign to the element + top: 'auto', // center vertically + left: 'auto' // center horizontally + }; + + /** The constructor */ + var Spinner = function Spinner(o) { + if (!this.spin) return new Spinner(o); + this.opts = merge(o || {}, Spinner.defaults, defaults); + }; + + Spinner.defaults = {}; + Spinner.prototype = { + spin: function(target) { + this.stop(); + var self = this; + var o = self.opts; + var el = self.el = css(createEl(0, {className: o.className}), {position: 'relative', zIndex: o.zIndex}); + var mid = o.radius+o.length+o.width; + var ep; // element position + var tp; // target position + + if (target) { + target.insertBefore(el, target.firstChild||null); + tp = pos(target); + ep = pos(el); + css(el, { + left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : o.left+mid) + 'px', + top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : o.top+mid) + 'px' + }); + } + + el.setAttribute('aria-role', 'progressbar'); + self.lines(el, self.opts); + + if (!useCssAnimations) { + // No CSS animation support, use setTimeout() instead + var i = 0; + var fps = o.fps; + var f = fps/o.speed; + var ostep = (1-o.opacity)/(f*o.trail / 100); + var astep = f/o.lines; + + !function anim() { + i++; + for (var s=o.lines; s; s--) { + var alpha = Math.max(1-(i+s*astep)%f * ostep, o.opacity); + self.opacity(el, o.lines-s, alpha, o); + } + self.timeout = self.el && setTimeout(anim, ~~(1000/fps)); + }(); + } + return self; + }, + stop: function() { + var el = this.el; + if (el) { + clearTimeout(this.timeout); + if (el.parentNode) el.parentNode.removeChild(el); + this.el = undefined; + } + return this; + }, + lines: function(el, o) { + var i = 0; + var seg; + + function fill(color, shadow) { + return css(createEl(), { + position: 'absolute', + width: (o.length+o.width) + 'px', + height: o.width + 'px', + background: color, + boxShadow: shadow, + transformOrigin: 'left', + transform: 'rotate(' + ~~(360/o.lines*i) + 'deg) translate(' + o.radius+'px' +',0)', + borderRadius: (o.width>>1) + 'px' + }); + } + for (; i < o.lines; i++) { + seg = css(createEl(), { + position: 'absolute', + top: 1+~(o.width/2) + 'px', + transform: o.hwaccel ? 'translate3d(0,0,0)' : '', + opacity: o.opacity, + animation: useCssAnimations && addAnimation(o.opacity, o.trail, i, o.lines) + ' ' + 1/o.speed + 's linear infinite' + }); + if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'})); + ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)'))); + } + return el; + }, + opacity: function(el, i, val) { + if (i < el.childNodes.length) el.childNodes[i].style.opacity = val; + } + }; + + ///////////////////////////////////////////////////////////////////////// + // VML rendering for IE + ///////////////////////////////////////////////////////////////////////// + + /** + * Check and init VML support + */ + !function() { + var s = css(createEl('group'), {behavior: 'url(#default#VML)'}); + var i; + + if (!vendor(s, 'transform') && s.adj) { + + // VML support detected. Insert CSS rules ... + for (i=4; i--;) sheet.addRule(['group', 'roundrect', 'fill', 'stroke'][i], 'behavior:url(#default#VML)'); + + Spinner.prototype.lines = function(el, o) { + var r = o.length+o.width; + var s = 2*r; + + function grp() { + return css(createEl('group', {coordsize: s +' '+s, coordorigin: -r +' '+-r}), {width: s, height: s}); + } + + var margin = -(o.width+o.length)*2+'px'; + var g = css(grp(), {position: 'absolute', top: margin, left: margin}); + + var i; + + function seg(i, dx, filter) { + ins(g, + ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}), + ins(css(createEl('roundrect', {arcsize: 1}), { + width: r, + height: o.width, + left: o.radius, + top: -o.width>>1, + filter: filter + }), + createEl('fill', {color: o.color, opacity: o.opacity}), + createEl('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change + ) + ) + ); + } + + if (o.shadow) { + for (i = 1; i <= o.lines; i++) { + seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)'); + } + } + for (i = 1; i <= o.lines; i++) seg(i); + return ins(el, g); + }; + Spinner.prototype.opacity = function(el, i, val, o) { + var c = el.firstChild; + o = o.shadow && o.lines || 0; + if (c && i+o < c.childNodes.length) { + c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild; + if (c) c.opacity = val; + } + }; + } + else { + useCssAnimations = vendor(s, 'animation'); + } + }(); + + window.Spinner = Spinner; + +})(window, document);
\ No newline at end of file |