Skip to content

Instantly share code, notes, and snippets.

@rubenspgcavalcante
Created April 19, 2014 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenspgcavalcante/11071627 to your computer and use it in GitHub Desktop.
Save rubenspgcavalcante/11071627 to your computer and use it in GitHub Desktop.
The card view declaration
/**
* The card controller
* @extends {maria.Controller}
*/
SL.MVC.CardController = {};
maria.Controller.subclass(SL.MVC, "CardController", {
properties: {
onDrag: function(){
/*
* When the user drag the card, get the new position of the card
* and update model based on the (x, y) position on the screen
*/
}
}
});
/**
* The card view
* @extends {maria.ElementView}
*/
SL.MVC.CardView = {};
SL.MVC.CardTemplate = SL.Utils.Template.load("card"); //<div class='card'></div>
maria.ElementView.subclass(SL.MVC, "CardView", {
uiActions: {
'drag .card': 'onDrag'
},
properties: {
buildData: function() {
//Loads the template into a jQuery object instance
var $templ = $(this.find(""));
//Loads a card SVG and put into the template
var cardSvg = SL.App.cardFactory.getCardSVG(this.getModel());
$templ.html(cardSvg);
//Transforms the div into a draggable element
$templ.draggable();
},
update: function(){
this.buildData();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment