From 563935933c191093b8ccd88fd1377775c5641b0d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 4 Jun 2012 23:33:32 -0700 Subject: components fix: adding a first draw event to components Adding a first draw allows the component to have the right element so that ninja can use it's controller to get the component instance Signed-off-by: Valerio Virgillito --- js/document/templates/app/main.js | 52 ++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'js/document/templates') diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js index a406abdb..fbd2e138 100644 --- a/js/document/templates/app/main.js +++ b/js/document/templates/app/main.js @@ -8,12 +8,38 @@ var Montage = require("montage/core/core").Montage, Template = require("montage/ui/template").Template, TemplateCreator = require("tools/template/template-creator").TemplateCreator; + +//var njmodelGet = function njmodelGet() { +// return (this.hasOwnProperty("_model") ? this._model: document.modelGenerator.call(this)); +//}; +// +//Object.defineProperty(Object.prototype, "_model", { +// enumerable: false, +// value: null, +// writable: true +//}); +// +//Object.defineProperty(Object.prototype, "elementModel", { +// configurable: true, +// get: njmodelGet, +// set: function() { +// } +//}); + exports.Main = Montage.create(Component, { hasTemplate: { value: false }, + componentToInsert: { + value: null + }, + + firstDrawCallback: { + value: null + }, + /** * Adding window hooks to callback into this object from Ninja. */ @@ -24,6 +50,12 @@ exports.Main = Montage.create(Component, { window.addComponent = function(element, data, callback) { var component; + if(!self.firstDrawCallback) { + self.firstDrawCallback = {}; + self.firstDrawCallback.callback = data.firstDraw.cb; + self.firstDrawCallback.context = data.firstDraw.ctx; + } + component = require.async(data.path) .then(function(component) { var componentRequire = component[data.name]; @@ -34,6 +66,9 @@ exports.Main = Montage.create(Component, { componentInstance.needsDraw = true; componentInstance.ownerComponent = self; + self.componentToInsert = componentInstance; + componentInstance.addEventListener("firstDraw", self, false); + callback(componentInstance, element); }) .end(); @@ -46,16 +81,15 @@ exports.Main = Montage.create(Component, { // var templateEvent = document.createEvent("CustomEvent"); templateEvent.initCustomEvent("mjsTemplateReady", false, true); - document.body.dispatchEvent(templateEvent); - - - // Dispatch event when this template has loaded. - /* - var newEvent = document.createEvent( "CustomEvent" ); - newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); - document.body.dispatchEvent( newEvent ); - */ + } + }, + + handleFirstDraw: { + value: function() { + this.firstDrawCallback.callback.call(this.firstDrawCallback.context, this.componentToInsert); + this.componentToInsert.removeEventListener("firstDraw", this, false); + this.componentToInsert = null; } } }); \ No newline at end of file -- cgit v1.2.3 From 0d7ff08d74ab28247de8a84b84796c183aa47f0d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 14:20:31 -0700 Subject: fixing a small typo Signed-off-by: Valerio Virgillito --- js/document/templates/app/main.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/document/templates') diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js index fbd2e138..0cdf718c 100644 --- a/js/document/templates/app/main.js +++ b/js/document/templates/app/main.js @@ -81,6 +81,7 @@ exports.Main = Montage.create(Component, { // var templateEvent = document.createEvent("CustomEvent"); templateEvent.initCustomEvent("mjsTemplateReady", false, true); + document.body.dispatchEvent(templateEvent); } }, -- cgit v1.2.3 From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/document/templates/banner/index.html | 24 +++++++++++++++++++++--- js/document/templates/html/index.html | 27 +++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) (limited to 'js/document/templates') diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index f1ee3d98..08a998e5 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html @@ -74,9 +74,27 @@ diff --git a/js/document/templates/html/index.html b/js/document/templates/html/index.html index 70187900..c74a7251 100755 --- a/js/document/templates/html/index.html +++ b/js/document/templates/html/index.html @@ -57,13 +57,32 @@ .nj-element-highlight { outline: 4px solid #ff0000; - } + } -- cgit v1.2.3 From 5a9be53435fcd8168aa7f4ddbec085a135f7b98a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 8 Jun 2012 14:02:26 -0700 Subject: Overriding scrollbar styles on the template so the scroll track is not white. This has the side benefit of fixing some of the zoom issues with the scrollbar too. Signed-off-by: Nivesh Rajbhandari --- js/document/templates/banner/index.html | 23 +++++++++++++++++++++++ js/document/templates/html/index.html | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'js/document/templates') diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index 08a998e5..626dc0bc 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html @@ -71,6 +71,29 @@ -webkit-transform-style: preserve-3d; -webkit-transform: perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } + + ::-webkit-scrollbar { width: 11px; height: 11px; } + ::-webkit-scrollbar-button:start:decrement, ::-webkit-scrollbar-button:end:increment { display: none; } + ::-webkit-scrollbar-button:vertical:start:increment, body::-webkit-scrollbar-button:vertical:end:decrement { display: none; } + ::-webkit-scrollbar-button:horizontal:start:increment, body::-webkit-scrollbar-button:horizontal:end:decrement { display: none; } + ::-webkit-scrollbar-track:vertical { background-color: black; } + ::-webkit-scrollbar-track:horizontal { background-color: black; } + ::-webkit-scrollbar-track-piece:vertical:start { background-color: transparent; } + ::-webkit-scrollbar-track-piece:horizontal:start { background-color: transparent; } + ::-webkit-scrollbar-track-piece:vertical:end { background-color: transparent; } + ::-webkit-scrollbar-track-piece:horizontal:end { background-color: transparent; } + ::-webkit-scrollbar-thumb:vertical { border-color: black; border-style: solid; border-width: 2px; -webkit-border-radius: 6px; background: -webkit-gradient(linear, left top, right top, color-stop(0.16, #8c8c8c), color-stop(0.49, #adadad), color-stop(0.82, #8c8c8c)); } + ::-webkit-scrollbar-thumb:vertical:hover { border-color: black; border-style: solid; border-width: 2px; -webkit-border-radius: 6px; background: -webkit-gradient(linear, left top, right top, color-stop(0.1, #bebebe), color-stop(0.5, white), color-stop(0.9, #bebebe)); } + ::-webkit-scrollbar-thumb:horizontal { border-color: black; border-style: solid; border-width: 2px; -webkit-border-radius: 6px; background: -webkit-gradient(linear, left top, left bottom, color-stop(0.1, #8c8c8c), color-stop(0.5, #adadad), color-stop(0.9, #8c8c8c)); } + ::-webkit-scrollbar-thumb:horizontal:hover { border-color: black; border-style: solid; border-width: 2px; -webkit-border-radius: 6px; background: -webkit-gradient(linear, left top, left bottom, color-stop(0.16, #bebebe), color-stop(0.49, white), color-stop(0.82, #bebebe)); } + ::-webkit-scrollbar-corner { background-color: black; } + ::-webkit-scrollbar-corner:window-inactive { background-color: black; } + ::-webkit-scrollbar-track:vertical:disabled { display: block; } + ::-webkit-scrollbar-track:horizontal:disabled { display: block; } + ::-webkit-scrollbar-track-piece:disabled { display: block; } + ::-webkit-scrollbar-corner:disabled { display: block; } + ::-webkit-resizer:disabled { display: block; } +