How to use the gaffa.createSpec function in gaffa

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 / 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);
github gaffa-tape / gaffa / actions / toJson.js View on Github external
var Gaffa = require('gaffa'),
    actionType = "toJson";

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

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

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

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

    this.target.set(!this.target.value, this);
};
Toggle.prototype.target = new Gaffa.Property();

module.exports = Toggle;
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 / behaviours / navigate.js View on Github external
var Gaffa = require('gaffa'),
    behaviourType = 'navigate';

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

    var behaviour = this;

    this.gaffa.notifications.add('navigation', function(){
    	behaviour.gaffa.actions.trigger(behaviour.actions.navigate, behaviour);
    });
};

module.exports = Navigate;
github gaffa-tape / gaffa / views / container.js View on Github external
var Gaffa = require('gaffa');

function Container(){}
Container = Gaffa.createSpec(Container, Gaffa.ContainerView);
Container.prototype.type = 'container';

Container.prototype.render = function(){
    this.views.content.element =
    this.renderedElement =
    document.createElement(this.tagName || 'div');
};

module.exports = Container;

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