浏览代码

[search] Deleted unused files, Maps: added enableGeocoding, onClick event, data tooltip, Widgets: resize event, fixed double markup, updated sortable

Enrico Berti 11 年之前
父节点
当前提交
217630ed08

+ 1 - 1
apps/search/src/search/templates/admin_collection_facets.mako

@@ -529,7 +529,7 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
 <script src="/static/ext/js/bootstrap-datepicker.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/bootstrap-editable.min.js"></script>
 <script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js"></script>
 
 <script type="text/javascript">

+ 1 - 1
apps/search/src/search/templates/admin_collection_sorting.mako

@@ -119,7 +119,7 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
   }
 </style>
 
-<script src="/search/static/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js"></script>
 
 <script type="text/javascript">

+ 3 - 3
apps/search/src/search/templates/admin_collection_template.mako

@@ -416,12 +416,12 @@ ${ commonheader(_('Search'), "search", user, "29px") | n,unicode }
   ${ hue_collection.result.get_extracode() | n,unicode }
 </span>
 
-<link rel="stylesheet" href="/search/static/css/freshereditor.css">
+<link rel="stylesheet" href="/static/css/freshereditor.css">
 <link rel="stylesheet" href="/static/ext/css/codemirror.css">
 
 <script src="/static/ext/js/knockout-min.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/shortcut.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/freshereditor.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/shortcut.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/freshereditor.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/codemirror-3.11.js"></script>
 <script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/codemirror-xml.js"></script>

+ 1 - 1
apps/search/src/search/templates/dashboard.mako

@@ -294,7 +294,7 @@ ${ commonheader(_('Search'), "search", user, "70px") | n,unicode }
 
 <script src="/static/ext/js/knockout-min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
 
 <link href="/static/ext/css/leaflet.css" rel="stylesheet">
 <link href="/static/ext/css/hue-charts.css" rel="stylesheet">

+ 5 - 6
apps/search/src/search/templates/search2.mako

@@ -253,7 +253,6 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 </script>
 
 <script type="text/html" id="widget-template">
-  <div data-bind="attr: {'id': 'wdg_'+ id(),}, css: klass">
   <div data-bind="attr: {'id': 'wdg_'+ id(),}, css: klass">
     <h2 class="card-heading simple">
       <span data-bind="visible: $root.isEditing">
@@ -801,7 +800,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
     <div data-bind="with: $root.collection.getFacetById($parent.id())">
       <div data-bind="mapChart: {data: {counts: $parent.counts, widget_id: $parent.id},
         transformer: mapChartDataTransformer,
-        onClick: function(d){ viewModel.query.selectRangeFacet({count: d.data.obj.value, widget_id: d.data.obj.widget_id, from: d.data.obj.from, to: d.data.obj.to, cat: d.data.obj.field}) },
+        onClick: function(d){ console.log(d); },
         onComplete: function(){ viewModel.getWidgetById($parent.id).isLoading(false)} }" />
     </div>
   </div>
@@ -863,7 +862,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 <link rel="stylesheet" href="/static/ext/css/hue-filetypes.css">
 <link rel="stylesheet" href="/static/ext/css/leaflet.css">
 <link rel="stylesheet" href="/static/ext/css/hue-charts.css">
-<link rel="stylesheet" href="/search/static/css/freshereditor.css">
+<link rel="stylesheet" href="/static/css/freshereditor.css">
 <link rel="stylesheet" href="/static/ext/css/codemirror.css">
 <link rel="stylesheet" href="/static/ext/css/bootstrap-editable.css">
 <link rel="stylesheet" href="/static/ext/css/bootstrap-slider.min.css">
@@ -874,18 +873,18 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
 <script src="/search/static/js/search.utils.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/knockout-min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/knockout.mapping-2.3.2.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/bootstrap-editable.min.js"></script>
 <script src="/static/ext/js/bootstrap-slider.min.js"></script>
 <script src="/static/js/bootstrap-spinedit.js"></script>
 <script src="/static/js/ko.editable.js"></script>
-<script src="/search/static/js/shortcut.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/freshereditor.min.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/ext/js/shortcut.js" type="text/javascript" charset="utf-8"></script>
+<script src="/static/js/freshereditor.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/codemirror-3.11.js"></script>
 <script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/codemirror-xml.js"></script>
 <script src="/static/ext/js/mustache.js"></script>
 <script src="/static/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js" type="text/javascript" charset="utf-8"></script>
-<script src="/search/static/js/knockout-sortable.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/jquery/plugins/jquery.flot.categories.min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/leaflet/leaflet.js" type="text/javascript" charset="utf-8"></script>

+ 0 - 29
apps/search/static/css/bootstrap-select.css

