Last active
August 29, 2015 14:12
-
-
Save chrismrgn/c34c5f449786cafda7bf to your computer and use it in GitHub Desktop.
OpenSchema.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
javascript: (function (UI, B, e, a, r, d) | |
{ | |
if ( typeof String.prototype.endsWith != 'function' ) { | |
String.prototype.endsWith = function( str ) { | |
return this.substring( this.length - str.length, this.length ) === str; | |
} | |
}; | |
try | |
{ | |
while (r = UI.frames[e++]) | |
{ | |
if ((a = r.$display && r.$display.getView()) && a.getId() == B) | |
{ | |
d = a; | |
break; | |
} | |
} | |
var m1 = window.top.frames[1]; | |
var itemId = d.getMainInterface().getListSelection().getVersionlessIds()[0]; | |
var item = m1.$models.getItem(itemId); | |
if(item.getTypeName().endsWith('Component')) | |
{ | |
console.log('Got a Component'); | |
var schema = item.getSchema(); | |
schema.load(); | |
setTimeout(function(){ | |
var schemaTCM = item.getSchemaId(); | |
var schemaTCMArray = schemaTCM.split('-'); | |
var parentPublicationTCM = schema.getOwningPublicationId(); | |
var parentPublicationTCMArray = parentPublicationTCM.split('-'); | |
var parentPublicationId = parentPublicationTCMArray[1]; | |
schemaTCMArray[0] = 'tcm:'+parentPublicationId; | |
var parentSchemaId = schemaTCMArray.join('-'); | |
var win = window.open('/WebUI/item.aspx?tcm=8#id='+parentSchemaId, '_blank'); | |
win.focus(); | |
}, 500); | |
} | |
else | |
{ | |
alert('Only works on Components'); | |
} | |
} | |
catch (x) {alert(x);}; | |
})(window.top, 'DashboardView', 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment