phpdoc/sami.js
(function(root) {
var bhIndex = null;
var rootPath = '';
var treeHtml = ' <ul> <li data-name="namespace:ServiceContainer" class="opened"> <div style="padding-left:0px" class="hd"> <span class="glyphicon glyphicon-play"></span><a href="ServiceContainer.html">ServiceContainer</a> </div> <div class="bd"> <ul> <li data-name="class:ServiceContainer_ApiServiceContainer" class="opened"> <div style="padding-left:26px" class="hd leaf"> <a href="ServiceContainer/ApiServiceContainer.html">ApiServiceContainer</a> </div> </li> <li data-name="class:ServiceContainer_ServiceContainer" class="opened"> <div style="padding-left:26px" class="hd leaf"> <a href="ServiceContainer/ServiceContainer.html">ServiceContainer</a> </div> </li> <li data-name="class:ServiceContainer_ServiceContainerInterface" class="opened"> <div style="padding-left:26px" class="hd leaf"> <a href="ServiceContainer/ServiceContainerInterface.html">ServiceContainerInterface</a> </div> </li> <li data-name="class:ServiceContainer_ServiceProviderInterface" class="opened"> <div style="padding-left:26px" class="hd leaf"> <a href="ServiceContainer/ServiceProviderInterface.html">ServiceProviderInterface</a> </div> </li> </ul></div> </li> </ul>';
var searchTypeClasses = {
'Namespace': 'label-default',
'Class': 'label-info',
'Interface': 'label-primary',
'Trait': 'label-success',
'Method': 'label-danger',
'_': 'label-warning'
};
var searchIndex = [
{"type": "Namespace", "link": "ServiceContainer.html", "name": "ServiceContainer", "doc": "Namespace ServiceContainer"},
{"type": "Interface", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ServiceContainerInterface.html", "name": "ServiceContainer\\ServiceContainerInterface", "doc": ""A simple service container interface""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_setProvider", "name": "ServiceContainer\\ServiceContainerInterface::setProvider", "doc": ""Define a service constructor like <code>array( name , callback , protected )<\/code> or a closure""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_setService", "name": "ServiceContainer\\ServiceContainerInterface::setService", "doc": ""Register a new service called <code>$name<\/code> declared as NOT protected by default""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_getService", "name": "ServiceContainer\\ServiceContainerInterface::getService", "doc": ""Get a service called <code>$name<\/code> throwing an error by default if it does not exist yet and can not be created""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_hasService", "name": "ServiceContainer\\ServiceContainerInterface::hasService", "doc": ""Test if a service exists in the container""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_unsetService", "name": "ServiceContainer\\ServiceContainerInterface::unsetService", "doc": ""Unset a service if it is not protected""},
{"type": "Interface", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ServiceProviderInterface.html", "name": "ServiceContainer\\ServiceProviderInterface", "doc": ""Interface ServiceProviderInterface""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_register", "name": "ServiceContainer\\ServiceProviderInterface::register", "doc": ""Launch actions when the service is registered in the container""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_boot", "name": "ServiceContainer\\ServiceProviderInterface::boot", "doc": ""Launch actions when the service is created""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_terminate", "name": "ServiceContainer\\ServiceProviderInterface::terminate", "doc": ""Launch actions when the service is destructed""},
{"type": "Class", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ApiServiceContainer.html", "name": "ServiceContainer\\ApiServiceContainer", "doc": ""A service container with constructors based on an API declaration and validation""},
{"type": "Method", "fromName": "ServiceContainer\\ApiServiceContainer", "fromLink": "ServiceContainer/ApiServiceContainer.html", "link": "ServiceContainer/ApiServiceContainer.html#method_apiFactory", "name": "ServiceContainer\\ApiServiceContainer::apiFactory", "doc": ""Usage:""},
{"type": "Class", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html", "name": "ServiceContainer\\ServiceContainer", "doc": ""A simple service container with constructors""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_init", "name": "ServiceContainer\\ServiceContainer::init", "doc": ""Initialize the service container system""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_setProvider", "name": "ServiceContainer\\ServiceContainer::setProvider", "doc": ""Define a service constructor like <code>array( name , callback , protected )<\/code> or a closure""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_getProvider", "name": "ServiceContainer\\ServiceContainer::getProvider", "doc": ""Get a service constructor if it exists""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_hasProvider", "name": "ServiceContainer\\ServiceContainer::hasProvider", "doc": ""Test if a constructor exists for a service""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_setProtected", "name": "ServiceContainer\\ServiceContainer::setProtected", "doc": ""Define a service as protected""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_isProtected", "name": "ServiceContainer\\ServiceContainer::isProtected", "doc": ""Test if a service is protected""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_setService", "name": "ServiceContainer\\ServiceContainer::setService", "doc": ""Register a new service called <code>$name<\/code> declared as NOT protected by default""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_getService", "name": "ServiceContainer\\ServiceContainer::getService", "doc": ""Get a service called <code>$name<\/code> throwing an error by default if it does not exist yet and can not be created""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_hasService", "name": "ServiceContainer\\ServiceContainer::hasService", "doc": ""Test if a service exists in the container""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainer", "fromLink": "ServiceContainer/ServiceContainer.html", "link": "ServiceContainer/ServiceContainer.html#method_unsetService", "name": "ServiceContainer\\ServiceContainer::unsetService", "doc": ""Unset a service if it is not protected""},
{"type": "Class", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ServiceContainerInterface.html", "name": "ServiceContainer\\ServiceContainerInterface", "doc": ""A simple service container interface""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_setProvider", "name": "ServiceContainer\\ServiceContainerInterface::setProvider", "doc": ""Define a service constructor like <code>array( name , callback , protected )<\/code> or a closure""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_setService", "name": "ServiceContainer\\ServiceContainerInterface::setService", "doc": ""Register a new service called <code>$name<\/code> declared as NOT protected by default""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_getService", "name": "ServiceContainer\\ServiceContainerInterface::getService", "doc": ""Get a service called <code>$name<\/code> throwing an error by default if it does not exist yet and can not be created""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_hasService", "name": "ServiceContainer\\ServiceContainerInterface::hasService", "doc": ""Test if a service exists in the container""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceContainerInterface", "fromLink": "ServiceContainer/ServiceContainerInterface.html", "link": "ServiceContainer/ServiceContainerInterface.html#method_unsetService", "name": "ServiceContainer\\ServiceContainerInterface::unsetService", "doc": ""Unset a service if it is not protected""},
{"type": "Class", "fromName": "ServiceContainer", "fromLink": "ServiceContainer.html", "link": "ServiceContainer/ServiceProviderInterface.html", "name": "ServiceContainer\\ServiceProviderInterface", "doc": ""Interface ServiceProviderInterface""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_register", "name": "ServiceContainer\\ServiceProviderInterface::register", "doc": ""Launch actions when the service is registered in the container""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_boot", "name": "ServiceContainer\\ServiceProviderInterface::boot", "doc": ""Launch actions when the service is created""},
{"type": "Method", "fromName": "ServiceContainer\\ServiceProviderInterface", "fromLink": "ServiceContainer/ServiceProviderInterface.html", "link": "ServiceContainer/ServiceProviderInterface.html#method_terminate", "name": "ServiceContainer\\ServiceProviderInterface::terminate", "doc": ""Launch actions when the service is destructed""},
// Fix trailing commas in the index
{}
];
/** Tokenizes strings by namespaces and functions */
function tokenizer(term) {
if (!term) {
return [];
}
var tokens = [term];
var meth = term.indexOf('::');
// Split tokens into methods if "::" is found.
if (meth > -1) {
tokens.push(term.substr(meth + 2));
term = term.substr(0, meth - 2);
}
// Split by namespace or fake namespace.
if (term.indexOf('\\') > -1) {
tokens = tokens.concat(term.split('\\'));
} else if (term.indexOf('_') > 0) {
tokens = tokens.concat(term.split('_'));
}
// Merge in splitting the string by case and return
tokens = tokens.concat(term.match(/(([A-Z]?[^A-Z]*)|([a-z]?[^a-z]*))/g).slice(0,-1));
return tokens;
};
root.Sami = {
/**
* Cleans the provided term. If no term is provided, then one is
* grabbed from the query string "search" parameter.
*/
cleanSearchTerm: function(term) {
// Grab from the query string
if (typeof term === 'undefined') {
var name = 'search';
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
if (results === null) {
return null;
}
term = decodeURIComponent(results[1].replace(/\+/g, " "));
}
return term.replace(/<(?:.|\n)*?>/gm, '');
},
/** Searches through the index for a given term */
search: function(term) {
// Create a new search index if needed
if (!bhIndex) {
bhIndex = new Bloodhound({
limit: 500,
local: searchIndex,
datumTokenizer: function (d) {
return tokenizer(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace
});
bhIndex.initialize();
}
results = [];
bhIndex.get(term, function(matches) {
results = matches;
});
if (!rootPath) {
return results;
}
// Fix the element links based on the current page depth.
return $.map(results, function(ele) {
if (ele.link.indexOf('..') > -1) {
return ele;
}
ele.link = rootPath + ele.link;
if (ele.fromLink) {
ele.fromLink = rootPath + ele.fromLink;
}
return ele;
});
},
/** Get a search class for a specific type */
getSearchClass: function(type) {
return searchTypeClasses[type] || searchTypeClasses['_'];
},
/** Add the left-nav tree to the site */
injectApiTree: function(ele) {
ele.html(treeHtml);
}
};
$(function() {
// Modify the HTML to work correctly based on the current depth
rootPath = $('body').attr('data-root-path');
treeHtml = treeHtml.replace(/href="/g, 'href="' + rootPath);
Sami.injectApiTree($('#api-tree'));
});
return root.Sami;
})(window);
$(function() {
// Enable the version switcher
$('#version-switcher').change(function() {
window.location = $(this).val()
});
// Toggle left-nav divs on click
$('#api-tree .hd span').click(function() {
$(this).parent().parent().toggleClass('opened');
});
// Expand the parent namespaces of the current page.
var expected = $('body').attr('data-name');
if (expected) {
// Open the currently selected node and its parents.
var container = $('#api-tree');
var node = $('#api-tree li[data-name="' + expected + '"]');
// Node might not be found when simulating namespaces
if (node.length > 0) {
node.addClass('active').addClass('opened');
node.parents('li').addClass('opened');
var scrollPos = node.offset().top - container.offset().top + container.scrollTop();
// Position the item nearer to the top of the screen.
scrollPos -= 200;
container.scrollTop(scrollPos);
}
}
var form = $('#search-form .typeahead');
form.typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'search',
displayKey: 'name',
source: function (q, cb) {
cb(Sami.search(q));
}
});
// The selection is direct-linked when the user selects a suggestion.
form.on('typeahead:selected', function(e, suggestion) {
window.location = suggestion.link;
});
// The form is submitted when the user hits enter.
form.keypress(function (e) {
if (e.which == 13) {
$('#search-form').submit();
return true;
}
});
});