@@ -1,29 +0,0 @@
-/*
- 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.
-*/
-
-a.dropdown-toggle, a.dropdown-toggle:hover {
-  text-decoration: none;
-}
-
-.dropdown a.dropdown-toggle {
-  color: gray;
-}
-
-.dropdown:hover a.dropdown-toggle, .open a.dropdown-toggle {
-  color: black;
-}

+ 0 - 43
apps/search/static/js/bootstrap-select.js

@@ -1,43 +0,0 @@
-/*
- * bootstrap-select.js
- */
-
-(function($) {
-
-  'use strict'; // jshint ;_;
-
-  $.fn.dropSelect = function(option) {
-    return this.each(function() {
-
-      var $this = $(this);
-      var display = $this.find('.dropdown-display');        // display span
-      var field = $this.find('input.dropdown-field');       // hidden input
-      var options = $this.find('ul.dropdown-menu > li > a');// select options
-
-      // when the hidden field is updated, update dropdown-toggle
-      var onFieldChange = function(event) {
-        var val = $(this).val();
-        var displayText = options.filter("[data-value='" + val + "']").html();
-        display.html(displayText);
-      };
-
-      // when an option is clicked, update the hidden field
-      var onOptionClick = function(event) {
-        // stop click from causing page refresh
-        event.preventDefault();
-        field.val($(this).attr('data-value'));
-        field.change();
-      };
-
-      field.change(onFieldChange);
-      options.click(onOptionClick);
-
-    });
-  };
-
-  // invoke on every div element with 'data-select=true'
-  $(function() {
-    $('div[data-select=true]').dropSelect();
-  });
-
-})(window.jQuery);

+ 33 - 18
apps/search/static/js/charts.ko.js

