rsaccon / Bespin playground (http://rsaccon.com/)

No description has been added.

commit 870: ae93e926e392
parent 869: 195e9be4f6f3
branch: default
[mq]: preview
rsaccon
12 months ago

Changed (Δ3.1 KB):

raw changeset »

frontend/css/editor.css (10 lines added, 1 lines removed)

frontend/editor.html (1 lines added, 0 lines removed)

frontend/js/bespin/client/settings.js (1 lines added, 0 lines removed)

frontend/js/bespin/cmd/commands.js (11 lines added, 3 lines removed)

frontend/js/bespin/events.js (52 lines added, 4 lines removed)

frontend/js/bespin/page/editor/dependencies.js (1 lines added, 0 lines removed)

frontend/js/bespin/page/index/dependencies.js (0 lines added, 1 lines removed)

frontend/js/bespin/user/register.js (2 lines added, 4 lines removed)

frontend/js/bespin/user/utils.js (1 lines added, 1 lines removed)

frontend/js/bespin/util/webpieces.js (7 lines added, 4 lines removed)

Up to file-list frontend/css/editor.css:

@@ -39,6 +39,15 @@ body {
39
39
    cursor: text !important;
40
40
}
41
41
42
#preview {
43
    position: absolute;
44
    top: 32px;
45
    bottom:33px;
46
    right: 0px;
47
    left: 0px;
48
    z-index: -1;
49
}
50
42
51
#filelist {
43
52
    position: absolute;
44
53
    margin: 0;
@@ -58,7 +67,7 @@ body {
58
67
    background: url("../images/background_white_50.png");
59
68
    -moz-border-radius: 10px;
60
69
    -webkit-border-radius: 10px;
61
    padding: 10px;    
70
    padding: 10px;
62
71
    -moz-opaque: true;
63
72
}
64
73

Up to file-list frontend/editor.html:

74
74
        <img id="toolbar_fontsize" src="images/icn_fontsize.png" alt="Font Size" title="Font Size">
75
75
    </div>
76
76
  	<div id="editor"></div>
77
	<div id="preview" style="display:none"></div>
77
78
    <div id="footer">
78
79
        <table cellpadding="0">
79
80
            <tr>

Up to file-list frontend/js/bespin/client/settings.js:

@@ -70,6 +70,7 @@ dojo.declare("bespin.client.settings.Cor
70
70
            'language': 'auto',
71
71
            'strictlines': 'on',
72
72
            'syntaxengine': 'simple',
73
            'preview': 'window',
73
74
            'tabarrow': 'on'
74
75
        };
75
76
    },

Up to file-list frontend/js/bespin/cmd/commands.js:

@@ -738,11 +738,19 @@ bespin.cmd.commands.add({
738
738
            });
739
739
        });
740
740
741
        bespin.util.webpieces.showCenterPopup(el);
742
743
        dojo.byId("overlay").onclick = dojo.byId("upload-close").onclick = function() {
741
        bespin.util.webpieces.showCenterPopup(el, true);
742
        
743
        // TODO: refactor this block into webpieces if popup is modal
744
        // pass the uploadClose DOM element as parameter to showCenterPopup
745
        var uploadClose, overlay;
746
        var hideCenterPopup = function(){
747
            el.removeChild(el.firstChild); 
744
748
            bespin.util.webpieces.hideCenterPopup(el);
749
            dojo.disconnect(uploadClose);
750
            dojo.disconnect(overlay);            
745
751
        };
752
        uploadClose = dojo.connect(dojo.byId("upload-close"), "onclick", hideCenterPopup);
753
        overlay = dojo.connect(dojo.byId("overlay"), "onclick", hideCenterPopup);
746
754
    },
747
755
748
756
    // ** {{{execute}}}

Up to file-list frontend/js/bespin/events.js:

