From e605e55ec18ddb461252247650bfcd352ca9c0c1 Mon Sep 17 00:00:00 2001 From: Markus Pleines Date: Wed, 4 Mar 2015 22:59:43 +0100 Subject: [PATCH 1/3] Added easy fallback for touch devices to rift --- js/rift.js | 54 +++++++++++++++++++++++++++++--------------------- js/rift.min.js | 7 +------ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/js/rift.js b/js/rift.js index ec9a803..8a23169 100644 --- a/js/rift.js +++ b/js/rift.js @@ -3,28 +3,36 @@ * @author Kyle Foster * MIT license */ -;(function ( $, window, document, undefined ) { +; +(function ($, window, document, undefined) { - $.fn.rift = function () { + $.fn.rift = function () { - return this.each(function () { - - // Vurribles - var element = $(this), - elemImg = element.find('img'), - imgSrc = elemImg.attr('src'); - - // We be chainin' - element - .prepend('') - .append('') - .find('span.top-span') - .css('background', 'url(' + imgSrc + ') no-repeat center top') - .css('background-size', '100%') - .parent() - .find('span.btm-span') - .css('background', 'url(' + imgSrc + ') no-repeat center bottom') - .css('background-size', '100%'); - }); - }; -})( jQuery, window, document ); \ No newline at end of file + return this.each(function () { + + // Vurribles + var element = $(this), + elemImg = element.find('img'), + imgSrc = elemImg.attr('src'); + + // We be chainin' + element + .prepend('') + .append('') + .find('span.top-span') + .css('background', 'url(' + imgSrc + ') no-repeat center top') + .css('background-size', '100%') + .parent() + .find('span.btm-span') + .css('background', 'url(' + imgSrc + ') no-repeat center bottom') + .css('background-size', '100%'); + }); + // Easy fallback for touch devices + var isTouchDevice = 'ontouchstart' in document.documentElement; + if (isTouchDevice) { + element.on('click', function (e) { + $(this).toggleClass('open'); + }) + } + }; +})(jQuery, window, document); \ No newline at end of file diff --git a/js/rift.min.js b/js/rift.min.js index 5c2095f..017e596 100644 --- a/js/rift.min.js +++ b/js/rift.min.js @@ -1,6 +1 @@ -/** - * Rift v1.0.0 - * @author Kyle Foster - * MIT license - */ -(function(e,t,n,r){e.fn.rift=function(){return this.each(function(){var t=e(this),n=t.find("img"),r=n.attr("src");t.prepend('').append('').find("span.top-span").css("background","url("+r+") no-repeat center top").css("background-size","100%").parent().find("span.btm-span").css("background","url("+r+") no-repeat center bottom").css("background-size","100%")})}})(jQuery,window,document) \ No newline at end of file +!function(n,s,a){n.fn.rift=function(){return this.each(function(){var s=n(this),a=s.find("img"),t=a.attr("src");s.prepend('').append('').find("span.top-span").css("background","url("+t+") no-repeat center top").css("background-size","100%").parent().find("span.btm-span").css("background","url("+t+") no-repeat center bottom").css("background-size","100%")})}}(jQuery,window,document); \ No newline at end of file From 530a1e14276f9868bb26613b7d14ff5a09474a25 Mon Sep 17 00:00:00 2001 From: Markus Pleines Date: Wed, 4 Mar 2015 23:00:35 +0100 Subject: [PATCH 2/3] Added easy fallback for touch devices --- js/rift.js | 57 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/js/rift.js b/js/rift.js index 8a23169..b94f9d8 100644 --- a/js/rift.js +++ b/js/rift.js @@ -3,36 +3,35 @@ * @author Kyle Foster * MIT license */ -; -(function ($, window, document, undefined) { +;(function ( $, window, document, undefined ) { - $.fn.rift = function () { + $.fn.rift = function () { - return this.each(function () { + return this.each(function () { - // Vurribles - var element = $(this), - elemImg = element.find('img'), - imgSrc = elemImg.attr('src'); + // Vurribles + var element = $(this), + elemImg = element.find('img'), + imgSrc = elemImg.attr('src'); - // We be chainin' - element - .prepend('') - .append('') - .find('span.top-span') - .css('background', 'url(' + imgSrc + ') no-repeat center top') - .css('background-size', '100%') - .parent() - .find('span.btm-span') - .css('background', 'url(' + imgSrc + ') no-repeat center bottom') - .css('background-size', '100%'); - }); - // Easy fallback for touch devices - var isTouchDevice = 'ontouchstart' in document.documentElement; - if (isTouchDevice) { - element.on('click', function (e) { - $(this).toggleClass('open'); - }) - } - }; -})(jQuery, window, document); \ No newline at end of file + // We be chainin' + element + .prepend('') + .append('') + .find('span.top-span') + .css('background', 'url(' + imgSrc + ') no-repeat center top') + .css('background-size', '100%') + .parent() + .find('span.btm-span') + .css('background', 'url(' + imgSrc + ') no-repeat center bottom') + .css('background-size', '100%'); + }); + // Easy fallback for touch devices + var isTouchDevice = 'ontouchstart' in document.documentElement; + if(isTouchDevice) { + element.on('click', function(e) { + $(this).toggleClass('open'); + }) + } + }; +})( jQuery, window, document ); \ No newline at end of file From 18536e1b9b4f680699c5c77c702343aca2ad6ca3 Mon Sep 17 00:00:00 2001 From: Markus Pleines Date: Thu, 5 Mar 2015 21:21:49 +0100 Subject: [PATCH 3/3] Touch Fallback (now working correctly) --- js/rift.js | 16 +++++++++------- js/rift.min.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/js/rift.js b/js/rift.js index b94f9d8..ce67ea2 100644 --- a/js/rift.js +++ b/js/rift.js @@ -11,8 +11,8 @@ // Vurribles var element = $(this), - elemImg = element.find('img'), - imgSrc = elemImg.attr('src'); + elemImg = element.find('img'), + imgSrc = elemImg.attr('src'); // We be chainin' element @@ -25,13 +25,15 @@ .find('span.btm-span') .css('background', 'url(' + imgSrc + ') no-repeat center bottom') .css('background-size', '100%'); - }); + // Easy fallback for touch devices var isTouchDevice = 'ontouchstart' in document.documentElement; if(isTouchDevice) { - element.on('click', function(e) { - $(this).toggleClass('open'); - }) + element.on('click', function(e) { + $(this).toggleClass('open'); + }) } + }); + }; -})( jQuery, window, document ); \ No newline at end of file +})( jQuery, window, document ); diff --git a/js/rift.min.js b/js/rift.min.js index 017e596..ed7446f 100644 --- a/js/rift.min.js +++ b/js/rift.min.js @@ -1 +1 @@ -!function(n,s,a){n.fn.rift=function(){return this.each(function(){var s=n(this),a=s.find("img"),t=a.attr("src");s.prepend('').append('').find("span.top-span").css("background","url("+t+") no-repeat center top").css("background-size","100%").parent().find("span.btm-span").css("background","url("+t+") no-repeat center bottom").css("background-size","100%")})}}(jQuery,window,document); \ No newline at end of file +!function(n,s,t){n.fn.rift=function(){return this.each(function(){var s=n(this),a=s.find("img"),c=a.attr("src");s.prepend('').append('').find("span.top-span").css("background","url("+c+") no-repeat center top").css("background-size","100%").parent().find("span.btm-span").css("background","url("+c+") no-repeat center bottom").css("background-size","100%");var e="ontouchstart"in t.documentElement;e&&s.on("click",function(){n(this).toggleClass("open")})})}}(jQuery,window,document); \ No newline at end of file