MaysamSh

PagesForMenu.aspx

Feb 2nd, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 12.65 KB | None | 0 0
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="PagesForMenu.aspx.vb" Inherits="cms_PagesForMenu" %>
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head id="Head1" runat="server">
  7.     <title></title>
  8.     <link href="style/StyleSheet.css" rel="stylesheet" />
  9.     <script src="../js/jquery-1.8.3.min.js"></script>
  10.     <script src="../ckeditor/ckeditor.js"></script>
  11.     <link href="../style/sen.css" rel="stylesheet" />
  12.     <link href="style/sen.extra.css" rel="stylesheet" />
  13.     <script src="../js/jquery.validate.min.js"></script>
  14.     <script>
  15.         function showNotificationBar(message, duration, bgColor, txtColor, height) {
  16.  
  17.             /*set default values*/
  18.             duration = typeof duration !== 'undefined' ? duration : 1500;
  19.             bgColor = typeof bgColor !== 'undefined' ? bgColor : "#eee";
  20.             txtColor = typeof txtColor !== 'undefined' ? txtColor : "#333";
  21.             height = typeof height !== 'undefined' ? height : 40;
  22.             /*create the notification bar div if it doesn't exist*/
  23.             if ($('#notification-bar').size() == 0) {
  24.                 var HTMLmessage = "<div class='notification-message' style='text-align:center; line-height: " + height + "px; direction:ltr; font-family:Trebuchet MS, Arial;'> " + message + " </div>";
  25.                 $('body').prepend("<div id='notification-bar' style='display:none; width:100%; height:" + height + "px; background-color: " + bgColor + "; position: fixed; z-index: 100; color: " + txtColor + ";border-bottom: 1px solid " + txtColor + ";'>" + HTMLmessage + "</div>");
  26.             } else {
  27.                 $('.notification-message').html(message);
  28.             }
  29.             /*animate the bar*/
  30.             $('#notification-bar').slideDown(function () {
  31.                 setTimeout(function () {
  32.                     $('#notification-bar').slideUp(function () { });
  33.                 }, duration);
  34.             });
  35.         }
  36.     </script>
  37.     <script>
  38.  
  39.         function InsertHTML() {
  40.             // Get the editor instance that we want to interact with.
  41.             var editor = CKEDITOR.instances.editor1;
  42.             var value = document.getElementById('htmlArea').value;
  43.             alert('sasa');
  44.             // Check the active editing mode.
  45.             if (editor.mode == 'wysiwyg') {
  46.                 // Insert HTML code.
  47.                 // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertHtml
  48.                 editor.insertHtml(value);
  49.             }
  50.             else
  51.                 alert('You must be in WYSIWYG mode!');
  52.         }
  53.  
  54.         function InsertText() {
  55.             // Get the editor instance that we want to interact with.
  56.             var editor = CKEDITOR.instances.editor1;
  57.             var value = document.getElementById('txtArea').value;
  58.  
  59.             // Check the active editing mode.
  60.             if (editor.mode == 'wysiwyg') {
  61.                 // Insert as plain text.
  62.                 // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertText
  63.                 editor.insertText(value);
  64.             }
  65.             else
  66.                 alert('You must be in WYSIWYG mode!');
  67.         }
  68.  
  69.         function SetContents() {
  70.             // Get the editor instance that we want to interact with.
  71.             var editor = CKEDITOR.instances.editor1;
  72.             var value = document.getElementById('htmlArea').value;
  73.  
  74.             // Set editor contents (replace current contents).
  75.             // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setData
  76.             editor.setData(value);
  77.         }
  78.  
  79.         function GetContents() {
  80.             // Get the editor instance that you want to interact with.
  81.             var editor = CKEDITOR.instances.editor1;
  82.  
  83.             // Get editor contents
  84.             // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getData
  85.             alert(editor.getData());
  86.         }
  87.  
  88.         function ExecuteCommand(commandName) {
  89.             // Get the editor instance that we want to interact with.
  90.             var editor = CKEDITOR.instances.editor1;
  91.  
  92.             // Check the active editing mode.
  93.             if (editor.mode == 'wysiwyg') {
  94.                 // Execute the command.
  95.                 // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-execCommand
  96.                 editor.execCommand(commandName);
  97.             }
  98.             else
  99.                 alert('You must be in WYSIWYG mode!');
  100.         }
  101.  
  102.         function CheckDirty() {
  103.             // Get the editor instance that we want to interact with.
  104.             var editor = CKEDITOR.instances.editor1;
  105.             // Checks whether the current editor contents present changes when compared
  106.             // to the contents loaded into the editor at startup
  107.             // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-checkDirty
  108.             alert(editor.checkDirty());
  109.         }
  110.  
  111.         function ResetDirty() {
  112.             // Get the editor instance that we want to interact with.
  113.             var editor = CKEDITOR.instances.editor1;
  114.             // Resets the "dirty state" of the editor (see CheckDirty())
  115.             // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-resetDirty
  116.             editor.resetDirty();
  117.             alert('The "IsDirty" status has been reset');
  118.         }
  119.  
  120.         function Focus() {
  121.             CKEDITOR.instances.editor1.focus();
  122.         }
  123.  
  124.         function onFocus() {
  125.             //document.getElementById('eMessage').innerHTML = '<b>' + this.name + ' is focused </b>';
  126.         }
  127.  
  128.         function onBlur() {
  129.             //document.getElementById('eMessage').innerHTML = this.name + ' lost focus';
  130.         }
  131.  
  132.     </script>
  133.     <script>
  134.         $(document).ready(function () {
  135.             //validator//////////////////////////////
  136.  
  137.             var rules = {
  138.                 webPagePriority: { required: true, number: true },
  139.                 webPageTitle: "required"
  140.             };
  141.             var messages = {
  142.                 webPagePriority: { required: "Title is required", number: "Page priority must be a number" },
  143.                 webPageTitle: "Page priority is requried"
  144.             };
  145.  
  146.  
  147.             //end validator/////////////////////////
  148.  
  149.  
  150.             // Get the editor instance that we want to interact with.
  151.             var editor = CKEDITOR.instances.editor1;
  152.  
  153.             // Set editor contents (replace current contents).
  154.             // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setData
  155.             //editor.setData(value);
  156.             //alert(editor.getData());
  157.             $('#webSubmit').click(function () {
  158.                 if ($("#form1").valid() == true) {
  159.                     submitForm();
  160.                 }
  161.             });
  162.             $('#webAddNew').click(function () {
  163.                 window.location.href = '<%=ResolveClientUrl("~/cms/")%>pages.aspx?section=<%=_Section%>&lang=<%=_lang%>'
  164.             });
  165.             $('#webUpdate').click(function () {
  166.                 if ($("#form1").valid() == true) {
  167.                     updateForm();
  168.                 }
  169.             });
  170.             $('#webDelete').live('click', function (event_ref) {
  171.                 event_ref.preventDefault();
  172.                 if (confirm('Are you sure?')) {
  173.                     window.location.href = '<%=ResolveClientUrl("~/cms/")%>delete.aspx?r=pages.aspx?section=<%=_Section%>,lang=<%=_lang%>' +
  174.                     '&t=Pages&k=id&kv=<%=_PageID%>';
  175.                 }
  176.             })
  177.         });
  178.  
  179.         function submitForm() {
  180.  
  181.             $('#webSubmit').attr('disabled', 'disabled');
  182.             var editor = CKEDITOR.instances.editor1;
  183.             $.post(
  184.                         '<%=ResolveClientUrl("~/ajax/") %>pages.aspx',
  185.                         {
  186.                             webPageTitle: $("#webPageTitle").val(), webPagePriority: $('#webPagePriority').val(), webPageContent: editor.getData(),
  187.                             lang: '<%=_Lang%>', webPageOwner: '0', webSection: '<%=_Section%>', actionMode: 'add'
  188.                             //lang: <asp lang>
  189.                         },
  190.                         function (data) {
  191.                             if (data.toString() == "done") {
  192.                                 $('#webSubmit').removeAttr('disabled');
  193.                                 showNotificationBar('Saved Successfully.');
  194.                                 setTimeout(redirectPage, 500);
  195.                             } else {
  196.                                 var now = new Date();
  197.                                 var outStr = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
  198.                                 showNotificationBar(data.toString());
  199.                                 alert(data.toString());
  200.                             }
  201.                         },
  202.                         "html"
  203.                         );
  204.                     }
  205.  
  206.                     function updateForm() {
  207.  
  208.                         $('#webUpdate').attr('disabled', 'disabled');
  209.                         var editor = CKEDITOR.instances.editor1;
  210.                         $.post(
  211.                                     '<%=ResolveClientUrl("~/ajax/") %>pages.aspx',
  212.                         {
  213.                             webPageTitle: $("#webPageTitle").val(), webPagePriority: $('#webPagePriority').val(), webPageContent: editor.getData(),
  214.                             webClause: 'ID=<%=_PageID%>', id: '<%=_PageID%>', actionMode: 'edit'
  215.                         },
  216.                         function (data) {
  217.                             if (data.toString() == "done") {
  218.                                 $('#webUpdate').removeAttr('disabled');
  219.                                 showNotificationBar('Saved Successfully.');
  220.                                 setTimeout(redirectPage, 500);
  221.                             } else {
  222.                                 var now = new Date();
  223.                                 var outStr = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
  224.                                 showNotificationBar(data.toString());
  225.                                 alert(data.toString());
  226.                             }
  227.                         },
  228.                         "html"
  229.                         );
  230.                     }
  231.  
  232.                     function redirectPage() {
  233.                         window.location.href = "<%=ResolveClientUrl("~/ajax/")%>ident.aspx?page=pages.aspx&section=<%=_Section%>&lang=<%=_lang%>";
  234.                     }
  235.  
  236.     </script>
  237. </head>
  238. <body>
  239.     <form id="form1" runat="server">
  240.         <div id="wrapper">
  241.             <div class="horizontalSpacer" id="TopSpacer" runat="server"></div>
  242.             <p class="notice centeredText" id="webMessageBox" runat="server">Hello</p>
  243.             <div class="verticalSpacer">&nbsp;</div>
  244.             <div id="right">&nbsp;</div>
  245.             <div id="content" class="roundedCorner padding boxShadow">
  246.                 <fieldset>
  247.                     <legend>Page</legend>
  248.                     <label for="webPageTitle">Title</label>
  249.                     <input id="webPageTitle" type="text" maxlength="30" runat="server" class="required" />
  250.                     <label for="editor1">Full content</label>
  251.                     <textarea cols="80" id="editor1" name="editor1" rows="10" runat="server"></textarea>
  252.                     <label for="webPagePriority">Page Priority (Decimal)</label>
  253.                     <input id="webPagePriority" type="text" maxlength="2" runat="server" class="required number" style="width: 50px;" />
  254.                     <button type="button" id="webSubmit" runat="server">Submit</button>
  255.                     <button type="button" id="webUpdate" runat="server" style="display: inline-block !important;">Update</button>
  256.                     <button type="button" id="webAddNew" runat="server" style="display: inline-block !important;">Add New</button>
  257.                     <button type="button" id="webDelete" runat="server" class="redColor" style="display: inline-block !important;">Delete</button>
  258.                 </fieldset>
  259.             </div>
  260.         </div>
  261.     </form>
  262.     <script>
  263.  
  264.         // Replace the <textarea id="editor1"> with an CKEditor instance.
  265.         CKEDITOR.replace('editor1', {
  266.             on: {
  267.                 focus: onFocus,
  268.                 blur: onBlur,
  269.  
  270.                 // Check for availability of corresponding plugins.
  271.                 pluginsLoaded: function (evt) {
  272.                     var doc = CKEDITOR.document, ed = evt.editor;
  273.                     if (!ed.getCommand('bold'))
  274.                         doc.getById('exec-bold').hide();
  275.                     if (!ed.getCommand('link'))
  276.                         doc.getById('exec-link').hide();
  277.                 }
  278.             }
  279.         });
  280.     </script>
  281.  
  282.  
  283.  
  284. </body>
  285. </html>
Advertisement
Add Comment
Please, Sign In to add comment