From fcaea2c6101cfa870fc87be7abcc55051b0e47bf Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 20 Jan 2012 23:26:22 +0530 Subject: [PATCH] Page edit changes --- server/wsgi/page_edit.js | 142 +++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 76 deletions(-) diff --git a/server/wsgi/page_edit.js b/server/wsgi/page_edit.js index dea191d..d1cd20d 100755 --- a/server/wsgi/page_edit.js +++ b/server/wsgi/page_edit.js @@ -1,7 +1,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, successUrl) { - var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue,locSel='',langSel=''; + var console, PopupControl, M4ImageElement,locName='',langName = '',styleName='',authorValue; 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; /** @@ -47,8 +47,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, buffer.push(string); return this; }; - console.log("inside buffer"); - console.log(buffer); + this.toString = function toString() { return buffer.join(''); }; @@ -1750,7 +1749,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, target.appendChild(author); ourcheck = document.createElement("input"); - ourcheck.setAttribute("id","our-check"); + ourcheck.setAttribute("id","your-check"); ourcheck.setAttribute("type","radio"); ourcheck.setAttribute("name", "blog"); ourcheck.setAttribute("alipielements", "alipi"); @@ -1758,7 +1757,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, target.appendChild(ourcheck); yourcheck = document.createElement("input"); - yourcheck.setAttribute("id","your-check"); + yourcheck.setAttribute("id","our-check"); yourcheck.setAttribute("type","radio"); yourcheck.setAttribute("name", "blog"); yourcheck.setAttribute("alipielements", "alipi"); @@ -1783,8 +1782,10 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, locButton.setAttribute("style","position:absolute;top:5%;left:90%;width:20px;"); locButton.setAttribute("alipielements", "alipi"); //locButton.setAttribute("type","button"); - target.appendChild(locButton); - + if (window.location.hostname != '127.0.0.1') { + target.appendChild(locButton); + } + langButton = document.createElement("input"); langButton.setAttribute("id","lang-bt"); langButton.setAttribute("title","Set your preferred location"); @@ -1793,9 +1794,11 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, langButton.setAttribute("style","position:absolute;top:25%;left:90%;width:20px;"); langButton.setAttribute("alipielements", "alipi"); //locButton.setAttribute("type","button"); - target.appendChild(langButton); - + if (window.location.hostname != '127.0.0.1') { + target.appendChild(langButton); + } } + this.activate = function activate() { $(function() { $( "#targetoverlay" ).dialog({ @@ -1809,7 +1812,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, } }, close: function() { - $( "#targetoverlay" ).hide(); + $( "#targetoverlay" ).remove(); }, }); }); @@ -1818,61 +1821,58 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, if(document.getElementById('loc-bt').value == '+'){ //remove input field and create a combo box $('#loc-select').hide(); - var def_loc = ['Srilanka','Colombo','Moratuwa']; - locSel= document.createElement("select"); + var def_loc = ['Srilanka','su','sa']; + locSel = document.createElement("select"); locSel.setAttribute("id","loct-select"); locSel.setAttribute("type","text"); locSel.setAttribute("alipielements", "alipi"); locSel.setAttribute("style","position:absolute;top:5%;left:40%;width:250px;"); for(i=0;i 0; }; - this.formUncomplete = function formUnomplete(){ - return (locName == '' && langName=='' && styleName == '' ); - }; this.apply = function apply(command) { var poofPosition, poofDiv; @@ -3354,20 +3348,20 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, this.publish = function publish() { var result; - if(document.getElementById('your-check').checked && window.location.hostname !='y.a11y.in') + if(document.getElementById('our-check').checked) + { + localStorage.myContent = buildDataString(); + window.location.href = "http://localhost/test.html"; + window.reload(); + } + else { - localStorage.myContent = buildDataString(); - window.location.href = "http://localhost/test.html"; - window.reload(); + AJAX.post('http://localhost/test', buildDataString(), function(result) { + ajaxResultProcessor.processPublishedResponse(result); + }); } - else{ - - AJAX.post('http://localhost/test', buildDataString(), function(result) { - ajaxResultProcessor.processPublishedResponse(result); - }); - } }; - + // this.switchMode = function switchMode(saveChanges) { // var result, requestParameters; @@ -3418,15 +3412,15 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, buffer.append('about='); //url=about //removed '&' on purpose buffer.append(window.location.search.split('=')[1]); buffer.append('&lang=');//lang - if (langName.value != "") + if (langName.value != "" ) buffer.append(encodeURIComponent(langName.value)); - else - buffer.append(encodeURIComponent(langSel.value)); + else + buffer.append(encodeURIComponent(document.getElementById('langs-select').value)); buffer.append('&location=');//location - if (locName.value != "") + if (locName.value != '') buffer.append(encodeURIComponent(locName.value)); else - buffer.append(encodeURIComponent(locSel.value)); + buffer.append(encodeURIComponent(document.getElementById('loct-select').value)); buffer.append('&style=');//style buffer.append(encodeURIComponent(styleSelect.value)); buffer.append('&blog='); //blog where to post @@ -3476,10 +3470,6 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, }; - this.formUncomplete = function fromUncomplete() { - return editCommandHistory.formUncomplete(); - }; - this.show = function show() { DOM.addListener('mouseover', function globalMouseOverListener(event) { @@ -3527,7 +3517,7 @@ function page_edit( boltSlug, pageSlug, uploadSlug, editMode, hasEditPermission, // passthrough } else if (event.target.getAttribute('m4pageedittype')) { // passthrough - } else if (event.target.id == "lang-select" || event.target.id == "loc-select" || event.target.id == "loc-bt" || event.target.id == "lang-bt" || alipiElements) { + } else if (event.target.id == "lang-select" || event.target.id == "loc-select" || alipiElements) { // passthrough } else if (event.clientX > document.body.clientWidth || event.clientY > document.body.clientHeight) { // passthrough if this click was outside of the html page, meaning on a scrollbar -- 1.7.10.4