aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/components/menu/menu-item.reel/menu-item.js13
-rwxr-xr-xjs/controllers/document-controller.js26
-rwxr-xr-xjs/data/menu-data.js830
-rwxr-xr-xjs/document/text-document.js8
4 files changed, 481 insertions, 396 deletions
diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js
index 64a89a6a..8d975c4b 100755
--- a/js/components/menu/menu-item.reel/menu-item.js
+++ b/js/components/menu/menu-item.reel/menu-item.js
@@ -61,6 +61,8 @@ exports.MenuItem = Montage.create(Component, {
61 61
62 prepareForDraw: { 62 prepareForDraw: {
63 value: function() { 63 value: function() {
64 var boundObject = this.application.ninja, strArr = null, i=0;
65
64 if(!this.data) return; 66 if(!this.data) return;
65 67
66 if(this.data.separator) { 68 if(this.data.separator) {
@@ -82,9 +84,16 @@ exports.MenuItem = Montage.create(Component, {
82 } 84 }
83 85
84 if(this.data.enabled.boundProperty) { 86 if(this.data.enabled.boundProperty) {
87 strArr = this.data.enabled.boundObj.split(".");
88 for(i=0;i<strArr.length;i++){
89 boundObject = boundObject[strArr[i]];
90 }
91
85 Object.defineBinding(this, "enabled", { 92 Object.defineBinding(this, "enabled", {
86 boundObject: this.application.ninja[this.data.enabled.boundObj], 93 boundObject: boundObject,
87 boundObjectPropertyPath: this.data.enabled.boundProperty 94 boundObjectPropertyPath: this.data.enabled.boundProperty,
95 boundValueMutator: this.data.enabled.boundValueMutator,
96 oneway : this.data.enabled.oneway
88 }); 97 });
89 98
90 } else { 99 } else {
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 7d982a62..4363e440 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -32,22 +32,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
32 _iframeHolder: { value: null, enumerable: false }, 32 _iframeHolder: { value: null, enumerable: false },
33 _textHolder: { value: null, enumerable: false }, 33 _textHolder: { value: null, enumerable: false },
34 _codeMirrorCounter: {value: 1, enumerable: false}, 34 _codeMirrorCounter: {value: 1, enumerable: false},
35
36 canSave:{value: false},//for Save menu state update
37 canSaveAll:{value: false},//for Save All menu state update
35 38
36 activeDocument: { 39 activeDocument: {
37 get: function() { 40 get: function() {
38 return this._activeDocument; 41 return this._activeDocument;
39 }, 42 },
40 set: function(doc) { 43 set: function(doc) {
41 if(!!this._activeDocument) this._activeDocument.isActive = false; 44 if(!!this._activeDocument){ this._activeDocument.isActive = false;}
42
43 this._activeDocument = doc; 45 this._activeDocument = doc;
44 if(!!this._activeDocument){ 46 if(!!this._activeDocument){
45
46 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 47 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
47 this._activeDocument.isActive = true; 48 this._activeDocument.isActive = true;
49
48 if(!!this._activeDocument.editor){ 50 if(!!this._activeDocument.editor){
49 this._activeDocument.editor.focus(); 51 this._activeDocument.editor.focus();
50 } 52 }
53
54 this.canSave = doc.needsSave;
55 this.canSaveAll = doc.needsSave;
56 }else{
57 this.canSave = false;
58 this.canSaveAll = false;
51 } 59 }
52 } 60 }
53 }, 61 },
@@ -61,6 +69,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
61 this.eventManager.addEventListener("executeSaveAs", this, false); 69 this.eventManager.addEventListener("executeSaveAs", this, false);
62 this.eventManager.addEventListener("executeSaveAll", this, false); 70 this.eventManager.addEventListener("executeSaveAll", this, false);
63 this.eventManager.addEventListener("executeFileClose", this, false); 71 this.eventManager.addEventListener("executeFileClose", this, false);
72 this.eventManager.addEventListener("executeFileCloseAll", this, false);
64 73
65 this.eventManager.addEventListener("styleSheetDirty", this, false); 74 this.eventManager.addEventListener("styleSheetDirty", this, false);
66 75
@@ -172,6 +181,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
172 } 181 }
173 }, 182 },
174 //////////////////////////////////////////////////////////////////// 183 ////////////////////////////////////////////////////////////////////
184 handleExecuteFileCloseAll:{
185 value: function(event) {
186 var i=0;
187 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
188 while(this._documents.length > 0){
189 this.closeDocument(this._documents[this._documents.length -1].uuid);
190 }
191 }
192 }
193 },
194 ////////////////////////////////////////////////////////////////////
175 // 195 //
176 fileSaveResult: { 196 fileSaveResult: {
177 value: function (result) { 197 value: function (result) {
diff --git a/js/data/menu-data.js b/js/data/menu-data.js
index 40512f5d..093ecf14 100755
--- a/js/data/menu-data.js
+++ b/js/data/menu-data.js
@@ -4,414 +4,464 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage; 7var Montage = require("montage/core/core").Montage;
8 8
9exports.MenuData = Montage.create( Montage, { 9exports.MenuData = Montage.create( Montage, {
10 topLevelMenu: { 10 topLevelMenu: {
11 value: [ 11 value: [
12 { 12 {
13 "header": "File", 13 "header": "File",
14 "entries": [ 14 "entries": [
15 { 15 {
16 "displayText" : "New Project", 16 "displayText" : "New Project",
17 "hasSubMenu" : false, 17 "hasSubMenu" : false,
18 "enabled": false, 18 "enabled": false,
19 "action": "executeNewProject" 19 "action": "executeNewProject"
20 }, 20 },
21 { 21 {
22 "displayText" : "New File", 22 "displayText" : "New File",
23 "hasSubMenu" : false, 23 "hasSubMenu" : false,
24 "enabled": true, 24 "enabled": true,
25 "action": "executeNewFile" 25 "action": "executeNewFile"
26 }, 26 },
27 { 27 {
28 "displayText" : "Open File", 28 "displayText" : "Open File",
29 "hasSubMenu" : false, 29 "hasSubMenu" : false,
30 "enabled": true, 30 "enabled": true,
31 "action": "executeFileOpen" 31 "action": "executeFileOpen"
32 }, 32 },
33 { 33 {
34 "displayText" : "Close File", 34 "displayText" : "Close File",
35 "hasSubMenu" : false, 35 "hasSubMenu" : false,
36 "enabled": true, 36 "enabled": {
37 "action": "executeFileClose" 37 "value": false,
38 }, 38 "boundObj": "documentController",
39 { 39 "boundProperty": "activeDocument",
40 "displayText" : "", 40 "oneway": true,
41 "separator": true 41 "boundValueMutator": function(activeDocument){
42 }, 42 if(activeDocument !== null){return true;}
43 { 43 else{return false;}
44 "displayText" : "Save",
45 "hasSubMenu" : false,
46 "enabled": true,
47 "action": "executeSave"
48 },
49 {
50 "displayText" : "Save As",
51 "hasSubMenu" : false,
52 "enabled": true,
53 "action":"executeSaveAs"
54 },
55 {
56 "displayText" : "Save All",
57 "hasSubMenu" : false,
58 "enabled": true,
59 "action": "executeSaveAll"
60 },
61 {
62 "displayText" : "",
63 "separator": true
64 },
65 {
66 "displayText" : "Open Project",
67 "hasSubMenu" : false,
68 "enabled": false
69 },
70 {
71 "displayText" : "Open Recent",
72 "hasSubMenu" : false,
73 "enabled": false
74 },
75 {
76 "displayText" : "Close Project",
77 "hasSubMenu" : false,
78 "enabled": false
79 }
80 ]
81 },
82 {
83 "header": "Edit",
84 "entries": [
85 {
86 "displayText" : "Undo",
87 "hasSubMenu" : false,
88 "enabled": {
89 "value": false,
90 "boundObj": "undocontroller",
91 "boundProperty": "canUndo"
92 },
93 "action": "executeUndo"
94 },
95 {
96 "displayText" : "Redo",
97 "hasSubMenu" : false,
98 "enabled": {
99 "value": false,
100