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