{:uriI"衒ile:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/form/_slugger.js.erb?type=application/javascript&pipeline=self&id=110a98e90f2195392fb274f1554f29fbb4c8914176bdd8a5fe700cf6c2c07f4d:ET:load_pathI"G/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts;T: filenameI"`/Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/form/_slugger.js.erb;T: nameI"fae/form/_slugger;T:logical_pathI"fae/form/_slugger.self.js;T:content_typeI"application/javascript;T: sourceI" /* global Fae */ 'use strict'; /** * Fae form * @namespace form * @memberof Fae */ Fae.form.slugger = { init: function() { this.addListener(); }, /** * Attach listeners to inputs and update slug fields with original safe values from the original inputs */ addListener: function() { var _this = this; $('.slug').each(function() { var $form = $(this).closest('form'); var $sluggers = $form.find('.slugger'); var $slug = $form.find('.slug'); var $select_slugger = $('.select.slugger'); if ($slug.val() !== '') { $sluggers.removeClass('slugger'); } else { // If it's a text field, listen for type input $sluggers.keyup(function(){ var text = _this._digestSlug( $sluggers ); $slug.val( text ); }); // If it's a select field, listen for the change if ($select_slugger.length) { $select_slugger.change(function(){ var text = _this._digestSlug( $sluggers ); $slug.val( text ); }); }; } }); }, /** * Convert a group of selects or text fields into one slug string * @access protected * @param {jQuery} $sluggers - Input or inputs that should be converted into a URL-safe string * @return {String} */ _digestSlug: function($sluggers) { var slug_text = [] $sluggers.each(function() { var $this = $(this); if ($this.val().length) { if ($this.is('input')) { slug_text.push( $this.val() ); } else { slug_text.push( $this.find('option:selected').text() ); } } }); // Combine all active slug fields for the query slug_text = slug_text.join(' '); // Strip accented characters var from = '脿谩芒茫盲忙氓莽猫茅锚毛臋膿臈矛铆卯茂帽貌贸么玫枚霉煤没眉媒每脌脕脗脙脛脟脠脡脢脣脤脥脦脧脩脪脫脭脮脰脵脷脹脺脻'; var to = 'aaaaaaaceeeeeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'; // Loop through all accented characters and replace with non-accents for (var i = 0; i < from.length; i++) { slug_text = slug_text.replace( new RegExp(from.charAt(i), 'g'), to.charAt(i) ); } // Remove leading and trailing spaces // Make them lowercase // Remove slashes, quotes or periods // Replace white spaces with a Fae.slug_separator // Remove leading and trailing dashes slug_text = slug_text .trim() .toLowerCase() .replace(/[^-\w\s]/g, '') .replace(/[-\s]+/g, '-') .replace(/(^-)|(-$)/g, ''); return slug_text; } }; ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"gprocessors:type=application/javascript&file_type=application/javascript&engines=.erb&pipeline=self;TTI"nfile-digest:///Library/WebServer/Documents/work/fine/_fae/app/assets/javascripts/fae/form/_slugger.js.erb;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%I(施&J豘[Q⿻7~莰dr螾梅: lengthi :dependencies_digest"%yA{tk秳_扝}鴣eG艀I]z怙Y"x:idI"E110a98e90f2195392fb274f1554f29fbb4c8914176bdd8a5fe700cf6c2c07f4d;F: mtimel+BlRW