Commit fcaea2c6101cfa870fc87be7abcc55051b0e47bf
- server/wsgi/page_edit.js 142 ----------------------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Diff rendering mode:
- inline
- side by side
server/wsgi/page_edit.js
1 | function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, successUrl) | 1 | function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, successUrl) |
---|---|---|---|
2 | { | 2 | { |
3 | 3 | ||
4 | 4 | var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue; | |
5 | var editAttributes, elementAttributes, fontTypeAttributes, normalFontAttributes, popupContainerAttributes, editButtonAttributes, editTextInputAttributes, editSubmitAttributes, editTitleAttributes, panelButtonAttributes, buttonPanelAttributes, actionPanelAttributes, closeButtonAttributes, actionButtonAttributes, redButtonAttributes, leftBorderStyle, rightBorderStyle, titleButtonImageAttributes, titleButtonDisplayTextAttributes, actionButtonImageAttributes, actionButtonDisplayTextAttributes,greyArrowAttributes, pageEditor, splashWindow, loadingTimerId, keepOriginal = false; | 5 | var editAttributes, elementAttributes, fontTypeAttributes, normalFontAttributes, popupContainerAttributes, editButtonAttributes, editTextInputAttributes, editSubmitAttributes, editTitleAttributes, panelButtonAttributes, buttonPanelAttributes, actionPanelAttributes, closeButtonAttributes, actionButtonAttributes, redButtonAttributes, leftBorderStyle, rightBorderStyle, titleButtonImageAttributes, titleButtonDisplayTextAttributes, actionButtonImageAttributes, actionButtonDisplayTextAttributes,greyArrowAttributes, pageEditor, splashWindow, loadingTimerId, keepOriginal = false; |
6 | 6 | ||
7 | /** | 7 | /** |
… | … | ||
47 | buffer.push(string); | 47 | buffer.push(string); |
48 | return this; | 48 | return this; |
49 | }; | 49 | }; |
50 | |||
51 | 50 | ||
52 | this.toString = function toString() { | 51 | this.toString = function toString() { |
53 | return buffer.join(''); | 52 | return buffer.join(''); |
54 | }; | 53 | }; |
… | … | ||
1749 | target.appendChild(author); | 1749 | target.appendChild(author); |
1750 | 1750 | ||
1751 | ourcheck = document.createElement("input"); | 1751 | ourcheck = document.createElement("input"); |
1752 | 1752 | ourcheck.setAttribute("id","your-check"); | |
1753 | ourcheck.setAttribute("type","radio"); | 1753 | ourcheck.setAttribute("type","radio"); |
1754 | ourcheck.setAttribute("name", "blog"); | 1754 | ourcheck.setAttribute("name", "blog"); |
1755 | ourcheck.setAttribute("alipielements", "alipi"); | 1755 | ourcheck.setAttribute("alipielements", "alipi"); |
… | … | ||
1757 | target.appendChild(ourcheck); | 1757 | target.appendChild(ourcheck); |
1758 | 1758 | ||
1759 | yourcheck = document.createElement("input"); | 1759 | yourcheck = document.createElement("input"); |
1760 | 1760 | yourcheck.setAttribute("id","our-check"); | |
1761 | yourcheck.setAttribute("type","radio"); | 1761 | yourcheck.setAttribute("type","radio"); |
1762 | yourcheck.setAttribute("name", "blog"); | 1762 | yourcheck.setAttribute("name", "blog"); |
1763 | yourcheck.setAttribute("alipielements", "alipi"); | 1763 | yourcheck.setAttribute("alipielements", "alipi"); |
… | … | ||
1782 | locButton.setAttribute("style","position:absolute;top:5%;left:90%;width:20px;"); | 1782 | locButton.setAttribute("style","position:absolute;top:5%;left:90%;width:20px;"); |
1783 | locButton.setAttribute("alipielements", "alipi"); | 1783 | locButton.setAttribute("alipielements", "alipi"); |
1784 | //locButton.setAttribute("type","button"); | 1784 | //locButton.setAttribute("type","button"); |
1785 | |||
1786 | 1785 | if (window.location.hostname != '127.0.0.1') { | |
1786 | target.appendChild(locButton); | ||
1787 | } | ||
1788 | |||
1787 | langButton = document.createElement("input"); | 1789 | langButton = document.createElement("input"); |
1788 | langButton.setAttribute("id","lang-bt"); | 1790 | langButton.setAttribute("id","lang-bt"); |
1789 | langButton.setAttribute("title","Set your preferred location"); | 1791 | langButton.setAttribute("title","Set your preferred location"); |
… | … | ||
1794 | langButton.setAttribute("style","position:absolute;top:25%;left:90%;width:20px;"); | 1794 | langButton.setAttribute("style","position:absolute;top:25%;left:90%;width:20px;"); |
1795 | langButton.setAttribute("alipielements", "alipi"); | 1795 | langButton.setAttribute("alipielements", "alipi"); |
1796 | //locButton.setAttribute("type","button"); | 1796 | //locButton.setAttribute("type","button"); |
1797 | |||
1798 | 1797 | if (window.location.hostname != '127.0.0.1') { | |
1798 | target.appendChild(langButton); | ||
1799 | } | ||
1799 | } | 1800 | } |
1801 | |||
1800 | this.activate = function activate() { | 1802 | this.activate = function activate() { |
1801 | $(function() { | 1803 | $(function() { |
1802 | $( "#targetoverlay" ).dialog({ | 1804 | $( "#targetoverlay" ).dialog({ |
… | … | ||
1812 | } | 1812 | } |
1813 | }, | 1813 | }, |
1814 | close: function() { | 1814 | close: function() { |
1815 | 1815 | $( "#targetoverlay" ).remove(); | |
1816 | }, | 1816 | }, |
1817 | }); | 1817 | }); |
1818 | }); | 1818 | }); |
… | … | ||
1821 | if(document.getElementById('loc-bt').value == '+'){ | 1821 | if(document.getElementById('loc-bt').value == '+'){ |
1822 | //remove input field and create a combo box | 1822 | //remove input field and create a combo box |
1823 | $('#loc-select').hide(); | 1823 | $('#loc-select').hide(); |
1824 | |||
1825 | 1824 | var def_loc = ['Srilanka','su','sa']; | |
1825 | locSel = document.createElement("select"); | ||
1826 | locSel.setAttribute("id","loct-select"); | 1826 | locSel.setAttribute("id","loct-select"); |
1827 | locSel.setAttribute("type","text"); | 1827 | locSel.setAttribute("type","text"); |
1828 | locSel.setAttribute("alipielements", "alipi"); | 1828 | locSel.setAttribute("alipielements", "alipi"); |
1829 | locSel.setAttribute("style","position:absolute;top:5%;left:40%;width:250px;"); | 1829 | locSel.setAttribute("style","position:absolute;top:5%;left:40%;width:250px;"); |
1830 | for(i=0;i<def_loc.length;i++){ | 1830 | for(i=0;i<def_loc.length;i++){ |
1831 | |||
1832 | |||
1833 | |||
1834 | 1831 | locopt = document.createElement("option"); | |
1832 | theText=document.createTextNode(def_loc[i]); | ||
1833 | locopt.appendChild(theText); | ||
1834 | locSel.appendChild(locopt); | ||
1835 | } | 1835 | } |
1836 | target.appendChild(locSel); | 1836 | target.appendChild(locSel); |
1837 | |||
1838 | 1837 | locButton.value = '-'; | |
1839 | } | 1838 | } |
1840 | else if(document.getElementById('loc-bt').value == '-'){ | 1839 | else if(document.getElementById('loc-bt').value == '-'){ |
1841 | |||
1842 | |||
1843 | |||
1844 | |||
1845 | 1840 | //show the input field and remove combo box | |
1841 | target.removeChild(locSel); | ||
1842 | $('#loc-select').show(); | ||
1843 | locButton.value = '+'; | ||
1846 | } | 1844 | } |
1847 | |||
1848 | 1845 | ||
1846 | |||
1849 | }); | 1847 | }); |
1850 | 1848 | ||
1851 | $("#lang-bt").click(function () { | 1849 | $("#lang-bt").click(function () { |
1852 | if(document.getElementById('lang-bt').value == '+'){ | 1850 | if(document.getElementById('lang-bt').value == '+'){ |
1853 | //remove input field and create a combo box | 1851 | //remove input field and create a combo box |
1854 | $('#lang-select').hide(); | 1852 | $('#lang-select').hide(); |
1855 | 1853 | var def_lang = ['Srilanka','su','sa']; | |
1856 | langSel= document.createElement("select"); | 1854 | langSel= document.createElement("select"); |
1857 | langSel.setAttribute("id","langs-select"); | 1855 | langSel.setAttribute("id","langs-select"); |
1858 | langSel.setAttribute("type","text"); | 1856 | langSel.setAttribute("type","text"); |
1859 | langSel.setAttribute("alipielements", "alipi"); | 1857 | langSel.setAttribute("alipielements", "alipi"); |
1860 | langSel.setAttribute("style","position:absolute;top:25%;left:40%;width:250px;"); | 1858 | langSel.setAttribute("style","position:absolute;top:25%;left:40%;width:250px;"); |
1861 | for(i=0;i<def_lang.length;i++){ | 1859 | for(i=0;i<def_lang.length;i++){ |
1862 | |||
1863 | |||
1864 | |||
1865 | 1860 | langopt = document.createElement("option"); | |
1861 | theText=document.createTextNode(def_lang[i]); | ||
1862 | langopt.appendChild(theText); | ||
1863 | langSel.appendChild(langopt); | ||
1866 | } | 1864 | } |
1867 | target.appendChild(langSel); | 1865 | target.appendChild(langSel); |
1868 | |||
1869 | 1866 | ||
1867 | langButton.value = '-'; | ||
1870 | } | 1868 | } |
1871 | else if(document.getElementById('lang-bt').value == '-'){ | 1869 | else if(document.getElementById('lang-bt').value == '-'){ |
1872 | |||
1873 | |||
1874 | |||
1875 | |||
1876 | 1870 | //show the input field and remove combo box | |
1871 | $('#lang-select').show(); | ||
1872 | target.removeChild(langSel); | ||
1873 | langButton.value = '+'; | ||
1877 | } | 1874 | } |
1875 | |||
1878 | 1876 | ||
1879 | |||
1880 | }); | 1877 | }); |
1881 | 1878 | ||
1882 | 1879 | ||
… | … | ||
3020 | publishButton.setAttribute("Value", "Publish"); | 3020 | publishButton.setAttribute("Value", "Publish"); |
3021 | publishButton.setAttribute("style", "position:fixed;top:0;right:5%;font-size:18px;font-weight:bold;width:100px;height:30px;"); | 3021 | publishButton.setAttribute("style", "position:fixed;top:0;right:5%;font-size:18px;font-weight:bold;width:100px;height:30px;"); |
3022 | overlayDiv.appendChild(publishButton); | 3022 | overlayDiv.appendChild(publishButton); |
3023 | 3023 | // var dialog = 0; | |
3024 | publishButton.onclick = function publishButtonOnClick() { | 3024 | publishButton.onclick = function publishButtonOnClick() { |
3025 | 3025 | if (pageEditor.hasChangesPending()) { | |
3026 | targetWindow = new TargetWindow(pageEditor); | 3026 | targetWindow = new TargetWindow(pageEditor); |
3027 | 3027 | // if (dialog == 0) { | |
3028 | targetWindow.createDialogBox(); | 3028 | targetWindow.createDialogBox(); |
3029 | |||
3030 | 3029 | // dialog = 1; | |
3030 | // } | ||
3031 | targetWindow.activate(); | 3031 | targetWindow.activate(); |
3032 | } else { | 3032 | } else { |
3033 | pageEditor.showMessage("Nothing to post"); | 3033 | pageEditor.showMessage("Nothing to post"); |
… | … | ||
3035 | }; | 3035 | }; |
3036 | 3036 | ||
3037 | 3037 | ||
3038 | 3038 | ||
3039 | this.blogpost = function blogpost() { | 3039 | this.blogpost = function blogpost() { |
3040 | |||
3041 | |||
3042 | |||
3043 | |||
3044 | |||
3045 | |||
3046 | 3040 | if((locName.value == "" && document.getElementById("loct-select") === null) || (langName.value == "" && document.getElementById("langs-select") === null) || styleSelect.value == "" || author.value == "" || (ourcheck.checked == false && yourcheck.checked == false)) { | |
3041 | alert("Please give all the details, it will be used further"); | ||
3042 | } | ||
3043 | else { | ||
3047 | pageEditor.commandPublish(); | 3044 | pageEditor.commandPublish(); |
3048 | pageEditor.showMessage("... Please wait, your blog is being posted"); | 3045 | pageEditor.showMessage("... Please wait, your blog is being posted"); |
3049 | $('#targetoverlay').remove(); | 3046 | $('#targetoverlay').remove(); |
3050 | } | 3047 | } |
3051 | }; | 3048 | }; |
3052 | // End of okButton function | 3049 | // End of okButton function |
3053 | 3050 | ||
3054 | this.show = function show(activate) { | 3051 | this.show = function show(activate) { |
3055 | var disabled = true; | 3052 | var disabled = true; |
3056 | var opacity = '0.4'; | 3053 | var opacity = '0.4'; |
… | … | ||
3188 | this.hasChangesPending = function hasChangesPending() { | 3188 | this.hasChangesPending = function hasChangesPending() { |
3189 | return history.length > 0; | 3189 | return history.length > 0; |
3190 | }; | 3190 | }; |
3191 | |||
3192 | |||
3193 | |||
3194 | 3191 | ||
3195 | this.apply = function apply(command) { | 3192 | this.apply = function apply(command) { |
3196 | var poofPosition, poofDiv; | 3193 | var poofPosition, poofDiv; |
… | … | ||
3348 | 3348 | ||
3349 | this.publish = function publish() { | 3349 | this.publish = function publish() { |
3350 | var result; | 3350 | var result; |
3351 | 3351 | if(document.getElementById('our-check').checked) | |
3352 | { | ||
3353 | localStorage.myContent = buildDataString(); | ||
3354 | window.location.href = "http://localhost/test.html"; | ||
3355 | window.reload(); | ||
3356 | } | ||
3357 | else | ||
3352 | { | 3358 | { |
3353 | |||
3354 | |||
3355 | 3359 | AJAX.post('http://localhost/test', buildDataString(), function(result) { | |
3360 | ajaxResultProcessor.processPublishedResponse(result); | ||
3361 | }); | ||
3356 | } | 3362 | } |
3357 | |||
3358 | |||
3359 | |||
3360 | |||
3361 | |||
3362 | |||
3363 | }; | 3363 | }; |
3364 | 3364 | ||
3365 | // this.switchMode = function switchMode(saveChanges) { | 3365 | // this.switchMode = function switchMode(saveChanges) { |
3366 | // var result, requestParameters; | 3366 | // var result, requestParameters; |
3367 | 3367 | ||
… | … | ||
3412 | buffer.append('about='); //url=about //removed '&' on purpose | 3412 | buffer.append('about='); //url=about //removed '&' on purpose |
3413 | buffer.append(window.location.search.split('=')[1]); | 3413 | buffer.append(window.location.search.split('=')[1]); |
3414 | buffer.append('&lang=');//lang | 3414 | buffer.append('&lang=');//lang |
3415 | 3415 | if (langName.value != "" ) | |
3416 | buffer.append(encodeURIComponent(langName.value)); | 3416 | buffer.append(encodeURIComponent(langName.value)); |
3417 | |||
3418 | 3417 | else | |
3418 | buffer.append(encodeURIComponent(document.getElementById('langs-select').value)); | ||
3419 | buffer.append('&location=');//location | 3419 | buffer.append('&location=');//location |
3420 | 3420 | if (locName.value != '') | |
3421 | buffer.append(encodeURIComponent(locName.value)); | 3421 | buffer.append(encodeURIComponent(locName.value)); |
3422 | else | 3422 | else |
3423 | 3423 | buffer.append(encodeURIComponent(document.getElementById('loct-select').value)); | |
3424 | buffer.append('&style=');//style | 3424 | buffer.append('&style=');//style |
3425 | buffer.append(encodeURIComponent(styleSelect.value)); | 3425 | buffer.append(encodeURIComponent(styleSelect.value)); |
3426 | buffer.append('&blog='); //blog where to post | 3426 | buffer.append('&blog='); //blog where to post |
… | … | ||
3470 | }; | 3470 | }; |
3471 | 3471 | ||
3472 | 3472 | ||
3473 | |||
3474 | |||
3475 | |||
3476 | |||
3477 | this.show = function show() { | 3473 | this.show = function show() { |
3478 | 3474 | ||
3479 | DOM.addListener('mouseover', function globalMouseOverListener(event) { | 3475 | DOM.addListener('mouseover', function globalMouseOverListener(event) { |
… | … | ||
3517 | // passthrough | 3517 | // passthrough |
3518 | } else if (event.target.getAttribute('m4pageedittype')) { | 3518 | } else if (event.target.getAttribute('m4pageedittype')) { |
3519 | // passthrough | 3519 | // passthrough |
3520 | 3520 | } else if (event.target.id == "lang-select" || event.target.id == "loc-select" || alipiElements) { | |
3521 | // passthrough | 3521 | // passthrough |
3522 | } else if (event.clientX > document.body.clientWidth || event.clientY > document.body.clientHeight) { | 3522 | } else if (event.clientX > document.body.clientWidth || event.clientY > document.body.clientHeight) { |
3523 | // passthrough if this click was outside of the html page, meaning on a scrollbar | 3523 | // passthrough if this click was outside of the html page, meaning on a scrollbar |