From 24ce6216cf83a90dd7ba7b8761932aead49bd9e7 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Fri, 9 Mar 2012 13:51:58 -0800 Subject: Squashed commit of the following: commit b4eb2f6cc1208fe5c18aa1f02a85adda25075d81 Merge: dac3dcd 3a9c7a5 Author: Valerio Virgillito Date: Fri Mar 9 10:46:29 2012 -0800 Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal commit 3a9c7a57a227a36ec47c6635fc6a0bd4c4b7f9c3 Merge: 5940b22 caa0825 Author: Valerio Virgillito Date: Thu Mar 8 15:51:58 2012 -0800 Merge pull request #102 from dhg637/Panels Fixed Some Calculation issues and bugs & appended disabled state when no documents exist commit dac3dcdc74e60a1948a6d8d994fa7ef38a446b7c Merge: 22a66cb 5940b22 Author: Valerio Virgillito Date: Thu Mar 8 13:57:28 2012 -0800 Merge branch 'refs/heads/master' into montage-integration commit 22a66cb6e243a3f1c867b62e3942fd2e828019d9 Author: Valerio Virgillito Date: Thu Mar 8 13:56:09 2012 -0800 integrating v0.7 montage into ninja Signed-off-by: Valerio Virgillito commit 5940b22e01de4fc36e5c5de5f3ed074f08fadb07 Merge: 9b006ac 130cd6d Author: Valerio Virgillito Date: Thu Mar 8 13:39:11 2012 -0800 Merge pull request #104 from ananyasen/integration-candidate IKNINJA-1270: fixed browser crashing when you close a document while playing a video commit 130cd6d4b99c9db344ec0ab44a54a59d11b31d2f Author: Ananya Sen Date: Thu Mar 8 13:29:58 2012 -0800 IKNINJA-1270: fixed browser crashing when you close a document while playing a video Signed-off-by: Ananya Sen commit caa08250663007bea76faf555f166b42cf4c76fb Author: Armen Kesablyan Date: Thu Mar 8 12:09:13 2012 -0800 Disabled State is now darker Signed-off-by: Armen Kesablyan commit 21cb7af351e738f446458af5b896c84e03fa5c17 Author: Armen Kesablyan Date: Thu Mar 8 12:05:43 2012 -0800 Z-Index issue of disabled state with file open dialog Signed-off-by: Armen Kesablyan commit 9b006acf1f6c2be5abc54f94a8bee7e684f106f9 Merge: 0637a6d 1c61c69 Author: Valerio Virgillito Date: Thu Mar 8 11:04:02 2012 -0800 Merge pull request #100 from imix23ways/TimelineUber Timeline uber commit 0637a6d9cc9fbe074145ad6beaa4725f5e7eb212 Merge: cef0708 d981394 Author: Valerio Virgillito Date: Wed Mar 7 19:32:38 2012 -0800 Merge pull request #103 from joseeight/FileIO-Build-Candidate File I/O Fixed commit d9813946dc28d8c28033a68b68300b9d9eda115c Author: Jose Antonio Marquez Date: Wed Mar 7 19:22:05 2012 -0800 Image data fix on Open Fixed a bug with data-uris not opening correctly. commit 8b0988b6dd2fe7f5977f70f651f7155c78ee872b Author: Jose Antonio Marquez Date: Wed Mar 7 19:04:19 2012 -0800 Adding To-do comments for CDN stylesheets Removed inserting CDN styles into head as it was proper because the hierarchy would be lost, and there is no current fast-alternative to achieve a preview. commit bb83bfb7af1e82dfbce7661fe2eb7612ff730c6f Author: Jose Antonio Marquez Date: Wed Mar 7 18:36:31 2012 -0800 Removing temp viewing of CDN styles It's not done correctly, we really need the proxy for this. commit 84931583f1da8da29784074978f146b281b8efa3 Author: Armen Kesablyan Date: Wed Mar 7 16:08:36 2012 -0800 Disabled state for panels Signed-off-by: Armen Kesablyan commit d18d91946627c53c646a6f167855551a1891f8f4 Author: Armen Kesablyan Date: Wed Mar 7 14:33:09 2012 -0800 Reordering and resizing now works Signed-off-by: Armen Kesablyan commit e3a5626b21ac8b906638bed9eb96aca5fadd26d8 Author: Armen Kesablyan Date: Wed Mar 7 11:41:10 2012 -0800 Fixed: Collapsed panels would collapse panels below Signed-off-by: Armen Kesablyan commit c7b07a9663ac1553fb10d8541b25274e522e07f7 Author: Armen Kesablyan Date: Wed Mar 7 10:39:23 2012 -0800 Fixed Collapsing and resizing window with panels Signed-off-by: Armen Kesablyan commit cef07085443b7c31e878daaad083b7408c57e104 Merge: 2e3943a fca9290 Author: Valerio Virgillito Date: Tue Mar 6 17:08:28 2012 -0800 Merge pull request #99 from joseeight/FileIO-Build-Candidate File IO Updates commit fca92904597895675ddd216399cd235f3c5a7cfa Merge: ec7cbc9 eebb7de Author: Jose Antonio Marquez Date: Tue Mar 6 17:02:44 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit eebb7de4d19cddec9c763a073d8cf41d76fe70f7 Author: Jose Antonio Marquez Date: Tue Mar 6 17:02:37 2012 -0800 Adding CDN support for URLs in linked CSS commit f6a60f50ca9cd09713baa27f2990eda9346496fc Merge: 7271c25 2e3943a Author: Jose Antonio Marquez Date: Tue Mar 6 16:19:59 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO Conflicts: js/controllers/selection-controller.js commit 7271c25bf34917b1751f433d284f21485057425b Author: Jose Antonio Marquez Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 3c4967fa93b3abc529fc404115707307ba72d5cd Merge: bee2df0 84332ab Author: Jose Antonio Marquez Date: Tue Mar 6 11:18:30 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO commit ec7cbc95de031d2be667c2a8629a9d63e91f7e1a Merge: 97176d4 bee2df0 Author: Jose Antonio Marquez Date: Tue Mar 6 11:05:04 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit bee2df0d4da72677aaa2adae669ffdd4ac210dd6 Author: Jose Antonio Marquez Date: Tue Mar 6 11:04:52 2012 -0800 Changing length of characters per line (pretty function) commit 97176d466bb0d217f1bc5f45e362ed15c3066507 Merge: de26ba9 887e555 Author: Jose Antonio Marquez Date: Mon Mar 5 23:35:08 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 887e555d00939a99fd13d0fc8fe081a4feb5d677 Author: Jose Antonio Marquez Date: Mon Mar 5 23:34:54 2012 -0800 CSS on CDN preview fix commit de26ba991c1d6351dfed4a81c246f62d40f075d6 Merge: 478c50e 4f274aa Author: Jose Antonio Marquez Date: Mon Mar 5 23:19:08 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 4f274aa5beff735f63905704e52e6ea938c140d9 Author: Jose Antonio Marquez Date: Mon Mar 5 23:18:49 2012 -0800 Temp support for CDN CSS Added a temp fix for allow the viewing of CSS on a CDN, however, the styles should not be editable, but will allow for accurate preview of styles. Need to coordinate with the CSS panel and styles manager to insert styles in the appropriate files or tags that have write permission. commit 478c50ee0ce0291c13c4f1e469a234b64946413e Merge: 869f5f1 a68fe3f Author: Jose Antonio Marquez Date: Mon Mar 5 22:24:20 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit a68fe3f0180f5ab3304ff201be8da40c4432bd40 Author: Jose Antonio Marquez Date: Mon Mar 5 22:23:59 2012 -0800 Minor Fix Forgot to comment out the return, therefore preventing to save. commit 869f5f1ca66b976ba07049b1180882cb8ccb9630 Merge: 0913cd5 4c4d49a Author: Jose Antonio Marquez Date: Mon Mar 5 20:07:10 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 4c4d49ae7958e2c87764f9319665189cf69c5c0a Author: Jose Antonio Marquez Date: Mon Mar 5 20:06:32 2012 -0800 Fixed URL parsing issue on actual opened document Still need to implement CSS loaded from a CDN, currently this would break Ninja. commit 0913cd53a13083119a6e6bfc2ee939e6becd40e0 Merge: 4505203 56efed8 Author: Jose Antonio Marquez Date: Mon Mar 5 16:16:34 2012 -0800 Merge branch 'refs/heads/FileIO' into FileIO-Build-Candidate commit 56efed8b1ed9974aade615fce2d96bc214d21540 Author: Jose Antonio Marquez Date: Mon Mar 5 15:55:30 2012 -0800 Resolved URL path issues in document and CSS Added logic to allow for files opened and assets linked in any order all under the cloud server root. commit 195624da6d0c5d15bcde8a8655355544687ef58a Author: Jose Antonio Marquez Date: Sun Mar 4 19:21:34 2012 -0800 Setting up document level URL parsing Set up logic to parse URLs document level (href, src, url) still need to add functionality to return proper value, currently only detecting current value. commit b2de52888a7c976cc9ae40518e3653cec0aac296 Author: Jose Antonio Marquez Date: Sun Mar 4 11:15:27 2012 -0800 Improved CSS URL cleaned Added logic to accommodate any URLs in a CSS file inside the opened document root. Need to add logic for handling linked references above the root. Also need to reformat into a reusable method as it might be needed besides CSS. commit 5c49635cc44815364f9a0296ffaa7acc34254937 Merge: 5c97959 13f52cf Author: Jose Antonio Marquez Date: Fri Mar 2 19:06:37 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO commit 45052033e018ecc0cba582f84c0431d3bd4020fe Merge: 940b9fc 13f52cf Author: Jose Antonio Marquez Date: Fri Mar 2 19:06:17 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO-Build-Candidate commit 940b9fc0bf71845bcae39de637e85697e5911eea Author: Jose Antonio Marquez Date: Fri Mar 2 15:54:12 2012 -0800 Formatting fixes commit 5c9795958b08c233eb2c4afab8054d55c3a33d98 Author: Jose Antonio Marquez Date: Fri Mar 2 14:52:18 2012 -0800 Minor logic fixes for URL resolution in CSS commit 4d35a90ba032d51ce701eebec323117d02e827fa Merge: e24631e 0aeb400 Author: Jose Antonio Marquez Date: Fri Mar 2 14:20:46 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO commit e24631ecac0772fc51756fe4aff9638de3b95faf Author: Jose Antonio Marquez Date: Fri Mar 2 14:11:08 2012 -0800 Fixing CSS URL issues Only partially, supporting unquoted files under same root. commit c4bfc8b79820b55cc86d755fe590ee649813232a Merge: ff77f86 ff0a956 Author: Jose Antonio Marquez Date: Fri Mar 2 10:34:57 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO commit ff77f861fba349dd36d6c15c9a545459c3a76583 Author: Jose Antonio Marquez Date: Fri Mar 2 10:34:01 2012 -0800 Fixing IO RegEx Fixed parsing files to have correct URLs with RegEx, inner content of CSS files still needs to be fixed. commit 66bc1f46938afc696b11878ebbb97d1fd361386e Merge: 80ac930 61dd921 Author: Jose Antonio Marquez Date: Thu Mar 1 18:13:18 2012 -0800 Merge branch 'refs/heads/Ninja-Internal' into FileIO commit 80ac930684255dd24cecae70b488285a6058488e Author: Jose Antonio Marquez Date: Thu Mar 1 13:34:45 2012 -0800 Optimizing URL intercepting detection Modified the way the webRequest maps to the file. commit 13aca03d4e0d11729d691db0b7f0d2f2a6899cf6 Merge: b09956e 8fee7d6 Author: Jose Antonio Marquez Russo Date: Wed Feb 29 15:41:12 2012 -0800 Merge pull request #24 from ananyasen/FileIO undo/redo per document , codemirror 2.22 update commit 8fee7d6bdb55ba18f396c3523081b18499fa1e30 Merge: 5d4f1aa b09956e Author: Ananya Sen Date: Wed Feb 29 15:21:31 2012 -0800 Merge branch 'refs/heads/ninja-internal-master' into FileIO Conflicts: js/controllers/selection-controller.js js/document/html-document.js js/panels/properties/content.reel/content.js Signed-off-by: Ananya Sen commit 5d4f1aad01737695238582c704e6d4f2c3a2f317 Merge: ccedeef 551e1f2 Author: Ananya Sen Date: Wed Feb 29 14:53:13 2012 -0800 Merge branch 'refs/heads/ninja-internal-master' into FileIO commit ccedeef38d6eb2e55d1782b82401828f3c99dd9c Merge: 7a259f8 84d6f6f Author: Ananya Sen Date: Wed Feb 29 13:56:35 2012 -0800 Merge pull request #4 from mqg734/AnanyaFileIO Fix for selection bug due to bad scrollLeft and scrollTop values when switching between documents. commit 84d6f6f5518e5ef8fc3d68be7e41c510f57b597a Author: Nivesh Rajbhandari Date: Wed Feb 29 13:53:45 2012 -0800 Fixing typo. Signed-off-by: Nivesh Rajbhandari commit 0cd17b6cf9231e60083958d85759d4796f505342 Author: Nivesh Rajbhandari Date: Wed Feb 29 13:48:11 2012 -0800 Fix for selection bug due to bad scrollLeft and scrollTop values when switching between documents. Signed-off-by: Nivesh Rajbhandari commit 7a259f8c78a2394e32c62654623285ee595c6249 Author: Ananya Sen Date: Wed Feb 29 13:25:35 2012 -0800 IKNINJA-1217: use encodeURI instead to save into sessionStorage Signed-off-by: Ananya Sen commit 4e21db069b28c79236c8c7fd19dcc7810d28c5cb Author: Ananya Sen Date: Wed Feb 29 12:18:09 2012 -0800 set selectionContainer before restoring selected elements Signed-off-by: Ananya Sen commit 03ea76700cb8bee3f4f58acf3e3503b0642d13fb Author: Ananya Sen Date: Wed Feb 29 11:46:19 2012 -0800 fixed selection which click after switching to a document Signed-off-by: Ananya Sen commit 7a9c2a91dfbbdd0cd7c79d81be5aeecd7887e7f1 Author: Ananya Sen Date: Wed Feb 29 10:12:38 2012 -0800 handle selections for switching documents Signed-off-by: Ananya Sen commit 1c7e86b6c2c802d720cc3075f75c7a61866ebc07 Author: Ananya Sen Date: Tue Feb 28 16:41:18 2012 -0800 fix for creatingNewFile flag Signed-off-by: Ananya Sen commit e0fab951e4f3869b04fd4a01f429a6654991cd68 Author: Ananya Sen Date: Tue Feb 28 15:33:35 2012 -0800 minor fixes in saving undo/redo stacks per document Signed-off-by: Ananya Sen commit 1766c6b17e2311fcd21c2be6608c7dcdc0a9b23a Author: Ananya Sen Date: Tue Feb 28 15:07:49 2012 -0800 persist selections while switching documents Signed-off-by: Ananya Sen commit 866df4801b9e77a0155ffbfb87adbc79a94ce9a5 Author: Ananya Sen Date: Tue Feb 28 12:34:33 2012 -0800 reverted null check as per request Signed-off-by: Ananya Sen commit ada597016685a83f2c9a8b25b28589b9221569c0 Author: Ananya Sen Date: Tue Feb 28 12:26:52 2012 -0800 reverting null checks as per request Signed-off-by: Ananya Sen commit bca9189a076432f35f99fc90f271c45ec00c0f1c Merge: 2edcdd8 6af71de Author: Ananya Sen Date: Tue Feb 28 10:06:48 2012 -0800 Merge branch 'refs/heads/FileIO-jose' into FileIO commit 2edcdd88ffc2f6ff0ea836e4da3e1fd2cb3e856f Author: Ananya Sen Date: Mon Feb 27 17:39:26 2012 -0800 persist undo/redo stack per html document Signed-off-by: Ananya Sen commit 51ed781953bc44bba3c70938aa57b856394cbc88 Author: Ananya Sen Date: Mon Feb 27 14:41:21 2012 -0800 updating to codemirror 2.22 Signed-off-by: Ananya Sen Signed-off-by: Jonathan Duran --- node_modules/montage/ui/application.js | 4 +- .../montage/ui/bluemoon/progress.reel/progress.js | 20 +- node_modules/montage/ui/check-input.js | 2 +- node_modules/montage/ui/checkbox.reel/checkbox.js | 2 +- node_modules/montage/ui/component.js | 115 ++- node_modules/montage/ui/composer/press-composer.js | 9 +- .../montage/ui/composer/translate-composer.js | 77 +- .../montage/ui/condition.reel/condition.js | 24 +- .../montage/ui/controller/array-controller.js | 8 +- node_modules/montage/ui/list.reel/list.html | 10 +- node_modules/montage/ui/loader.reel/loader.js | 6 +- .../ui/loading-panel.reel/loading-panel.css | 38 +- .../ui/loading-panel.reel/loading-panel.html | 6 +- node_modules/montage/ui/native-control.js | 3 - .../montage/ui/popup/confirm.reel/confirm.js | 4 +- node_modules/montage/ui/popup/popup.reel/popup.js | 159 ++-- node_modules/montage/ui/progress.reel/progress.css | 51 -- .../montage/ui/progress.reel/progress.html | 32 - node_modules/montage/ui/progress.reel/progress.js | 144 +--- node_modules/montage/ui/progress.reel/rule.png | Bin 956 -> 0 bytes node_modules/montage/ui/progress.reel/scroll.png | Bin 272 -> 0 bytes .../montage/ui/radio-button.reel/radio-button.js | 3 +- .../montage/ui/repetition.reel/repetition.js | 127 +++- node_modules/montage/ui/scroll.js | 820 --------------------- .../montage/ui/scroller.reel/scroller.html | 1 + node_modules/montage/ui/scroller.reel/scroller.js | 36 +- .../montage/ui/select-input.reel/select-input.js | 115 ++- .../ui/skeleton/range-input.reel/range-input.css | 27 + .../ui/skeleton/range-input.reel/range-input.html | 62 ++ .../ui/skeleton/range-input.reel/range-input.js | 234 ++++++ node_modules/montage/ui/slot.reel/slot.js | 19 +- node_modules/montage/ui/template.js | 4 + node_modules/montage/ui/text-input.js | 16 +- node_modules/montage/ui/textarea.reel/textarea.js | 2 +- .../montage/ui/toggle-button.reel/toggle-button.js | 9 +- .../ui/toggle-switch.reel/toggle-switch.css | 162 ++++ .../ui/toggle-switch.reel/toggle-switch.html | 16 + .../montage/ui/toggle-switch.reel/toggle-switch.js | 424 +++++++++++ 38 files changed, 1454 insertions(+), 1337 deletions(-) delete mode 100755 node_modules/montage/ui/progress.reel/progress.css delete mode 100755 node_modules/montage/ui/progress.reel/progress.html delete mode 100755 node_modules/montage/ui/progress.reel/rule.png delete mode 100755 node_modules/montage/ui/progress.reel/scroll.png delete mode 100755 node_modules/montage/ui/scroll.js create mode 100644 node_modules/montage/ui/skeleton/range-input.reel/range-input.css create mode 100644 node_modules/montage/ui/skeleton/range-input.reel/range-input.html create mode 100644 node_modules/montage/ui/skeleton/range-input.reel/range-input.js create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.css create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.html create mode 100644 node_modules/montage/ui/toggle-switch.reel/toggle-switch.js (limited to 'node_modules/montage/ui') diff --git a/node_modules/montage/ui/application.js b/node_modules/montage/ui/application.js index c7b3dc73..7cb4bd97 100755 --- a/node_modules/montage/ui/application.js +++ b/node_modules/montage/ui/application.js @@ -175,7 +175,7 @@ var Application = exports.Application = Montage.create(Montage, /** @lends monta _createPopupSlot: {value: function(zIndex) { var slotEl = document.createElement('div'); document.body.appendChild(slotEl); - slotEl.style['z-index'] = zIndex; + slotEl.style.zIndex = zIndex; slotEl.style.position = 'absolute'; var popupSlot = Slot.create(); @@ -221,7 +221,7 @@ var Application = exports.Application = Montage.create(Montage, /** @lends monta } // use the new zIndex for custom popup if(!isSystemPopup) { - popupSlot.element.style['z-index'] = zIndex; + popupSlot.element.style.zIndex = zIndex; } popupSlot.content = content; diff --git a/node_modules/montage/ui/bluemoon/progress.reel/progress.js b/node_modules/montage/ui/bluemoon/progress.reel/progress.js index 8bc68b05..20c60d94 100644 --- a/node_modules/montage/ui/bluemoon/progress.reel/progress.js +++ b/node_modules/montage/ui/bluemoon/progress.reel/progress.js @@ -43,8 +43,8 @@ exports.Progress = Montage.create(Component,/** @lends module:"montage/ui/bluemo set: function(val) { if(val !== this._value) { this._value = val; - if(this._value > this._maximumValue) { - this._value = this._maximumValue; + if(this._value > this._max) { + this._value = this._max; } if(this._value < 0) { this._value = 0; @@ -57,7 +57,7 @@ exports.Progress = Montage.create(Component,/** @lends module:"montage/ui/bluemo Description TODO @private */ - _maximumValue: { + _max: { enumerable: false, value: 100 }, @@ -66,15 +66,15 @@ exports.Progress = Montage.create(Component,/** @lends module:"montage/ui/bluemo @type {Function} @default {Number} 100 */ - maximumValue: { + max: { get: function() { - return this._maximumValue; + return this._max; }, set: function(val) { - if(val !== this._maximumValue) { - this._maximumValue = val; - if(this._maximumValue <= 0) { - this._maximumValue = 1; // Prevent divide by zero errors + if(val !== this._max) { + this._max = val; + if(this._max <= 0) { + this._max = 1; // Prevent divide by zero errors } this.needsDraw = true; } @@ -120,7 +120,7 @@ exports.Progress = Montage.create(Component,/** @lends module:"montage/ui/bluemo draw: { enumerable: false, value: function() { - var ratio = this._value / this._maximumValue; + var ratio = this._value / this._max; // constrain to interval [0, 1] ratio = Math.min(Math.max(ratio, 0), 1); // map into [0, 100] diff --git a/node_modules/montage/ui/check-input.js b/node_modules/montage/ui/check-input.js index 42538c02..1621eb45 100644 --- a/node_modules/montage/ui/check-input.js +++ b/node_modules/montage/ui/check-input.js @@ -69,7 +69,7 @@ var CheckInput = exports.CheckInput = Montage.create(NativeControl, { Stores if we need to fake checking. When preventDefault is called on touchstart and touchend events (e.g. by - the scrollview component) the checkbox doesn't check itself, so we need + the scroller component) the checkbox doesn't check itself, so we need to fake it later. @default false diff --git a/node_modules/montage/ui/checkbox.reel/checkbox.js b/node_modules/montage/ui/checkbox.reel/checkbox.js index df2995c3..c6364e97 100644 --- a/node_modules/montage/ui/checkbox.reel/checkbox.js +++ b/node_modules/montage/ui/checkbox.reel/checkbox.js @@ -9,7 +9,7 @@ var Montage = require("montage").Montage, var Checkbox = exports.Checkbox = Montage.create(CheckInput, {}); Checkbox.addAttributes({ - autofocus: 'off', // on/off + autofocus: {value: false, dataType: 'boolean'}, disabled: {value: false, dataType: 'boolean'}, checked: {value: false, dataType: 'boolean'}, form: null, diff --git a/node_modules/montage/ui/component.js b/node_modules/montage/ui/component.js index d347f655..69559fc1 100755 --- a/node_modules/montage/ui/component.js +++ b/node_modules/montage/ui/component.js @@ -59,7 +59,6 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon value: function() { var actionEvent = document.createEvent("CustomEvent"); actionEvent.initCustomEvent("action", true, true, null); - actionEvent.type = "action"; return actionEvent; } }, @@ -162,6 +161,15 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon } }, + setElementWithParentComponent: { + value: function(element, parent) { + this._alternateParentComponent = parent; + if (this.element != element) { + this.element = element; + } + } + }, + // access to the Application object /** Description TODO @@ -215,6 +223,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon return targetElementController; } }, + + _alternateParentComponent: { + value: null + }, + /** Description TODO @private @@ -235,21 +248,27 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon get: function() { var cachedParentComponent = this._cachedParentComponent; if (cachedParentComponent == null) { - var anElement = this.element, - aParentNode, - eventManager = this.eventManager; - if (anElement) { - while ((aParentNode = anElement.parentNode) !== null && eventManager.eventHandlerForElement(aParentNode) == null) { - anElement = aParentNode; - } - return (this._cachedParentComponent = aParentNode ? eventManager.eventHandlerForElement(aParentNode) : null); - } + return (this._cachedParentComponent = this.findParentComponent()); } else { return cachedParentComponent; } } }, + findParentComponent: { + value: function() { + var anElement = this.element, + aParentNode, + eventManager = this.eventManager; + if (anElement) { + while ((aParentNode = anElement.parentNode) !== null && eventManager.eventHandlerForElement(aParentNode) == null) { + anElement = aParentNode; + } + return aParentNode ? eventManager.eventHandlerForElement(aParentNode) : this._alternateParentComponent; + } + } + }, + querySelectorComponent: { value: function(selector) { if (typeof selector !== "string") { @@ -406,19 +425,30 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon attachToParentComponent: { value: function() { this._cachedParentComponent = null; - - var parentComponent = this.parentComponent; - + + var parentComponent = this.parentComponent, + childComponents, + childComponent; + if (parentComponent) { + childComponents = parentComponent.childComponents; + for (var i = 0; (childComponent = childComponents[i]); i++) { + var newParentComponent = childComponent.findParentComponent(); + if (newParentComponent === this) { + parentComponent.removeChildComponent(childComponent); + newParentComponent._addChildComponent(childComponent); + } + } + parentComponent._addChildComponent(this); } } }, - + detachFromParentComponent: { value: function() { var parentComponent = this.parentComponent; - + if (parentComponent) { parentComponent.removeChildComponent(this); } @@ -438,6 +468,7 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon if (ix > -1) { childComponents.splice(ix, 1); childComponent._cachedParentComponent = null; + childComponent._alternateParentComponent = null; } } }, @@ -458,7 +489,6 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon */ ownerComponent: { enumerable: false, - serializable: true, value: null }, /** @@ -488,7 +518,7 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon enumerable: false, value: null }, - + /** * Remove all bindings and starts buffering the needsDraw. * @function @@ -498,23 +528,20 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon this.needsDraw = false; this.traverseComponentTree(function(component) { Object.deleteBindings(component); - component.canDrawGate.setField("componentTreeLoaded", false); - component.blockDrawGate.setField("element", false); - component.blockDrawGate.setField("drawRequested", false); component.needsDraw = false; }); } }, - + originalContent: { value: null }, - + _newContent: { enumerable: false, value: null }, - + content: { get: function() { if (this._element) { @@ -526,21 +553,21 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon set: function(value) { var components = [], childNodes; - + this._newContent = value; this.needsDraw = true; - + if (typeof this.contentWillChange === "function") { this.contentWillChange(value); } - + // cleanup current content components = this.childComponents; for (var i = 0, component; (component = components[i]); i++) { component.detachFromParentComponent(); component.cleanupDeletedComponentTree(); } - + if (value instanceof Element) { findAndDetachComponents(value); } else { @@ -548,11 +575,11 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon findAndDetachComponents(value[i]); } } - + // find the component fringe and detach them from the component tree function findAndDetachComponents(node) { var component = node.controller; - + if (component) { component.detachFromParentComponent(); components.push(component); @@ -563,14 +590,14 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon } } } - + // not sure if I can rely on _cachedParentComponent to detach the nodes instead of doing one loop for dettach and another to attach... for (var i = 0, component; (component = components[i]); i++) { this._addChildComponent(component); } } }, - + /** Description TODO @function @@ -581,6 +608,9 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon if (this._element) { this.originalContent = Array.prototype.slice.call(this._element.childNodes, 0); } + if (!("identifier" in this)) { + this.identifier = Montage.getInfoForObject(this).label; + } } }, @@ -886,6 +916,15 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon // this call will be synchronous if the template is cached. Template.templateWithModuleId(info.require, templateModuleId, onTemplateLoad); }}, + + templateDidDeserializeObject: { + value: function(object) { + if (Component.isPrototypeOf(object)) { + object.ownerComponent = this; + } + } + }, + /** Callback for the _canDrawGate.
Propagates to the parent and adds the component to the draw list. @@ -990,10 +1029,10 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon if (attributeName === "id" || attributeName === "data-montage-id") { continue; } else { - value = (template.getAttribute(attributeName) || "") + " " + + value = (template.getAttribute(attributeName) || "") + (attributeName === "style" ? "; " : " ") + attribute.nodeValue; } - + template.setAttribute(attributeName, value); } @@ -1072,13 +1111,13 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon value: function() { var contents = this._newContent, element; - + this._canDrawTable = {}; this._canDrawCount = 0; - + if (contents) { element = this._element; - + element.innerHTML = ""; if (contents instanceof Element) { @@ -1088,7 +1127,7 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon element.appendChild(content); } } - + this._newContent = null; if (typeof this.contentDidChange === "function") { this.contentDidChange(); @@ -1196,7 +1235,7 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon } if (this._needsDraw !== value) { if (drawLogger.isDebug) { - drawLogger.debug("NEEDS DRAW TOGGLED " + value + " FOR " + (this.element != null ? this.element.id : '')); + drawLogger.debug("NEEDS DRAW TOGGLED " + value + " FOR " + this._montage_metadata.objectName); } this._needsDraw = !!value; if (value) { diff --git a/node_modules/montage/ui/composer/press-composer.js b/node_modules/montage/ui/composer/press-composer.js index 942de162..4a6b99b2 100644 --- a/node_modules/montage/ui/composer/press-composer.js +++ b/node_modules/montage/ui/composer/press-composer.js @@ -103,7 +103,10 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m _startInteraction: { enumerable: false, value: function(event) { - if ("disabled" in this.component && this.component.disabled) { + if ( + ("disabled" in this.component && this.component.disabled) || + this._observedPointer !== null + ) { return false; } @@ -401,8 +404,8 @@ var PressEvent = (function(){ // These properties are available directly on the event eventProps = ["altKey", "ctrlKey", "metaKey", "shiftKey", - "cancelBubble", "clipboardData", "currentTarget", "defaultPrevented", - "eventPhase", "returnValue", "srcElement", "timeStamp", "preventDefault", + "cancelBubble", "currentTarget", "defaultPrevented", + "eventPhase", "timeStamp", "preventDefault", "stopImmediatePropagation", "stopPropagation"]; // These properties are available on the event in the case of mouse, and // on the _touch in the case of touch diff --git a/node_modules/montage/ui/composer/translate-composer.js b/node_modules/montage/ui/composer/translate-composer.js index 485290b4..4ce165dc 100644 --- a/node_modules/montage/ui/composer/translate-composer.js +++ b/node_modules/montage/ui/composer/translate-composer.js @@ -4,7 +4,7 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ /** - @module montage/ui/composer/long-press-composer + @module montage/ui/composer/long-press-composer @requires montage @requires montage/ui/composer/composer */ @@ -15,7 +15,19 @@ var Montage = require("montage").Montage, @class module:montage/ui/composer/translate-composer.TranslateComposer @extends module:montage/ui/composer/composer.Composer */ -exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui/event/composer/translate-composer.TranslateComposer# */ { +var TranslateComposer = exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui/event/composer/translate-composer.TranslateComposer# */ { + + /** + These elements perform some native action when clicked/touched and so we + should not preventDefault when a mousedown/touchstart happens on them. + @private + */ + _NATIVE_ELEMENTS: { + value: ["A", "IFRAME", "EMBED", "OBJECT", "VIDEO", "AUDIO", "CANVAS", + "LABEL", "INPUT", "BUTTON", "SELECT", "TEXTAREA", "KEYGEN", + "DETAILS", "COMMAND" + ] + }, _externalUpdate: { enumerable: false, @@ -191,6 +203,8 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui } }, + invertAxis: {value: null}, + _hasMomentum: { enumerable: false, value: true @@ -296,16 +310,31 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui value: null }, + /** + Returns if we should preventDefault on a touchstart/mousedown event. + @param {Event} The event + @returns {Boolean} Whether preventDefault should be called + @private + */ + _shouldPreventDefault: { + value: function(event) { + return !!event.target.tagName && TranslateComposer._NATIVE_ELEMENTS.indexOf(event.target.tagName) === -1 && !event.target.isContentEditable; + } + }, + +/** + Description TODO + @function + @param {Event} event TODO + */ captureMousedown: { enumerable: false, value: function (event) { + if (event.button !== 0) { + return; + } - // TODO this is a bit of a temporary workaround to ensure that we allow input fields - //to receive the mousedown that gives them focus and sets the cursor a the mousedown coordinates - if (!(event.target.tagName && - ("INPUT" === event.target.tagName || "SELECT" === event.target.tagName || "TEXTAREA" === event.target.tagName)) && - !event.target.isContentEditable) { - + if (this._shouldPreventDefault(event)) { event.preventDefault(); } @@ -317,11 +346,16 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui } }, + /** + Handle the mousedown that bubbled back up from beneath the element + If nobody else claimed this pointer, we should handle it now + @function + @param {Event} event TODO + */ handleMousedown: { enumerable: false, value: function (event) { - - if (!this.eventManager.componentClaimingPointer(this._observedPointer, this)) { + if (event.button === 0 && !this.eventManager.componentClaimingPointer(this._observedPointer, this)) { this.eventManager.claimPointer(this._observedPointer, this); this._start(event.clientX, event.clientY, event.target); } @@ -371,10 +405,11 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui captureTouchstart: { enumerable: false, value: function (event) { + if (this._shouldPreventDefault(event)) { + event.preventDefault(); + } - event.preventDefault(); - - // If already scrolling the scrollview, ignore any new touchstarts + // If already scrolling, ignore any new touchstarts if (this._observedPointer !== null && this.eventManager.isPointerClaimedByComponent(this._observedPointer, this)) { return; } @@ -391,7 +426,9 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui if (!this.eventManager.componentClaimingPointer(this._observedPointer)) { if (event.targetTouches.length === 1) { - event.preventDefault(); + if (this._shouldPreventDefault(event)) { + event.preventDefault(); + } this.eventManager.claimPointer(this._observedPointer, this); this._start(event.targetTouches[0].clientX, event.targetTouches[0].clientY, event.targetTouches[0].target); @@ -458,7 +495,7 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui angle = velocity.angle; - // The motion is with the grain of the scrollview; we may want to see if we should claim the pointer + // The motion is with the grain of the element; we may want to see if we should claim the pointer if ("horizontal" === this.axis) { isRight = (angle <= lowerRight && angle >= upperRight); @@ -516,11 +553,13 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui value: function (x, y) { this._isSelfUpdate=true; + var delta; if (this._axis!="vertical") { + var delta = this.invertAxis ? (x-this._pointerX) : (this._pointerX-x); if ((this._translateX<0)||(this._translateX>this._maxTranslateX)) { - this.translateX+=((this._pointerX-x)/2)*this._pointerSpeedMultiplier; + this.translateX+=(delta/2)*this._pointerSpeedMultiplier; } else { - this.translateX+=(this._pointerX-x)*this._pointerSpeedMultiplier; + this.translateX+=(delta)*this._pointerSpeedMultiplier; } } if (this._axis!="horizontal") { @@ -530,6 +569,7 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui this.translateY+=(this._pointerY-y)*this._pointerSpeedMultiplier; } } + this._isSelfUpdate=false; this._pointerX=x; this._pointerY=y; @@ -573,7 +613,6 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui var translateStartEvent = document.createEvent("CustomEvent"); translateStartEvent.initCustomEvent("translateStart", true, true, null); - translateStartEvent.type = "translateStart"; this.dispatchEvent(translateStartEvent); } }, @@ -584,11 +623,11 @@ exports.TranslateComposer = Montage.create(Composer,/** @lends module:montage/ui var translateEndEvent = document.createEvent("CustomEvent"); translateEndEvent.initCustomEvent("translateEnd", true, true, null); - translateEndEvent.type = "translateEnd"; this.dispatchEvent(translateEndEvent); } }, + _end: { enumerable: false, value: function (event) { diff --git a/node_modules/montage/ui/condition.reel/condition.js b/node_modules/montage/ui/condition.reel/condition.js index 053adb16..064f51b7 100755 --- a/node_modules/montage/ui/condition.reel/condition.js +++ b/node_modules/montage/ui/condition.reel/condition.js @@ -110,9 +110,6 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond enumerable:false }, - /** - - */ // TODO should this strategy be part of another class? // TODO expose the options as an exported enum removalStrategy:{ @@ -131,11 +128,7 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond } }, - /** - @param - @returns - */ didCreate:{ value:function () { this._slot = Slot.create(); @@ -150,19 +143,14 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond prepareForDraw: { enumerable: false, value: function() { - + var i, childList, childElement; if (!this.content) { this.content = document.createElement("div"); - - var conditionContentRange = document.createRange(); - conditionContentRange.selectNodeContents(this._element); - - // TODO not wrap the range if it is a range of a single element - // we want to only deal with single elements when appending and removing; - // this keeps us from having to keep track of the range or risk losing - // a reference to the elements when they're extracted - conditionContentRange.surroundContents(this.content); - conditionContentRange.deleteContents(); //remove the contents that are part of the original structure + childList = Array.prototype.slice.call(this._element.childNodes, 0); + for (i = 0; (childElement = childList[i]); i++) { + childElement.parentElement.removeChild(childElement); + this.content.appendChild(childElement); + } } var slotRoot = document.createElement("div"); diff --git a/node_modules/montage/ui/controller/array-controller.js b/node_modules/montage/ui/controller/array-controller.js index 868ae5de..f355efc1 100755 --- a/node_modules/montage/ui/controller/array-controller.js +++ b/node_modules/montage/ui/controller/array-controller.js @@ -519,9 +519,11 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController, return null; } - this._selectedObjects = this.content.filter(function(value, i) { - return this._selectedContentIndexes.indexOf(i) >= 0; - }, this); + if(this.content) { + this._selectedObjects = this.content.filter(function(value, i) { + return this._selectedContentIndexes.indexOf(i) >= 0; + }, this); + } return this._selectedObjects; }, diff --git a/node_modules/montage/ui/list.reel/list.html b/node_modules/montage/ui/list.reel/list.html index 98629f04..2e52b11d 100755 --- a/node_modules/montage/ui/list.reel/list.html +++ b/node_modules/montage/ui/list.reel/list.html @@ -40,12 +40,12 @@ } } }, - "scrollview1": { - "module": "montage/ui/scrollview.reel", - "name": "Scrollview", + "scroller1": { + "module": "montage/ui/scroller.reel", + "name": "Scroller", "properties": { "element": { - "#": "scrollView" + "#": "scroller" } }, "bindings": { @@ -74,7 +74,7 @@
-
+
diff --git a/node_modules/montage/ui/loader.reel/loader.js b/node_modules/montage/ui/loader.reel/loader.js index b392c915..941c17da 100755 --- a/node_modules/montage/ui/loader.reel/loader.js +++ b/node_modules/montage/ui/loader.reel/loader.js @@ -298,8 +298,7 @@ exports.Loader = Montage.create(Component, /** @lends module:montage/ui/loader.L for (i = 0; (iChild = children[i]); i++) { if ((iComponent = iChild.controller)) { - this.childComponents.push(iComponent); - iComponent._cachedParentComponent = this; + iComponent.attachToParentComponent(); iComponent.needsDraw = true; } } @@ -342,8 +341,7 @@ exports.Loader = Montage.create(Component, /** @lends module:montage/ui/loader.L // based on its template this._mainComponent = exports[this.mainName].create(); this.childComponents.push(this._mainComponent); - this._mainComponent._cachedParentComponent = this; - this._mainComponent.element = document.createElement("div"); + this._mainComponent.setElementWithParentComponent(document.createElement("div"), this); this._mainComponent.needsDraw = true; } }, diff --git a/node_modules/montage/ui/loading-panel.reel/loading-panel.css b/node_modules/montage/ui/loading-panel.reel/loading-panel.css index 9a82a320..39f0db06 100755 --- a/node_modules/montage/ui/loading-panel.reel/loading-panel.css +++ b/node_modules/montage/ui/loading-panel.reel/loading-panel.css @@ -4,32 +4,40 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -/* disabled for now */ -.montage-loading-panel > .loadingIndicator { - display: none; -} - .montage-loading-panel { position: absolute; + z-index: 999; top: 0; right: 0; bottom: 0; left: 0; - background-color: hsl(0,0%,0%); - display: -webkit-box; - -webkit-box-pack: center; - -webkit-box-align: center; } -.montage-loading-panel > .loadingCount { +.montage-loading-panel > .loadingIndicator { width: 200px; - height: 200px; + margin: 20px; + display: none; /* disabled for now, because the loading doesn't really look continuos enough. */ +} + + +.montage-loading-panel > .loadingCount { + position: absolute; + width: 160px; + height: 160px; + top: 50%; + left: 50%; + margin: -90px; + padding: 10px; border-radius: 50%; - text-align: center; color: #fff; - font: 40px/200px "Lucida Grande", Lucida, Verdana, sans-serif; - text-shadow: 0 0px 6px hsla(200,100%,50%,.6); - -webkit-box-shadow: inset 0px 0px 0 5px hsl(200,0%,10%); + font: 30px/160px "Helvetica Neue", Helvetica, Geneva, sans-serif; + text-align: center; + background: hsla(0,0%,0%,.6); + background: -webkit-radial-gradient( center 33% , hsla(0,0%,0%,.6) 10%, hsla(0,0%,0%,.8) ); + background: -moz-radial-gradient( center 33% , hsla(0,0%,0%,.65) 10%, hsla(0,0%,0%,.8) ); + -webkit-box-shadow: inset 0 0 0 3px hsla(0,0%,0%,.3), 0 0 0 3px hsla(0,0%,100%,.3); + box-shadow: inset 0 0 0 3px hsla(0,0%,0%,.3), 0 0 0 3px hsla(0,0%,100%,.3); + overflow: hidden; } .montage-loading-panel > .loadingCount > .divider { diff --git a/node_modules/montage/ui/loading-panel.reel/loading-panel.html b/node_modules/montage/ui/loading-panel.reel/loading-panel.html index 27825a09..ff1677ea 100755 --- a/node_modules/montage/ui/loading-panel.reel/loading-panel.html +++ b/node_modules/montage/ui/loading-panel.reel/loading-panel.html @@ -34,7 +34,7 @@ "boundObjectPropertyPath": "initializedModuleCount", "oneway": true }, - "maximumValue": { + "max": { "boundObject": {"@": "owner"}, "boundObjectPropertyPath": "requiredModuleCount", "oneway": true @@ -81,7 +81,9 @@
- 0/0 + 0 + / + 0
diff --git a/node_modules/montage/ui/native-control.js b/node_modules/montage/ui/native-control.js index d308ad89..907711e2 100644 --- a/node_modules/montage/ui/native-control.js +++ b/node_modules/montage/ui/native-control.js @@ -200,9 +200,6 @@ var NativeControl = exports.NativeControl = Montage.create(Component, { for(var attributeName in this._elementAttributeValues) { if(this._elementAttributeValues.hasOwnProperty(attributeName)) { - if(attributeName === 'value') { - continue; - } var value = this[attributeName]; descriptor = this._getElementAttributeDescriptor(attributeName, this); if(descriptor && descriptor.dataType === 'boolean') { diff --git a/node_modules/montage/ui/popup/confirm.reel/confirm.js b/node_modules/montage/ui/popup/confirm.reel/confirm.js index 7e186e29..0fc5fea0 100755 --- a/node_modules/montage/ui/popup/confirm.reel/confirm.js +++ b/node_modules/montage/ui/popup/confirm.reel/confirm.js @@ -115,7 +115,7 @@ var Confirm = exports.Confirm = Montage.create(Component, /** @lends module:"mon this.okCallback.call(this, evt); } var anEvent = document.createEvent("CustomEvent"); - anEvent.initCustomEvent("montage_confirm_ok", true, true); + anEvent.initCustomEvent("montage_confirm_ok", true, true, null); this.dispatchEvent(anEvent); this.popup.hide(); @@ -132,7 +132,7 @@ var Confirm = exports.Confirm = Montage.create(Component, /** @lends module:"mon this.cancelCallback.call(this, evt); } var anEvent = document.createEvent("CustomEvent"); - anEvent.initCustomEvent("montage_confirm_cancel", true, true); + anEvent.initCustomEvent("montage_confirm_cancel", true, true, null); this.dispatchEvent(anEvent); this.popup.hide(); diff --git a/node_modules/montage/ui/popup/popup.reel/popup.js b/node_modules/montage/ui/popup/popup.reel/popup.js index f13a6aed..2a61e75e 100755 --- a/node_modules/montage/ui/popup/popup.reel/popup.js +++ b/node_modules/montage/ui/popup/popup.reel/popup.js @@ -27,6 +27,10 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul // A Delegate to control positioning (and other features, in future) of the popup in a custom manner delegate: {value: null}, + /** + Internal property. + @private + */ contentEl: { value: null }, @@ -34,66 +38,24 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul Description TODO @type {Property} @default {Container} null + @private */ containerEl: { value: null }, -/** - Description TODO - @private -*/ - _pointer: { - value: true - }, -/** - Description TODO - @type {Function} - @default {Boolean} true - */ - pointer: { - get: function() { - return this._pointer; - }, - set: function(value) { - if (this._pointer !== value) { - this._pointer = value; - this.needsDraw = true; - } - } - }, -/** - Description TODO - @private -*/ - _boxed: { - value: true - }, -/** - Description TODO - @type {Function} - @default {Boolean} true - */ - boxed: { - get: function() { - return this._boxed; - }, - set: function(value) { - if (this._boxed !== value) { - this._boxed = value; - this.needsDraw = true; - } - } - }, + /** Description TODO @private */ _slot: {value: null}, /** + Description TODO @type {Function} @default null + @private */ slot: { get: function() { @@ -112,7 +74,8 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul */ _content: {value: null}, /** - Description TODO + The Montage component that will be shown in this popup. + @type {Function} @default null */ @@ -137,7 +100,8 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul */ _modal: { value: false }, /** - Description TODO + If true, the Popup will be rendered as a Modal. + @type {Function} @default {Boolean} false */ @@ -156,8 +120,10 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul } }, - // An Object wtih values {top, left}. Set it only if the popup should display at a - // given location instead of anchoring it to a anchor element or at the center of the screen. + /** + An Object wtih values {top, left}. Set it only if the popup should display at a + given location always. + */ _position: {value: null}, position: { get: function() { @@ -169,8 +135,12 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul } }, + /** + * Number of milliseconds after which the Popup must be dismissed. Default is 0. + */ autoDismiss: { value: 0 }, + /** @private */ _displayed: { value: false }, displayed: { get: function() { @@ -204,9 +174,10 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul /** + Internal method. @private */ - _getPosition: { + _getElementPosition: { value: function(obj) { var curleft = 0, curtop = 0, curHt = 0, curWd = 0; if (obj.offsetParent) { @@ -222,16 +193,21 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul } }, - _calculatePosition: { + _positionPopup: { value: function() { - var pos, delegate = this.delegate, anchor = this.anchor, type = this.type; + var position, delegate = this.delegate, anchor = this.anchor, type = this.type; - if(delegate && (typeof delegate.positionPopup === 'function')) { + // if a delegate is provided, use that to get the position + if(delegate && (typeof delegate.willPositionPopup === 'function')) { var anchorPosition; if(anchor) { - anchorPosition = this._getPosition(anchor); + anchorPosition = this._getElementPosition(anchor); } - pos = delegate.positionPopup(this, anchor, anchorPosition); + position = delegate.willPositionPopup(this, anchor, anchorPosition); + } else if(this.position !== null) { + // If a position has been specified but no delegate has been provided + // we assume that the position is static and hence use that + position = this.position; } else { // @todo - advanced positioning support var $el = this.contentEl || this.content.element; @@ -243,67 +219,55 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul var viewportWidth = window.innerWidth; if (anchor) { + // if an anchor is provided, we position the popup relative to the anchor + // if (anchor.nodeName) { // if anchor is an element - var elPosition = this._getPosition(anchor); + var elPosition = this._getElementPosition(anchor); var tgtHeight = parseFloat(anchor.style.height || 0) || anchor.offsetHeight || 0; var tgtWidth = parseFloat(anchor.style.width || 0) || anchor.offsetWidth || 0; - pos = { + position = { top: elPosition[1] + tgtHeight + 20 /* pointer */, left: elPosition[0] + (tgtWidth / 2) - (elWidth / 2) }; - if (pos.left < 0) { - pos.left = elPosition[0]; + if (position.left < 0) { + position.left = elPosition[0]; this._showHidePointer(false); // dont show the pointer - @todo - support pointer arrow at different parts of the popup } } else { // anchor is absolute position {top, left} - pos = anchor; + position = anchor; } } else { - // position it at top or center - // for now, just show it at center - pos = { + // No positioning hints provided. POsition it at the center of the viewport by default + position = { top: (viewportHeight / 2 - (elHeight / 2)), left: (viewportWidth / 2 - (elWidth / 2)) }; } } - return pos; - } - }, - - _positionPopup: { - value: function() { - //console.log('--> position popup'); - var pos = this.position; + //this.position = position; var popupSlot = this._popupSlot; - if(pos) { - if (pos.top) { - popupSlot.element.style.top = pos.top + 'px'; - } - if (pos.left) { - popupSlot.element.style.left = pos.left + 'px'; - } - if (pos.right) { - popupSlot.element.style.right = pos.right + 'px'; - } - if (pos.bottom) { - popupSlot.element.style.bottom = pos.bottom + 'px'; - } + if(position) { + popupSlot.element.style.top = (position.top ? position.top + 'px' : ''); + popupSlot.element.style.left = (position.left ? position.left + 'px' : ''); + popupSlot.element.style.right = (position.right ? position.right + 'px' : ''); + popupSlot.element.style.bottom = (position.bottom ? position.bottom + 'px' : ''); } + } }, + _createModalMask: { value: function() { var el = document.createElement('div'); el.classList.add('montage-popup-modal-mask'); - el.style['z-index'] = 6999; + el.style.zIndex = 6999; el.classList.add('montage-invisible'); document.body.appendChild(el); @@ -340,6 +304,13 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul } }, + /** + * Show the Popup. The Popup is displayed at a position determined by the following conditions: + * 1) If a delegate is provided and the willPositionPopup function is implemented, the position is always determined by the delegate + * 2) If Popup.position has been set, the Popup is always displayed at this location + * 3) If an anchor has been set, the popup is displayed below the anchor + * 4) If no positional hints are provided, the Popup is displayed at the center of the screen + */ show: { value: function() { var type = this.type, @@ -352,6 +323,9 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul } }, + /** + * Hide the popup + */ hide: { value: function() { this._removeEventListeners(); @@ -397,9 +371,6 @@ var Popup = exports.Popup = Montage.create(Component, { /** @lends module:"modul draw: { value: function() { if (this.displayed) { - // custom, alert, confirm, notify - // only one popup of each type can be displayed at the same time - // kishore - does the above restriction make sense ? should we restrict it ? if(this.modal === true) { this.element.classList.add('montage-modal'); @@ -416,7 +387,7 @@ var Popup = exports.Popup