CreatePageFromTemplate

    目次
    ヘッダーがありません
    /***
    
        CreatePageFromTemplate(templateName, buttonName)
    
    ***/
    
    dekiapi();
    jquery.ui('smoothness');
    
    var templatename = ($templatename ?? $0);
    var buttonname = ($buttonname ?? $1);
    var buttontext = "Enter " .. string.tolower(buttonname) .. " name";
    
    <div id="newpagediv">
        <table id="newpagetable" style="width:100%;" class="table">
            <tr>
                <th id="nptth">
                    "Create " .. buttonname;
                </th>
            </tr>
            <tr>
                <td>
                    <div id="waitdiv">
                        template("MindTouch/Controls/WaitingIcon32x32");
                        <br />
                        "Please wait...";
                    </div>
                    <div id="creatediv">
                        template("MindTouch/Controls/TextBox", { 
                            id: "pname", 
                            text: buttontext, 
                            class: ""
                        });
                        <input type="hidden" value=(page.path) id="ppath"/>
                        <input type="hidden" value=('Template:' .. templatename) id="tp"/>
                        <input type="hidden" value=(site.uri) id="siteuri"/>
                        <br />
                        <br />
                        <input type="button" value=(buttonname) ctor="
                            var working = false;
                            when($this.click) {
                                if (working == false) {
                                    working = true;
                                    #creatediv.hide();
                                    #waitdiv.show();
                                    @newpage({
                                        siteuri: #siteuri.val(), 
                                        pname: #pname.val(), 
                                        ppath: #ppath.val(), 
                                        tpath: #tp.val() 
                                    });
                                };
                            }
                            
                            when(@newpage) {
                                var page_path = @newpage.ppath + '/' + @newpage.pname;
                                var page_api = MindTouch.Deki.GetPageApi(Deki.Env.SiteApi, page_path);
                                MindTouch.Web.Get(page_api, null, function(xhr) {
                                    if(xhr.status == '200') {
                                        alert('That page already exists. Please choose a different name.');
                                        #creatediv.show();
                                        #waitdiv.hide();
                                        #pname.val('Enter ' + {{ string.tolower(buttonname) }} + ' name');
                                        working = false;
                                    } else if(xhr.status == '404') { 
                                        var template_api = MindTouch.Deki.GetPageApi(Deki.Env.SiteApi, @newpage.tpath);
                                        MindTouch.Deki.CreatePageFromTemplate(page_api, template_api, function() {
                                            @loadnewpage({ 
                                                siteuri: @newpage.siteuri, 
                                                ppath: @newpage.ppath, 
                                                pname: @newpage.pname
                                            }); 
                                        }, function() {
                                            alert('Page create failed. Please try again.');
                                            working = false;
                                        });
                                    }
                                });
                            };
                
                            when(@loadnewpage) {
                                var newpath = (@loadnewpage.siteuri + @loadnewpage.ppath + '/' + @loadnewpage.pname);
                                window.location = newpath;
                            };
                        " /> 
                    </div>
                </td>
            </tr>
        </table>
    </div>
    
    
    <div><style type="text/css">"
    #pname {
    font-style: italic; 
    color: #778899;
    }
    
    #newpagetable {
        width: 100% !important;
    }
    
    #newpagetable #nptth {
        text-align: center !important;
    }
    
    #waitdiv {
        display: none;
        text-align: center;
    }
    
    #creatediv {
        text-align: center;
    }
    
    "</style></div>
    タグ (タグ編集)
    • No tags

    ファイル 0

     
    あなたはコメントを投稿するには ログイン しなければなりません。
    Powered by MindTouch Core