From e259c2aac235342a7cc0fa576317308db2d03e52 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Fri, 27 Dec 2013 16:58:21 -0700 Subject: [PATCH] Updating uxGenie dependency. Adding features due to this upgrade to the demo. Forgot to add tests to last commit so including those now. --- demo-files/app.js | 93 ++++++++++++++++++++++------------- demo-files/images/mocha.png | Bin 0 -> 3955 bytes demo-files/style.css | 18 ++++++- demo-files/vendor/uxGenie.js | 79 ++++++++++++++++++++++++++--- index.html | 36 +++++++++----- test/tests.js | 61 ++++++++++++++++------- 6 files changed, 215 insertions(+), 72 deletions(-) create mode 100644 demo-files/images/mocha.png diff --git a/demo-files/app.js b/demo-files/app.js index 400f94f..2012941 100644 --- a/demo-files/app.js +++ b/demo-files/app.js @@ -7,6 +7,13 @@ app.constant('genie', genie); app.controller('GenieCtrl', function($scope, genie, ga) { + $scope.demoContext = 'genie-demo'; + $scope.iconPrefix = 'glyphicon glyphicon-'; + $scope.iconPrefix = { + b: 'glyphicon glyphicon-', + f: 'fa fa-' + } + genie.context($scope.demoContext); $scope.genieVisible = false; @@ -34,12 +41,16 @@ $scope.addWishFromInput = function() { if ($scope.wishMagicWords) { ga('send', 'event', 'button', 'click', 'Create Wish: ' + $scope.wishMagicWords); - addWish($scope.wishMagicWords); + addWish($scope.wishMagicWords, null, { + uxGenie: { + iIcon: 'glyphicon glyphicon-exclamation-sign' + } + }); $scope.wishMagicWords = ''; } }; - function addWish(magicWords, action) { + function addWish(magicWords, action, data) { if (typeof magicWords === 'string') { magicWords = magicWords.split(','); } @@ -47,69 +58,85 @@ magicWords: magicWords, action: action || function(wish) { alert('Your "' + wish.magicWords[0] + '" wish is my command!'); - } + }, + context: $scope.demoContext, + data: data }); } - function addStyleWish(style, altStyle, property) { + function addStyleWish(style, altStyle, property, iIcon, altiIcon) { var originalWish, altWish; + function swapWishes(wish) { + genie.removeContext(wish.context.all); + genie.addContext(wish.data.otherWish.context.all); + } function applyStyleAndSwapWishes(wish) { $scope.genieStyle[property] = wish.data.style.toLowerCase(); - genie.deregisterWish(wish); - genie(wish.data.otherWish); + swapWishes(wish); } originalWish = genie({ - magicWords: 'Style the lamp: ' + style, + magicWords: 'Make lamp ' + style, + context: { + all: ['genie-style-' + property + '-' + style, $scope.demoContext] + }, action: applyStyleAndSwapWishes, data: { - style: style + style: style, + uxGenie: { + iIcon: 'glyphicon glyphicon-' + iIcon + } } }); altWish = genie({ - magicWords: 'Style the lamp: ' + altStyle, + magicWords: 'Make lamp ' + altStyle, + context: { + all: ['genie-style-' + property + '-' + altStyle, $scope.demoContext] + }, action: applyStyleAndSwapWishes, data: { style: altStyle, - otherWish: originalWish + otherWish: originalWish, + uxGenie: { + iIcon: 'glyphicon glyphicon-' + altiIcon + } } }); originalWish.data.otherWish = altWish; - genie.deregisterWish(altWish); - } - - function addDestinationWish(magicWord, destination) { - addWish('Navigate: ' + magicWord, { - destination: destination, - openNewTab: true + $scope.$watch('genieStyle["' + property + '"]', function(newVal) { + if (newVal === style.toLowerCase()) { + swapWishes(originalWish); + } else { + swapWishes(altWish); + } }); } - - addDestinationWish('Genie on GitHub', 'http://www.github.com/kentcdodds/genie'); - addDestinationWish('UX-Genie on GitHub', 'http://www.github.com/kentcdodds/ux-genie'); - addDestinationWish('Genie Tests', './test'); - addStyleWish('Dark', 'Light', 'color'); - addStyleWish('Small', 'Large', 'size'); - addStyleWish('Slow', 'Fast', 'animationSpeed'); + addStyleWish('Dark', 'Light', 'color', 'picture', 'picture'); + addStyleWish('Small', 'Large', 'size', 'resize-small', 'resize-full'); + addStyleWish('Slow', 'Fast', 'animationSpeed', 'fast-backward', 'fast-forward'); var genieTagline = encodeURIComponent('Genie: Better than keyboard shortcuts'); var genieHome = encodeURIComponent('http://kent.doddsfamily.us/genie'); - function addNavigateWishWithoutPrefix(magicWord, shareUrl) { + function addNavigateWishWithoutPrefix(magicWord, shareUrl, iIcon) { addWish(magicWord, { destination: shareUrl, openNewTab: true + }, { + uxGenie: { + iIcon: iIcon + } }); } - addNavigateWishWithoutPrefix('Tweet #GenieJS', 'https://twitter.com/intent/tweet?hashtags=GenieJS&original_referer=' + genieHome + '&text=' + genieTagline + '&tw_p=tweetbutton&url=' + genieHome + '&via=kentcdodds'); - addNavigateWishWithoutPrefix('Share #GenieJS on Google+', 'http://plus.google.com/share?&url=' + genieHome); - addNavigateWishWithoutPrefix('Email about GenieJS', 'mailto:?&subject=' + encodeURIComponent('Cool JavaScript Library: Genie') + '&body=' + genieTagline + encodeURIComponent('\nCheck it out here: ') + genieHome); - - addNavigateWishWithoutPrefix('Code with @kentcdodds', 'http://www.github.com/kentcdodds'); - addNavigateWishWithoutPrefix('Follow @kentcdodds', 'https://twitter.com/intent/follow?original_referer=' + genieHome + '®ion=follow_link&screen_name=kentcdodds&tw_p=followbutton&variant=2.0'); - addNavigateWishWithoutPrefix('Circle +KentCDodds', 'http://plus.google.com/+KentCDodds'); - addNavigateWishWithoutPrefix('Visit Kent\'s website', 'http://kent.doddsfamily.us'); + addNavigateWishWithoutPrefix('Tweet #GenieJS', 'https://twitter.com/intent/tweet?hashtags=GenieJS&original_referer=' + genieHome + '&text=' + genieTagline + '&tw_p=tweetbutton&url=' + genieHome + '&via=kentcdodds', $scope.iconPrefix.f + 'share'); + addNavigateWishWithoutPrefix('Share #GenieJS on Google+', 'http://plus.google.com/share?&url=' + genieHome, $scope.iconPrefix.f + 'share'); + addNavigateWishWithoutPrefix('Email about GenieJS', 'mailto:?&subject=' + encodeURIComponent('Cool JavaScript Library: Genie') + '&body=' + genieTagline + encodeURIComponent('\nCheck it out here: ') + genieHome, $scope.iconPrefix.f + 'envelope'); + + addNavigateWishWithoutPrefix('Code with @kentcdodds', 'http://www.github.com/kentcdodds', $scope.iconPrefix.f + 'github'); + addNavigateWishWithoutPrefix('Follow @kentcdodds', 'https://twitter.com/intent/follow?original_referer=' + genieHome + '®ion=follow_link&screen_name=kentcdodds&tw_p=followbutton&variant=2.0', $scope.iconPrefix.f + 'twitter'); + addNavigateWishWithoutPrefix('Circle +KentCDodds', 'http://plus.google.com/+KentCDodds', $scope.iconPrefix.f + 'google-plus'); + addNavigateWishWithoutPrefix('Visit Kent\'s website', 'http://kent.doddsfamily.us', $scope.iconPrefix.f + 'globe'); }); diff --git a/demo-files/images/mocha.png b/demo-files/images/mocha.png new file mode 100644 index 0000000000000000000000000000000000000000..1ea76151083d5dfe21ce4e89cbebbde3efa15bf5 GIT binary patch literal 3955 zcmV-(4~+1MP)5000U>X+uL$Nkc;* zP;zf(X>4Tx07wm;mUmQB*%pV-y*Itk5+Wca^cs2zAksTX6$DXM^`x7XQc?|s+0 z08spb1j2M!0f022SQPH-!CVp(%f$Br7!UytSOLJ{W@ZFO_(THK{JlMynW#v{v-a*T zfMmPdEWc1DbJqWVks>!kBnAKqMb$PuekK>?0+ds;#ThdH1j_W4DKdsJG8Ul;qO2n0 z#IJ1jr{*iW$(WZWsE0n`c;fQ!l&-AnmjxZO1uWyz`0VP>&nP`#itsL#`S=Q!g`M=rU9)45( zJ;-|dRq-b5&z?byo>|{)?5r=n76A4nTALlSzLiw~v~31J<>9PP?;rs31pu_(obw)r zY+jPY;tVGXi|p)da{-@gE-UCa`=5eu%D;v=_nFJ?`&K)q7e9d`Nfk3?MdhZarb|T3 z%nS~f&t(1g5dY)AIcd$w!z`Siz!&j_=v7hZlnI21XuE|xfmo0(WD10T)!}~_HYW!e zew}L+XmwuzeT6wtxJd`dZ#@7*BLgIEKY9Xv>st^p3dp{^Xswa2bB{85{^$B13tWnB z;Y>jyQ|9&zk7RNsqAVGs--K+z0uqo1bf5|}fi5rtEMN^BfHQCd-XH*kfJhJnmIE$G z0%<@5vOzxB0181d*a3EfYH$G5fqKvcPJ%XY23!PJzzuK<41h;K3WmW;Fah3yX$XSw z5EY_9s*o0>51B&N5F1(uc|$=^I1~fLLy3?Ol0f;;Ca4%HgQ}rJP(Ab`bQ-z{U4#0d z2hboi2K@njgb|nm(_szR0JebHusa+GN5aeCM0gdP2N%HG;Yzp`J`T6S7vUT504#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S8eNF-u?eSMC^OchnKU}HxVUI-ZEe=j&|n)I8#X>ZZgq8aPTmQo8tGl9 z@{Bs+8rBMlky%|`wYj-DTV7ta`T2QkZEdyf?QI(!9d&in)YN2ygM&6PF=1zCXErr8 zW$Wwf*4Wr+r>Cd3ySr<2j+B?@`Rm5M1~I$&73a+*6O0~SwFoV}4244ONzbT=X_%Rr zv7@6S=k@IDtcw~`+uYo2j1C=PVYBdAZ za(wS;LP+nb{tOu-{d9`mX=;SvSAYr$-4ro0%rQ>@iRof3k;nUnsk^wi zaD`k|RpmvKYjtXPN8#wZG~IL0C?nrfj$iroOgG`3UZ&UNVorMbtHaT2v{dxJzMFK; zzDwEUj7fK&?+ZZ0=YCuhP;6u>LaOkQzNtr(?{sXfLs_PL%2VGpOK_D zHS)Ep9~$J3kc#cGHAH#cwA@#QNT1Jyn_Vqn2vtLh(nF2ndPReK@OPPhxJeIK|4shT zjbN#cJvZdtKractim6cGSaZ5rDZ~1B0f@3TL;@^ooig4-UjwfJZk{dpt79CXJc)&> z!{QkJM#}uW+kJXLZ$*5Ubpd=n1DH-ml2P&hbM+I(zXPJ%`-ty7{{d?udZa39!Fd1x N002ovPDHLkV1fWes0RQ5 literal 0 HcmV?d00001 diff --git a/demo-files/style.css b/demo-files/style.css index 1a85214..b2e7c61 100644 --- a/demo-files/style.css +++ b/demo-files/style.css @@ -91,6 +91,10 @@ h3 { .genie-wish { } +.genie-wish > img, .genie-wish > i { + vertical-align: text-top; +} + .genie-wish.focused { -mos-border-radius: 8px; border-radius: 8px; @@ -149,6 +153,11 @@ h3 { line-height: 50px; } +#uxLampContainer.large .genie-wish > img, #uxLampContainer.large .genie-wish > i { + height: 35px; + margin-right: 10px; +} + /* ng-genie small styles */ #uxLampContainer.small .genie-container { width: 300px; @@ -165,10 +174,15 @@ h3 { #uxLampContainer.small .genie-wishes { max-height: 216px; - font-size: 24px; + font-size: 18px; } #uxLampContainer.small .genie-wish { padding: 0px 12px 0px 12px; line-height: 36px; -} \ No newline at end of file +} + +#uxLampContainer.small .genie-wish > img, #uxLampContainer.small .genie-wish > i { + height: 20px; + margin-right: 5px; +} diff --git a/demo-files/vendor/uxGenie.js b/demo-files/vendor/uxGenie.js index 850e3dc..c3e4b81 100644 --- a/demo-files/vendor/uxGenie.js +++ b/demo-files/vendor/uxGenie.js @@ -28,12 +28,14 @@ return ['
', '', '
', - '
', - '{{wish.data.displayText || wish.magicWords[0]}}', + '
', + '', + '', + '{{wish.data.uxGenie.displayText || wish.magicWords[0]}}', '
'].join(''); }, scope: { @@ -175,7 +177,6 @@ scope.wishCallback(genie.makeWish(wish, scope.genieInput)); saveToLocalStorage(wish); scope.$apply(function() { - updateMatchingWishes(scope.genieInput); scope.lampVisible = false; }); } @@ -207,6 +208,7 @@ if (scope.rubClass) { scope.$watch('lampVisible', function(newVal) { if (newVal) { + updateMatchingWishes(scope.genieInput); el.addClass(scope.rubClass); // Needs to be lampVisible before it can be selected $timeout(function() { @@ -239,4 +241,65 @@ } } }]); -})); + + uxGenie.directive('genieWish', ['genie', function(genie) { + return { + scope: { + wishData: '=?', + wishAction: '&?' + }, + link: function(scope, el, attrs) { + var id = attrs.wishId; + var context = attrs.wishContext ? attrs.wishContext.split(',') : null; + var data = scope.wishData || {}; + var uxGenieData = data.uxGenie = data.uxGenie || {}; + + uxGenieData.element = el[0]; + uxGenieData.event = attrs.wishEvent || uxGenieData.event || 'click'; + uxGenieData.iIcon = attrs.wishIIcon; + uxGenieData.imgIcon = attrs.wishImgIcon; + + var action = function(wish) { + var modifiers = []; + if (attrs.eventModifiers) { + modifiers = attrs.eventModifiers.split(','); + } + var event = new MouseEvent(wish.data.uxGenie.event, { + view: window, + bubbles: true, + cancelable: true, + ctrlKey: modifiers.indexOf('ctrlKey') > -1, + altKey: modifiers.indexOf('altKey') > -1, + shiftKey: modifiers.indexOf('shiftKey') > -1, + metaKey: modifiers.indexOf('metaKey') > -1 + }); + wish.data.uxGenie.element.dispatchEvent(event); + + if (attrs.wishAction) { + scope.wishAction({wish: wish}); + } + }; + + // get magic words + var magicWords = null; + ['genieWish', 'name', 'id'].every(function(attrName) { + magicWords = attrs[attrName]; + return !magicWords; + }); + if (magicWords) { + magicWords = magicWords.split(','); + } else { + throw new Error('Thrown by the genie-wish directive: All genie-wish elements must have a magic-words, id, or name attribute.'); + } + + genie({ + id: id, + magicWords: magicWords, + context: context, + action: action, + data: data + }); + } + } + }]); +})); \ No newline at end of file diff --git a/index.html b/index.html index f067bce..02556b7 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@ + @@ -18,24 +19,28 @@

GenieJS

Press Ctrl+Space (or click - - here) - - to rub the lamp

+ here) to rub the lamp

Then type an apostrophe ( ' ) to see all the wishes

Wishes made: {{wishesMade}}

- GenieJS was built to simulate the behavior in apps like Alfred.
+ GenieJS was built to simulate the behavior in apps like + Alfred.
+ Essentially, you register actions with keywords and then you can find those actions via a keyword search.
- For info on the vernacular of wishes and magic words, - see the project on GitHub.
- I'm in the process of moving tests to Mocha. Go here to run the Mocha tests, - click here to run the old tests... + + For info on the vernacular of wishes and magic words, + see the project on GitHub.
+ + There's also an AngularJS + module with a few useful directives called uxGenie on GitHub.
+ + I'm in the process of moving tests to Mocha. Go here to run the Mocha tests, + click here to run the old tests...

Note: If you're on a mobile device, you will not be able to use this demo. Instead you can watch this - demo video. Please also visit the - GitHub project. + demo video. Please also visit the + GitHub project.

@@ -47,7 +52,14 @@

Wishes made: {{wishesMade}}

  1. Press Ctrl+Space to open the Genie Search Box
  2. -
  3. Optionally type an apostrophe (') to show all wishes (about this feature)
  4. +
  5. Optionally type an apostrophe (') to show all wishes + (about this feature) +
  6. Type anything to filter the wishes
  7. Mouse over or arrow down to the wish you wish and click/press return
  8. Notice how genie organizes the wishes as you make them
  9. diff --git a/test/tests.js b/test/tests.js index d358f64..ad40f58 100644 --- a/test/tests.js +++ b/test/tests.js @@ -164,7 +164,7 @@ describe('genie', function(){ expect(allWishes).to.have.length(allWishCount - 1); }); - it('should remove only wishes in a given context when deregisterWishesWithContex is called', function() { + it('should remove only wishes in a given context (excluding the default context) when deregisterWishesWithContex is called', function() { var allWishes = genie.getMatchingWishes(); expect(allWishes).to.have.length(allWishCount); genie.deregisterWishesWithContext('context1'); @@ -182,65 +182,86 @@ describe('genie', function(){ describe('#context #addContext #removeContext', function() { var defaultContextWish; - var allWishCount = 5; beforeEach(function(done) { defaultContextWish = genie(fillInWish()); - newContextWish1 = genie(fillInWish({ + var newContextWish1 = genie(fillInWish({ context: 'context1' })); - newContextWish2 = genie(fillInWish({ + var newContextWish2 = genie(fillInWish({ context: 'context2' })); - newContextWish3 = genie(fillInWish({ - context: ['context3'], + var newContextWish3 = genie(fillInWish({ + context: ['context3'] + })); + var multiContextWish = genie(fillInWish({ + context: ['context1', 'context2', 'context3'] + })); + var complexContextAll = genie(fillInWish({ + context: { + all: ['context1', 'context2', 'context3'] + } })); - multiContextWish = genie(fillInWish({ - context: ['context1', 'context2', 'context3'], + var complexContextAny = genie(fillInWish({ + context: { + any: ['context1', 'context3', 'context5'] + } + })); + var complexContextNone = genie(fillInWish({ + context: { + none: ['context1', 'context2'] + } + })); + var veryComplexContext = genie(fillInWish({ + context: { + all: ['context1', 'context3'], + any: ['context4', 'context5'], + none: ['context2'] + } })); done(); }); it('should have all wishes when genie.context is default', function() { var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(allWishCount); + expect(allWishes).to.have.length(9); }); it('should have only wishes with default context when genie.context is not default', function() { genie.context('different-context'); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(1); + expect(allWishes).to.have.length(2); expect(allWishes[0]).to.equal(defaultContextWish); }); it('should have only in context wishes (including default context wishes) when genie.context is not default', function() { genie.context('context1'); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(3); + expect(allWishes).to.have.length(4); }); it('should be able to have multiple contexts', function() { genie.context(['context1', 'context2']); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(4); + expect(allWishes).to.have.length(5); }); it('should be able to add a string context', function() { genie.context('context1'); genie.addContext('context2'); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(4); + expect(allWishes).to.have.length(5); }); it('should be able to add an array of contexts', function() { genie.context('context1'); genie.addContext(['context2', 'context3']); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(allWishCount); + expect(allWishes).to.have.length(7); }); it('should be able to remove string context', function() { genie.context(['context1', 'context2']); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(4); + expect(allWishes).to.have.length(5); genie.removeContext('context1'); var allWishes = genie.getMatchingWishes(); @@ -250,11 +271,17 @@ describe('genie', function(){ it('should be able to remove an array of contexts', function() { genie.context(['context1', 'context2', 'context3']); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(allWishCount); + expect(allWishes).to.have.length(7); genie.removeContext(['context1', 'context2']); var allWishes = genie.getMatchingWishes(); - expect(allWishes).to.have.length(3); + expect(allWishes).to.have.length(5); }); + + it('should be able to manage complex contexts', function() { + genie.context(['context1', 'context3', 'context5']); + var allWishes = genie.getMatchingWishes(); + expect(allWishes).to.have.length(6); + }) }); }); \ No newline at end of file