silk.postings.carousel = xb.core.object.extend( { } ); silk.postings.carousel.mount = xb.core.object.extend( silk.node.mount, { ctor: function( domNode, name, resource ) { var self = this; if ( !this.DOMNodeHandler ) { this.DOMNodeHandler = silk.postings.carousel.mount.handler; } silk.node.mount.prototype.ctor.call( this, domNode, name, resource ); }, onDOMChange: function( handler, before ) { //debugger } } ); silk.postings.carousel.mount.handler = xb.core.object.extend( silk.node.mount.DOMNode, { factory: function( mount, domNode ) { return new silk.postings.carousel.mount.handler( mount, domNode ); }, ctor: function( mount, domNode ) { this.owl = null; silk.node.mount.DOMNode.prototype.ctor.call( this, mount, domNode ); }, getValue: function() { debugger var data = this.each( function( context, index ) { // console.warn( "each", this.domNode ); if ( $( this.domNode.parentNode ).hasClass( "cloned" ) ) { return null; } return this.getValue(); }, { mp: this } ); return data; }, display: function( data ) { if ( this.owl !== null ) { return; } var data = data.getArray(); if ( data.length < 2 ) { for ( var i = data.length; i < 2; i++ ) { data.push( { "image": { "src": "/images/placeholder.jpg" } } ); } } this.render( data, true ); if ( this.owl !== null ) { console.log( this.owl ); $( this.owl ).trigger( "destroy.owl.carousel" ); } var settings = {}; if ( typeof( carousel[ this.mount.resource.config.name ] ) !== "undefined" ) { settings = xb.core.object.prototype.copy.call( carousel[ this.mount.resource.config.name ] ); } //console.log( "EDIT?", document.body.getAttribute( "data-simply-edit" ) ); if ( document.body.getAttribute( "data-simply-edit" ) ) { settings[ "autoplay" ] = false; settings[ "mouseDrag" ] = false; } //console.log( "INITING OWL", this.domNode ); this.owl = $( this.domNode ).owlCarousel( settings ); $( "img[data-simply-src]" ).each( function() { //console.log( "IMG: ", this.getAttribute( "data-simply-src" ), "=>", this.getAttribute( "src" ) ); this.setAttribute( "src", this.getAttribute( "data-simply-src" ) ); } ); } } );