/** * Copyright 2014 Openstack Foundation * Licensed 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( $ ){ var form = null; var table_regions = null; var table_az = null; var form_validator = null; var locations = []; var methods = { init : function(options){ form = $(this); //regions table_regions = $('#datacenter-regions-table',form); table_az = $('#az-table',form); $('#add-datacenter-location-country',form) .addClass('add-location-control') .addClass('location-country'); $('#add-datacenter-location-country',form).chosen({disable_search_threshold: 3}); $('#add-datacenter-location-region',form).chosen({disable_search_threshold: 3}); $('#add_region_color',form).ColorPicker({ onSubmit: function(hsb, hex, rgb, el) { $(el).val(hex); $(el).css('backgroundColor', '#' + hex); $(el).ColorPickerHide(); }, onBeforeShow: function () { $(this).ColorPickerSetColor(this.value); }, onChange: function (hsb, hex, rgb) { var input = $(this).data('colorpicker').el; $(input).val(hex); $(input).css('backgroundColor', '#' + hex); } }).bind('keyup', function(){ $(this).ColorPickerSetColor(this.value); }); $.validator.addMethod("validate_duplicate_location", function (value, element, arg) { var locations = $('.data-center-location','#data-center-locations-container'); var location_info_container = arg[0]; var city = $('.location-city',location_info_container).val(); var state = $('.location-state',location_info_container).val(); var country = $('.location-country',location_info_container).val(); var region = $('.location-region',location_info_container).val(); var location_slug = convertToSlug(city)+'-'+convertToSlug(state)+'-'+convertToSlug(country)+'-'+convertToSlug(region); for(var i=0;i tr",table_regions); for(var i=0;i', { value: '', text : '--select region--' })); for(var i in regions){ dll_region.append($('