Skip to content

Instantly share code, notes, and snippets.

View mattparker's full-sized avatar

Matt Parker mattparker

View GitHub Profile
// Note that _disabledRules is also added to constructor.
// These are the public API methods.
/**
* Enable a particular rule (or several) that's previously been disabled.
* The selector parameter can be a RegExp; each rule matching the pattern
* will be enabled
* @param sel {String} String or RegExp to match to selectors to enable
* @method enableRule
YUI.add('fielddef', function (Y) {
/**
* A field definition sets up everything except the actual value of a field.
*
*/
Y.FieldDef = Y.Base.create(
// A rough idea for a RecordSetIndex plugin
// Filtering, searching, sorting on the host RecordSet could use the index if
// it's available (possibly creating it the first time someone does a sort or whatever)
// So RecordSet.filter() should be something like:
/*
filter: function(k,v) {
if (this.hasIndex(k)) {
return this.getIndex(k).find(v);
} else {
// proceed as normal!
@mattparker
mattparker / 1. ArrayList with events.js
Created September 30, 2010 12:47
YUI3: A simple example adding events to Base extensions augmented by ArrayList
/**
* Y.ArrayListEvents fires some events for ArrayList.
* 8/10/10: update - Added events for everything, pretty much,
* and added nicer signatures for subscribers
* Also changed the name slightly (from Y.ArrayListEventProvider)
*/
Y.ArrayListEvents = Y.Base.create(
'arraylistevents',
Y.Plugin.Base,
@mattparker
mattparker / RelatedModelList.js
Created October 20, 2011 13:05
RelatedModelList - an idea to join Models to other ModelLists
YUI.add('RelatedModelList', function (Y) {
/**
* Intended as augmentation of Model to enable easy loading
* of related ModelList instances. For example, an author Model
* may have a BookList ModelList.
*
* The ModelList that is instantiated will need to know what
* to do to load, save etc the data: this is up to the implementer.
@mattparker
mattparker / Y.Array.set.js
Created August 30, 2012 12:43
YUI Y.Array set methods (intersect, diff, union)
YUI.add("arraySet", function (Y) {
"use strict";
var A = Y.Array,
L = Y.Lang,
iO = A.indexOf;
/**
@mattparker
mattparker / mediaViewScrollview.js
Created September 25, 2012 14:11
scrollview View wrapper
/**
*
*
*
*
* mediaViewScrollview
*
*
*
*
@mattparker
mattparker / arrayset.test.js
Created October 8, 2012 09:23
Test cases for Y.Array set methods (https://gist.github.com/3527740)
YUI.add("arraySet-tests", function (Y) {
var ASSERT = Y.Assert,
ARRAYASSERT = Y.ArrayAssert;
var testSimpleIntersects = new Y.Test.Case({
name: "Test of simple arrays of numbers, strings",
testNumbers: function () {
@mattparker
mattparker / graphics-static-chooser.js
Created October 16, 2012 12:34
To assign the correct graphics implementation when all are loaded statically
// relates to YUI ticket http://yuilibrary.com/projects/yui3/ticket/2532864
//
//
YUI.add("graphics-static-chooser", function (Y) {
//
//
// Loading graphics (statically) using the configurator is tricky,
// because it feature detects on the browser you're using the configurator
@mattparker
mattparker / _getOffsetAndFinish.js
Created November 6, 2012 17:27
idea for kb refactor of Y.Color.Harmony
/**
Generates a series of colors from startColor at various offsets
@protected
@method _getOffsetAndFinish
@param {String} startColor Start color
@param {Array} arrOffsets Array of colors
@param {String} [to]
@returns {Array} Of offsetted and finished colors
**/
_getOffsetAndFinish: function (startColor, arrOffsets, to) {