Created
June 15, 2012 01:19
-
-
Save brianium/2934077 to your computer and use it in GitHub Desktop.
sample Wulib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports, undefined){ | |
var Wulib = {}, | |
activeDoc = app.activeDocument; | |
var ArtBoard = function(board) { | |
this.board = board; | |
}; | |
ArtBoard.prototype = { | |
addPadding:function(val) { | |
this.board.top += val + 'px'; | |
this.board.left += val + 'px'; | |
}, | |
getOffsets:function() { | |
return {left:this.board.left,top:this.board.top}; | |
} | |
}; | |
Wulib.ArtBoard = ArtBoard; | |
Wulib.ArtBoardService = { | |
fetchAll:function() { | |
var boards = []; | |
activeDoc.artboards.each(function(board){ | |
boards.push(new Wulib.ArtBoard(board)); | |
}) | |
return boards; | |
} | |
}; | |
exports.Wulib = Wulib; | |
})(this); //self invoking closure ensures protection from outside variables | |
//'this' usually refers to the global object in this context | |
//main application logic | |
var artboards = Wulib.ArtBoardService.fetchAll(); | |
//do stuff with artboards |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment