1$(function () { 2 'use strict'; 3 4 // on change block 5 $('#block_class,#shared_block_id').on('change', function (e) { 6 var url = document.location.toString(), 7 el = e.currentTarget; 8 9 // set up location 10 url = url.replace(/[&?]className=[^&]*/, ''); 11 url = url.replace(/[&?]configSiteSharedBlocksId=[^&]*/, ''); 12 url = url + (url.indexOf('?') > -1 ? '&' : '?') + el.name + '=' + el.value; 13 14 // change location of form 15 sectionAdmin().blockEditFormLocation(url); 16 sectionAdmin().resizeBlockEditModal(); 17 }); 18 19 // tooltips 20 $('[data-toggle="tooltip"]').tooltip(); 21 22 // on change block layout class 23 $('.block_layout_class').on('change', function () { 24 var blockClass = this.name.match(/(.+?)\[/)[1], 25 blockOptionsWrap = $(this).closest('.block-layout-wrap').find('.block-layout-options'); 26 27 //console.log(blockClass); 28 //console.log(this.value); 29 //console.log(blockOptionsWrap); 30 31 sectionAdmin().getBlockLayout(blockClass, this.value, blockOptionsWrap); 32 }); 33 34 // on remove block 35 $('#remove-block').on('click', function (e) { 36 var id = getIdFromUrl(), 37 $btn = $(this), 38 $block = parent.$('*[data-config_site_block_id="' + id + '"]'); 39 40 $btn.button('loading'); 41 42 // remove the block 43 var rem = sectionAdmin().removeBlock($block, id, function () { 44 $btn.button('reset'); 45 parent.$('.modal').modal('hide'); 46 }); 47 48 // if something went wrong and could not remove the block then still reset the button to original state 49 if (rem === false) { 50 $btn.button('reset'); 51 } 52 }); 53 54 $('#block-visible-on').find('input[type=radio]').on('change', function () { 55 var $sharedWrap = $('#sharedBlockTitle-wrap'); 56 $sharedWrap.hide(); 57 if (this.value == 2) { 58 $sharedWrap.fadeIn('fast'); 59 } 60 }); 61 62 (function () { 63 var $bsSizing = $('#bootstrap-sizing'), 64 $cssInput = $('#advanced-css-options').find('input[type=text]'), 65 $advCssOpts = $cssInput.closest('.row'); 66 67 /** 68 * 69 * @param [size] 70 * @param [cols] 71 */ 72 function parseColClasses(size, cols) {
73 var cssClasses = $cssInput.val(), 74 classes = {}, 75 otherClasses = '', 76 rex; 77 78 cssClasses = (cssClasses) ? cssClasses.split(' ') : []; 79 80 // get current classes from input 81 for (var i = 0; i < cssClasses.length; i++) { 82 rex = cssClasses[i].match(/^(col-[^-]+)-([0-9]+)$/); 83 if (!rex) { 84 otherClasses += (otherClasses ? ' ' : '') + cssClasses[i]; 85 continue; 86 } 87 88 // eg. col-md = 2 (for col-md-2) 89 classes[rex[1]] = rex[2]; 90 } 91 92 if (size) { 93 if (cols !== '') { 94 classes['col-' + size] = cols; 95 } 96 else if ('col-' + size in classes) { 97 delete classes['col-' + size]; 98 } 99 } 100 101 // merge classes with other 102 $bsSizing.find('select').val(''); 103 for (var x in classes) { 104 if (!classes.hasOwnProperty(x)) { 105 continue; 106 } 107 108 // set option in appropriate dropdown 109 $bsSizing.find('select#sizing-' + x).val(classes[x]); 110 111 // append to custom css classes 112 otherClasses += (otherClasses ? ' ' : '') + [x, '-', classes[x]].join(''); 113 } 114 115 // apply to custom css classes input 116 $cssInput.val(otherClasses); 117 } 118 119 $bsSizing.find('select').on('change', function () { 120 parseColClasses(this.getAttribute('data-tier'), this.value); 121 }); 122 123 // on show style button hit 124 $bsSizing.find('button.btn').on('click', function (e) { 125 e.preventDefault(); 126 var $el = $(this), 127 isActive = $el.hasClass('active'); 128 129 // hide or show 130 $el[isActive ? 'removeClass' : 'addClass']('active'); 131 $advCssOpts[isActive ? 'slideUp' : 'slideDown']('fast', function () { 132 sectionAdmin().resizeBlockEditModal(); 133 }); 134 }); 135 136 // update selects on change 137 $cssInput.on('change', function () { 138 parseColClasses(); 139 }); 140 141 // set default col sizes if this is a new block 142 if (!document.location.href.match(/[&?]configSiteBlockId=[0-9]+/)) { 143 $cssInput.val(($cssInput.val() ? $cssInput.val() + ' ' : '') + 'col-md-12 col-sm-12 col-xs-12'); 144 } 145 146 // on load 147 $advCssOpts.hide(); 148 parseColClasses(); 149 })(); 150}); 151 152/** 153 * 154 * @returns {*} 155 */ 156function getIdFromUrl() { 157 var url = document.location.toString(), 158 m; 159 160 m = url.match(/[&?]configSiteBlockId=([0-9]+)/); 161 if (m && m[0]) { 162 return m[1]; 163 } 164 165 return null; 166} 167 168/** 169 * 170 * @returns {*} 171 */ 172function sectionAdmin() { 173 // find inline editor instance 174 if (!parent.window.SECTION_ADMIN) { 175 if (!window.SECTION_ADMIN) { 176 throw new Error("You must run this form from within the bootstrap modal on the inline-editor pages."); 177 } 178 else { 179 return window.SECTION_ADMIN; 180 } 181 } 182 else { 183 return parent.window.SECTION_ADMIN; 184 } 185} 186 187/** 188 * Overwrite filebrowser methods (see file-browser.js module for public methods that can be overridden 189 * @param overrides 190 */ 191function overrideFileBrowser(overrides) { 192 if (!window.FileBrowser) { 193 window.FileBrowser = {}; 194 } 195 $.extend(window.FileBrowser, overrides); 196} 197 198/** 199 * Overwrite book picker methods (see book-picker.js module for public methods that can be overridden 200 * @param overrides 201 */ 202function overrideBookPicker(overrides) { 203 if (!window.BookPicker) { 204 window.BookPicker = {}; 205 } 206 $.extend(window.BookPicker, overrides); 207} 208 209/** 210 * Overwrite person picker methods (see person-picker.js module for public methods that can be overridden 211 * @param overrides 212 */ 213function overridePersonPicker(overrides) { 214 if (!window.PersonPicker) { 215 window.PersonPicker = {}; 216 } 217 $.extend(window.PersonPicker, overrides); 218} 219 220/** 221 * Overwrite link picker methods (see link-picker.js module for public methods that can be overridden 222 * @param overrides 223 */ 224function overrideLinkPicker(overrides) { 225 if (!window.LinkPicker) { 226 window.LinkPicker = {}; 227 } 228 $.extend(window.LinkPicker, overrides); 229} 230 231/** 232 * Create popup window. The attributes of the link can contain options for the popup 233 * by using the 'data-pop-opts' attribute and separating comma separating the values like so: 234 * status=yes,scrollbars=no,width=100,height=500 etc. 235 * If no options are passed then the 'defaultOpts' are used. If some options are passed then they 236 * will be merged with the defaultOpts 237 * 238 * @param url 239 * @param [opts] 240 * @returns {*|window|window} 241 */ 242function openWindow(url, opts) { 243 var win = window, 244 _opts = {}, joinOpts = '', 245 defaultOpts, x, i; 246 247 // default window options (overridden in data-opts attribute) 248 defaultOpts = { 249 width: 1020, 250 height: 600, 251 top: null, // will auto set if not in the data-pop-opts to centered 252 left: null, // will auto set if not in the data-pop-opts to centered 253 scrollbars: 'yes', 254 menubar: 'no', 255 resizable: 'no', 256 status: 'yes', 257 location: 'no', 258 toolbar: 'no' 259 }; 260 261 // set up opts object 262 if (opts) { 263 opts = opts.split(','); 264 $(opts).each(function () { 265 i = this.split('='); 266 _opts[i[0]] = i[1]; 267 }); 268 _opts = $.extend(defaultOpts, _opts); 269 270 } 271 else { 272 _opts = defaultOpts; 273 } 274 // set up screen position 275 if ((opts && !opts.left) || !opts) {
276 _opts.left = (screen.availWidth / 2) - (_opts.width / 2); 277 } 278 // set up screen position 279 if ((opts && !opts.top) || !opts) { 280 _opts.top = (screen.availHeight / 2) - (_opts.height / 2); 281 } 282 283 // set up win settings 284 $.each(_opts, function (k, v) { 285 joinOpts += (joinOpts ? ',' : '') + k + '=' + v; 286 }); 287 288 // open the window 289 win = window.open(url, 'win', joinOpts); 290 win.moveTo(_opts.left, _opts.top); 291 292 if (win.open) { 293 win.focus(); 294 return win; 295 } 296 // display message if a popup blocker stopped the window from opening 297 else { 298 alert('Please allow popups for this page to open'); 299 } 300}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.