diff options
author | Ananya Sen | 2012-05-31 10:13:40 -0700 |
---|---|---|
committer | Ananya Sen | 2012-05-31 10:13:40 -0700 |
commit | 286457b4f23974277274ba388afd283e8aa085cb (patch) | |
tree | c21bf791e7c4f572d12f97987ea6b89e74da67fe /js/document | |
parent | 4d9b481c58090e8f1fc7b0e9d73a81b0f49cccc8 (diff) | |
parent | d49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff) | |
download | ninja-286457b4f23974277274ba388afd283e8aa085cb.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Conflicts:
js/controllers/styles-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document')
24 files changed, 1719 insertions, 761 deletions
diff --git a/js/document/html-document.js b/js/document/_toDelete/html-document.js index 9d083dd8..447d90e3 100755 --- a/js/document/html-document.js +++ b/js/document/_toDelete/html-document.js | |||
@@ -209,8 +209,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
209 | { | 209 | { |
210 | /* | 210 | /* |
211 | // Use this code to test the runtime version of WebGL | 211 | // Use this code to test the runtime version of WebGL |
212 | var cdm = new NinjaCvsRt.CanvasDataManager(); | 212 | var cvsDataMngr = Object.create(NinjaCvsRt.CanvasDataManager, {}); |
213 | cdm.loadGLData(elt, value, null ); | 213 | cvsDataMngr.loadGLData(elt, value); |
214 | */ | 214 | */ |
215 | 215 | ||
216 | // /* | 216 | // /* |
@@ -454,55 +454,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
454 | } | 454 | } |
455 | }, | 455 | }, |
456 | 456 | ||
457 | /** | ||
458 | * Return the specified inline attribute from the element. | ||
459 | */ | ||
460 | GetElementAttribute: { | ||
461 | value: function(element, attribute) { | ||
462 | |||
463 | var value; | ||
464 | |||
465 | if(attribute === "src") { | ||
466 | return element[attribute].replace(window.location.href, ''); | ||
467 | } | ||
468 | |||
469 | value = element[attribute]; | ||
470 | |||
471 | if(value !== undefined) return value; | ||
472 | // if(value || value === false) return [value, "inline"]; | ||
473 | |||
474 | // 3. | ||
475 | //value = this._document.defaultView.getComputedStyle(element,null).getPropertyValue(attribute); | ||
476 | //if(value) return value; | ||
477 | |||
478 | return null; | ||
479 | } | ||
480 | }, | ||
481 | |||
482 | GetElementStyle: { | ||
483 | value: function(element, style) { | ||
484 | // return this._queryStylesheets(element, style); | ||
485 | } | ||
486 | }, | ||
487 | |||
488 | SetStyle: { | ||
489 | value: function(type, selector, style, value) { | ||
490 | try { | ||
491 | for(var j=0; j<this._stylesheets.length;j++){ | ||
492 | for(var i=0; i<this._stylesheets[j].cssRules.length;i++) { | ||
493 | if(this._stylesheets[j].cssRules[i].selectorText === type + selector) { | ||
494 | this._stylesheets[j].cssRules[i].style[style] = value; | ||
495 | |||
496 | return true; | ||
497 | } | ||
498 | } | ||
499 | } | ||
500 | } catch(err) { | ||
501 | console.log("Cannot change the style of selector: " + selector + " " + err); | ||
502 | } | ||
503 | } | ||
504 | }, | ||
505 | |||
506 | GetElementFromPoint: { | 457 | GetElementFromPoint: { |
507 | value: function(x, y) { | 458 | value: function(x, y) { |
508 | return this._window.getElement(x,y); | 459 | return this._window.getElement(x,y); |
@@ -919,97 +870,5 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
919 | //Error | 870 | //Error |
920 | } | 871 | } |
921 | } | 872 | } |
922 | }, | 873 | } |
923 | //////////////////////////////////////////////////////////////////// | ||
924 | saveAppState:{ | ||
925 | enumerable: false, | ||
926 | value: function () { | ||
927 | |||
928 | this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; | ||
929 | this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; | ||
930 | |||
931 | this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; | ||
932 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | ||
933 | |||
934 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ | ||
935 | this.selectionModel = this.application.ninja.selectedElements.slice(0); | ||
936 | } | ||
937 | |||
938 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | ||
939 | |||
940 | //persist a clone of history per document | ||
941 | this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); | ||
942 | this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); | ||
943 | this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start | ||
944 | |||
945 | //pause videos on switching or closing the document, so that the browser does not keep downloading the media data | ||
946 | this.pauseVideos(); | ||
947 | } | ||
948 | }, | ||
949 | |||
950 | //////////////////////////////////////////////////////////////////// | ||
951 | restoreAppState:{ | ||
952 | enumerable: false, | ||
953 | value: function () { | ||
954 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | ||
955 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | ||
956 | |||
957 | if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ | ||
958 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; | ||
959 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; | ||
960 | this.application.ninja.stage.handleScroll(); | ||
961 | } | ||
962 | |||
963 | this.application.ninja.currentSelectedContainer = this.documentRoot; | ||
964 | if(this.selectionModel){ | ||
965 | this.application.ninja.selectedElements = this.selectionModel.slice(0); | ||
966 | } | ||
967 | |||
968 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | ||
969 | |||
970 | this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); | ||
971 | this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); | ||
972 | |||
973 | |||
974 | } | ||
975 | }, | ||
976 | //////////////////////////////////////////////////////////////////// | ||
977 | /** | ||
978 | *pause videos on switching or closing the document, so that the browser does not keep downloading the media data | ||
979 | */ | ||
980 | pauseVideos:{ | ||
981 | value:function(){ | ||
982 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
983 | for(i=0;i<videosArr.length;i++){ | ||
984 | if(!videosArr[i].paused){ | ||
985 | videosArr[i].pause(); | ||
986 | } | ||
987 | } | ||
988 | } | ||
989 | }, | ||
990 | |||
991 | /** | ||
992 | * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected | ||
993 | *removeSrc : boolean to remove the src if the video... set only in the close document flow | ||
994 | */ | ||
995 | stopVideos:{ | ||
996 | value:function(){ | ||
997 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
998 | for(i=0;i<videosArr.length;i++){ | ||
999 | videosArr[i].src = ""; | ||
1000 | } | ||
1001 | } | ||
1002 | }, | ||
1003 | pauseAndStopVideos:{ | ||
1004 | value:function(){ | ||
1005 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
1006 | for(i=0;i<videosArr.length;i++){ | ||
1007 | if(!videosArr[i].paused){ | ||
1008 | videosArr[i].pause(); | ||
1009 | } | ||
1010 | videosArr[i].src = ""; | ||
1011 | } | ||
1012 | } | ||
1013 | } | ||
1014 | //////////////////////////////////////////////////////////////////// | ||
1015 | }); \ No newline at end of file | 874 | }); \ No newline at end of file |
diff --git a/js/document/text-document.js b/js/document/_toDelete/text-document.js index 2574b67c..2574b67c 100755 --- a/js/document/text-document.js +++ b/js/document/_toDelete/text-document.js | |||
diff --git a/js/document/document-html.js b/js/document/document-html.js index 89717dd6..c60a12a2 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -6,361 +6,172 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component, |
11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel; | 11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, |
12 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; | ||