Commit fcaea2c6101cfa870fc87be7abcc55051b0e47bf

  • avatar
  • Ajay <ajay @serv…ots.com>
  • Fri Jan 20 23:26:22 IST 2012
Page edit changes
  
11function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, successUrl)
22{
33
4 var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue,locSel='',langSel='';
4 var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue;
55 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;
66
77 /**
4747 buffer.push(string);
4848 return this;
4949 };
50 console.log("inside buffer");
51 console.log(buffer);
50
5251 this.toString = function toString() {
5352 return buffer.join('');
5453 };
17491749 target.appendChild(author);
17501750
17511751 ourcheck = document.createElement("input");
1752 ourcheck.setAttribute("id","our-check");
1752 ourcheck.setAttribute("id","your-check");
17531753 ourcheck.setAttribute("type","radio");
17541754 ourcheck.setAttribute("name", "blog");
17551755 ourcheck.setAttribute("alipielements", "alipi");
17571757 target.appendChild(ourcheck);
17581758
17591759 yourcheck = document.createElement("input");
1760 yourcheck.setAttribute("id","your-check");
1760 yourcheck.setAttribute("id","our-check");
17611761 yourcheck.setAttribute("type","radio");
17621762 yourcheck.setAttribute("name", "blog");
17631763 yourcheck.setAttribute("alipielements", "alipi");
17821782 locButton.setAttribute("style","position:absolute;top:5%;left:90%;width:20px;");
17831783 locButton.setAttribute("alipielements", "alipi");
17841784 //locButton.setAttribute("type","button");
1785 target.appendChild(locButton);
1786
1785 if (window.location.hostname != '127.0.0.1') {
1786 target.appendChild(locButton);
1787 }
1788
17871789 langButton = document.createElement("input");
17881790 langButton.setAttribute("id","lang-bt");
17891791 langButton.setAttribute("title","Set your preferred location");
17941794 langButton.setAttribute("style","position:absolute;top:25%;left:90%;width:20px;");
17951795 langButton.setAttribute("alipielements", "alipi");
17961796 //locButton.setAttribute("type","button");
1797 target.appendChild(langButton);
1798
1797 if (window.location.hostname != '127.0.0.1') {
1798 target.appendChild(langButton);
1799 }
17991800 }
1801
18001802 this.activate = function activate() {
18011803 $(function() {
18021804 $( "#targetoverlay" ).dialog({
18121812 }
18131813 },
18141814 close: function() {
1815 $( "#targetoverlay" ).hide();
1815 $( "#targetoverlay" ).remove();
18161816 },
18171817 });
18181818 });
18211821 if(document.getElementById('loc-bt').value == '+'){
18221822 //remove input field and create a combo box
18231823 $('#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");
18261826 locSel.setAttribute("id","loct-select");
18271827 locSel.setAttribute("type","text");
18281828 locSel.setAttribute("alipielements", "alipi");
18291829 locSel.setAttribute("style","position:absolute;top:5%;left:40%;width:250px;");
18301830 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);
18351835 }
18361836 target.appendChild(locSel);
1837
1838 document.getElementById('loc-bt').value = '-';
1837 locButton.value = '-';
18391838 }
18401839 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 = '+';
18461844 }
1847
1848
1845
1846
18491847 });
18501848
18511849 $("#lang-bt").click(function () {
18521850 if(document.getElementById('lang-bt').value == '+'){
18531851 //remove input field and create a combo box
18541852 $('#lang-select').hide();
1855 var def_lang = ['Sinhala','Tamil','English'];
1853 var def_lang = ['Srilanka','su','sa'];
18561854 langSel= document.createElement("select");
18571855 langSel.setAttribute("id","langs-select");
18581856 langSel.setAttribute("type","text");
18591857 langSel.setAttribute("alipielements", "alipi");
18601858 langSel.setAttribute("style","position:absolute;top:25%;left:40%;width:250px;");
18611859 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);
18661864 }
18671865 target.appendChild(langSel);
1868
1869 document.getElementById('lang-bt').value = '-';
1866
1867 langButton.value = '-';
18701868 }
18711869 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 = '+';
18771874 }
1875
18781876
1879
18801877 });
18811878
18821879
30203020 publishButton.setAttribute("Value", "Publish");
30213021 publishButton.setAttribute("style", "position:fixed;top:0;right:5%;font-size:18px;font-weight:bold;width:100px;height:30px;");
30223022 overlayDiv.appendChild(publishButton);
3023 var dialog = 0;
3023 // var dialog = 0;
30243024 publishButton.onclick = function publishButtonOnClick() {
3025 if (pageEditor.hasChangesPending() /* && (pageEditor.formUncomplete() ==false) */ ) {
3025 if (pageEditor.hasChangesPending()) {
30263026 targetWindow = new TargetWindow(pageEditor);
3027 if (dialog == 0) {
3027 // if (dialog == 0) {
30283028 targetWindow.createDialogBox();
3029 dialog = 1;
3030 }
3029 // dialog = 1;
3030 // }
30313031 targetWindow.activate();
30323032 } else {
30333033 pageEditor.showMessage("Nothing to post");
30353035 };
30363036
30373037
3038
3038
30393039 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 {
30473044 pageEditor.commandPublish();
30483045 pageEditor.showMessage("... Please wait, your blog is being posted");
30493046 $('#targetoverlay').remove();
30503047 }
30513048 };
30523049 // End of okButton function
3053
3050
30543051 this.show = function show(activate) {
30553052 var disabled = true;
30563053 var opacity = '0.4';
31883188 this.hasChangesPending = function hasChangesPending() {
31893189 return history.length > 0;
31903190 };
3191 this.formUncomplete = function formUnomplete(){
3192 return (locName == '' && langName=='' && styleName == '' );
3193 };
31943191
31953192 this.apply = function apply(command) {
31963193 var poofPosition, poofDiv;
33483348
33493349 this.publish = function publish() {
33503350 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
33523358 {
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 });
33563362 }
3357 else{
3358
3359 AJAX.post('http://localhost/test', buildDataString(), function(result) {
3360 ajaxResultProcessor.processPublishedResponse(result);
3361 });
3362 }
33633363 };
3364
3364
33653365 // this.switchMode = function switchMode(saveChanges) {
33663366 // var result, requestParameters;
33673367
34123412 buffer.append('about='); //url=about //removed '&' on purpose
34133413 buffer.append(window.location.search.split('=')[1]);
34143414 buffer.append('&lang=');//lang
3415 if (langName.value != "")
3415 if (langName.value != "" )
34163416 buffer.append(encodeURIComponent(langName.value));
3417 else
3418 buffer.append(encodeURIComponent(langSel.value));
3417 else
3418 buffer.append(encodeURIComponent(document.getElementById('langs-select').value));
34193419 buffer.append('&location=');//location
3420 if (locName.value != "")
3420 if (locName.value != '')
34213421 buffer.append(encodeURIComponent(locName.value));
34223422 else
3423 buffer.append(encodeURIComponent(locSel.value));
3423 buffer.append(encodeURIComponent(document.getElementById('loct-select').value));
34243424 buffer.append('&style=');//style
34253425 buffer.append(encodeURIComponent(styleSelect.value));
34263426 buffer.append('&blog='); //blog where to post
34703470 };
34713471
34723472
3473 this.formUncomplete = function fromUncomplete() {
3474 return editCommandHistory.formUncomplete();
3475 };
3476
34773473 this.show = function show() {
34783474
34793475 DOM.addListener('mouseover', function globalMouseOverListener(event) {
35173517 // passthrough
35183518 } else if (event.target.getAttribute('m4pageedittype')) {
35193519 // 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) {
35213521 // passthrough
35223522 } else if (event.clientX > document.body.clientWidth || event.clientY > document.body.clientHeight) {
35233523 // passthrough if this click was outside of the html page, meaning on a scrollbar