From 5f3acb4c8909316953bb0adea512ff2d3bfe54cd Mon Sep 17 00:00:00 2001 From: needle2k Date: Fri, 28 Jun 2013 12:21:44 +0200 Subject: [PATCH 1/3] Create attrchange.js taken from http://meetselva.github.io/attrchange/ --- js/attrchange.js | 129 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 js/attrchange.js diff --git a/js/attrchange.js b/js/attrchange.js new file mode 100644 index 0000000..0455c6f --- /dev/null +++ b/js/attrchange.js @@ -0,0 +1,129 @@ +/* +A simple jQuery function that can add listeners on attribute change. +http://meetselva.github.io/attrchange/ + +About License: +Copyright (C) 2013 Selvakumar Arumugam +You may use attrchange plugin under the terms of the MIT Licese. +https://github.com/meetselva/attrchange/blob/master/MIT-License.txt +*/ +(function($) { + function isDOMAttrModifiedSupported() { + var p = document.createElement('p'); + var flag = false; + + if (p.addEventListener) p.addEventListener('DOMAttrModified', function() { + flag = true + }, false); + else if (p.attachEvent) p.attachEvent('onDOMAttrModified', function() { + flag = true + }); + else return false; + + p.setAttribute('id', 'target'); + + return flag; + } + + function checkAttributes(chkAttr, e) { + if (chkAttr) { + var attributes = this.data('attr-old-value'); + + if (e.attributeName.indexOf('style') >= 0) { + if (!attributes['style']) attributes['style'] = {}; //initialize + var keys = e.attributeName.split('.'); + e.attributeName = keys[0]; + e.oldValue = attributes['style'][keys[1]]; //old value + e.newValue = keys[1] + ':' + this.prop("style")[$.camelCase(keys[1])]; //new value + attributes['style'][keys[1]] = e.newValue; + } else { + e.oldValue = attributes[e.attributeName]; + e.newValue = this.attr(e.attributeName); + attributes[e.attributeName] = e.newValue; + } + + this.data('attr-old-value', attributes); //update the old value object + } + } + + //initialize Mutation Observer + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + $.fn.attrchange = function(o) { + + var cfg = { + trackValues: false, + callback: $.noop + }; + + //for backward compatibility + if (typeof o === "function" ) { + cfg.callback = o; + } else { + $.extend(cfg, o); + } + + if (cfg.trackValues) { //get attributes old value + $(this).each(function (i, el) { + var attributes = {}; + for (var attr, i=0, attrs=el.attributes, l=attrs.length; i Date: Fri, 28 Jun 2013 12:33:10 +0200 Subject: [PATCH 2/3] Update magic-slider.js added observer for lightBox overlay to prevent autoSlide false, if lightbox is initialized // Selector to be observed lightBoxOpenSelector: "lbOverlay", // lightbox overlay div // enable/ disable observe observeLightBoxOpen: false, --- js/magic-slider.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/magic-slider.js b/js/magic-slider.js index fc530cd..132bc96 100755 --- a/js/magic-slider.js +++ b/js/magic-slider.js @@ -39,6 +39,8 @@ $.fn.magicSlider = function(settings) { carousel: false, changeSliderHeadline: false, sliderHeadlineSelector: "#magic_slider_head", // Selector for headline + lightBoxOpenSelector: "lbOverlay", // lightbox overlay div + observeLightBoxOpen: false, pauseOnMouseEnter: false // affects autoSlide }, settings); @@ -115,6 +117,19 @@ $.fn.magicSlider = function(settings) { $('.' + sliderID + '_panel_container', slider).css({ width: panelContainerWidth }); }; + + // observe lightbox init to pause autoSlide + if (settings.observeLightBoxOpen === true) { + $('#' + settings.lightBoxOpenSelector).attrchange(function(attrName) { + var currentDisplay = $('#' + settings.lightBoxOpenSelector).css('display'); + if ( currentDisplay === 'block') { + mouseEvent = true; + } else { + mouseEvent = false; + } + }); + } + // check if pauseOnMouseEnter is true, set mouseEvent Boolean if (settings.pauseOnMouseEnter === true) { $('.' + sliderID + '_panel_container', slider).mouseenter(function(){ From aac71bf3aca2cc8f084d2d8a4d0b90099221b4a8 Mon Sep 17 00:00:00 2001 From: needle2k Date: Fri, 28 Jun 2013 12:38:40 +0200 Subject: [PATCH 3/3] Update Readme.md --- Readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 1de674e..c9203a1 100755 --- a/Readme.md +++ b/Readme.md @@ -30,4 +30,10 @@ Thanks A lot! * **better rel-linking** .. because of the new slider-identifying you can just use the slider-ID as rel, no more counting -for more info, look: [the github page](http://orangenwerk.github.com/magic-slider/) \ No newline at end of file +for more info, look: [the github page](http://orangenwerk.github.com/magic-slider/) + +## more improvements + +* Added observe Lightbox(overlay) init to pause autoSlide +* Added Mouseenter, Mouseleave to pause autoSlide +