@@ -104,6 +104,7 @@ ko.bindingHandlers.mapChart = {
     var _chunk = _maxWeight / _data.length;
 
     var _mapdata = {};
+    var _maphovers = {};
     var _fills = {};
     var _noncountries = [];
     if (_options.isScale){
@@ -117,7 +118,8 @@ ko.bindingHandlers.mapChart = {
         if (_country != null){
           _mapdata[_country.alpha3] = {
             fillKey: "fill_" + Math.floor(item.value/_chunk)
-          }
+          };
+          _maphovers[_country.name.split(",")[0].toLowerCase()] = item.value;
         }
         else {
           _noncountries.push(item);
@@ -132,7 +134,8 @@ ko.bindingHandlers.mapChart = {
         if (_country != null){
           _mapdata[_country.alpha3] = {
             fillKey: "selected"
-          }
+          };
+          _maphovers[_country.name.split(",")[0].toLowerCase()] = item.value;
         }
         else {
           _noncountries.push(item);
@@ -148,26 +151,30 @@ ko.bindingHandlers.mapChart = {
       done: function(datamap) {
 
         datamap.svg.selectAll('.datamaps-subunit').on('click', function(geography) {
-          _options.onClick(geography);
+          if (typeof _options.onClick != "undefined"){
+            _options.onClick(geography);
+          }
         });
 
         var _bubbles = [];
-      $(_noncountries).each(function(cnt, item){
-          HueGeo.getCityCoordinates(item.label, function(lat, lng){
-              _bubbles.push({
-                fillKey: "selected",
-                label: item.label,
-                radius: 4,
-                latitude: lat,
-                longitude: lng
-              });
-              _map.bubbles(_bubbles, {
-                popupTemplate: function(geo, data) {
-                  return '<div class="hoverinfo"><strong>'  + data.label + '</strong></div>'
-                }
+        if (_options.enableGeocoding){
+          $(_noncountries).each(function(cnt, item){
+              HueGeo.getCityCoordinates(item.label, function(lat, lng){
+                  _bubbles.push({
+                    fillKey: "selected",
+                    label: item.label,
+                    radius: 4,
+                    latitude: lat,
+                    longitude: lng
+                  });
+                  _map.bubbles(_bubbles, {
+                    popupTemplate: function(geo, data) {
+                      return '<div class="hoverinfo"><strong>'  + data.label + '</strong></div>'
+                    }
+                  });
               });
           });
-      });
+        }
       },
       geographyConfig: {
         hideAntarctica: true,
@@ -175,10 +182,18 @@ ko.bindingHandlers.mapChart = {
         borderColor: HueColors.DARK_BLUE,
         highlightOnHover: true,
         highlightFillColor: HueColors.DARK_BLUE,
-        highlightBorderColor: HueColors.DARK_BLUE
+        highlightBorderColor: HueColors.DARK_BLUE,
+        popupTemplate: function(geography, data) {
+          var _hover = _maphovers[geography.properties.name.toLowerCase()];
+          return '<div class="hoverinfo" style="text-align: center"><strong>' + geography.properties.name + '</strong>' + ((typeof _hover != "undefined")?'<br/>' + _hover : '') + '</div>'
+        }
       }
     });
     _options.onComplete();
+    nv.utils.windowResize(_map.update);
+    $(element).parents(".card-widget").on("resize", function(){
+      console.log("resize!");
+    });
   },
   update: function (element, valueAccessor) {
     var value = valueAccessor();

文件差异内容过多而无法显示
+ 0 - 1
apps/search/static/js/knockout-sortable.min.js


+ 2 - 0
apps/search/static/js/search.ko.js

@@ -102,10 +102,12 @@ var Widget = function (size, id, name, widgetType, properties, offset, loading)
 
   self.expand = function () {
     self.size(self.size() + 1);
+    $("#wdg_" + self.id()).trigger("resize");
   }
   
   self.compress = function () {
     self.size(self.size() - 1);
+    $("#wdg_" + self.id()).trigger("resize");
   }
 
   self.moveLeft = function () {

+ 0 - 226
apps/search/static/js/shortcut.js

@@ -1,226 +0,0 @@
-/**
-* http://www.openjs.com/scripts/events/keyboard_shortcuts/
-* Version : 2.01.B
-* By Binny V A
-* License : BSD
-*/
-var shortcut = {
-	'all_shortcuts': {}, //All the shortcuts are stored in this array
-	'add': function (shortcut_combination, callback, opt) {
-		//Provide a set of default options
-		var default_options = {
-			'type': 'keydown',
-			'propagate': false,
-			'disable_in_input': false,
-			'target': document,
-			'keycode': false
-		};
-		if (!opt) {
-			opt = default_options;
-		}
-		else {
-			var dfo;
-			for (dfo in default_options) {
-				if (typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
-			}
-		}
-
-		var ele = opt.target;
-		if (typeof opt.target == 'string') ele = document.getElementById(opt.target);
-		var ths = this;
-		shortcut_combination = shortcut_combination.toLowerCase();
-
-		//The function to be called at keypress
-		var func = function (e) {
-			e = e || window.event;
-
-			if (opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
-				var element;
-				if (e.target) element = e.target;
-				else if (e.srcElement) element = e.srcElement;
-				if (element.nodeType == 3) element = element.parentNode;
-
-				if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
-			}
-
-			//Find Which key is pressed
-			if (e.keyCode) code = e.keyCode;
-			else if (e.which) code = e.which;
-			var character = String.fromCharCode(code).toLowerCase();
-
-			if (code == 188) character = ","; //If the user presses , when the type is onkeydown
-			if (code == 190) character = "."; //If the user presses , when the type is onkeydown
-
-			var keys = shortcut_combination.split("+");
-			//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
-			var kp = 0;
-
-			//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
-			var shift_nums = {
-				"`": "~",
-				"1": "!",
-				"2": "@",
-				"3": "#",
-				"4": "$",
-				"5": "%",
-				"6": "^",
-				"7": "&",
-				"8": "*",
-				"9": "(",
-				"0": ")",
-				"-": "_",
-				"=": "+",
-				";": ":",
-				"'": "\"",
-				",": "<",
-				".": ">",
-				"/": "?",
-				"\\": "|"
-			}
-			//Special Keys - and their codes
-			var special_keys = {
-				'esc': 27,
-				'escape': 27,
-				'tab': 9,
-				'space': 32,
-				'return': 13,
-				'enter': 13,
-				'backspace': 8,
-
-				'scrolllock': 145,
-				'scroll_lock': 145,
-				'scroll': 145,
-				'capslock': 20,
-				'caps_lock': 20,
-				'caps': 20,
-				'numlock': 144,
-				'num_lock': 144,
-				'num': 144,
-
-				'pause': 19,
-				'break': 19,
-
-				'insert': 45,
-				'home': 36,
-				'delete': 46,
-				'end': 35,
-
-				'pageup': 33,
-				'page_up': 33,
-				'pu': 33,
-
-				'pagedown': 34,
-				'page_down': 34,
-				'pd': 34,
-
-				'left': 37,
-				'up': 38,
-				'right': 39,
-				'down': 40,
-
-				'f1': 112,
-				'f2': 113,
-				'f3': 114,
-				'f4': 115,
-				'f5': 116,
-				'f6': 117,
-				'f7': 118,
-				'f8': 119,
-				'f9': 120,
-				'f10': 121,
-				'f11': 122,
-				'f12': 123
-			}
-
-			var modifiers = {
-				shift: { wanted: false, pressed: false },
-				ctrl: { wanted: false, pressed: false },
-				alt: { wanted: false, pressed: false },
-				meta: { wanted: false, pressed: false}	//Meta is Mac specific
-			};
-
-			if (e.ctrlKey) modifiers.ctrl.pressed = true;
-			if (e.shiftKey) modifiers.shift.pressed = true;
-			if (e.altKey) modifiers.alt.pressed = true;
-			if (e.metaKey) modifiers.meta.pressed = true;
-
-			for (var i = 0; k = keys[i], i < keys.length; i++) {
-				//Modifiers
-				if (k == 'ctrl' || k == 'control') {
-					kp++;
-					modifiers.ctrl.wanted = true;
-
-				} else if (k == 'shift') {
-					kp++;
-					modifiers.shift.wanted = true;
-
-				} else if (k == 'alt') {
-					kp++;
-					modifiers.alt.wanted = true;
-				} else if (k == 'meta') {
-					kp++;
-					modifiers.meta.wanted = true;
-				} else if (k.length > 1) { //If it is a special key
-					if (special_keys[k] == code) kp++;
-
-				} else if (opt['keycode']) {
-					if (opt['keycode'] == code) kp++;
-
-				} else { //The special keys did not match
-					if (character == k) kp++;
-					else {
-						if (shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
-							character = shift_nums[character];
-							if (character == k) kp++;
-						}
-					}
-				}
-			}
-
-			if (kp == keys.length &&
-						modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
-						modifiers.shift.pressed == modifiers.shift.wanted &&
-						modifiers.alt.pressed == modifiers.alt.wanted &&
-						modifiers.meta.pressed == modifiers.meta.wanted) {
-				callback(e);
-
-				if (!opt['propagate']) { //Stop the event
-					//e.cancelBubble is supported by IE - this will kill the bubbling process.
-					e.cancelBubble = true;
-					e.returnValue = false;
-
-					//e.stopPropagation works in Firefox.
-					if (e.stopPropagation) {
-						e.stopPropagation();
-						e.preventDefault();
-					}
-					return false;
-				}
-			}
-		}
-		this.all_shortcuts[shortcut_combination] = {
-			'callback': func,
-			'target': ele,
-			'event': opt['type']
-		};
-		//Attach the function with the event
-		if (ele.addEventListener) ele.addEventListener(opt['type'], func, false);
-		else if (ele.attachEvent) ele.attachEvent('on' + opt['type'], func);
-		else ele['on' + opt['type']] = func;
-	},
-
-	//Remove the shortcut - just specify the shortcut and I will remove the binding
-	'remove': function (shortcut_combination) {
-		shortcut_combination = shortcut_combination.toLowerCase();
-		var binding = this.all_shortcuts[shortcut_combination];
-		delete (this.all_shortcuts[shortcut_combination])
-		if (!binding) return;
-		var type = binding['event'];
-		var ele = binding['target'];
-		var callback = binding['callback'];
-
-		if (ele.detachEvent) ele.detachEvent('on' + type, callback);
-		else if (ele.removeEventListener) ele.removeEventListener(type, callback, false);
-		else ele['on' + type] = false;
-	}
-}

+ 4 - 0
apps/search/static/css/freshereditor.css → desktop/core/static/css/freshereditor.css

@@ -30,3 +30,7 @@
   background-color: #333;
 }
 
+.colorpanel table {
+  width: 100%;
+  height: 120px;
+}

+ 0 - 43
desktop/core/static/ext/js/bootstrap-select.js

@@ -1,43 +0,0 @@
-/*
- * bootstrap-select.js
- */
-
-(function($) {
-
-  'use strict'; // jshint ;_;
-
-  $.fn.dropSelect = function(option) {
-    return this.each(function() {
-
-      var $this = $(this);
-      var display = $this.find('.dropdown-display');        // display span
-      var field = $this.find('input.dropdown-field');       // hidden input
-      var options = $this.find('ul.dropdown-menu > li > a');// select options
-
-      // when the hidden field is updated, update dropdown-toggle
-      var onFieldChange = function(event) {
-        var val = $(this).val();
-        var displayText = options.filter("[data-value='" + val + "']").html();
-        display.html(displayText);
-      };
-
-      // when an option is clicked, update the hidden field
-      var onOptionClick = function(event) {
-        // stop click from causing page refresh
-        event.preventDefault();
-        field.val($(this).attr('data-value'));
-        field.change();
-      };
-
-      field.change(onFieldChange);
-      options.click(onOptionClick);
-
-    });
-  };
-
-  // invoke on every div element with 'data-select=true'
-  $(function() {
-    $('div[data-select=true]').dropSelect();
-  });
-
-})(window.jQuery);

文件差异内容过多而无法显示
+ 0 - 1
desktop/core/static/ext/js/knockout-sortable.min.js


+ 16 - 0
desktop/core/static/ext/js/shortcut.js → desktop/core/static/ext/js/shortcut.js

@@ -1,3 +1,19 @@
+// 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.
+
 (function() {
   (function($) {
     var methods;

文件差异内容过多而无法显示
+ 0 - 1
desktop/core/static/js/knockout-sortable.min.js


部分文件因为文件数量过多而无法显示