How to use gaffa - 10 common examples

To help you get started, we’ve selected a few gaffa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaffa-tape / gaffa / views / textbox.js View on Github external
var renderedElement = crel('input'),
        updateEventNames = (this.updateEventName || "change").split(' ');

    this._removeHandlers.push(this.gaffa.events.on(this.updateEventName || "change", renderedElement, setValue));

    this.renderedElement = renderedElement;

};

Textbox.prototype.value = new Gaffa.Property(updateValue);

Textbox.prototype.subType = new Gaffa.Property(updateSubType);

Textbox.prototype.placeholder = new Gaffa.Property(updatePlaceholder);

Textbox.prototype.disabled = new Gaffa.Property(updateDisabled);

Textbox.prototype.required = new Gaffa.Property(updateRequired);

module.exports = Textbox;
github gaffa-tape / gaffa / views / textbox.js View on Github external
Textbox.prototype.render = function(){
    var renderedElement = crel('input'),
        updateEventNames = (this.updateEventName || "change").split(' ');

    this._removeHandlers.push(this.gaffa.events.on(this.updateEventName || "change", renderedElement, setValue));

    this.renderedElement = renderedElement;

};

Textbox.prototype.value = new Gaffa.Property(updateValue);

Textbox.prototype.subType = new Gaffa.Property(updateSubType);

Textbox.prototype.placeholder = new Gaffa.Property(updatePlaceholder);

Textbox.prototype.disabled = new Gaffa.Property(updateDisabled);

Textbox.prototype.required = new Gaffa.Property(updateRequired);

module.exports = Textbox;
github gaffa-tape / gaffa / actions / switch.js View on Github external
var Gaffa = require('gaffa'),
    actionType = "switch";

function Switch(){}
Switch = Gaffa.createSpec(Switch, Gaffa.Action);
Switch.prototype.type = actionType;
Switch.prototype['switch'] = new Gaffa.Property();

Switch.prototype.trigger = function(parent, scope, event) {

    if(this['switch'].value != null){
        this.triggerActions(this['switch'].value, scope, event);
    }
};

module.exports = Switch;
github gaffa-tape / gaffa / views / textbox.js View on Github external
this._removeHandlers.push(this.gaffa.events.on(this.updateEventName || "change", renderedElement, setValue));

    this.renderedElement = renderedElement;

};

Textbox.prototype.value = new Gaffa.Property(updateValue);

Textbox.prototype.subType = new Gaffa.Property(updateSubType);

Textbox.prototype.placeholder = new Gaffa.Property(updatePlaceholder);

Textbox.prototype.disabled = new Gaffa.Property(updateDisabled);

Textbox.prototype.required = new Gaffa.Property(updateRequired);

module.exports = Textbox;
github gaffa-tape / gaffa / views / radio.js View on Github external
option.setAttribute('type', 'radio');
                option.setAttribute('name', groupName);

                option.setAttribute('value', currentValue);
                option.setAttribute('id', groupName + currentValue);
                label.innerHTML = gaffa.utils.getProp(value, i + gaffa.pathSeparator + property.textPath);
                label.setAttribute('for', groupName + currentValue);

                element.append($(container).append(option, label));
            }
        }
    }
}

Radio.prototype.groupName = new Gaffa.Property(updateOptions);

Radio.prototype.options = new Gaffa.Property(updateOptions);

Radio.prototype.value = new Gaffa.Property(function (viewModel, value) {
    var options = $(this.renderedElement).find('input');

    options.each(function(){
        var option = $(this);
        if(value === option.attr('value')){
            option.attr("checked", "checked");
        }
    });
});

module.exports = Radio;
github gaffa-tape / gaffa / behaviours / pageLoad.js View on Github external
var Gaffa = require('gaffa'),
    behaviourType = 'pageLoad';

function PageLoadBehaviour(){}
PageLoadBehaviour = Gaffa.createSpec(PageLoadBehaviour, Gaffa.Behaviour);
PageLoadBehaviour.prototype.type = behaviourType;
PageLoadBehaviour.prototype.bind = function(){

    this.gaffa.actions.trigger(this.actions.load, this);
};

module.exports = PageLoadBehaviour;
github gaffa-tape / gaffa / actions / fromJson.js View on Github external
var Gaffa = require('gaffa'),
    actionType = "fromJson";

function FromJson(){}
FromJson = Gaffa.createSpec(FromJson, Gaffa.Action);
FromJson.prototype.type = actionType;
FromJson.prototype.trigger = function(){

    this.target.set(JSON.parse(this.source.value), this);
};
FromJson.prototype.target = new Gaffa.Property();
FromJson.prototype.source = new Gaffa.Property();



module.exports = FromJson;
github gaffa-tape / gaffa / actions / forEach.js View on Github external
psudoParent.parent = this;
        psudoParent.sourcePath = keys ? keys[i] : '' + i;

        var actions = JSON.parse(JSON.stringify(this.actions['forEach']));

        psudoParent.actions.all = actions;
        psudoParent = this.gaffa.initialiseViewItem(psudoParent, psudoParent.gaffa, psudoParent.actions.constructors);

        scope.item = items[i];

        psudoParent.triggerActions('all', scope, event);
    }
};

function EachPsudoParent(){}
EachPsudoParent = Gaffa.createSpec(EachPsudoParent, Gaffa.Action);
EachPsudoParent.prototype.type = 'eachPsudoParent';

module.exports =  ForEach;
github gaffa-tape / gaffa / views / switchContainer.js View on Github external
var Gaffa = require('gaffa'),
    crel = require('crel'),
    viewType = "switchContainer",
	cachedElement;

function SwitchContainer(){}
SwitchContainer = Gaffa.createSpec(SwitchContainer, Gaffa.ContainerView);
SwitchContainer.prototype.type = viewType;

SwitchContainer.prototype.render = function(){

    var renderedElement = crel(this.tagName || 'div');

    this.views.content.element = renderedElement;
    this.renderedElement = renderedElement;

};

function createNewView(property, template, templateKey){
    if(!property.templateCache){
        property.templateCache= {};
    }
    var view = JSON.parse(
github gaffa-tape / gaffa / behaviours / modelChange.js View on Github external
var Gaffa = require('gaffa'),
    behaviourType = 'modelChange';

    
function executeBehaviour(behaviour, value){
    behaviour.gaffa.actions.trigger(behaviour.actions.change, behaviour);
}

function ModelChangeBehaviour(){}
ModelChangeBehaviour = Gaffa.createSpec(ModelChangeBehaviour, Gaffa.Behaviour);
ModelChangeBehaviour.prototype.type = behaviourType;
ModelChangeBehaviour.prototype.condition = new Gaffa.Property({value: true});
ModelChangeBehaviour.prototype.watch = new Gaffa.Property({
    update: function(behaviour, value){
        var gaffa = behaviour.gaffa;

        if(!behaviour.condition.value){
            return;
        }

        var throttleTime = behaviour.throttle;
        if(!isNaN(throttleTime)){
            var now = new Date();
            if(!behaviour.lastTrigger || now - behaviour.lastTrigger > throttleTime){
                behaviour.lastTrigger = now;
                executeBehaviour(behaviour, value);

gaffa

A powerful, fast, and relatively small application framework.

Unrecognized
Latest version published 8 years ago

Package Health Score

36 / 100
Full package analysis

Popular gaffa functions

Similar packages