@@ -73,20 +73,68 @@ bespin.subscribe("editor:evalfile", func
73
73
});
74
74
75
75
// ** {{{ Event: editor:preview }}} **
76
// 
76
//
77
77
// Preview the given file in a browser context
78
78
bespin.subscribe("editor:preview", function(event) {
79
79
    var editSession = bespin.get('editSession');
80
80
    var filename = event.filename || editSession.path;  // default to current page
81
    var project  = event.project  || editSession.project; 
81
    var project  = event.project  || editSession.project;
82
    var url = bespin.util.path.combine("preview/at", project, filename);
83
    var settings = bespin.get("settings");
82
84
83
85
    // Make sure to save the file first
84
86
    bespin.publish("editor:savefile", {
85
87
        filename: filename
86
88
    });
87
89
88
    if (filename) {
89
        window.open(bespin.util.path.combine("preview/at", project, filename));
90
    if (settings && filename) {
91
        var type = settings.get("preview");
92
        if (type == "inline") {
93
            var preview = dojo.byId("preview");
94
            var subheader = dojo.byId("subheader");
95
            var editor = dojo.byId("editor");
96
            if (dojo.style(preview, "display") == "none") {
97
                dojo.style(editor, "display", "none");
98
                dojo.style(subheader, "display", "none");
99
                dojo.style(preview, "display", "block");
100
                var inlineIframe = dojo.create("iframe", {
101
                    frameBorder: 0,
102
                    src: url,
103
                    style: "border:0; width:100%; height:100%; background-color: white; display:block"
104
                }, preview);
105
                var esc = dojo.connect(document, "onkeypress", function(e) {
106
                    var key = e.keyCode || e.charCode;
107
                    if (key == dojo.keys.ESCAPE) {
108
                        preview.removeChild(inlineIframe);
109
                        dojo.style(preview, "display", "none");
110
                        dojo.style(subheader, "display", "block");
111
                        dojo.style(editor, "display", "block"); 
112
                        dojo.disconnect(esc); 
113
                }
114
            });
115
            }
116
        } else if (type == "iphone") {
117
            var centerpopup = dojo.byId("centerpopup");
118
            if (dojo.byId("iphoneIframe") == null) {
119
                var iphoneIframe = dojo.create("iframe", {
120
                    id: "iphoneIframe",
121
                    frameBorder: 0,
122
                    src: url,
123
                    style: "border:0; width:320px; height:460px; background-color: white; display:block"
124
                }, centerpopup);
125
                bespin.util.webpieces.showCenterPopup(centerpopup);
126
                var esc = dojo.connect(document, "onkeypress", function(e) {
127
                    var key = e.keyCode || e.charCode;
128
                    if (key == dojo.keys.ESCAPE) {
129
                        centerpopup.removeChild(iphoneIframe);
130
                        bespin.util.webpieces.hideCenterPopup(centerpopup);
131
                        dojo.disconnect(esc);
132
                    }
133
                });
134
            }
135
        } else {
136
            window.open(url);
137
        }
90
138
    }
91
139
});
92
140

Up to file-list frontend/js/bespin/page/editor/dependencies.js:

@@ -37,6 +37,7 @@ dojo.require("bespin.util.tokenobject");
37
37
dojo.require("bespin.util.util");
38
38
dojo.require("bespin.util.mousewheelevent");
39
39
dojo.require("bespin.util.urlbar");
40
dojo.require("bespin.util.webpieces"); 
40
41
41
42
dojo.require("bespin.client.filesystem");
42
43
dojo.require("bespin.client.settings");

Up to file-list frontend/js/bespin/page/index/dependencies.js:

25
25
dojo.provide("bespin.page.index.dependencies");
26
26
27
27
dojo.require("dojo.cookie");
28
dojo.require("dijit._base.place");
29
28
30
29
dojo.require("bespin.bespin");
31
30
dojo.require("bespin.util.navigate");

Up to file-list frontend/js/bespin/user/register.js:

@@ -88,10 +88,8 @@ dojo.provide("bespin.user.register");
88
88
        showForm: function() {
89
89
            if (utils.showingBrowserCompatScreen()) return;
90
90
            dojo.style('logged_in', 'display', 'none');
91
            dojo.style('not_logged_in', 'display', 'none');
92
            dojo.style('overlay', 'display', 'block');
93
            dojo.style('centerpopup', 'display', 'block');            
94
            webpieces.showCenterPopup(dojo.byId('centerpopup'));  
91
            dojo.style('not_logged_in', 'display', 'none');           
92
            webpieces.showCenterPopup(dojo.byId('centerpopup'), true);  
95
93
        },
96
94
        hideForm: function() {
97
95
            webpieces.hideCenterPopup(dojo.byId('centerpopup'));

Up to file-list frontend/js/bespin/user/utils.js:

@@ -67,7 +67,7 @@ dojo.mixin(bespin.user.utils, {
67
67
68
68
    showingBrowserCompatScreen: function() {
69
69
       if (!this.checkBrowserAbility()) { // if you don't have the ability
70
            bespin.util.webpieces.showCenterPopup(dojo.byId('browser_not_compat'));
70
            bespin.util.webpieces.showCenterPopup(dojo.byId('browser_not_compat'), true);
71
71
72
72
            return true;
73
73
        } else {

Up to file-list frontend/js/bespin/util/webpieces.js:

24
24
25
25
dojo.provide("bespin.util.webpieces");
26
26
27
dojo.require("dijit._base.place"); 
28
27
29
// = Utility functions for Web snippets =
28
30
//
29
31
// There are little widgets and components that we want to reuse
30
32
31
33
dojo.mixin(bespin.util.webpieces, {
32
34
    // -- Center Popup
33
    showCenterPopup: function(el) {
34
        this.showOverlay();
35
    showCenterPopup: function(el, isModal) {
36
        if (isModal) {
37
            this.showOverlay();
38
        }
35
39
        dojo.style(el, 'display', 'block');
36
40
37
41
        // retrieve required dimensions
@@ -57,7 +61,7 @@ dojo.mixin(bespin.util.webpieces, {
57
61
58
62
    // -- Overlay
59
63
    
60
    showOverlay: function() {
64
    showOverlay: function() { 
61
65
        dojo.style('overlay', 'display', 'block');
62
66
    },
63
67
@@ -79,5 +83,4 @@ dojo.mixin(bespin.util.webpieces, {
79
83
        dojo.byId("status").innerHTML = msg;
80
84
        dojo.style('status', 'display', 'block');
81
85
    }
82
83
86
});