Browse Source

HUE-1320 [core] Drop support for IE8 and migrate to jQuery 2

Migrated to jQuery 2
Got rid of html5 shim
Removed unused jQuery plugins and updated the placeholder plugin for IE9
Enrico Berti 12 năm trước cách đây
mục cha
commit
3917dcfdbf

+ 2 - 2
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -596,7 +596,7 @@ from django.utils.translation import ugettext as _
         $("#newNameInput").removeClass("fieldError");
       });
 
-      $("#moveForm").live("submit", function () {
+      $("#moveForm").on("submit", function () {
         if ($.trim($("#moveForm").find("input.pathChooser").val()) == "") {
           $("#moveNameRequiredAlert").show();
           $("#moveForm").find("input[name='*dest_path']").addClass("fieldError");
@@ -606,7 +606,7 @@ from django.utils.translation import ugettext as _
         return true;
       });
 
-      $("#moveForm").find("input[name='dest_path']").live("focus", function () {
+      $("#moveForm").on("focus", "input[name='dest_path']", function () {
         $("#moveNameRequiredAlert").hide();
         $("#moveForm").find("input[name='dest_path']").removeClass("fieldError");
       });

+ 1 - 1
apps/jobbrowser/src/jobbrowser/templates/jobs.mako

@@ -195,7 +195,7 @@ ${ commonheader(None, "jobbrowser", user) | n,unicode }
             }
         });
 
-        $(".kill").live("click", function(e){
+        $(document).on("click", ".kill", function(e){
             $("#kill-job").attr("action", $(e.target).attr("kill-action"));
             $("#killModal").modal({
                 keyboard: true,

+ 7 - 1
apps/oozie/static/js/workflow.js

@@ -444,7 +444,13 @@ var WorkflowModule = function($, NodeModelChooser, Node, ForkNode, DecisionNode,
               case 'parameters':
                 // These may be serialized JSON data since that is how they are stored
                 self[key].removeAll();
-                var arr = $.parseJSON(value) || value;
+                var arr;
+                try {
+                  arr = $.parseJSON(value);
+                }
+                catch (error){
+                  arr = value;
+                }
 
                 $.each(arr, function(index, obj) {
                   var mapping = ko.mapping.fromJS(obj);

+ 0 - 13
apps/search/src/search/templates/admin_collections.mako

@@ -147,7 +147,6 @@ ${ commonheader(_('Search'), "search", user, "40px") | n,unicode }
 
 <script src="/static/ext/js/knockout-2.1.0.js" type="text/javascript" charset="utf-8"></script>
 <script src="/search/static/js/search.ko.js" type="text/javascript" charset="utf-8"></script>
-<script src="/static/ext/js/jquery/plugins/jquery-ui-draggable-droppable-sortable-1.8.23.min.js"></script>
 
 <script type="text/javascript">
 
@@ -168,18 +167,6 @@ ${ commonheader(_('Search'), "search", user, "40px") | n,unicode }
 
     var orderedCores;
     serializeList();
-    /**
-    $("#collections").sortable({
-      placeholder: "placeholder",
-      update: function (event, ui) {
-        serializeList();
-        ##TODO: serialize via ajax the order of collections
-        ## the array is: orderedCores
-        ## console.log(orderedCores)
-      }
-    });
-    $("#collections").disableSelection();
-    */
 
     function serializeList() {
       orderedCores = [];

+ 4 - 8
desktop/core/src/desktop/templates/common_header.mako

@@ -54,11 +54,6 @@ from django.utils.translation import ugettext as _
   <link href="/static/css/hue2.css" rel="stylesheet">
   <link href="/static/ext/css/fileuploader.css" rel="stylesheet">
 
-  <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
-  <!--[if lt IE 9]>
-  <script src="/static/ext/js/html5.js"></script>
-  <![endif]-->
-
   <style type="text/css">
     % if conf.CUSTOM.BANNER_TOP_HTML.get():
       body {
@@ -104,7 +99,8 @@ from django.utils.translation import ugettext as _
 
   </script>
 
-  <script src="/static/ext/js/jquery/jquery-1.8.1.min.js"></script>
+  <script src="/static/ext/js/jquery/jquery-2.0.2.min.js"></script>
+  <script src="/static/js/Source/jHue/jquery.migration.js"></script>
   <script src="/static/js/Source/jHue/jquery.filechooser.js"></script>
   <script src="/static/js/Source/jHue/jquery.selector.js"></script>
   <script src="/static/js/Source/jHue/jquery.alert.js"></script>
@@ -115,7 +111,7 @@ from django.utils.translation import ugettext as _
   <script src="/static/js/Source/jHue/jquery.scrollup.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.total-storage.min.js"></script>
-  <script src="/static/ext/js/jquery/plugins/jquery.simpleplaceholder.js"></script>
+  <script src="/static/ext/js/jquery/plugins/jquery.placeholder.min.js"></script>
   <script src="/static/ext/js/jquery/plugins/jquery.dataTables.1.8.2.min.js"></script>
   <script src="/static/js/Source/jHue/jquery.datatables.sorting.js"></script>
   <script src="/static/ext/js/bootstrap.min.js"></script>
@@ -123,7 +119,7 @@ from django.utils.translation import ugettext as _
 
   <script type="text/javascript" charset="utf-8">
     $(document).ready(function(){
-      $("input:text[placeholder]").simplePlaceholder();
+      $("input, textarea").placeholder();
       $(".submitter").keydown(function(e){
         if (e.keyCode==13){
           $(this).closest("form").submit();

+ 2 - 1
desktop/core/src/desktop/templates/common_jasmine.mako

@@ -23,7 +23,8 @@
     <link rel="stylesheet" type="text/css" href="/static/ext/css/jasmine.css">
     <script type="text/javascript" src="/static/ext/js/jasmine/jasmine-1.2.0.js"></script>
     <script type="text/javascript" src="/static/ext/js/jasmine/jasmine-html-1.2.0.js"></script>
-    <script type="text/javascript" src="/static/ext/js/jquery/jquery-1.8.1.min.js"></script>
+    <script type="text/javascript" src="/static/ext/js/jquery/jquery-2.0.2.min.js"></script>
+    <script type="text/javascript" src="/static/js/Source/jHue/jquery.migration.js"></script>
     <script type="text/javascript" src="/static/ext/js/jasmine/jasmine-jquery-1.3.1.js"></script>
     <script type="text/javascript" src="/static/ext/js/knockout-2.1.0.js"></script>
 

+ 1 - 6
desktop/core/src/desktop/templates/login.mako

@@ -35,11 +35,6 @@ from django.utils.translation import ugettext as _
   <link href="/static/ext/css/font-awesome.min.css" rel="stylesheet">
   <link href="/static/css/hue2.css" rel="stylesheet">
 
-  <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
-  <!--[if lt IE 9]>
-  <script src="/static/ext/js/html5.js"></script>
-  <![endif]-->
-
   <style type="text/css">
     body {
       padding-top: 80px;
@@ -153,7 +148,7 @@ from django.utils.translation import ugettext as _
     </div>
   </div>
 
-  <script src="/static/ext/js/jquery/jquery-1.8.1.min.js"></script>
+  <script src="/static/ext/js/jquery/jquery-2.0.2.min.js"></script>
   <script>
     $(document).ready(function(){
 

+ 0 - 9
desktop/core/static/ext/js/html5.js

@@ -1,9 +0,0 @@
-/*
- HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
- Uncompressed source: https://github.com/aFarkas/html5shiv
-*/
-(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
-a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
-c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
-"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
-for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 1
desktop/core/static/ext/js/jquery/jquery-1.8.1.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 0
desktop/core/static/ext/js/jquery/jquery-2.0.2.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 8
desktop/core/static/ext/js/jquery/plugins/jquery-ui-autocomplete-1.8.18.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 5
desktop/core/static/ext/js/jquery/plugins/jquery-ui-autocomplete-1.9.1.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 4
desktop/core/static/ext/js/jquery/plugins/jquery-ui-autocomplete-datepicker-1.8.23.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
desktop/core/static/ext/js/jquery/plugins/jquery.placeholder.min.js


+ 0 - 62
desktop/core/static/ext/js/jquery/plugins/jquery.simpleplaceholder.js

@@ -1,62 +0,0 @@
-/* https://github.com/marcgg/Simple-Placeholder */
-/******************************
-
-Simple Placeholder
-
-******************************/
-
-(function($) {
-	$.simplePlaceholder = {
-		placeholder_class: null,
-
-		hide_placeholder: function(){
-			var $this = $(this);
-			if($this.val() == $this.attr('placeholder')){
-				$this.val("").removeClass($.simplePlaceholder.placeholder_class);
-			}
-		},
-
-		show_placeholder: function(){
-			var $this = $(this);
-			if($this.val() == ""){
-				$this.val($this.attr('placeholder')).addClass($.simplePlaceholder.placeholder_class);
-			}
-		},
-
-		prevent_placeholder_submit: function(){
-			$(this).find(".simple-placeholder").each(function(e){
-				var $this = $(this);
-				if($this.val() == $this.attr('placeholder')){
-					$this.val('');
-				}
-			});
-			return true;
-		}
-	};
-
-	$.fn.simplePlaceholder = function(options) {
-		if(document.createElement('input').placeholder == undefined){
-			var config = {
-				placeholder_class : 'placeholding'
-			};
-
-			if(options) $.extend(config, options);
-			$.simplePlaceholder.placeholder_class = config.placeholder_class;
-
-			this.each(function() {
-				var $this = $(this);
-				$this.focus($.simplePlaceholder.hide_placeholder);
-				$this.blur($.simplePlaceholder.show_placeholder);
-				if($this.val() == '') {
-					$this.val($this.attr("placeholder"));
-					$this.addClass($.simplePlaceholder.placeholder_class);
-				}
-				$this.addClass("simple-placeholder");
-				$(this.form).submit($.simplePlaceholder.prevent_placeholder_submit);
-			});
-		}
-
-		return this;
-	};
-
-})(jQuery);

+ 111 - 0
desktop/core/static/js/Source/jHue/jquery.migration.js

@@ -0,0 +1,111 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+/*
+ * Repo for missing jQuery 2 functions, this ease the transition without updating every other plugin in Hue
+ *
+ */
+
+jQuery.uaMatch = function (ua) {
+  ua = ua.toLowerCase();
+
+  var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
+    /(webkit)[ \/]([\w.]+)/.exec(ua) ||
+    /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
+    /(msie) ([\w.]+)/.exec(ua) ||
+    ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
+    [];
+
+  return {
+    browser: match[ 1 ] || "",
+    version: match[ 2 ] || "0"
+  };
+};
+
+// Don't clobber any existing jQuery.browser in case it's different
+if (!jQuery.browser) {
+  matched = jQuery.uaMatch(navigator.userAgent);
+  browser = {};
+
+  if (matched.browser) {
+    browser[ matched.browser ] = true;
+    browser.version = matched.version;
+  }
+
+  // Chrome is Webkit, but Webkit is also Safari.
+  if (browser.chrome) {
+    browser.webkit = true;
+  } else if (browser.webkit) {
+    browser.safari = true;
+  }
+
+  jQuery.browser = browser;
+}
+
+// Since jQuery.clean is used internally on older versions, we only shim if it's missing
+if (!jQuery.clean) {
+  jQuery.clean = function (elems, context, fragment, scripts) {
+    // Set context per 1.8 logic
+    context = context || document;
+    context = !context.nodeType && context[0] || context;
+    context = context.ownerDocument || context;
+
+    var i, elem, handleScript, jsTags,
+      ret = [];
+
+    jQuery.merge(ret, jQuery.buildFragment(elems, context).childNodes);
+
+    // Complex logic lifted directly from jQuery 1.8
+    if (fragment) {
+      // Special handling of each script element
+      handleScript = function (elem) {
+        // Check if we consider it executable
+        if (!elem.type || rscriptType.test(elem.type)) {
+          // Detach the script and store it in the scripts array (if provided) or the fragment
+          // Return truthy to indicate that it has been handled
+          return scripts ?
+            scripts.push(elem.parentNode ? elem.parentNode.removeChild(elem) : elem) :
+            fragment.appendChild(elem);
+        }
+      };
+
+      for (i = 0; (elem = ret[i]) != null; i++) {
+        // Check if we're done after handling an executable script
+        if (!( jQuery.nodeName(elem, "script") && handleScript(elem) )) {
+          // Append to fragment and handle embedded scripts
+          fragment.appendChild(elem);
+          if (typeof elem.getElementsByTagName !== "undefined") {
+            // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
+            jsTags = jQuery.grep(jQuery.merge([], elem.getElementsByTagName("script")), handleScript);
+
+            // Splice the scripts into ret after their former ancestor and advance our index beyond them
+            ret.splice.apply(ret, [i + 1, 0].concat(jsTags));
+            i += jsTags.length;
+          }
+        }
+      }
+    }
+
+    return ret;
+  };
+}
+
+var rscriptType = /\/(java|ecma)script/i,
+  oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
+
+jQuery.fn.andSelf = function () {
+  return oldSelf.apply(this, arguments);
+};
+

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác