├── style.css ├── README.md ├── rzslider.min.css ├── index.html ├── script.js ├── xml2json.js └── rzslider.min.js /style.css: -------------------------------------------------------------------------------- 1 | /* Styles go here */ 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Price-Comparison-Website 2 | Website gets data via API’s from various e-commerce sites like Amazon and displays the products for the user. User can filter according to price and brand type and sort according to price. Technology: HTML, CSS, JQuery and AngularJS. 3 | -------------------------------------------------------------------------------- /rzslider.min.css: -------------------------------------------------------------------------------- 1 | /*! angularjs-slider - v5.8.7 - (c) Rafal Zajac , Valentin Hervieu , Jussi Saarivirta , Angelin Sirbu - https://github.com/angular-slider/angularjs-slider - 2016-11-09 */ 2 | .rzslider{position:relative;display:inline-block; 3 | width:100%; 4 | height:4px; 5 | margin:35px 0 15px 0; 6 | vertical-align:middle; 7 | -webkit-user-select:none; 8 | -moz-user-select:none; 9 | -ms-user-select:none; 10 | user-select:none} 11 | .rzslider.with-legend{margin-bottom:40px} 12 | .rzslider[disabled]{cursor:not-allowed} 13 | .rzslider[disabled] .rz-pointer{cursor:not-allowed;background-color:#d8e0f3} 14 | .rzslider[disabled] .rz-bar-wrapper.rz-draggable{cursor:not-allowed} 15 | .rzslider[disabled] .rz-bar.rz-selection{background:#8b91a2} 16 | .rzslider[disabled].rz-ticks .rz-tick{cursor:not-allowed} 17 | .rzslider[disabled] .rz-ticks .rz-tick.rz-selected{background:#8b91a2} 18 | .rzslider span{position:absolute;display:inline-block;white-space:nowrap} 19 | .rzslider .rz-base{width:100%;height:100%;padding:0} 20 | .rzslider .rz-bar-wrapper{left:0;z-index:1;width:100%; 21 | height:32px;padding-top:16px;margin-top:-16px;box-sizing:border-box} 22 | .rzslider .rz-bar-wrapper.rz-draggable{cursor:move}.rzslider .rz-bar{left:0;z-index:1;width:100%;height:4px;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-bar.rz-selection{z-index:2;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-pointer{top:-7px;z-index:3;width:16px;height:16px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px} 23 | .rzslider .rz-pointer:after{ 24 | } 25 | .rzslider .rz-pointer:hover:after{background-color:#fff}.rzslider .rz-pointer.rz-active{z-index: 4;} 26 | .rzslider .rz-pointer.rz-active:after{}.rzslider .rz-bubble{bottom:16px;padding:1px 3px; 27 | color:black;cursor:default;font-family: 'Open Sans', sans-serif;}.rzslider .rz-bubble.rz-selection{top:16px} 28 | .rzslider .rz-bubble.rz-limit{color:black;font-family: 'Open Sans', sans-serif;}.rzslider .rz-ticks{position:absolute;top:-3px;left:0;z-index:1;width:100%;height:0;margin:0;list-style:none;box-sizing:border-box}.rzslider .rz-ticks .rz-tick{position:absolute;top:0;left:0;width:10px;height:10px;margin-left:11px;text-align:center;cursor:pointer;background:#d8e0f3;border-radius:50%}.rzslider .rz-ticks .rz-tick.rz-selected{background:#0db9f0}.rzslider .rz-ticks .rz-tick .rz-tick-value{position:absolute;top:-30px;transform:translate(-50%,0)}.rzslider .rz-ticks .rz-tick .rz-tick-legend{position:absolute;top:24px;max-width:50px;white-space:normal;transform:translate(-50%,0)}.rzslider .rz-ticks.rz-ticks-values-under .rz-tick-value{top:initial;bottom:-32px}.rzslider.rz-vertical{position:relative;width:4px;height:100%;padding:0;margin:0 20px;vertical-align:baseline}.rzslider.rz-vertical .rz-base{width:100%;height:100%;padding:0}.rzslider.rz-vertical .rz-bar-wrapper{top:auto;left:0;width:32px;height:100%;padding:0 0 0 16px;margin:0 0 0 -16px}.rzslider.rz-vertical .rz-bar{bottom:0;left:auto;width:4px;height:100%}.rzslider.rz-vertical .rz-pointer{top:auto;bottom:0;left:-14px!important}.rzslider.rz-vertical .rz-bubble{bottom:0;left:16px!important;margin-left:3px}.rzslider.rz-vertical .rz-bubble.rz-selection{top:auto;left:16px!important}.rzslider.rz-vertical .rz-ticks{top:0;left:-3px;z-index:1;width:0;height:100%}.rzslider.rz-vertical .rz-ticks .rz-tick{margin-top:11px;margin-left:auto;vertical-align:middle}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-value{top:initial;left:24px;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-legend{top:initial;right:24px;max-width:none;white-space:nowrap;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks.rz-ticks-values-under .rz-tick-value{right:24px;bottom:initial;left:initial} -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 53 | 54 | 55 | 56 | 57 | 58 |
59 | 60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 |
72 | 73 | 74 |
75 | 76 |
77 |

Brand

78 |
    79 |
  • 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |
  • 88 |
89 | 94 |
95 | 99 | 100 |
101 | 102 | - 103 | 104 | 106 | 107 |
108 |
109 | 115 | 116 | 117 |
118 |
119 | 120 | 121 | 122 | 123 | 124 | 128 | 137 | 138 | 139 | 140 | 141 | 142 |
    143 | 144 |
  • 146 | 147 |
    148 | 149 | 150 | 151 | 152 | 153 |
    154 | 155 | 156 |

    {{item.ItemAttributes.Title}}

    158 | 159 | 160 |

    {{item.ItemAttributes.ListPrice.FormattedPrice}} 161 | 162 |

    163 |
    164 | 165 | 166 | 167 | 168 |
    169 | 170 |
    171 |
    172 | 173 | 174 |
  • 175 | 176 | 177 |
178 | 179 | 180 | 181 |
182 | 183 | 184 | 185 |
186 | 187 |
188 | 189 | 190 | 191 |

{{NoMoreItems}}

192 |
193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /script.js: -------------------------------------------------------------------------------- 1 | // Code goes here 2 | 3 | var app=angular.module("PriceComparisonSearch",['angular.filter','rzModule']); 4 | var sortType; 5 | 6 | 7 | // window.onload=function() 8 | // { 9 | // console.log("Window loaded"); 10 | // }; 11 | 12 | 13 | 14 | 15 | 16 | var MainController=function($scope,$http) 17 | { 18 | 19 | 20 | 21 | 22 | function sha256(stringToSign, secretKey) { 23 | var hex = CryptoJS.HmacSHA256(stringToSign, secretKey); 24 | return hex.toString(CryptoJS.enc.Base64); 25 | } 26 | 27 | function timestamp() { 28 | var date = new Date(); 29 | var y = date.getUTCFullYear().toString(); 30 | var m = (date.getUTCMonth() + 1).toString(); 31 | var d = date.getUTCDate().toString(); 32 | var h = date.getUTCHours().toString(); 33 | var min = date.getUTCMinutes().toString(); 34 | var s = date.getUTCSeconds().toString(); 35 | 36 | if(m.length < 2) { m = "0" + m; } 37 | if(d.length < 2) { d = "0" + d; } 38 | if(h.length < 2) { h = "0" + h; } 39 | if(min.length < 2) { min = "0" + min; } 40 | if(s.length < 2) { s = "0" + s} 41 | 42 | var date1 = y + "-" + m + "-" + d; 43 | var time = h + ":" + min + ":" + s; 44 | return date1 + "T" + time + "Z"; 45 | } 46 | 47 | function getAmazonItemInfo(keyword,ItemPage) { 48 | var PrivateKey = "0ZBy/gl6fuYzOir9wgD+Z/wAMBUXHf2Piz4Y9lTD"; 49 | var PublicKey = "AKIAJYZXU7INGAR7BJDA"; 50 | var AssociateTag = "ssudan-21"; 51 | 52 | keyword=keyword.replace(/ /g,"%20"); 53 | 54 | var parameters = []; 55 | parameters.push("AWSAccessKeyId=" + PublicKey); 56 | parameters.push("ItemPage=" + ItemPage); 57 | parameters.push("Keywords=" + keyword); 58 | parameters.push("ResponseGroup=" +"Images%2CItemAttributes%2COffers"); 59 | parameters.push("SearchIndex=" +"All"); 60 | parameters.push("Operation=ItemSearch"); 61 | parameters.push("Service=AWSECommerceService"); 62 | parameters.push("Timestamp=" + encodeURIComponent(timestamp())); 63 | // parameters.push("Version=2011-08-01"); 64 | parameters.push("AssociateTag=" + AssociateTag); 65 | 66 | parameters.sort(); 67 | var paramString = parameters.join('&'); 68 | 69 | var signingKey = "GET\n" + "webservices.amazon.in\n" + "/onca/xml\n" + paramString 70 | 71 | var signature = sha256(signingKey,PrivateKey); 72 | signature = encodeURIComponent(signature); 73 | 74 | var amazonUrl = "https://webservices.amazon.in/onca/xml?" + paramString + "&Signature=" + signature; 75 | console.log(amazonUrl); 76 | return amazonUrl; 77 | } 78 | 79 | 80 | function maxmin(temp) 81 | { 82 | var maxprice=-1; 83 | var minprice=10000000; 84 | var pricearr=[]; 85 | for(var x=0;x vB) ? 1 : 0; 129 | // }); 130 | // $(parent).append(items); 131 | // } 132 | 133 | 134 | 135 | 136 | $scope.brand=[]; 137 | 138 | 139 | 140 | var i=1,y=0,k=0; 141 | var ItemArray=[]; 142 | 143 | 144 | $scope.search=function() 145 | { 146 | 147 | //var hash = CryptoJS.HmacSHA256("GET webservices.amazon.in /onca/xml AWSAccessKeyId=AKIAJYZXU7INGAR7BJDA&AssociateTag=ssudan-21&Keywords=iPhone&Operation=ItemSearch&ResponseGroup=Images%2CItemAttributes%2COffers&SearchIndex=All&Service=AWSECommerceService&Timestamp=2016-11-30T09%3A55%3A42Z", "0ZBy/gl6fuYzOir9wgD+Z/wAMBUXHf2Piz4Y9lTD"); 148 | //var base64 = hash.toString(CryptoJS.enc.Base64); 149 | i=1,y=0,k=0; 150 | ItemArray=[]; 151 | // for(i=0;i<5;i++) 152 | // { 153 | // ItemArray[i]=[]; 154 | // } 155 | 156 | // var UserSearchKeyword=$scope.searchquery; 157 | 158 | // if(UserSearchKeyword!=$scope.searchquery) 159 | // { 160 | // var i=1,y=0,k=0; 161 | // var ItemArray=[]; 162 | // } 163 | // for(i=1;i<=5;i++) 164 | // { 165 | var url=getAmazonItemInfo($scope.searchquery,i); 166 | $http.get("https://cors-anywhere.herokuapp.com/"+url).then(jsondata,errormsg); 167 | 168 | 169 | 170 | $scope.sortOrder='+MRP'; 171 | //} 172 | // var invocation=new XMLHttpRequest(); 173 | 174 | // invocation.open('GET',url,true); 175 | // invocation.onreadystatechange=handler; 176 | // invocation.send(); 177 | 178 | // $http({ 179 | // method: 'JSONP', 180 | // url: url 181 | // }).success(jsondata).error(errormsg); 182 | 183 | 184 | 185 | }; 186 | var temp,newtemp; 187 | var jsondata=function(response) 188 | { 189 | //console.log(response.data); 190 | 191 | //ItemArray[k]=[]; 192 | 193 | // console.log(response); 194 | var x2js = new X2JS(); 195 | //var xmlText = "Successval1val2"; 196 | var jsonObj = x2js.xml_str2json(response.data); 197 | 198 | 199 | 200 | // for(var y=0;y<10;y++) 201 | // { 202 | 203 | // try 204 | // { 205 | // jsonObj.ItemSearchResponse.Items.Item[y]["MRP"]=jsonObj.ItemSearchResponse.Items.Item[y].ItemAttributes.ListPrice.Amount; 206 | // } 207 | 208 | // catch(ex) 209 | // { 210 | // console("caught exception"); 211 | // } 212 | // } 213 | 214 | //jsonObj.ItemSearchResponse.Items.Item[0]["MRP"]="999" 215 | //var obj = JSON.parse(jsonObj.ItemSearchResponse.Items); 216 | temp= jsonObj.ItemSearchResponse.Items.Item; 217 | //obj['Items'].Item[0].push({"MRP":"999"}); 218 | //jsonStr = JSON.stringify(obj); 219 | //temp=jsonStr; 220 | maxmin(temp); 221 | 222 | console.log(temp); 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | // if(k==4) 232 | // { 233 | // console.log("inside"); 234 | // // console.log(ItemArray); 235 | // console.log("inside"); 236 | // } 237 | 238 | // var x=temp[i].MediumImage.URL; 239 | // } 240 | // catch(err) 241 | // { 242 | // // temp[i].push({MediumImage.URL:"Working"}); 243 | // } 244 | //console.log(temp); 245 | $scope.items= temp; 246 | 247 | newtemp=temp; 248 | 249 | // if(k<4) 250 | // { 251 | // k++; 252 | // } 253 | //console.log(x); 254 | //temp[i].MediumImage.URL=x.replace("_SL160_","_AC_US160_"); 255 | 256 | } 257 | 258 | 259 | 260 | $scope.runfilter=function() 261 | { 262 | 263 | 264 | 265 | 266 | 267 | $scope.customfilter=function() 268 | { 269 | return function (p) { 270 | // console.log(p.ASIN); 271 | for(var x1 in $scope.brand) 272 | { 273 | if(p.ItemAttributes.Brand===$scope.brand[x1]) 274 | { 275 | return true; 276 | } 277 | 278 | // if($scope.brand[x1]!=undefined) 279 | // { 280 | // var res= 281 | // } 282 | // for (var i in $scope.useMakes) { 283 | // if (p.make == $scope.group[i] && $scope.useMakes[i]) { 284 | 285 | } 286 | 287 | var count=0; 288 | for(var e=0;e<$scope.brand.length;e++) 289 | { 290 | if($scope.brand[e]===undefined) 291 | { 292 | count++; 293 | } 294 | if(count===$scope.brand.length) 295 | { 296 | return true; 297 | } 298 | // console.log($scope.brand[e]); 299 | } 300 | 301 | // console.log($scope.brand); 302 | // console.log($scope.brand[1]); 303 | 304 | 305 | 306 | // if($scope.brand===undefined) 307 | // { 308 | // return true; 309 | // } 310 | 311 | 312 | 313 | // } 314 | } 315 | }; 316 | 317 | }; 318 | 319 | 320 | $scope.sortAscending=function() 321 | { 322 | sortType="Ascending"; 323 | $('li.prod').sort(function(a, b) 324 | { var contentA = parseInt($(a).attr('data-price')); var contentB = parseInt($(b).attr('data-price')); 325 | return (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; }).appendTo($(".products")); 326 | }; 327 | 328 | $scope.sortDecending=function() 329 | { 330 | sortType="Decending"; 331 | $('li.prod').sort(function(a, b) 332 | { var contentA = parseInt($(a).attr('data-price')); var contentB = parseInt($(b).attr('data-price')); 333 | return (contentA > contentB) ? -1 : (contentA < contentB) ? 1 : 0; }).appendTo($(".products")); 334 | }; 335 | 336 | 337 | // $scope.FilterByPrice=function() 338 | // { 339 | 340 | 341 | $scope.priceFilter=function() 342 | 343 | { 344 | 345 | return function(p) 346 | { 347 | var price=0; 348 | price=parseInt(p.ItemAttributes.ListPrice.Amount)/100; 349 | if(parseInt($scope.slider.min)<=price && price<=parseInt($scope.slider.max)) 350 | { 351 | // return 1; 352 | return true; 353 | } 354 | 355 | 356 | 357 | } 358 | 359 | }; 360 | 361 | //}; 362 | 363 | 364 | 365 | // $('li.prod').each(function(a, b) 366 | // { var contentA = parseInt($(b).attr('data-price')); 367 | // //var contentB = parseInt($(b).attr('data-price')); 368 | // //console.log(contentA/100); 369 | // contentA=contentA/100; 370 | // if(parseInt($scope.slider.min) contentB) ? 1 : 0; }).appendTo($(".products")); 448 | 449 | // } 450 | // if(sortType==="Decending") 451 | // { 452 | 453 | // $('li.prod').sort(function(a, b) 454 | // { var contentA = parseInt($(a).attr('data-price')); var contentB = parseInt($(b).attr('data-price')); 455 | // return (contentA > contentB) ? -1 : (contentA < contentB) ? 1 : 0; }).appendTo($(".products")); 456 | 457 | // } 458 | 459 | // } 460 | // } 461 | // } 462 | // }); 463 | 464 | // app.directive('onFinishRender', function ($timeout) { 465 | // return { 466 | // restrict: 'A', 467 | // link: function (scope, element, attr) { 468 | // if (scope.$last === true) { 469 | // // $timeout(function () { 470 | // // scope.$emit(attr.onFinishRender); 471 | // // console.log("Load Complete"); 472 | // // }); 473 | // console.log("Load Complete"); 474 | // } 475 | // } 476 | // } 477 | // }); 478 | 479 | // app.directive('collapseElem', ['$timeout', function ($timeout) { 480 | // return { 481 | // link: function ($scope, element, attrs) { 482 | // $scope.$on('dataloaded', function () { 483 | // $timeout(function () { 484 | 485 | // console.log("Load complete"); 486 | // }, 0, false); 487 | // }) 488 | // } 489 | // }; 490 | // }]); 491 | 492 | 493 | app.controller("MainController",MainController); -------------------------------------------------------------------------------- /xml2json.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011-2013 Abdulla Abdurakhmanov 3 | Original sources are available at https://code.google.com/p/x2js/ 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | (function (root, factory) { 19 | if (typeof define === "function" && define.amd) { 20 | define([], factory); 21 | } else if (typeof exports === "object") { 22 | module.exports = factory(); 23 | } else { 24 | root.X2JS = factory(); 25 | } 26 | }(this, function () { 27 | return function (config) { 28 | 'use strict'; 29 | 30 | var VERSION = "1.2.0"; 31 | 32 | config = config || {}; 33 | initConfigDefaults(); 34 | initRequiredPolyfills(); 35 | 36 | function initConfigDefaults() { 37 | if(config.escapeMode === undefined) { 38 | config.escapeMode = true; 39 | } 40 | 41 | config.attributePrefix = config.attributePrefix || "_"; 42 | config.arrayAccessForm = config.arrayAccessForm || "none"; 43 | config.emptyNodeForm = config.emptyNodeForm || "text"; 44 | 45 | if(config.enableToStringFunc === undefined) { 46 | config.enableToStringFunc = true; 47 | } 48 | config.arrayAccessFormPaths = config.arrayAccessFormPaths || []; 49 | if(config.skipEmptyTextNodesForObj === undefined) { 50 | config.skipEmptyTextNodesForObj = true; 51 | } 52 | if(config.stripWhitespaces === undefined) { 53 | config.stripWhitespaces = true; 54 | } 55 | config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || []; 56 | 57 | if(config.useDoubleQuotes === undefined) { 58 | config.useDoubleQuotes = false; 59 | } 60 | 61 | config.xmlElementsFilter = config.xmlElementsFilter || []; 62 | config.jsonPropertiesFilter = config.jsonPropertiesFilter || []; 63 | 64 | if(config.keepCData === undefined) { 65 | config.keepCData = false; 66 | } 67 | } 68 | 69 | var DOMNodeTypes = { 70 | ELEMENT_NODE : 1, 71 | TEXT_NODE : 3, 72 | CDATA_SECTION_NODE : 4, 73 | COMMENT_NODE : 8, 74 | DOCUMENT_NODE : 9 75 | }; 76 | 77 | function initRequiredPolyfills() { 78 | } 79 | 80 | function getNodeLocalName( node ) { 81 | var nodeLocalName = node.localName; 82 | if(nodeLocalName == null) // Yeah, this is IE!! 83 | nodeLocalName = node.baseName; 84 | if(nodeLocalName == null || nodeLocalName=="") // =="" is IE too 85 | nodeLocalName = node.nodeName; 86 | return nodeLocalName; 87 | } 88 | 89 | function getNodePrefix(node) { 90 | return node.prefix; 91 | } 92 | 93 | function escapeXmlChars(str) { 94 | if(typeof(str) == "string") 95 | return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); 96 | else 97 | return str; 98 | } 99 | 100 | function unescapeXmlChars(str) { 101 | return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&'); 102 | } 103 | 104 | function checkInStdFiltersArrayForm(stdFiltersArrayForm, obj, name, path) { 105 | var idx = 0; 106 | for(; idx < stdFiltersArrayForm.length; idx++) { 107 | var filterPath = stdFiltersArrayForm[idx]; 108 | if( typeof filterPath === "string" ) { 109 | if(filterPath == path) 110 | break; 111 | } 112 | else 113 | if( filterPath instanceof RegExp) { 114 | if(filterPath.test(path)) 115 | break; 116 | } 117 | else 118 | if( typeof filterPath === "function") { 119 | if(filterPath(obj, name, path)) 120 | break; 121 | } 122 | } 123 | return idx!=stdFiltersArrayForm.length; 124 | } 125 | 126 | function toArrayAccessForm(obj, childName, path) { 127 | switch(config.arrayAccessForm) { 128 | case "property": 129 | if(!(obj[childName] instanceof Array)) 130 | obj[childName+"_asArray"] = [obj[childName]]; 131 | else 132 | obj[childName+"_asArray"] = obj[childName]; 133 | break; 134 | /*case "none": 135 | break;*/ 136 | } 137 | 138 | if(!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) { 139 | if(checkInStdFiltersArrayForm(config.arrayAccessFormPaths, obj, childName, path)) { 140 | obj[childName] = [obj[childName]]; 141 | } 142 | } 143 | } 144 | 145 | function fromXmlDateTime(prop) { 146 | // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object 147 | // Improved to support full spec and optional parts 148 | var bits = prop.split(/[-T:+Z]/g); 149 | 150 | var d = new Date(bits[0], bits[1]-1, bits[2]); 151 | var secondBits = bits[5].split("\."); 152 | d.setHours(bits[3], bits[4], secondBits[0]); 153 | if(secondBits.length>1) 154 | d.setMilliseconds(secondBits[1]); 155 | 156 | // Get supplied time zone offset in minutes 157 | if(bits[6] && bits[7]) { 158 | var offsetMinutes = bits[6] * 60 + Number(bits[7]); 159 | var sign = /\d\d-\d\d:\d\d$/.test(prop)? '-' : '+'; 160 | 161 | // Apply the sign 162 | offsetMinutes = 0 + (sign == '-'? -1 * offsetMinutes : offsetMinutes); 163 | 164 | // Apply offset and local timezone 165 | d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset()) 166 | } 167 | else 168 | if(prop.indexOf("Z", prop.length - 1) !== -1) { 169 | d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds())); 170 | } 171 | 172 | // d is now a local time equivalent to the supplied time 173 | return d; 174 | } 175 | 176 | function checkFromXmlDateTimePaths(value, childName, fullPath) { 177 | if(config.datetimeAccessFormPaths.length > 0) { 178 | var path = fullPath.split("\.#")[0]; 179 | if(checkInStdFiltersArrayForm(config.datetimeAccessFormPaths, value, childName, path)) { 180 | return fromXmlDateTime(value); 181 | } 182 | else 183 | return value; 184 | } 185 | else 186 | return value; 187 | } 188 | 189 | function checkXmlElementsFilter(obj, childType, childName, childPath) { 190 | if( childType == DOMNodeTypes.ELEMENT_NODE && config.xmlElementsFilter.length > 0) { 191 | return checkInStdFiltersArrayForm(config.xmlElementsFilter, obj, childName, childPath); 192 | } 193 | else 194 | return true; 195 | } 196 | 197 | function parseDOMChildren( node, path ) { 198 | if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) { 199 | var result = new Object; 200 | var nodeChildren = node.childNodes; 201 | // Alternative for firstElementChild which is not supported in some environments 202 | for(var cidx=0; cidx 1 && result.__text!=null && config.skipEmptyTextNodesForObj) { 292 | if( (config.stripWhitespaces && result.__text=="") || (result.__text.trim()=="")) { 293 | delete result.__text; 294 | } 295 | } 296 | delete result.__cnt; 297 | 298 | if( config.enableToStringFunc && (result.__text!=null || result.__cdata!=null )) { 299 | result.toString = function() { 300 | return (this.__text!=null? this.__text:'')+( this.__cdata!=null ? this.__cdata:''); 301 | }; 302 | } 303 | 304 | return result; 305 | } 306 | else 307 | if(node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) { 308 | return node.nodeValue; 309 | } 310 | } 311 | 312 | function startTag(jsonObj, element, attrList, closed) { 313 | var resultStr = "<"+ ( (jsonObj!=null && jsonObj.__prefix!=null)? (jsonObj.__prefix+":"):"") + element; 314 | if(attrList!=null) { 315 | for(var aidx = 0; aidx < attrList.length; aidx++) { 316 | var attrName = attrList[aidx]; 317 | var attrVal = jsonObj[attrName]; 318 | if(config.escapeMode) 319 | attrVal=escapeXmlChars(attrVal); 320 | resultStr+=" "+attrName.substr(config.attributePrefix.length)+"="; 321 | if(config.useDoubleQuotes) 322 | resultStr+='"'+attrVal+'"'; 323 | else 324 | resultStr+="'"+attrVal+"'"; 325 | } 326 | } 327 | if(!closed) 328 | resultStr+=">"; 329 | else 330 | resultStr+="/>"; 331 | return resultStr; 332 | } 333 | 334 | function endTag(jsonObj,elementName) { 335 | return ""; 336 | } 337 | 338 | function endsWith(str, suffix) { 339 | return str.indexOf(suffix, str.length - suffix.length) !== -1; 340 | } 341 | 342 | function jsonXmlSpecialElem ( jsonObj, jsonObjField ) { 343 | if((config.arrayAccessForm=="property" && endsWith(jsonObjField.toString(),("_asArray"))) 344 | || jsonObjField.toString().indexOf(config.attributePrefix)==0 345 | || jsonObjField.toString().indexOf("__")==0 346 | || (jsonObj[jsonObjField] instanceof Function) ) 347 | return true; 348 | else 349 | return false; 350 | } 351 | 352 | function jsonXmlElemCount ( jsonObj ) { 353 | var elementsCnt = 0; 354 | if(jsonObj instanceof Object ) { 355 | for( var it in jsonObj ) { 356 | if(jsonXmlSpecialElem ( jsonObj, it) ) 357 | continue; 358 | elementsCnt++; 359 | } 360 | } 361 | return elementsCnt; 362 | } 363 | 364 | function checkJsonObjPropertiesFilter(jsonObj, propertyName, jsonObjPath) { 365 | return config.jsonPropertiesFilter.length == 0 366 | || jsonObjPath=="" 367 | || checkInStdFiltersArrayForm(config.jsonPropertiesFilter, jsonObj, propertyName, jsonObjPath); 368 | } 369 | 370 | function parseJSONAttributes ( jsonObj ) { 371 | var attrList = []; 372 | if(jsonObj instanceof Object ) { 373 | for( var ait in jsonObj ) { 374 | if(ait.toString().indexOf("__")== -1 && ait.toString().indexOf(config.attributePrefix)==0) { 375 | attrList.push(ait); 376 | } 377 | } 378 | } 379 | return attrList; 380 | } 381 | 382 | function parseJSONTextAttrs ( jsonTxtObj ) { 383 | var result =""; 384 | 385 | if(jsonTxtObj.__cdata!=null) { 386 | result+=""; 387 | } 388 | 389 | if(jsonTxtObj.__text!=null) { 390 | if(config.escapeMode) 391 | result+=escapeXmlChars(jsonTxtObj.__text); 392 | else 393 | result+=jsonTxtObj.__text; 394 | } 395 | return result; 396 | } 397 | 398 | function parseJSONTextObject ( jsonTxtObj ) { 399 | var result =""; 400 | 401 | if( jsonTxtObj instanceof Object ) { 402 | result+=parseJSONTextAttrs ( jsonTxtObj ); 403 | } 404 | else 405 | if(jsonTxtObj!=null) { 406 | if(config.escapeMode) 407 | result+=escapeXmlChars(jsonTxtObj); 408 | else 409 | result+=jsonTxtObj; 410 | } 411 | 412 | return result; 413 | } 414 | 415 | function getJsonPropertyPath(jsonObjPath, jsonPropName) { 416 | if (jsonObjPath==="") { 417 | return jsonPropName; 418 | } 419 | else 420 | return jsonObjPath+"."+jsonPropName; 421 | } 422 | 423 | function parseJSONArray ( jsonArrRoot, jsonArrObj, attrList, jsonObjPath ) { 424 | var result = ""; 425 | if(jsonArrRoot.length == 0) { 426 | result+=startTag(jsonArrRoot, jsonArrObj, attrList, true); 427 | } 428 | else { 429 | for(var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) { 430 | result+=startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false); 431 | result+=parseJSONObject(jsonArrRoot[arIdx], getJsonPropertyPath(jsonObjPath,jsonArrObj)); 432 | result+=endTag(jsonArrRoot[arIdx],jsonArrObj); 433 | } 434 | } 435 | return result; 436 | } 437 | 438 | function parseJSONObject ( jsonObj, jsonObjPath ) { 439 | var result = ""; 440 | 441 | var elementsCnt = jsonXmlElemCount ( jsonObj ); 442 | 443 | if(elementsCnt > 0) { 444 | for( var it in jsonObj ) { 445 | 446 | if(jsonXmlSpecialElem ( jsonObj, it) || (jsonObjPath!="" && !checkJsonObjPropertiesFilter(jsonObj, it, getJsonPropertyPath(jsonObjPath,it))) ) 447 | continue; 448 | 449 | var subObj = jsonObj[it]; 450 | 451 | var attrList = parseJSONAttributes( subObj ) 452 | 453 | if(subObj == null || subObj == undefined) { 454 | result+=startTag(subObj, it, attrList, true); 455 | } 456 | else 457 | if(subObj instanceof Object) { 458 | 459 | if(subObj instanceof Array) { 460 | result+=parseJSONArray( subObj, it, attrList, jsonObjPath ); 461 | } 462 | else if(subObj instanceof Date) { 463 | result+=startTag(subObj, it, attrList, false); 464 | result+=subObj.toISOString(); 465 | result+=endTag(subObj,it); 466 | } 467 | else { 468 | var subObjElementsCnt = jsonXmlElemCount ( subObj ); 469 | if(subObjElementsCnt > 0 || subObj.__text!=null || subObj.__cdata!=null) { 470 | result+=startTag(subObj, it, attrList, false); 471 | result+=parseJSONObject(subObj, getJsonPropertyPath(jsonObjPath,it)); 472 | result+=endTag(subObj,it); 473 | } 474 | else { 475 | result+=startTag(subObj, it, attrList, true); 476 | } 477 | } 478 | } 479 | else { 480 | result+=startTag(subObj, it, attrList, false); 481 | result+=parseJSONTextObject(subObj); 482 | result+=endTag(subObj,it); 483 | } 484 | } 485 | } 486 | result+=parseJSONTextObject(jsonObj); 487 | 488 | return result; 489 | } 490 | 491 | this.parseXmlString = function(xmlDocStr) { 492 | var isIEParser = window.ActiveXObject || "ActiveXObject" in window; 493 | if (xmlDocStr === undefined) { 494 | return null; 495 | } 496 | var xmlDoc; 497 | if (window.DOMParser) { 498 | var parser=new window.DOMParser(); 499 | var parsererrorNS = null; 500 | // IE9+ now is here 501 | if(!isIEParser) { 502 | try { 503 | parsererrorNS = parser.parseFromString("INVALID", "text/xml").getElementsByTagName("parsererror")[0].namespaceURI; 504 | } 505 | catch(err) { 506 | parsererrorNS = null; 507 | } 508 | } 509 | try { 510 | xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" ); 511 | if( parsererrorNS!= null && xmlDoc.getElementsByTagNameNS(parsererrorNS, "parsererror").length > 0) { 512 | //throw new Error('Error parsing XML: '+xmlDocStr); 513 | xmlDoc = null; 514 | } 515 | } 516 | catch(err) { 517 | xmlDoc = null; 518 | } 519 | } 520 | else { 521 | // IE :( 522 | if(xmlDocStr.indexOf("") + 2 ); 524 | } 525 | xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 526 | xmlDoc.async="false"; 527 | xmlDoc.loadXML(xmlDocStr); 528 | } 529 | return xmlDoc; 530 | }; 531 | 532 | this.asArray = function(prop) { 533 | if (prop === undefined || prop == null) 534 | return []; 535 | else 536 | if(prop instanceof Array) 537 | return prop; 538 | else 539 | return [prop]; 540 | }; 541 | 542 | this.toXmlDateTime = function(dt) { 543 | if(dt instanceof Date) 544 | return dt.toISOString(); 545 | else 546 | if(typeof(dt) === 'number' ) 547 | return new Date(dt).toISOString(); 548 | else 549 | return null; 550 | }; 551 | 552 | this.asDateTime = function(prop) { 553 | if(typeof(prop) == "string") { 554 | return fromXmlDateTime(prop); 555 | } 556 | else 557 | return prop; 558 | }; 559 | 560 | this.xml2json = function (xmlDoc) { 561 | return parseDOMChildren ( xmlDoc ); 562 | }; 563 | 564 | this.xml_str2json = function (xmlDocStr) { 565 | var xmlDoc = this.parseXmlString(xmlDocStr); 566 | if(xmlDoc!=null) 567 | return this.xml2json(xmlDoc); 568 | else 569 | return null; 570 | }; 571 | 572 | this.json2xml_str = function (jsonObj) { 573 | return parseJSONObject ( jsonObj, "" ); 574 | }; 575 | 576 | this.json2xml = function (jsonObj) { 577 | var xmlDocStr = this.json2xml_str (jsonObj); 578 | return this.parseXmlString(xmlDocStr); 579 | }; 580 | 581 | this.getVersion = function () { 582 | return VERSION; 583 | }; 584 | } 585 | })) -------------------------------------------------------------------------------- /rzslider.min.js: -------------------------------------------------------------------------------- 1 | /*! angularjs-slider - v5.8.7 - (c) Rafal Zajac , Valentin Hervieu , Jussi Saarivirta , Angelin Sirbu - https://github.com/angular-slider/angularjs-slider - 2016-11-09 */ 2 | !function(a,b){"use strict";if("function"==typeof define&&define.amd)define(["angular"],b);else if("object"==typeof module&&module.exports){var c=require("angular");c&&c.module||"undefined"==typeof angular||(c=angular),module.exports=b(c)}else b(a.angular)}(this,function(a){"use strict";var b=a.module("rzModule",[]).factory("RzSliderOptions",function(){var b={floor:0,ceil:null,step:1,precision:0,minRange:null,maxRange:null,pushRange:!1,minLimit:null,maxLimit:null,id:null,translate:null,getLegend:null,stepsArray:null,bindIndexForStepsArray:!1,draggableRange:!1,draggableRangeOnly:!1,showSelectionBar:!1,showSelectionBarEnd:!1,showSelectionBarFromValue:null,hidePointerLabels:!1,hideLimitLabels:!1,autoHideLimitLabels:!0,readOnly:!1,disabled:!1,interval:350,showTicks:!1,showTicksValues:!1,ticksArray:null,ticksTooltip:null,ticksValuesTooltip:null,vertical:!1,getSelectionBarColor:null,getTickColor:null,getPointerColor:null,keyboardSupport:!0,scale:1,enforceStep:!0,enforceRange:!1,noSwitching:!1,onlyBindHandles:!1,onStart:null,onChange:null,onEnd:null,rightToLeft:!1,boundPointerLabels:!0,mergeRangeLabelsIfSame:!1,customTemplateScope:null,logScale:!1,customValueToPosition:null,customPositionToValue:null},c={},d={};return d.options=function(b){a.extend(c,b)},d.getOptions=function(d){return a.extend({},b,c,d)},d}).factory("rzThrottle",["$timeout",function(a){return function(b,c,d){var e,f,g,h=Date.now||function(){return(new Date).getTime()},i=null,j=0;d=d||{};var k=function(){j=h(),i=null,g=b.apply(e,f),e=f=null};return function(){var l=h(),m=c-(l-j);return e=this,f=arguments,0>=m?(a.cancel(i),i=null,j=l,g=b.apply(e,f),e=f=null):i||d.trailing===!1||(i=a(k,m)),g}}}]).factory("RzSlider",["$timeout","$document","$window","$compile","RzSliderOptions","rzThrottle",function(b,c,d,e,f,g){var h=function(a,b){this.scope=a,this.lowValue=0,this.highValue=0,this.sliderElem=b,this.range=void 0!==this.scope.rzSliderModel&&void 0!==this.scope.rzSliderHigh,this.dragging={active:!1,value:0,difference:0,position:0,lowLimit:0,highLimit:0},this.positionProperty="left",this.dimensionProperty="width",this.handleHalfDim=0,this.maxPos=0,this.precision=0,this.step=1,this.tracking="",this.minValue=0,this.maxValue=0,this.valueRange=0,this.intermediateTicks=!1,this.initHasRun=!1,this.firstKeyDown=!1,this.internalChange=!1,this.cmbLabelShown=!1,this.currentFocusElement=null,this.fullBar=null,this.selBar=null,this.minH=null,this.maxH=null,this.flrLab=null,this.ceilLab=null,this.minLab=null,this.maxLab=null,this.cmbLab=null,this.ticks=null,this.init()};return h.prototype={init:function(){var b,c,e=this,f=function(){e.calcViewDimensions()};this.applyOptions(),this.syncLowValue(),this.range&&this.syncHighValue(),this.initElemHandles(),this.manageElementsStyle(),this.setDisabledState(),this.calcViewDimensions(),this.setMinAndMax(),this.addAccessibility(),this.updateCeilLab(),this.updateFloorLab(),this.initHandles(),this.manageEventsBindings(),this.scope.$on("reCalcViewDimensions",f),a.element(d).on("resize",f),this.initHasRun=!0,b=g(function(){e.onLowHandleChange()},e.options.interval),c=g(function(){e.onHighHandleChange()},e.options.interval),this.scope.$on("rzSliderForceRender",function(){e.resetLabelsValue(),b(),e.range&&c(),e.resetSlider()}),this.scope.$watch("rzSliderOptions()",function(a,b){a!==b&&(e.applyOptions(),e.syncLowValue(),e.range&&e.syncHighValue(),e.resetSlider())},!0),this.scope.$watch("rzSliderModel",function(a,c){e.internalChange||a!==c&&b()}),this.scope.$watch("rzSliderHigh",function(a,b){e.internalChange||a!==b&&(null!=a&&c(),(e.range&&null==a||!e.range&&null!=a)&&(e.applyOptions(),e.resetSlider()))}),this.scope.$on("$destroy",function(){e.unbindEvents(),a.element(d).off("resize",f),e.currentFocusElement=null})},findStepIndex:function(b){for(var c=0,d=0;d0&&0===b.rzsd)&&(f=!0,b.rzsv=e),g||b.html(e),this.scope[c+"Label"]=e,f&&this.getDimension(b)},setMinAndMax:function(){if(this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.logScale&&0===this.minValue)throw Error("Can't use floor=0 with logarithmic scale");this.options.enforceStep&&(this.lowValue=this.roundStep(this.lowValue),this.range&&(this.highValue=this.roundStep(this.highValue))),null!=this.options.ceil?this.maxValue=this.options.ceil:this.maxValue=this.options.ceil=this.range?this.highValue:this.lowValue,this.options.enforceRange&&(this.lowValue=this.sanitizeValue(this.lowValue),this.range&&(this.highValue=this.sanitizeValue(this.highValue))),this.applyLowValue(),this.range&&this.applyHighValue(),this.valueRange=this.maxValue-this.minValue},addAccessibility:function(){this.minH.attr("role","slider"),this.updateAriaAttributes(),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.minH.attr("tabindex",""):this.minH.attr("tabindex","0"),this.options.vertical&&this.minH.attr("aria-orientation","vertical"),this.range&&(this.maxH.attr("role","slider"),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.maxH.attr("tabindex",""):this.maxH.attr("tabindex","0"),this.options.vertical&&this.maxH.attr("aria-orientation","vertical"))},updateAriaAttributes:function(){this.minH.attr({"aria-valuenow":this.scope.rzSliderModel,"aria-valuetext":this.customTrFn(this.scope.rzSliderModel,this.options.id,"model"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue}),this.range&&this.maxH.attr({"aria-valuenow":this.scope.rzSliderHigh,"aria-valuetext":this.customTrFn(this.scope.rzSliderHigh,this.options.id,"high"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue})},calcViewDimensions:function(){var a=this.getDimension(this.minH);if(this.handleHalfDim=a/2,this.barDimension=this.getDimension(this.fullBar),this.maxPos=this.barDimension-a,this.getDimension(this.sliderElem),this.sliderElem.rzsp=this.sliderElem[0].getBoundingClientRect()[this.positionProperty],this.initHasRun){this.updateFloorLab(),this.updateCeilLab(),this.initHandles();var c=this;b(function(){c.updateTicksScale()})}},updateTicksScale:function(){if(this.options.showTicks){var a=this.options.ticksArray||this.getTicksArray(),b=this.options.vertical?"translateY":"translateX",c=this;this.options.rightToLeft&&a.reverse(),this.scope.ticks=a.map(function(a){var d=c.valueToPosition(a);c.options.vertical&&(d=c.maxPos-d);var e={selected:c.isTickSelected(a),style:{transform:b+"("+Math.round(d)+"px)"}};if(e.selected&&c.options.getSelectionBarColor&&(e.style["background-color"]=c.getSelectionBarColor()),!e.selected&&c.options.getTickColor&&(e.style["background-color"]=c.getTickColor(a)),c.options.ticksTooltip&&(e.tooltip=c.options.ticksTooltip(a),e.tooltipPlacement=c.options.vertical?"right":"top"),c.options.showTicksValues&&(e.value=c.getDisplayValue(a,"tick-value"),c.options.ticksValuesTooltip&&(e.valueTooltip=c.options.ticksValuesTooltip(a),e.valueTooltipPlacement=c.options.vertical?"right":"top")),c.getLegend){var f=c.getLegend(a,c.options.id);f&&(e.legend=f)}return e})}},getTicksArray:function(){var a=this.step,b=[];this.intermediateTicks&&(a=this.options.showTicks);for(var c=this.minValue;c<=this.maxValue;c+=a)b.push(c);return b},isTickSelected:function(a){if(!this.range)if(null!==this.options.showSelectionBarFromValue){var b=this.options.showSelectionBarFromValue;if(this.lowValue>b&&a>=b&&a<=this.lowValue)return!0;if(this.lowValue=a&&a>=this.lowValue)return!0}else if(this.options.showSelectionBarEnd){if(a>=this.lowValue)return!0}else if(this.options.showSelectionBar&&a<=this.lowValue)return!0;return this.range&&a>=this.lowValue&&a<=this.highValue?!0:!1},updateFloorLab:function(){this.translateFn(this.minValue,this.flrLab,"floor"),this.getDimension(this.flrLab);var a=this.options.rightToLeft?this.barDimension-this.flrLab.rzsd:0;this.setPosition(this.flrLab,a)},updateCeilLab:function(){this.translateFn(this.maxValue,this.ceilLab,"ceil"),this.getDimension(this.ceilLab);var a=this.options.rightToLeft?0:this.barDimension-this.ceilLab.rzsd;this.setPosition(this.ceilLab,a)},updateHandles:function(a,b){"lowValue"===a?this.updateLowHandle(b):this.updateHighHandle(b),this.updateSelectionBar(),this.updateTicksScale(),this.range&&this.updateCmbLabel()},getHandleLabelPos:function(a,b){var c=this[a].rzsd,d=b-c/2+this.handleHalfDim,e=this.barDimension-c;return this.options.boundPointerLabels?this.options.rightToLeft&&"minLab"===a||!this.options.rightToLeft&&"maxLab"===a?Math.min(d,e):Math.min(Math.max(d,0),e):d},updateLowHandle:function(a){if(this.setPosition(this.minH,a),this.translateFn(this.lowValue,this.minLab,"model"),this.setPosition(this.minLab,this.getHandleLabelPos("minLab",a)),this.options.getPointerColor){var b=this.getPointerColor("min");this.scope.minPointerStyle={backgroundColor:b}}this.options.autoHideLimitLabels&&this.shFloorCeil()},updateHighHandle:function(a){if(this.setPosition(this.maxH,a),this.translateFn(this.highValue,this.maxLab,"high"),this.setPosition(this.maxLab,this.getHandleLabelPos("maxLab",a)),this.options.getPointerColor){var b=this.getPointerColor("max");this.scope.maxPointerStyle={backgroundColor:b}}this.options.autoHideLimitLabels&&this.shFloorCeil()},shFloorCeil:function(){if(!this.options.hidePointerLabels){var a=!1,b=!1,c=this.isLabelBelowFloorLab(this.minLab),d=this.isLabelAboveCeilLab(this.minLab),e=this.isLabelAboveCeilLab(this.maxLab),f=this.isLabelBelowFloorLab(this.cmbLab),g=this.isLabelAboveCeilLab(this.cmbLab);if(c?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),d?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range){var h=this.cmbLabelShown?g:e,i=this.cmbLabelShown?f:c;h?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),i?this.hideEl(this.flrLab):a||this.showEl(this.flrLab)}}},isLabelBelowFloorLab:function(a){var b=this.options.rightToLeft,c=a.rzsp,d=a.rzsd,e=this.flrLab.rzsp,f=this.flrLab.rzsd;return b?c+d>=e-2:e+f+2>=c},isLabelAboveCeilLab:function(a){var b=this.options.rightToLeft,c=a.rzsp,d=a.rzsd,e=this.ceilLab.rzsp,f=this.ceilLab.rzsd;return b?e+f+2>=c:c+d>=e-2},updateSelectionBar:function(){var a=0,b=0,c=this.options.rightToLeft?!this.options.showSelectionBarEnd:this.options.showSelectionBarEnd,d=this.options.rightToLeft?this.maxH.rzsp+this.handleHalfDim:this.minH.rzsp+this.handleHalfDim;if(this.range)b=Math.abs(this.maxH.rzsp-this.minH.rzsp),a=d;else if(null!==this.options.showSelectionBarFromValue){var e=this.options.showSelectionBarFromValue,f=this.valueToPosition(e),g=this.options.rightToLeft?this.lowValue<=e:this.lowValue>e;g?(b=this.minH.rzsp-f,a=f+this.handleHalfDim):(b=f-this.minH.rzsp,a=this.minH.rzsp+this.handleHalfDim)}else c?(b=Math.abs(this.maxPos-this.minH.rzsp)+this.handleHalfDim,a=this.minH.rzsp+this.handleHalfDim):(b=Math.abs(this.maxH.rzsp-this.minH.rzsp)+this.handleHalfDim,a=0);if(this.setDimension(this.selBar,b),this.setPosition(this.selBar,a),this.options.getSelectionBarColor){var h=this.getSelectionBarColor();this.scope.barStyle={backgroundColor:h}}},getSelectionBarColor:function(){return this.range?this.options.getSelectionBarColor(this.scope.rzSliderModel,this.scope.rzSliderHigh):this.options.getSelectionBarColor(this.scope.rzSliderModel)},getPointerColor:function(a){return"max"===a?this.options.getPointerColor(this.scope.rzSliderHigh,a):this.options.getPointerColor(this.scope.rzSliderModel,a)},getTickColor:function(a){return this.options.getTickColor(a)},updateCmbLabel:function(){var a=null;if(a=this.options.rightToLeft?this.minLab.rzsp-this.minLab.rzsd-10<=this.maxLab.rzsp:this.minLab.rzsp+this.minLab.rzsd+10>=this.maxLab.rzsp){var b=this.getDisplayValue(this.lowValue,"model"),c=this.getDisplayValue(this.highValue,"high"),d="";d=this.options.mergeRangeLabelsIfSame&&b===c?b:this.options.rightToLeft?c+" - "+b:b+" - "+c,this.translateFn(d,this.cmbLab,"cmb",!1);var e=this.options.boundPointerLabels?Math.min(Math.max(this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2,0),this.barDimension-this.cmbLab.rzsd):this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2;this.setPosition(this.cmbLab,e),this.cmbLabelShown=!0,this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)}else this.cmbLabelShown=!1,this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab);this.options.autoHideLimitLabels&&this.shFloorCeil()},getDisplayValue:function(a,b){return this.options.stepsArray&&!this.options.bindIndexForStepsArray&&(a=this.getStepValue(a)),this.customTrFn(a,this.options.id,b)},roundStep:function(a,b){var c=b?b:this.step,d=parseFloat((a-this.minValue)/c).toPrecision(12);d=Math.round(+d)*c;var e=(this.minValue+d).toFixed(this.precision);return+e},hideEl:function(a){return a.css({visibility:"hidden"})},showEl:function(a){return a.rzAlwaysHide?a:a.css({visibility:"visible"})},setPosition:function(a,b){a.rzsp=b;var c={};return c[this.positionProperty]=Math.round(b)+"px",a.css(c),b},getDimension:function(a){var b=a[0].getBoundingClientRect();return this.options.vertical?a.rzsd=(b.bottom-b.top)*this.options.scale:a.rzsd=(b.right-b.left)*this.options.scale,a.rzsd},setDimension:function(a,b){a.rzsd=b;var c={};return c[this.dimensionProperty]=Math.round(b)+"px",a.css(c),b},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},valueToPosition:function(a){var b=this.linearValueToPosition;this.options.customValueToPosition?b=this.options.customValueToPosition:this.options.logScale&&(b=this.logValueToPosition),a=this.sanitizeValue(a);var c=b(a,this.minValue,this.maxValue)||0;return this.options.rightToLeft&&(c=1-c),c*this.maxPos},linearValueToPosition:function(a,b,c){var d=c-b;return(a-b)/d},logValueToPosition:function(a,b,c){a=Math.log(a),b=Math.log(b),c=Math.log(c);var d=c-b;return(a-b)/d},positionToValue:function(a){var b=a/this.maxPos;this.options.rightToLeft&&(b=1-b);var c=this.linearPositionToValue;return this.options.customPositionToValue?c=this.options.customPositionToValue:this.options.logScale&&(c=this.logPositionToValue),c(b,this.minValue,this.maxValue)||0},linearPositionToValue:function(a,b,c){return a*(c-b)+b},logPositionToValue:function(a,b,c){b=Math.log(b),c=Math.log(c);var d=a*(c-b)+b;return Math.exp(d)},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return void 0!==a[b]?a[b]:void 0===a.originalEvent?a.touches[0][b]:a.originalEvent.touches[0][b]},getEventPosition:function(a){var b=this.sliderElem.rzsp,c=0;return c=this.options.vertical?-this.getEventXY(a)+b:this.getEventXY(a)-b,c*this.options.scale-this.handleHalfDim},getEventNames:function(a){var b={moveEvent:"",endEvent:""};return a.touches||void 0!==a.originalEvent&&a.originalEvent.touches?(b.moveEvent="touchmove",b.endEvent="touchend"):(b.moveEvent="mousemove",b.endEvent="mouseup"),b},getNearestHandle:function(a){if(!this.range)return this.minH;var b=this.getEventPosition(a),c=Math.abs(b-this.minH.rzsp),d=Math.abs(b-this.maxH.rzsp);return d>c?this.minH:c>d?this.maxH:this.options.rightToLeft?b>this.minH.rzsp?this.minH:this.maxH:b=f?e=h:f>=this.maxPos?e=g:(e=this.positionToValue(f),e=d&&a.isNumber(this.options.showTicks)?this.roundStep(e,this.options.showTicks):this.roundStep(e)),this.positionTrackingHandle(e)},onEnd:function(a,b){var d=this.getEventNames(b).moveEvent;this.options.keyboardSupport||(this.minH.removeClass("rz-active"),this.maxH.removeClass("rz-active"),this.tracking=""),this.dragging.active=!1,c.off(d,a),this.callOnEnd()},onTickClick:function(a,b){this.onMove(a,b,!0)},onPointerFocus:function(b,c){this.tracking=c,b.one("blur",a.bind(this,this.onPointerBlur,b)),b.on("keydown",a.bind(this,this.onKeyboardEvent)),b.on("keyup",a.bind(this,this.onKeyUp)),this.firstKeyDown=!0,b.addClass("rz-active"),this.currentFocusElement={pointer:b,ref:c}},onKeyUp:function(){this.firstKeyDown=!0,this.callOnEnd()},onPointerBlur:function(a){a.off("keydown"),a.off("keyup"),this.tracking="",a.removeClass("rz-active"),this.currentFocusElement=null},getKeyActions:function(a){var b=a+this.step,c=a-this.step,d=a+this.valueRange/10,e=a-this.valueRange/10,f={UP:b,DOWN:c,LEFT:c,RIGHT:b,PAGEUP:d,PAGEDOWN:e,HOME:this.minValue,END:this.maxValue};return this.options.rightToLeft&&(f.LEFT=b,f.RIGHT=c,this.options.vertical&&(f.UP=c,f.DOWN=b)),f},onKeyboardEvent:function(a){var c=this[this.tracking],d=a.keyCode||a.which,e={38:"UP",40:"DOWN",37:"LEFT",39:"RIGHT",33:"PAGEUP",34:"PAGEDOWN",36:"HOME",35:"END"},f=this.getKeyActions(c),g=e[d],h=f[g];if(null!=h&&""!==this.tracking){a.preventDefault(),this.firstKeyDown&&(this.firstKeyDown=!1,this.callOnStart());var i=this;b(function(){var a=i.roundStep(i.sanitizeValue(h));if(i.options.draggableRangeOnly){var b,c,d=i.highValue-i.lowValue;"lowValue"===i.tracking?(b=a,c=a+d,c>i.maxValue&&(c=i.maxValue,b=c-d)):(c=a,b=a-d,b=k,h=k>=this.maxPos-e,g){if(0===i.rzsp)return;c=this.getValue("min",k,!0,!1),d=this.getValue("max",k,!0,!1)}else if(h){if(j.rzsp===this.maxPos)return;d=this.getValue("max",k,!0,!0),c=this.getValue("min",k,!0,!0)}else c=this.getValue("min",k,!1),d=this.getValue("max",k,!1);this.positionTrackingBar(c,d)},positionTrackingBar:function(a,b){null!=this.options.minLimit&&athis.options.maxLimit&&(b=this.options.maxLimit,a=b-this.dragging.difference),this.lowValue=a,this.highValue=b,this.applyLowValue(),this.range&&this.applyHighValue(),this.applyModel(),this.updateHandles("lowValue",this.valueToPosition(a)),this.updateHandles("highValue",this.valueToPosition(b))},positionTrackingHandle:function(a){var b=!1;a=this.applyMinMaxLimit(a),this.range&&(this.options.pushRange?(a=this.applyPushRange(a),b=!0):(this.options.noSwitching&&("lowValue"===this.tracking&&a>this.highValue?a=this.applyMinMaxRange(this.highValue):"highValue"===this.tracking&&athis.highValue?(this.lowValue=this.highValue,this.applyLowValue(),this.updateHandles(this.tracking,this.maxH.rzsp),this.updateAriaAttributes(),this.tracking="highValue",this.minH.removeClass("rz-active"),this.maxH.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(this.maxH),b=!0):"highValue"===this.tracking&&athis.options.maxLimit?this.options.maxLimit:a},applyMinMaxRange:function(a){var b="lowValue"===this.tracking?this.highValue:this.lowValue,c=Math.abs(a-b);return null!=this.options.minRange&&cthis.options.maxRange?"lowValue"===this.tracking?this.highValue-this.options.maxRange:this.lowValue+this.options.maxRange:a},applyPushRange:function(a){var b="lowValue"===this.tracking?this.highValue-a:a-this.lowValue,c=null!==this.options.minRange?this.options.minRange:this.options.step,d=this.options.maxRange;return c>b?("lowValue"===this.tracking?(this.highValue=Math.min(a+c,this.maxValue),a=this.highValue-c,this.applyHighValue(),this.updateHandles("highValue",this.valueToPosition(this.highValue))):(this.lowValue=Math.max(a-c,this.minValue),a=this.lowValue+c,this.applyLowValue(),this.updateHandles("lowValue",this.valueToPosition(this.lowValue))),this.updateAriaAttributes()):null!==d&&b>d&&("lowValue"===this.tracking?(this.highValue=a+d,this.applyHighValue(),this.updateHandles("highValue",this.valueToPosition(this.highValue))):(this.lowValue=a-d,this.applyLowValue(),this.updateHandles("lowValue",this.valueToPosition(this.lowValue))),this.updateAriaAttributes()),a},applyModel:function(){this.internalChange=!0,this.scope.$apply(),this.callOnChange(),this.internalChange=!1},callOnStart:function(){if(this.options.onStart){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onStart(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnChange:function(){if(this.options.onChange){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onChange(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnEnd:function(){if(this.options.onEnd){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onEnd(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}this.scope.$emit("slideEnded")}},h}]).directive("rzslider",["RzSlider",function(a){return{restrict:"AE",replace:!0,scope:{rzSliderModel:"=?",rzSliderHigh:"=?",rzSliderOptions:"&?",rzSliderTplUrl:"@"},templateUrl:function(a,b){return b.rzSliderTplUrl||"rzSliderTpl.html"},link:function(b,c){b.slider=new a(b,c)}}}]);return b.run(["$templateCache",function(a){a.put("rzSliderTpl.html",'
  • {{ t.value }} {{ t.legend }}
'); 3 | }]),b.name}); --------------------------------------------------------------------------------