Skip to content

Instantly share code, notes, and snippets.

View natecavanaugh's full-sized avatar

Nate Cavanaugh natecavanaugh

View GitHub Profile
@natecavanaugh
natecavanaugh / gist:6284612
Created August 20, 2013 17:34
main.js control panel
Liferay.Util.portletTitleEdit = function() {
};
if (!themeDisplay.isStatePopUp()) {
AUI().ready('aui-live-search', 'aui-overlay-context-panel', 'event-mouseenter', 'liferay-message', 'liferay-panel', 'liferay-store', 'node-focusmanager', 'transition',
function(A) {
var body = A.getBody();
var portletInformationEl = A.one('#cpContextPanelTemplate');
var portletInformationIcon = A.one('#cpPortletTitleHelpIcon');
@natecavanaugh
natecavanaugh / _mixins.scss
Last active December 20, 2015 07:19
improve respond-to mixin
// phone, tablet, desktop
// phone, desktop, tablet
// tablet, phone, desktop
// tablet, desktop, phone
// desktop, phone, tablet
// desktop, tablet, phone
// phone: max-width: 767
// tablet: min-width: 768 - max-width: 979
// desktop: min-width: 980
@natecavanaugh
natecavanaugh / form_navigator_responsive.css
Created July 24, 2013 16:26
Make the form navigator respond to tablets
/* ---------- Form navigator ---------- */
@import "mixins";
@include respond-to(tablet) {
.aui .taglib-form-navigator {
> .tab-content {
clear: both;
float: none;
width: 100%;
@natecavanaugh
natecavanaugh / contrast_ratio.js
Created July 16, 2013 21:09
contrast ratio calculator
// Ported from http://stackoverflow.com/a/17343790/905036
function relativeLuminance(col) {
//Remove any leading #
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
var components = {};
col = col.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
//Convert hex to 0-1 scale
AUI().use("autocomplete", "autocomplete-highlighters", "aui-io-request", function (A) {
A.one('#<portlet:namespace/>academyName').plug(A.Plugin.AutoComplete, {
resultHighlighter: 'phraseMatch',
resultListLocator: 'orgs',
resultTextLocator: 'name',
queryDelimiter: ',',
minQueryLength: 3,
source: function(query) {
var queryUrl = '<%=searchUrl%>&<portlet:namespace />keywords=' + query + '&<portlet:namespace/>types=' + types;
var request = A.io.request(
@natecavanaugh
natecavanaugh / test_responsive.css
Created May 16, 2013 18:35
Test responsive breakpoints in scss
body:before, #wrapper:after, #wrapper:before {
position: fixed;
content: '';
display: block;
border: 1px solid #000;
height: 100%;
top: 0;
left: 0;
opacity: 0.5;
}
@natecavanaugh
natecavanaugh / get_cached_aui_instance.js
Created March 28, 2013 15:35
Getting cached AUI instance to accomodate for cross-window retrieval
var getCachedInstance = function(yuiInstance, o, args) {
var instance = this;
// Need the current window, not A.config.win
var alloyInstance = yuiInstance._AUI_CACHED || ALLOY;
if (o || instance instanceof AUI) {
args = ALLOY.Array(args);
args.unshift(ALLOY.config);
@natecavanaugh
natecavanaugh / get_service_sync.js
Created March 22, 2013 16:36
A version of Liferay JS services that return synchronously (not recommended)
function getServiceSync() {
var xhr = null;
var args = parent.Liferay.Service.parseInvokeArgs(arguments);
var syncIOConfig = {
sync: true,
on: {
success: function(event, id, obj){
xhr = obj;
}
toggleDisabled = function(field, force) {
var container;
if (field.hasClass('aui-field-input') || field) {
container = field.ancestor('.aui-field');
}
else {
container = field;
field = field.children('.aui-field,.aui-button');
}
@natecavanaugh
natecavanaugh / lportal-2-15-2013-stacktrace
Created February 15, 2013 22:46
lportal-2-15-2013-stacktrace
INFO: Initializing Spring FrameworkServlet 'Remoting Servlet'
21:04:19,544 ERROR [main][ModuleFrameworkAdapterHelper:62] Unable to configure the class loader for the module framework
21:04:19,545 ERROR [main][ModuleFrameworkAdapterHelper:76] Unable to load the module framework
Feb 15, 2013 9:04:19 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Module Framework Servlet as unavailable
Feb 15, 2013 9:04:19 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet threw load() exception
java.lang.NullPointerException
at com.liferay.portal.module.framework.ModuleFrameworkAdapterHelper.getClassLoader(ModuleFrameworkAdapterHelper.java:50)
at com.liferay.portal.module.framework.ModuleFrameworkAdapterHelper.<init>(ModuleFrameworkAdapterHelper.java:72)