Last active
August 29, 2015 14:11
-
-
Save bkoopman/4748ea17be3a15bf2fb6 to your computer and use it in GitHub Desktop.
Updated version of xpm-jquery-plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* XPM specific functions | |
*/ | |
(function($) { | |
// initialize global variable | |
SDL_ENV.isInXpm = false; | |
// check and set global variable | |
$.fn.checkIfInXpm = function() { | |
// check via availability of Tridion objects | |
if (typeof Tridion != "undefined" && typeof Tridion.Web.UI.SiteEdit != "undefined") { | |
console.log("in XPM"); | |
SDL_ENV.isInXpm = true; | |
// display elements specifically for experience manager | |
$(".xpm-only").show(); | |
} else { | |
console.log("not in XPM"); | |
SDL_ENV.isInXpm = false; | |
// hide elements specifically for experience manager | |
$(".xpm-only").hide(); | |
} | |
}; | |
}(jQuery)); | |
$(document).ready(function() { | |
// wait 5 seconds after document ready (to complete XPM load) and check if we are in XPM (setting global variable) | |
setTimeout(function() { | |
$().checkIfInXpm(); | |
}, 5000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment