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
| window.BaseListView = window.BaseView.extend({ | |
| close: function() { | |
| this._closeAllSubViews(); | |
| window.BaseView.prototype.close.call(this); | |
| }, | |
| initialize: function(options) { | |
| this._subViews = []; | |
| this.collection.on("add", this._renderSubView, this); | |
| this.collection.on("reset", this._renderSubViews, this); | |
| this.collection.on("remove", this._closeSubView, this); |
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
| app.get('/proxied_image/:image_url', function(request_from_client, response_to_client){ | |
| sys.puts("Starting proxy"); | |
| var image_url = request_from_client.params.image_url; | |
| var image_host_name = url.parse(image_url).hostname | |
| var filename = url.parse(image_url).pathname.split("/").pop() | |
| var http_client = http.createClient(80, image_host_name); | |
| var image_get_request = http_client.request('GET', image_url, {"host": image_host_name}); | |
| image_get_request.addListener('response', function(proxy_response){ |
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
| def assertUserValidationException(fx): | |
| def decorator(fx): | |
| try: | |
| fx() | |
| except barrister.RpcException as e: | |
| assert e.code == 1002 | |
| else: | |
| assert False, "Should have thrown an RpcException with status code 1002" | |
| return decorator |
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
| 165 def testUnableToRemoveOwnerProjectAccess(self): | |
| 166 try: | |
| 167 raise barrister.RpcException(40, "dingle") | |
| 168 except barrister.RpcException as e: | |
| 169 assert e.code == 40 | |
| // |
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
| // CollectionView + ItemView example | |
| var MySubView = Marionette.ItemView.extend({ | |
| "triggers": { | |
| "click .save": "widget:saved" | |
| } | |
| }); | |
| var MyCollectionView = Marionette.CollectionView.extend({ | |
| "initialize": function(options) { |
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
| var all_items = [{ | |
| "name": "cat", | |
| "id": 1 | |
| }, { | |
| "name": "dog", | |
| "id": 2 | |
| }, { | |
| "name": "spoon", | |
| "id": 3 | |
| }, { |
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
| RestResponse r; | |
| if (d == null) { | |
| r = new RestResponse(something_something); | |
| } | |
| if (!r) { | |
| r = new RestResponse(something_else); | |
| } |
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
| /////// | |
| // u.js | |
| function isEmail (email) { | |
| var regEx = /^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; | |
| return regEx.test(email); | |
| } | |
| /////////// | |
| // test.js |
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
| test("Handler is invoked as callback from jQuery delegate method directly...", function() { | |
| var Controller, | |
| View, | |
| $el, | |
| c, | |
| v, | |
| mock; | |
| Controller = function() { | |
| var self = {}; |
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
| module("Event delegation test"); | |
| test("Keyup in view should trigger callback in controller", function() { | |
| var Controller, | |
| View, | |
| $el, | |
| c, | |
| v, | |
| mock; |