[otrs-cvs] FAQ/var/httpd/htdocs/js FAQ.Agent.TicketCompose.js, 1.9, 1.10

"CVS commits notifications of OTRS.org" <[email protected]> Wed, 12 Jun 2013 18:13:02 +0000
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/FAQ/var/httpd/htdocs/js
In directory lancelot:/tmp/cvs-serv4748/var/httpd/htdocs/js

Modified Files:
	FAQ.Agent.TicketCompose.js 
Log Message:
Added Insert Full FAQ (Text Images and Attachments) feature into tickets.

Author: cr

Index: FAQ.Agent.TicketCompose.js
===================================================================
RCS file: /home/cvs/FAQ/var/httpd/htdocs/js/FAQ.Agent.TicketCompose.js,v
retrieving revision 1.9
retrieving revision 1.10
diff -2 -u -d -r1.9 -r1.10
--- FAQ.Agent.TicketCompose.js	7 Feb 2013 14:07:58 -0000	1.9
+++ FAQ.Agent.TicketCompose.js	12 Jun 2013 18:12:57 -0000	1.10
@@ -109,5 +109,4 @@
     };
 
-
     /**
      * @function
@@ -118,5 +117,5 @@
      *      Do nothing and show an error message.
      */
-    TargetNS.SetData = function (FAQTitle, FAQContent, FAQHTMLContent) {
+    function SetData (FAQTitle, FAQContent, FAQHTMLContent) {
         if ($('#Subject', parent.document).length && $('#RichText', parent.document).length) {
             var $ParentSubject = $('#Subject', parent.document),
@@ -189,6 +188,86 @@
             return;
         }
+    }
+
+    /**
+     * @function
+     * @param {Boolean} Setting to add FAQ item text or not
+     * @param {Boolean} Setting to add FAQ item link or not
+     * @return nothing
+     */
+    TargetNS.SetText = function (InsertText, InsertLink) {
+        var FAQTitle = $('#FAQTitle').val(),
+        FAQContent = '',
+        FAQHTMLContent = '',
+        FAQLink;
+
+        if ( InsertText === 1 ) {
+            FAQContent = $('#FAQBody').val();
+            FAQHTMLContent = FAQContent;
+        }
+        else {
+            FAQContent = '';
+            FAQHTMLContent = FAQContent;
+        }
+
+        if (InsertLink === 1 ) {
+            FAQLink = $('#FAQPublicLink').val();
+            FAQContent = FAQContent + '\n' + FAQLink;
+            FAQHTMLContent = FAQHTMLContent + '<br/>' + '<a href="' + FAQLink + '">' + FAQTitle + '</a>';
+        }
+
+        SetData (FAQTitle, FAQContent, FAQHTMLContent);
     };
 
+    /**
+     * @function
+     * @param {Boolean} Setting to add FAQ item text or not
+     * @param {Boolean} Setting to add FAQ item link or not
+     * @return nothing
+     */
+    TargetNS.SetFullFAQ = function (InsertText, InsertLink) {
+
+        // get the FAQ richtext and trigger attachment processing
+        parent.Core.AJAX.FunctionCall(
+            parent.Core.Config.Get('Baselink'),
+            {
+                Action: 'AgentFAQRichText',
+                FAQID: $('input[name=FAQID]').val(),
+                FormID: parent.$('input[name=FormID]').val()
+            },
+            function (Response) {
+                var FAQTitle = Response.FAQTitle,
+                    FAQContent = '',
+                    FAQHTMLContent = '',
+                    FAQLink;
+
+                if ( InsertText === 1 ) {
+                    FAQContent = Response.FAQContent;
+                    FAQHTMLContent = Response.FAQHTMLContent;
+                }
+
+
+                if (InsertLink === 1 ) {
+                    FAQLink = $('#FAQPublicLink').val();
+                    FAQContent = FAQContent + '\n' + FAQLink;
+                    FAQHTMLContent = FAQHTMLContent + '<br/><br/>' + '<a href="' + FAQLink + '">' + FAQTitle + '</a>';
+                }
+
+                // sync the attachment list with the attachments in the UploadCache
+                // 1st: delete the current attachment list
+                $('#FileUpload', parent.document).parent().siblings('li').remove();
+
+                // 2nd: add all files based on the metadata returned in Response
+                $(Response.TicketAttachments).each(function(index) {
+                    $('#FileUpload', parent.document).before(
+                        '<li>' + this.Filename + ' (' + this.Filesize + ')<button type="submit" id="AttachmentDelete' + this.FileID + '" name="AttachmentDelete' + this.FileID + '" value="Delete" class="SpacingLeft">' + Response.Localization.Delete + '</button></li>'
+                    );
+                });
+
+                SetData (FAQTitle, FAQContent, FAQHTMLContent);
+            },
+            'json'
+        );
+    };
     return TargetNS;
 }(FAQ.Agent.TicketCompose || {}));
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log