var silk = ( xb.core.object.extend( { ctor: function() { var self = this; $( document ).on( "ready", function( evt ) { self.init(); } ); }, init: function() { window.setTimeout( function() { if ( document.body.getAttribute( "data-simply-edit" ) === null ) { objectFitImages(); } }, 1250 ); /* var loadEditor = function( settings ) { console.warn( settings ); var se_script = document.createElement( "script" ); se_script.setAttribute( "data-simply-endpoint", settings[ "simply-endpoint" ] ); se_script.setAttribute( "data-api-key", settings[ "simply-api-key" ] ); se_script.setAttribute( "data-simply-images", "/images/" ); se_script.setAttribute( "data-simply-files", "/bestanden/" ); se_script.src = settings[ "simply-src"]; document.body.appendChild( se_script ); }; window.addEventListener( "hashchange", function( evt ) { var hash = window.location.hash; if ( typeof( editor ) === "object" ) { console.warn( "Editor already loaded..." ); return; } if ( !hash.match( /#simply-edit/ ) ) { return; } console.warn( "Loading editor" ); var http = new XMLHttpRequest(); http.open( "get", "/components/apps/editor/simply-edit/json.settings.php", true ); http.onreadystatechange = function() { if ( http.readyState == 4 ) { var settings = null; try { settings = JSON.parse( http.responseText ); } catch( e ) {}; if ( settings !== null ) { loadEditor( settings ); } } }; return http.send(); //document.body.appendChild( ) } ); */ }, content: {}, inEditMode: function() { return ( document.body.getAttribute( "data-simply-edit" ) !== null ); }, parseURLQuery: function( query ) { var result = {}; if ( typeof( query ) === "string" ) { query .replace( /[?&]+([^=&]+)=([^&]*)/gi, function( str, key, value ) { var v = []; decodeURIComponent( value ) .replace( /(([\\][|]|[^|])+)/gi, function( str, part ) { v.push( part.replace( /[\\][|]/, "|" ) ); } ) ; if ( key.substr( -2 ) === "[]" ) { key = key.substr( 0, key.length - 2 ); } if ( ! ( result[ key ] instanceof Array ) ) { result[ key ] = []; } for ( var i = 0, il = v.length; i < il; i++ ) { result[ key ].push( v[ i ] ); } } ) ; } return result; }, //shamelessly copied from Muze | Bij gebrek aan API editorSelectDOMNode: function( target ) { var sel = vdSelectionState.get(); sel.selectNode(target); vdSelectionState.save(sel); sel.startContainer.ownerDocument.defaultView.getSelection().removeAllRanges(); editor.context.update(); window.setTimeout(function() { removeMouseSelectionEvent = muze.event.attach(document, "mousedown", function(evt) { var target = muze.event.target(evt); // Keep the selection when the click is within a toolbar; if (editor.node.hasToolbarParent(target)) { return; } if (document.querySelector(":focus") && editor.node.hasToolbarParent(document.querySelector(":focus"))) { return; } muze.event.detach(document, "mousedown", removeMouseSelectionEvent); muze.event.detach(document, "touchstart", removeTouchSelectionEvent); vdSelectionState.remove(); }); removeTouchSelectionEvent = muze.event.attach(document, "touchstart", function(evt) { var target = muze.event.target(evt); // Keep the selection when the click is within a toolbar; if (editor.node.hasToolbarParent(target)) { return; } if (document.querySelector(":focus") && editor.node.hasToolbarParent(document.querySelector(":focus"))) { return; } muze.event.detach(document, "mousedown", removeMouseSelectionEvent); muze.event.detach(document, "touchstart", removeTouchSelectionEvent); vdSelectionState.remove(); }); }, 50); } } ) )();