Advertisement
Guest User

SJSXC v3.2.1

a guest
Jul 10th, 2017
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. >(/usr/lib/GNUstep/SOGo/WebServerResources/sjsxc/js)<-(21:00)# diff -u sjsxc_old.js sjsxc_new.js
  2. --- sjsxc.js    2017-07-10 20:51:38.482110063 +0200
  3. +++ sjsxc.orig  2017-07-10 20:51:16.962328998 +0200
  4. @@ -1,4 +1,17 @@
  5. -/* jshint undef: false, newcap: false, latedef:nofunc */
  6. +/*!
  7. + * sjsxc v3.2.1 - 2017-06-02
  8. + *
  9. + * Copyright (c) 2017 Klaus Herberth <klaus@jsxc.org> <br>
  10. + * Released under the MIT license
  11. + *
  12. + * Please see http://jsxc.org/
  13. + *
  14. + * @author Klaus Herberth <klaus@jsxc.org>
  15. + * @version 3.2.1
  16. + * @license MIT
  17. + */
  18. +
  19. +/* jshint undef: false, newcap: false */
  20.  
  21.  (function($, pt) {
  22.  
  23. @@ -38,50 +51,35 @@
  24.        };
  25.     }
  26.  
  27. -   function onRosterToggle(event, state) {
  28. -         if ($(window).width() < 768) {
  29. -            // Do not resize elements on extra small devices (bootstrap definition)
  30. -            return;
  31. +   function onRosterToggle(event, state, duration) {
  32. +      var wrapper = $('#rightPanel');
  33. +      var control = $('#toolbar');
  34. +      var roster_width = (state === 'shown') ? $('#jsxc_roster').outerWidth() : 0;
  35. +
  36. +      wrapper.animate({
  37. +         marginRight: (roster_width) + 'px'
  38. +      }, duration);
  39. +
  40. +      control.animate({
  41. +         marginRight: (roster_width) + 'px'
  42. +      }, duration, 'swing', function() {
  43. +         if (typeof SOGoResizableTableInterface !== 'undefined') {
  44. +            SOGoResizableTableInterface.resize.call(pt('messageListHeader'));
  45.           }
  46. -
  47. -        if (state === 'shown') {
  48. -           $('body').addClass('jsxc_rosterVisible');
  49. -        } else {
  50. -           $('body').removeClass('jsxc_rosterVisible');
  51. -        }
  52. +      });
  53.     }
  54.  
  55.     function onRosterReady() {
  56. -      injectChatIcon();
  57.  
  58. -      if ($(window).width() < 768) {
  59. -          // Do not resize elements on extra small devices (bootstrap definition)
  60. -          return;
  61. -      }
  62. -
  63. -        if ($('#jsxc_roster').hasClass('jsxc_state_hidden')) {
  64. -           $('body').removeClass('jsxc_rosterVisible');
  65. -        } else {
  66. -           $('body').addClass('jsxc_rosterVisible');
  67. -        }
  68. -
  69. -        function injectChatIcon() {
  70. -          var settingsButton = $('md-toolbar a[ng-href$="Mail"]');
  71. -
  72. -          if (settingsButton.length === 0) {
  73. -             setTimeout(injectChatIcon, 500);
  74. -             return;
  75. -          }
  76. +      var roster_right = parseFloat($('#jsxc_roster').css('right'));
  77. +      var mr = (204 + ($.isNumeric(roster_right) ? roster_right : 0));
  78.  
  79. -          var a = $('<a>');
  80. -          a.addClass('md-icon-button md-button md-ink-ripple');
  81. -          a.attr('id', 'jsxc_chatIcon');
  82. -          a.click(function(){
  83. -             jsxc.gui.roster.toggle();
  84. -          });
  85. +      $('#toolbar').css('marginRight', mr + 'px');
  86. +      $('#rightPanel').css('marginRight', mr + 'px');
  87.  
  88. -          settingsButton.after(a);
  89. -       }
  90. +      if (typeof SOGoResizableTableInterface !== 'undefined') {
  91. +         SOGoResizableTableInterface.resize.call(pt('messageListHeader'));
  92. +      }
  93.     }
  94.  
  95.     function lazyLoadCss(val) {
  96. @@ -118,6 +116,10 @@
  97.  
  98.     var sjsxc_start = function() {
  99.  
  100. +      if ($('#linkBanner').length === 0) {
  101. +         return;
  102. +      }
  103. +
  104.        $(document).on('ready.roster.jsxc', onRosterReady);
  105.        $(document).on('toggle.roster.jsxc', onRosterToggle);
  106.        $(document).on('connecting.jsxc', function() {
  107. @@ -146,107 +148,71 @@
  108.        }
  109.  
  110.        jsxc.init($.extend({
  111. -         app_name: 'SOGo v3',
  112. +         app_name: 'SOGo',
  113.           loginForm: {
  114. -            form: '#login [name="loginForm"]',
  115. -            jid: '#login [ng-model="app.creds.username"]',
  116. -            pass: '#login [ng-model="app.creds.password"]',
  117. +            form: '#connectForm',
  118. +            jid: '#userName',
  119. +            pass: '#password',
  120.              onConnecting: 'quiet',
  121. -            onAuthFail: 'submit',
  122. -            ifFound: 'force'
  123. +            onAuthFail: 'quiet',
  124. +            attachIfFound: false
  125.           },
  126. -         logoutElement: '[href="../logoff"]',
  127. +         logoutElement: $('#logoff'),
  128. +         rosterAppend: 'body',
  129.           root: ResourcesURL + '/sjsxc/js/jsxc',
  130.           RTCPeerConfig: {
  131.              url: '/SOGo.woa/WebServerResources/sjsxc/ajax/getturncredentials.php'
  132.           },
  133. -         loadSettings: function() {
  134. -            return sjsxc.config;
  135. -         },
  136. -         displayRosterMinimized: function() {
  137. -             return true; //$('[ng-href="../logoff"]').length > 0;
  138. -         },
  139.           formFound: function() {
  140. -            $('#login button[type="submit"]:first').attr('id', 'submit');
  141. -            $('#login button[type="submit"]:first').click(function(ev) {
  142. -               var conn = jsxc.xmpp.conn;
  143. -
  144. -               var submitLoginForm = $(this).data('submitLoginForm');
  145. -               if(submitLoginForm){
  146. -                  $(this).data('submitLoginForm', false);
  147. -               }
  148. +            var submit = pt("submit");
  149. +            submit.stopObserving("click", onLoginClick);
  150. +
  151. +            var userName = pt("userName");
  152. +            userName.stopObserving("keydown", onFieldKeyDown);
  153. +
  154. +            var passw = pt("password");
  155. +            passw.stopObserving("keydown", onFieldKeyDown);
  156.  
  157. -               if (!(conn && conn.connected && conn.authenticated) && !submitLoginForm) {
  158. -                  ev.stopPropagation();
  159. -                  ev.preventDefault();
  160. +            $('#connectForm').submit(function(ev){
  161. +                onLoginClick(ev);
  162.  
  163. -                  // trigger our own connection function
  164. -                  $(jsxc.options.loginForm.form).submit();
  165. +                return false;
  166. +            });
  167. +            $('#submit').click(function() {
  168. +                if(!$(this).prop('disabled')) {
  169. +                    $('#connectForm').submit();
  170. +                }
  171. +            });
  172. +            $('#userName, #password').keypress(function(ev) {
  173. +               if (ev.which !== 13) {
  174. +                  return;
  175.                 }
  176. +
  177. +               $('#connectForm').submit();
  178.              });
  179. +         },
  180. +         loadSettings: function() {
  181. +            return sjsxc.config;
  182. +         },
  183. +         displayRosterMinimized: function() {
  184. +             return $('#logoff').length > 0;
  185.           }
  186.        }, sjsxc.config.jsxc || {}));
  187.  
  188.        // Add submit link without chat functionality
  189. -      /*if (jsxc.el_exists($('#login'))) {
  190. +      if (jsxc.el_exists($('#loginCell'))) {
  191.  
  192.           var link = $('<a/>').text($.t('Log_in_without_chat')).click(function() {
  193.              jsxc.submitLoginForm();
  194.           });
  195.  
  196.           var alt = $('<p id="jsxc_alt"/>').append(link);
  197. -         $('#submit').before(alt);
  198. -      }*/
  199. -   };
  200. -
  201. -   jsxc.submitLoginForm = function() {
  202. -      var form = $(jsxc.options.loginForm.form).off('submit');
  203. -
  204. -      // Attach original events
  205. -      var submits = form.data('submits') || [];
  206. -      $.each(submits, function(index, val) {
  207. -         form.submit(val);
  208. -      });
  209. -
  210. -      if (form.find('#submit').length > 0) {
  211. -         form.find('#submit').data('submitLoginForm', true);
  212. -         form.find('#submit').click();
  213. -      } else if (form.find('[type="submit"]').length > 0) {
  214. -         form.find('[type="submit"]').click();
  215. -      } else if (form.get(0) && typeof form.get(0).submit === 'function') {
  216. -         form.submit();
  217. -      } else {
  218. -         jsxc.warn('Could not submit login form.');
  219. +         $('#loginCell').append('<br/>').append(alt);
  220.        }
  221. -
  222. -      form.submit(function(ev) {
  223. -         ev.preventDefault();
  224. -
  225. -         jsxc.prepareLogin(function(settings) {
  226. -            if (settings !== false) {
  227. -               // settings.xmpp.onlogin is deprecated since v2.1.0
  228. -               var enabled = (settings.loginForm && settings.loginForm.enable) || (settings.xmpp && settings.xmpp.onlogin);
  229. -               enabled = enabled === "true" || enabled === true;
  230. -
  231. -               if (enabled) {
  232. -                  jsxc.options.loginForm.triggered = true;
  233. -
  234. -                  jsxc.xmpp.login(jsxc.options.xmpp.jid, jsxc.options.xmpp.password);
  235. -
  236. -                  return;
  237. -               }
  238. -            }
  239. -
  240. -            jsxc.submitLoginForm();
  241. -         });
  242. -
  243. -         // Trigger submit in jsxc.xmpp.connected()
  244. -         return false;
  245. -      });
  246.     };
  247.  
  248.     var sjsxc_init = function() {
  249. -      if ($('#jsxc_sogo_test').css('background-color') !== '' && $('#jsxc_sogo_test').css('position') === 'absolute') {
  250. +      if ($('#jsxc_sogo_test').css('text-align') === 'right') {
  251.           $('#jsxc_sogo_test').remove();
  252.           sjsxc_start();
  253.        } else {
  254. @@ -263,7 +229,7 @@
  255.  
  256.        $.extend(true, sjsxc.config, sjsxc.config[document.domain] || {});
  257.  
  258. -      var el = $('<div>').attr('class', 'jsxc_window').attr('id', 'jsxc_sogo_test');
  259. +      var el = $('<div>').attr('class', 'jsxc_right').attr('id', 'jsxc_sogo_test');
  260.        $('body').append(el);
  261.  
  262.        var enable = JSON.parse(localStorage.getItem('sjsxc.enable'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement