/a.js
Last active
October 28, 2015 17:57
Revisions
-
jriecken revised this gist
Oct 28, 2015 . No changes.There are no files selected for viewing
-
jriecken created this gist
Oct 28, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ var expectEditor = { toBeClosed: function() { expect($('.image-editor')).toBeHidden(); expect($('.drag-to-reposition')).toBeHidden(); expect($('.filter-options')).toBeHidden(); expect($('.tools')).toBeHidden(); expect($('.patterns')).toBeHidden(); expect($('.edit-img')).toBeVisible(); }, toBeOpen: function() { expect($('.image-editor')).toBeVisible(); expect($('.drag-to-reposition')).toBeVisible(); expect($('.filter-options')).toBeHidden(); expect($('.tools')).toBeVisible(); expect($('.patterns')).toBeHidden(); expect($('.edit-img')).toBeHidden(); } }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ var _controlEditMode = function(toClose) { if (toClose) { $imageElem.removeClass('hide'); $canvasElem.parent().addClass('hide'); $tools.addClass('hide'); $editBtn.removeClass('hide'); $dragToReposition.addClass('hide'); $(document).trigger('editor.closed') } else { $(imageElemSelector).addClass('hide'); $canvasElem.parent().removeClass('hide'); $tools.removeClass('hide'); $editBtn.addClass('hide'); if (fabricCanvas.getObjects().length) { $dragToReposition.removeClass('hide'); } $(document).trigger('editor.opened'); } $filterLayer.addClass('hide'); }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ beforeEach(function() { myEditor = imageEditor.init({ canvas: 'canvas', imageElemSelector: '.myImg', }); expect(myEditor).toBeTruthy(); }); describe('Testing open/close', function() { it('should be able to open by clicking on edit', function() { $('.edit-img').click(); expectEditor.toBeOpen(); }); /* some other tests */ } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ var initImageEditor = function(options) { fabricCanvas = new fabric.Canvas(canvasID, canvasOptions); var imageUrl = 'some/default/image.png'; fabric.Image.fromURL(imageUrl, function(img) { fabricCanvas.add(img); }, imgOptions); return 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ beforeEach(function(done) { imageEditor.init({ canvas: 'canvas', imageElemSelector: '.myImg', success: function() { myEditor = imageEditor.getEditor(); expect(myEditor).toBeTruthy(); done(); } }); }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ var initImageEditor = function(options) { fabricCanvas = new fabric.Canvas(canvasID, canvasOptions); var imageUrl = 'some/default/image.png'; fabric.Image.fromURL(imageUrl, function(img) { fabricCanvas.add(img); if (options.success) options.success(); }, imgOptions); };