diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-04-17 02:28:03 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-04-17 02:28:03 +0400 |
commit | f85e6caa77c092cfb736b4d0250bec92a0d973a3 (patch) | |
tree | 87b870466b3ae7e36f3bddca06b3dbc82ec37c31 /plugins/SitesManager/templates | |
parent | 48187389f65599017f4f1fabcc8054069015e445 (diff) |
[mauser]- refs #62 commited huge work by Maciej ZawadziĆski: thanks! still some work to do + QA but looks really good :)
[mauser]- refs #116 commited partial fix
[mauser]- refs #65 commited partial fix
- fixed broken tests
Diffstat (limited to 'plugins/SitesManager/templates')
-rw-r--r-- | plugins/SitesManager/templates/DisplayJavascriptCode.tpl | 10 | ||||
-rw-r--r-- | plugins/SitesManager/templates/SitesManager.js | 360 | ||||
-rw-r--r-- | plugins/SitesManager/templates/SitesManager.tpl | 76 |
3 files changed, 224 insertions, 222 deletions
diff --git a/plugins/SitesManager/templates/DisplayJavascriptCode.tpl b/plugins/SitesManager/templates/DisplayJavascriptCode.tpl index efbc060321..544d2a880c 100644 --- a/plugins/SitesManager/templates/DisplayJavascriptCode.tpl +++ b/plugins/SitesManager/templates/DisplayJavascriptCode.tpl @@ -1,5 +1,5 @@ -<p>Here is the javascript code to include on all your pages:</p> - -<code> -{$jsTag} -</code> +<p>{'SitesManager_JsCodeHelp'|translate}:</p>
+
+<code>
+{$jsTag}
+</code>
diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js index 46eb71759d..84c684dd27 100644 --- a/plugins/SitesManager/templates/SitesManager.js +++ b/plugins/SitesManager/templates/SitesManager.js @@ -1,180 +1,180 @@ - -function getEncoded(siteName) -{ - // compatible with old browsers but wouldnt work for UTF8 strings - if (encodeURIComponent) { - siteName = encodeURIComponent(siteName); - } else { - siteName = escape(siteName); - } - return siteName; -} - -function getDeleteSiteAJAX( idSite ) -{ - var ajaxRequest = getStandardAjaxConf(); - toggleAjaxLoading(); - - // prepare the API parameters to update the user - var parameters = new Object; - parameters.module = 'API'; - parameters.format = 'json'; - parameters.method = 'SitesManager.deleteSite'; - parameters.idSite = idSite; - - ajaxRequest.data = parameters; - - return ajaxRequest; -} - -function getAddSiteAJAX( row ) -{ - var ajaxRequest = getStandardAjaxConf(); - toggleAjaxLoading(); - - // prepare the API parameters to add the user - var parameters = new Object; - - var siteName = $(row).find('input[@id=siteadd_name]').val(); - var urls = $(row).find('textarea[@id=siteadd_urls]').val(); - var urls = urls.trim().split("\n"); - - var request = ''; - request += '&module=API'; - request += '&format=json'; - request += '&method=SitesManager.addSite'; - - siteName = getEncoded(siteName); - request += '&siteName='+siteName; - - $.each(urls, function (key,value){ request+= '&urls[]='+escape(value);} ); - - ajaxRequest.data = request; - - return ajaxRequest; -} -function getUpdateSiteAJAX( row ) -{ - var ajaxRequest = getStandardAjaxConf(); - toggleAjaxLoading(); - - var siteName = $(row).find('input[@id=siteName]').val(); - var idSite = $(row).children('#idSite').html(); - var urls = $(row).find('textarea[@id=urls]').val().trim().split("\n"); - - var request = ''; - request += '&module=API'; - request += '&format=json'; - request += '&method=SitesManager.updateSite'; - siteName = getEncoded(siteName); - request += '&siteName='+siteName; - request += '&idSite='+idSite; - $.each(urls, function (key,value){ if(value.length>1) request+= '&urls[]='+value;} ); - - ajaxRequest.data = request; - - return ajaxRequest; - -} - - - $(document).ready( function() { - $('#addRowSite').click( function() { - ajaxHideError(); - $(this).toggle(); - - var numberOfRows = $('table#editSites')[0].rows.length; - var newRowIdNumeric = numberOfRows ; - var newRowId = 'row' + newRowIdNumeric; - - $(' <tr id="'+newRowId+'">\ - <td>'+newRowIdNumeric+'</td>\ - <td><input id="siteadd_name" value="Name" size=10></td>\ - <td><textarea cols=30 rows=3 id="siteadd_urls">http://siteUrl.com/\nhttp://siteUrl2.com/</textarea></td>\ - <td><img src="plugins/UsersManager/images/ok.png" id="addsite" href="#"></td>\ - <td><img src="plugins/UsersManager/images/remove.png" id="cancel"></td>\ - </tr>') - .appendTo('#editSites') - ; - $('#'+newRowId).keypress( submitSiteOnEnter ); - $('#addsite').click( function(){ $.ajax( getAddSiteAJAX($('tr#'+newRowId)) ); } ); - $('#cancel').click(function() { ajaxHideError(); $(this).parents('tr').remove(); $('#addRowSite').toggle(); }); - - } ); - - // when click on deleteuser, the we ask for confirmation and then delete the user - $('.deleteSite').click( function() { - ajaxHideError(); - var idRow = $(this).attr('id'); - var nameToDelete = $(this).parent().parent().find('#siteName').html(); - var idsiteToDelete = $(this).parent().parent().find('#idSite').html(); - if(confirm('Are you sure you want to delete the website "'+nameToDelete+'" (idSite = '+idsiteToDelete+')?')) - { - $.ajax( getDeleteSiteAJAX( idsiteToDelete ) ); - } - } - ); - - var alreadyEdited = new Array; - // when click on edituser, the cells become editable - $('.editSite') - .click( function() { - ajaxHideError(); - var idRow = $(this).attr('id'); - if(alreadyEdited[idRow]==1) return; - alreadyEdited[idRow] = 1; - $('tr#'+idRow+' .editableSite').each( - // make the fields editable - // change the EDIT button to VALID button - function (i,n) { - var contentBefore = $(n).html(); - var idName = $(n).attr('id'); - if(idName == 'siteName') - { - var contentAfter = '<input id="'+idName+'" value="'+contentBefore+'" size="10">'; - $(n) - .html(contentAfter) - .keypress( submitSiteOnEnter ); - } - if(idName == 'urls') - { - var contentAfter = '<textarea cols=30 rows=3 id="urls">'+contentBefore.replace(/<br>/gi,"\n")+'</textarea>'; - $(n).html(contentAfter); - } - } - ); - - $(this) - .toggle() - .parent() - .prepend( $('<img src="plugins/UsersManager/images/ok.png" id="updateSite">') - .click( function(){ $.ajax( getUpdateSiteAJAX( $('tr#'+idRow) ) ); } ) - ); - - - - } - ); - - - $('td.editableSite') - .hover( function() { - $(this).css({ cursor: "pointer"}); - }, - function() { - $(this).css({ cursor: "auto"}); - } - ) - .click( function(){ $(this).parent().find('.editSite').click(); } ) - ; -}); - -function submitSiteOnEnter(e) -{ - var key=e.keyCode || e.which; - if (key==13) - { - $(this).parent().find('#updateSite').click(); - $(this).find('#addsite').click(); - } -} +
+function getEncoded(siteName)
+{
+ // compatible with old browsers but wouldnt work for UTF8 strings
+ if (encodeURIComponent) {
+ siteName = encodeURIComponent(siteName);
+ } else {
+ siteName = escape(siteName);
+ }
+ return siteName;
+}
+
+function getDeleteSiteAJAX( idSite )
+{
+ var ajaxRequest = getStandardAjaxConf();
+ toggleAjaxLoading();
+
+ // prepare the API parameters to update the user
+ var parameters = new Object;
+ parameters.module = 'API';
+ parameters.format = 'json';
+ parameters.method = 'SitesManager.deleteSite';
+ parameters.idSite = idSite;
+
+ ajaxRequest.data = parameters;
+
+ return ajaxRequest;
+}
+
+function getAddSiteAJAX( row )
+{
+ var ajaxRequest = getStandardAjaxConf();
+ toggleAjaxLoading();
+
+ // prepare the API parameters to add the user
+ var parameters = new Object;
+
+ var siteName = $(row).find('input[@id=siteadd_name]').val();
+ var urls = $(row).find('textarea[@id=siteadd_urls]').val();
+ var urls = urls.trim().split("\n");
+
+ var request = '';
+ request += '&module=API';
+ request += '&format=json';
+ request += '&method=SitesManager.addSite';
+
+ siteName = getEncoded(siteName);
+ request += '&siteName='+siteName;
+
+ $.each(urls, function (key,value){ request+= '&urls[]='+escape(value);} );
+
+ ajaxRequest.data = request;
+
+ return ajaxRequest;
+}
+function getUpdateSiteAJAX( row )
+{
+ var ajaxRequest = getStandardAjaxConf();
+ toggleAjaxLoading();
+
+ var siteName = $(row).find('input[@id=siteName]').val();
+ var idSite = $(row).children('#idSite').html();
+ var urls = $(row).find('textarea[@id=urls]').val().trim().split("\n");
+
+ var request = '';
+ request += '&module=API';
+ request += '&format=json';
+ request += '&method=SitesManager.updateSite';
+ siteName = getEncoded(siteName);
+ request += '&siteName='+siteName;
+ request += '&idSite='+idSite;
+ $.each(urls, function (key,value){ if(value.length>1) request+= '&urls[]='+value;} );
+
+ ajaxRequest.data = request;
+
+ return ajaxRequest;
+
+}
+
+
+ $(document).ready( function() {
+ $('#addRowSite').click( function() {
+ ajaxHideError();
+ $(this).toggle();
+
+ var numberOfRows = $('table#editSites')[0].rows.length;
+ var newRowIdNumeric = numberOfRows ;
+ var newRowId = 'row' + newRowIdNumeric;
+
+ $(' <tr id="'+newRowId+'">\
+ <td>'+newRowIdNumeric+'</td>\
+ <td><input id="siteadd_name" value="Name" size=10></td>\
+ <td><textarea cols=30 rows=3 id="siteadd_urls">http://siteUrl.com/\nhttp://siteUrl2.com/</textarea></td>\
+ <td><img src="plugins/UsersManager/images/ok.png" id="addsite" href="#"></td>\
+ <td><img src="plugins/UsersManager/images/remove.png" id="cancel"></td>\
+ </tr>')
+ .appendTo('#editSites')
+ ;
+ $('#'+newRowId).keypress( submitSiteOnEnter );
+ $('#addsite').click( function(){ $.ajax( getAddSiteAJAX($('tr#'+newRowId)) ); } );
+ $('#cancel').click(function() { ajaxHideError(); $(this).parents('tr').remove(); $('#addRowSite').toggle(); });
+
+ } );
+
+ // when click on deleteuser, the we ask for confirmation and then delete the user
+ $('.deleteSite').click( function() {
+ ajaxHideError();
+ var idRow = $(this).attr('id');
+ var nameToDelete = $(this).parent().parent().find('#siteName').html();
+ var idsiteToDelete = $(this).parent().parent().find('#idSite').html();
+ if(confirm(sprintf(_pk_translate('SitesManager_DeleteConfirm','Are you sure you want to delete the website %s'),'"'+nameToDelete+'" (idSite = '+idsiteToDelete+')')) )
+ {
+ $.ajax( getDeleteSiteAJAX( idsiteToDelete ) );
+ }
+ }
+ );
+
+ var alreadyEdited = new Array;
+ // when click on edituser, the cells become editable
+ $('.editSite')
+ .click( function() {
+ ajaxHideError();
+ var idRow = $(this).attr('id');
+ if(alreadyEdited[idRow]==1) return;
+ alreadyEdited[idRow] = 1;
+ $('tr#'+idRow+' .editableSite').each(
+ // make the fields editable
+ // change the EDIT button to VALID button
+ function (i,n) {
+ var contentBefore = $(n).html();
+ var idName = $(n).attr('id');
+ if(idName == 'siteName')
+ {
+ var contentAfter = '<input id="'+idName+'" value="'+contentBefore+'" size="10">';
+ $(n)
+ .html(contentAfter)
+ .keypress( submitSiteOnEnter );
+ }
+ if(idName == 'urls')
+ {
+ var contentAfter = '<textarea cols=30 rows=3 id="urls">'+contentBefore.replace(/<br>/gi,"\n")+'</textarea>';
+ $(n).html(contentAfter);
+ }
+ }
+ );
+
+ $(this)
+ .toggle()
+ .parent()
+ .prepend( $('<img src="plugins/UsersManager/images/ok.png" id="updateSite">')
+ .click( function(){ $.ajax( getUpdateSiteAJAX( $('tr#'+idRow) ) ); } )
+ );
+
+
+
+ }
+ );
+
+
+ $('td.editableSite')
+ .hover( function() {
+ $(this).css({ cursor: "pointer"});
+ },
+ function() {
+ $(this).css({ cursor: "auto"});
+ }
+ )
+ .click( function(){ $(this).parent().find('.editSite').click(); } )
+ ;
+});
+
+function submitSiteOnEnter(e)
+{
+ var key=e.keyCode || e.which;
+ if (key==13)
+ {
+ $(this).parent().find('#updateSite').click();
+ $(this).find('#addsite').click();
+ }
+}
diff --git a/plugins/SitesManager/templates/SitesManager.tpl b/plugins/SitesManager/templates/SitesManager.tpl index 24e029eb37..83b26cddb0 100644 --- a/plugins/SitesManager/templates/SitesManager.tpl +++ b/plugins/SitesManager/templates/SitesManager.tpl @@ -1,37 +1,39 @@ -<script type="text/javascript" src="plugins/SitesManager/templates/SitesManager.js"></script> - -<h2>Sites</h2> -<div id="ajaxError" style="display:none"></div> -<div id="ajaxLoading" style="display:none">Loading... <img src="themes/default/loading.gif"></div> - -{if $sites|@count == 0} - You don't have any website to administrate. -{else} - <table id="editSites" border=1 cellpadding="10"> - <thead> - <tr> - <th>Id</th> - <th>Name</th> - <th>URLs</th> - <th> </th> - <th> </th> - <th> Javascript code </th> - </tr> - </thead> - <tbody> - {foreach from=$sites key=i item=site} - <tr id="row{$i}"> - <td id="idSite">{$site.idsite}</td> - <td id="siteName" class="editableSite">{$site.name}</td> - <td id="urls" class="editableSite">{foreach from=$site.alias_urls item=url}{$url}<br>{/foreach}</td> - <td><img src='plugins/UsersManager/images/edit.png' class="editSite" id="row{$i}" href='#'></td> - <td><img src='plugins/UsersManager/images/remove.png' class="deleteSite" id="row{$i}" value="Delete"></td> - <td><a href='{url actionToLoad=displayJavascriptCode idsite=$site.idsite}'>Show Code</a></td> - </tr> - {/foreach} - - </tbody> - </table> - <div id="addRowSite"><img src='plugins/UsersManager/images/add.png'> <a href="#">Add a new Site</a></div> -{/if} - +{loadJavascriptTranslations modules='SitesManager'}
+
+<script type="text/javascript" src="plugins/SitesManager/templates/SitesManager.js"></script>
+
+<h2>{'SitesManager_Sites'|translate}</h2>
+<div id="ajaxError" style="display:none"></div>
+<div id="ajaxLoading" style="display:none">{'General_LoadingData'|translate} <img src="themes/default/loading.gif"></div>
+
+{if $sites|@count == 0}
+ {'SitesManager_NoWebsites'|translate}
+{else}
+ <table id="editSites" border=1 cellpadding="10">
+ <thead>
+ <tr>
+ <th>{'SitesManager_Id'|translate}</th>
+ <th>{'SitesManager_Name'|translate}</th>
+ <th>{'SitesManager_Urls'|translate}</th>
+ <th> </th>
+ <th> </th>
+ <th> {'SitesManager_JsCode'|translate} </th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$sites key=i item=site}
+ <tr id="row{$i}">
+ <td id="idSite">{$site.idsite}</td>
+ <td id="siteName" class="editableSite">{$site.name}</td>
+ <td id="urls" class="editableSite">{foreach from=$site.alias_urls item=url}{$url}<br>{/foreach}</td>
+ <td><img src='plugins/UsersManager/images/edit.png' class="editSite" id="row{$i}" href='#'></td>
+ <td><img src='plugins/UsersManager/images/remove.png' class="deleteSite" id="row{$i}" value="{'General_Delete'|translate}"></td>
+ <td><a href='{url actionToLoad=displayJavascriptCode idsite=$site.idsite}'>{'SitesManager_ShowJsCode'|translate}</a></td>
+ </tr>
+ {/foreach}
+
+ </tbody>
+ </table>
+ <div id="addRowSite"><img src='plugins/UsersManager/images/add.png'> <a href="#">{'SitesManager_AddSite'|translate}</a></div>
+{/if}
+
|